fix error in pom and add data for accept click events in bootstrap dialogs

This commit is contained in:
Ezequiel Bergamaschi 2014-12-26 23:13:12 -03:00
parent e38f5dbce6
commit 2d513f5c85
4 changed files with 18 additions and 20 deletions

View File

@ -7,12 +7,12 @@ var BootstrapDialog = new Class({
acceptButton: true, acceptButton: true,
removeButton:false, removeButton:false,
errorMessage: false, errorMessage: false,
onRemoveClickData:{} onEventData:{}
}, },
initialize: function (title, options) { initialize: function (title, options) {
this.setOptions(options); this.setOptions(options);
this.options.onRemoveClickData.dialog = this; this.options.onEventData.dialog = this;
this._native = $('<div class="modal fade" tabindex="-1"></div>').append('<div class="modal-dialog"></div>'); this._native = $('<div class="modal fade" tabindex="-1"></div>').append('<div class="modal-dialog"></div>');
var content = $('<div class="modal-content"></div>'); var content = $('<div class="modal-content"></div>');
content.on('keydown', function(event) { content.on('keydown', function(event) {
@ -48,12 +48,12 @@ var BootstrapDialog = new Class({
if (this.options.acceptButton) { if (this.options.acceptButton) {
this.acceptButton = $('<button type="button" class="btn btn-primary" id="acceptBtn" data-dismiss="modal">'+ $msg('ACCEPT') + '</button>'); this.acceptButton = $('<button type="button" class="btn btn-primary" id="acceptBtn" data-dismiss="modal">'+ $msg('ACCEPT') + '</button>');
footer.append(this.acceptButton); footer.append(this.acceptButton);
this.acceptButton.unbind('click').click(this.onAcceptClick) this.acceptButton.unbind('click').on("click",this.options.onEventData, this.onAcceptClick)
} }
if (this.options.removeButton) { if (this.options.removeButton) {
this.removeButton = $('<button type="button" class="btn btn-secondary" id="removeBtn" data-dismiss="modal">'+ $msg('REMOVE') +'</button>'); this.removeButton = $('<button type="button" class="btn btn-secondary" id="removeBtn" data-dismiss="modal">'+ $msg('REMOVE') +'</button>');
footer.append(this.removeButton); footer.append(this.removeButton);
this.removeButton.on('click', this.options.onRemoveClickData, this.onRemoveClick); this.removeButton.on('click', this.options.onEventData, this.onRemoveClick);
} }
if (this.options.cancelButton) { if (this.options.cancelButton) {
footer.append('<button type="button" class="btn btn-secondary" data-dismiss="modal">'+ $msg('CANCEL') +'</button>'); footer.append('<button type="button" class="btn btn-secondary" data-dismiss="modal">'+ $msg('CANCEL') +'</button>');

View File

@ -28,7 +28,7 @@ mindplot.widget.LinkEditor = new Class({
acceptButton: true, acceptButton: true,
removeButton: typeof model.getValue() != 'undefined', removeButton: typeof model.getValue() != 'undefined',
errorMessage: true, errorMessage: true,
onRemoveClickData: {model: this._model} onEventData: {model: this._model}
}); });
this.css({margin:"150px auto"}); this.css({margin:"150px auto"});
var panel = this._buildPanel(model); var panel = this._buildPanel(model);

View File

@ -27,7 +27,7 @@ mindplot.widget.NoteEditor = new Class({
closeButton: true, closeButton: true,
acceptButton: true, acceptButton: true,
removeButton: typeof model.getValue() != 'undefined', removeButton: typeof model.getValue() != 'undefined',
onRemoveClickData: {model: this._model} onEventData: {model: this._model}
}); });
this.css({margin:"150px auto"}); this.css({margin:"150px auto"});
var panel = this._buildPanel(model); var panel = this._buildPanel(model);
@ -60,24 +60,20 @@ mindplot.widget.NoteEditor = new Class({
textArea.val(model.getValue()); textArea.val(model.getValue());
} }
var me = this;
$(document).ready(function () {
$(document).on('submit','#noteFormId',function (event) {
event.stopPropagation();
event.preventDefault();
if (textArea.val()) {
model.setValue(textArea.val());
}
me.close();
});
});
result.append(form); result.append(form);
return result; return result;
}, },
onAcceptClick: function() { onAcceptClick: function(event) {
$("#noteFormId").submit(); event.data.dialog._submitForm(event.data.model);
},
_submitForm: function(model) {
var textarea = this._native.find("textarea");
if (textarea.val()) {
model.setValue(textarea.val());
}
this.close();
}, },
onDialogShown: function() { onDialogShown: function() {

View File

@ -98,6 +98,8 @@
<groupId>com.github.searls</groupId> <groupId>com.github.searls</groupId>
<artifactId>jasmine-maven-plugin</artifactId> <artifactId>jasmine-maven-plugin</artifactId>
<version>1.3.1.5</version> <version>1.3.1.5</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId> <artifactId>maven-release-plugin</artifactId>
<version>2.5</version> <version>2.5</version>