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(); me.show();
}); });
},
onDialogShown: function() {
if (typeof(onDialogShown) == "function") {
onDialogShown();
}
} }

View File

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

View File

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

View File

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

View File

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