update editors

This commit is contained in:
Mariela Michalek 2014-04-10 19:33:20 -03:00
parent 63959d086a
commit 3df56a4d97
2 changed files with 81 additions and 226 deletions

View File

@ -21,7 +21,11 @@ mindplot.widget.LinkEditor = new Class({
initialize:function (model) {
$assert(model, "model can not be null");
this.parent($msg("LINK"));
this.parent($msg("LINK"), {
cancelButton: true,
closeButton: true,
acceptButton: true
});
var panel = this._buildPanel(model);
this.setContent(panel);
},
@ -64,64 +68,25 @@ mindplot.widget.LinkEditor = new Class({
form.append(input);
form.append(open);
// Register submit event ...
form.submit(function (event) {
// event.stopPropagation();
$(document).ready(function () {
$(document).on('submit','#linkFormId',function () {
event.stopPropagation();
event.preventDefault();
if (input.value != null && input.value.trim() != "") {
model.setValue(input.value);
}
this.close();
}.bind(this));
});
// form.addEvent('submit', function (event) {
// event.stopPropagation();
// event.preventDefault();
//
// if (input.value != null && input.value.trim() != "") {
// model.setValue(input.value);
// }
// this.close();
// }.bind(this));
// Add buttons ...
var buttonContainer = $('<div></div>');
buttonContainer.css('paddingTop','5').css('textAlign','center');
// var buttonContainer = new Element('div').setStyles({paddingTop:5, textAlign:'center'});
//
// Create remove button ...
// if ($defined(model.getValue())) {
// var rmButton = new Element('input', {type:'button', value:$msg('REMOVE'), 'class':'btn-primary'});
// rmButton.setStyle('margin', '5px');
// rmButton.addClass('button');
// rmButton.inject(buttonContainer);
// rmButton.addEvent('click', function (event) {
// model.setValue(null);
// event.stopPropagation();
// this.close();
// }.bind(this));
// buttonContainer.inject(form);
// }
form.append(buttonContainer);
// var cButton = new Element('input', {type:'button', value:$msg('CANCEL'), 'class':'btn-secondary'});
// cButton.setStyle('margin', '5px');
// cButton.addClass('button');
// cButton.addEvent('click', function () {
// this.close();
// }.bind(this));
// buttonContainer.inject(form);
$(document).on('click','#acceptBtn',function () {
$("#linkFormId").submit();
});
});
// result.addEvent('keydown', function (event) {
// event.stopPropagation();
// });
//
result.append(form);
return result;
}

View File

@ -1,3 +1,66 @@
mindplot.widget.NoteEditor = new Class({
Extends:BootstrapDialog,
initialize:function (model) {
$assert(model, "model can not be null");
this.parent($msg("Note"), {
cancelButton: true,
closeButton: true,
acceptButton: true
});
var panel = this._buildPanel(model);
this.setContent(panel);
},
_buildPanel:function (model) {
var result = $('<div></div>').css("padding-top", "5px");
var form = $('<form></form>').attr({
'action':'none',
'id':'noteFormId'
});
// Add textarea
var textArea = $('<textarea></textarea>').attr({
'placeholder':$msg('WRITE_YOUR_TEXT_HERE'),
'required':'true',
'autofocus':'autofocus'
});
textArea.css({
'width':'100%',
'height':80,
'resize':'none'
});
form.append(textArea);
if (model.getValue() != null){
textArea.val(model.getValue());
}
result.append(form);
$(document).ready(function () {
$(document).on('submit','#noteFormId',function () {
event.stopPropagation();
event.preventDefault();
if (textArea.val()) {
model.setValue(textArea.val());
}
this.close();
});
$(document).on('click','#acceptBtn',function () {
$("#noteFormId").submit();
});
});
return result;
},
close:function () {
this.close();
}
});
/*
* Copyright [2012] [wisemapping]
*
@ -15,176 +78,3 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
mindplot.widget.NoteEditor = new Class({
Extends:BootstrapDialog,
initialize:function (model) {
console.log("Re-impl required ....");
$assert(model, "model can not be null");
this.parent();
var panel = this._buildPanel(model);
// this.parent({
// closeButton:true,
// destroyOnClose:true,
// title:$msg('NOTE'),
// onInitialize:function (wrapper) {
// wrapper.setStyle('opacity', 0);
// this.fx = new Fx.Morph(wrapper, {
// duration:600,
// transition:Fx.Transitions.Bounce.easeOut
// });
// },
//
// onBeforeOpen:function () {
// this.overlay = new Overlay(this.options.inject, {
// duration:this.options.duration
// });
// if (this.options.closeOnOverlayClick)
// this.overlay.addEvent('click', this.close.bind(this));
// this.overlay.open();
//
// this.fx.start({
// 'margin-top':[-200, -100],
// opacity:[0, 1]
// }).chain(function () {
// this.fireEvent('show');
// }.bind(this));
// },
//
// onBeforeClose:function () {
// this.fx.start({
// 'margin-top':[-100, 0],
// opacity:0
// }).chain(function () {
// this.fireEvent('hide');
// }.bind(this));
// this.overlay.destroy();
// }
// });
// this.setContent(panel);
this.setContent(panel);
},
_buildPanel:function (model) {
var result = $('<div></div>').css("padding-top", "5px");
var form = $('<form></form>').attr({
'action':'none',
'id':'noteFormId'
});
// Add textarea
var textArea = $('<textarea></textarea>').attr({
'placeholder':$msg('WRITE_YOUR_TEXT_HERE'),
'required':'true',
'autofocus':'autofocus'
});
textArea.css({
'width':'100%',
'height':80,
'resize':'none'
});
form.append(textArea);
// var textArea = new Element('textarea',
// {placeholder:$msg('WRITE_YOUR_TEXT_HERE'),
// required:true,
// autofocus:'autofocus'
// });
// textArea.setStyles({
// 'width':'100%',
// 'height':80, resize:'none'
// });
if (model.getValue() != null){
textArea.value = model.getValue();
}
// Register submit event
form.submit(function (event) {
event.preventDefault();
event.stopPropagation();
if (textArea.value) {
model.setValue(textArea.value);
}
this.close();
}.bind(this));
// form.addEvent('submit', function (event) {
// event.preventDefault();
// event.stopPropagation();
// if (textArea.value) {
// model.setValue(textArea.value);
// }
// this.close();
// }.bind(this));
// Add buttons ...
var buttonContainer = $('<div></div>');
buttonContainer.css({
'paddingTop':'5',
'textAlign':'center'
});
// Create accept button ...
var okButton = $('<input>');
okButton.attr('type','submit').attr(
'value',$msg('ACCEPT')).attr(
'class','btn-primary');
buttonContainer.append(okButton);
// var okButton = new Element('input', {type:'submit', value:$msg('ACCEPT'), 'class':'btn-primary'});
// okButton.addClass('button');
// okButton.inject(buttonContainer);
// Create remove button ...
// if ($defined(model.getValue())) {
// var rmButton = new Element('input', {type:'button', value:$msg('REMOVE'), 'class':'btn-primary'});
// rmButton.setStyle('margin', '5px');
// rmButton.addClass('button');
// rmButton.inject(buttonContainer);
// rmButton.addEvent('click', function () {
// model.setValue(null);
// this.close();
// }.bind(this));
// buttonContainer.inject(form);
// }
// Create cancel button ...
var cancelButton = $('<input>');
cancelButton.attr('id','cancel').attr('type','button').attr(
'value',$msg('CANCEL')).attr(
'class','btn-secondary');
cancelButton.css('margin','5px');
// cancelButton.on('click','input', function (e) {
// console.log('this is the click');
// e.preventDefault();
// });
$(document).on('click', "input.btn-secondary", function () {
$(modal-dialog).hide();
});
buttonContainer.append(cancelButton);
form.append(buttonContainer);
// var cButton = new Element('input', {type:'button', value:$msg('CANCEL'), 'class':'btn-secondary'});
// cButton.setStyle('margin', '5px');
// cButton.addClass('button');
// cButton.inject(buttonContainer);
// cButton.addEvent('click', function () {
// this.close();
// }.bind(this));
// buttonContainer.inject(form);
// result.addEvent('keydown', function (event) {
// event.stopPropagation();
// });
result.append(form);
return result;
},
show:function () {
this.parent("Note");
}
});