trigger event when dialog is shown to perform custom dialog actions

This commit is contained in:
Ezequiel Bergamaschi 2014-09-11 14:38:49 -03:00
parent 71b9357a9f
commit 7c31954b19
5 changed files with 24 additions and 4 deletions

View File

@ -37,6 +37,12 @@ BootstrapDialog.Request = new Class({
});
me.show();
});
},
onDialogShown: function() {
if (typeof(onDialogShown) == "function") {
onDialogShown();
}
}

View File

@ -34,6 +34,7 @@ var BootstrapDialog = new Class({
content.append(footer);
}
this._native.find(".modal-dialog").append(content);
this._native.on('shown.bs.modal', this.onDialogShown);
},
_buildFooter: function() {
@ -78,7 +79,9 @@ var BootstrapDialog = new Class({
//this method should be abstract
},
onDialogShown: function() {
},
onRemoveClick: function(event) {
event.data.model.setValue(null);
event.data.dialog.close();

View File

@ -51,7 +51,7 @@ mindplot.widget.LinkEditor = new Class({
});
// Add Input
var input = $('<input/>').attr({
var input = $('<input id="inputUrl"/>').attr({
'placeholder': 'http://www.example.com/',
'required': 'true',
'autofocus': 'autofocus',
@ -116,6 +116,10 @@ mindplot.widget.LinkEditor = new Class({
if (!this.formSubmitted) {
event.stopPropagation();
}
},
onDialogShown: function() {
$(this).find('#inputUrl').focus();
}
});

View File

@ -44,10 +44,9 @@ mindplot.widget.NoteEditor = new Class({
});
// Add textarea
var textArea = $('<textarea></textarea>').attr({
var textArea = $('<textarea></textarea autofocus>').attr({
'placeholder':$msg('WRITE_YOUR_TEXT_HERE'),
'required':'true',
'autofocus':'autofocus',
'class':'form-control'
});
textArea.css({
@ -82,6 +81,10 @@ mindplot.widget.NoteEditor = new Class({
onAcceptClick: function() {
$("#noteFormId").submit();
},
onDialogShown: function() {
$(this).find('textarea').focus();
}
});

View File

@ -71,7 +71,7 @@
<p><strong><spring:message code="ADD_PEOPLE"/>:</strong></p>
<input type="text" id="collabEmails" name="collabEmails" class="form-control"
<input type="text" id="collabEmails" name="collabEmails" class="form-control" autofocus='autofocus'
placeholder="<spring:message code="COLLABORATORS_SEPARATED_BY_COMA"/>"/>
<div class="btn-group" id="roleBtn">
@ -113,6 +113,10 @@ $("#collabEmails").keyup(function(event) {
}
});
function onDialogShown() {
$('#collabEmails').focus();
}
var messages = {
owner:'<spring:message code="IS_OWNER"/>',
editor:'<spring:message code="CAN_EDIT"/>',