mirror of
https://bitbucket.org/wisemapping/wisemapping-open-source.git
synced 2024-11-22 22:27:55 +01:00
update submit functionality on link editor
This commit is contained in:
parent
4f74576ae7
commit
9cb881faaa
@ -41,7 +41,7 @@ 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.on('click', this.onAcceptClick)
|
this.acceptButton.unbind('click').click(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>');
|
||||||
@ -103,6 +103,10 @@ var BootstrapDialog = new Class({
|
|||||||
this._native.find('.alert-danger').show();
|
this._native.find('.alert-danger').show();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
cleanError: function(){
|
||||||
|
this._native.find('.alert-danger').hide();
|
||||||
|
},
|
||||||
|
|
||||||
showRemoveButton: function(){
|
showRemoveButton: function(){
|
||||||
this.removeButton.show();
|
this.removeButton.show();
|
||||||
}
|
}
|
||||||
|
@ -37,14 +37,14 @@ mindplot.widget.LinkEditor = new Class({
|
|||||||
|
|
||||||
_buildPanel:function (model) {
|
_buildPanel:function (model) {
|
||||||
var result = $('<div></div>').css("padding-top", "5px");
|
var result = $('<div></div>').css("padding-top", "5px");
|
||||||
var form = $('<form></form>').attr({
|
this.form = $('<form></form>').attr({
|
||||||
'action': 'none',
|
'action': 'none',
|
||||||
'id': 'linkFormId'
|
'id': 'linkFormId'
|
||||||
});
|
});
|
||||||
var text = $('<p></p>').text("Paste your url here:");
|
var text = $('<p></p>').text("Paste your url here:");
|
||||||
text.css('margin','0px 0px 20px');
|
text.css('margin','0px 0px 20px');
|
||||||
|
|
||||||
form.append(text);
|
this.form.append(text);
|
||||||
|
|
||||||
var section = $('<div></div>').attr({
|
var section = $('<div></div>').attr({
|
||||||
'class': 'input-group'
|
'class': 'input-group'
|
||||||
@ -78,30 +78,32 @@ mindplot.widget.LinkEditor = new Class({
|
|||||||
|
|
||||||
section.append(input);
|
section.append(input);
|
||||||
section.append(spanControl);
|
section.append(spanControl);
|
||||||
form.append(section);
|
this.form.append(section);
|
||||||
|
|
||||||
var me = this;
|
var me = this;
|
||||||
$(document).ready(function () {
|
this.form.unbind('submit').submit(
|
||||||
$(document).on('submit','#linkFormId',function (event) {
|
function (event) {
|
||||||
event.stopPropagation();
|
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
if(me.checkURL(input.val())){
|
if(me.checkURL(input.val())){
|
||||||
|
me.cleanError();
|
||||||
var inputValue = input.val();
|
var inputValue = input.val();
|
||||||
if (inputValue != null && inputValue.trim() != "") {
|
if (inputValue != null && inputValue.trim() != "") {
|
||||||
model.setValue(inputValue);
|
model.setValue(inputValue);
|
||||||
}
|
}
|
||||||
me.close();
|
me.close();
|
||||||
|
this.formSubmitted = true;
|
||||||
|
} else {
|
||||||
|
me.alertError($msg('URL_ERROR'));
|
||||||
|
event.stopPropagation();
|
||||||
}
|
}
|
||||||
me.alertError($msg("URL_ERROR")); //FIXME: add msg
|
}
|
||||||
});
|
);
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
if (typeof model.getValue() != 'undefined'){
|
if (typeof model.getValue() != 'undefined'){
|
||||||
this.showRemoveButton();
|
this.showRemoveButton();
|
||||||
}
|
}
|
||||||
|
|
||||||
result.append(form);
|
result.append(this.form);
|
||||||
return result;
|
return result;
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -110,8 +112,12 @@ mindplot.widget.LinkEditor = new Class({
|
|||||||
return(regex.test(url));
|
return(regex.test(url));
|
||||||
},
|
},
|
||||||
|
|
||||||
onAcceptClick: function() {
|
onAcceptClick: function(event) {
|
||||||
$("#linkFormId").submit();
|
this.formSubmitted = false;
|
||||||
|
$("#linkFormId").trigger('submit');
|
||||||
|
if (!this.formSubmitted) {
|
||||||
|
event.stopPropagation();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user