mirror of
https://bitbucket.org/wisemapping/wisemapping-open-source.git
synced 2024-09-12 07:10:07 +02:00
add url error BootstrapDialog and LinkEditor
This commit is contained in:
parent
30dac452ad
commit
6d50e0769e
@ -6,6 +6,7 @@ var BootstrapDialog = new Class({
|
||||
closeButton: false,
|
||||
acceptButton: true,
|
||||
removeButton:false,
|
||||
errorMessage: false,
|
||||
onRemoveClickData:{}
|
||||
},
|
||||
|
||||
@ -18,12 +19,17 @@ var BootstrapDialog = new Class({
|
||||
if (header) {
|
||||
content.append(header);
|
||||
}
|
||||
content.append('<div class="modal-body"></div>');
|
||||
var body = $('<div class="modal-body"></div>');
|
||||
if(this.options.errorMessage){
|
||||
var error = $('<div class="alert alert-danger"></div>');
|
||||
error.hide();
|
||||
body.append(error);
|
||||
}
|
||||
content.append(body);
|
||||
var footer = this._buildFooter();
|
||||
if (footer) {
|
||||
content.append(footer);
|
||||
}
|
||||
|
||||
this._native.find(".modal-dialog").append(content);
|
||||
},
|
||||
|
||||
@ -84,7 +90,7 @@ var BootstrapDialog = new Class({
|
||||
this._native.find('.modal-body').append(content);
|
||||
},
|
||||
|
||||
css:function(options){
|
||||
css: function(options){
|
||||
this._native.find('.modal-dialog').css(options);
|
||||
},
|
||||
|
||||
@ -92,6 +98,11 @@ var BootstrapDialog = new Class({
|
||||
this._native.modal('hide');
|
||||
},
|
||||
|
||||
alertError: function(message){
|
||||
this._native.find('.alert-danger').text(message);
|
||||
this._native.find('.alert-danger').show();
|
||||
},
|
||||
|
||||
showRemoveButton: function(){
|
||||
this.removeButton.show();
|
||||
}
|
||||
|
@ -27,6 +27,7 @@ mindplot.widget.LinkEditor = new Class({
|
||||
closeButton: true,
|
||||
acceptButton: true,
|
||||
removeButton: true,
|
||||
errorMessage: true,
|
||||
onRemoveClickData: {model: this._model}
|
||||
});
|
||||
this.css({width:"600px"});
|
||||
@ -73,22 +74,25 @@ mindplot.widget.LinkEditor = new Class({
|
||||
openButton.click(function(){
|
||||
window.open(input.val(),"_blank", "status=1,width=700,height=450,resize=1");
|
||||
});
|
||||
var spanControl = $('<span class="input-group-btn"></span>').append(openButton)
|
||||
var spanControl = $('<span class="input-group-btn"></span>').append(openButton);
|
||||
|
||||
section.append(input);
|
||||
section.append(spanControl);
|
||||
form.append(section);
|
||||
|
||||
var me = this;
|
||||
$(document).ready(function () {
|
||||
var me = this;
|
||||
$(document).on('submit','#linkFormId',function (event) {
|
||||
event.stopPropagation();
|
||||
event.preventDefault();
|
||||
var inputValue = input.val();
|
||||
if (inputValue != null && inputValue.trim() != "") {
|
||||
model.setValue(inputValue);
|
||||
if(me.checkURL(input.val())){
|
||||
var inputValue = input.val();
|
||||
if (inputValue != null && inputValue.trim() != "") {
|
||||
model.setValue(inputValue);
|
||||
}
|
||||
me.close();
|
||||
}
|
||||
me.close();
|
||||
me.alertError($msg("URL_ERROR")); //FIXME: add msg
|
||||
});
|
||||
|
||||
});
|
||||
@ -101,7 +105,13 @@ mindplot.widget.LinkEditor = new Class({
|
||||
return result;
|
||||
},
|
||||
|
||||
checkURL: function(url){
|
||||
var regex = /^(http|https|ftp):\/\/[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,5}(:[0-9]{1,5})?(\/.*)?$/i;
|
||||
return(regex.test(url));
|
||||
},
|
||||
|
||||
onAcceptClick: function() {
|
||||
$("#linkFormId").submit();
|
||||
}
|
||||
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user