update editors with remove button

This commit is contained in:
Mariela Michalek 2014-04-18 17:13:44 -03:00
parent e5b5e28843
commit 98e798bfce
2 changed files with 38 additions and 10 deletions

View File

@ -24,8 +24,10 @@ mindplot.widget.LinkEditor = new Class({
this.parent($msg("LINK"), {
cancelButton: true,
closeButton: true,
acceptButton: true
acceptButton: true,
removeButton: true
});
this._model = model;
var panel = this._buildPanel(model);
this.setContent(panel);
},
@ -83,10 +85,10 @@ mindplot.widget.LinkEditor = new Class({
});
// result.addEvent('keydown', function (event) {
// event.stopPropagation();
// });
//
if (typeof model.getValue() != 'undefined'){
this.showRemoveButton();
}
result.append(form);
return result;
},
@ -95,6 +97,15 @@ mindplot.widget.LinkEditor = new Class({
$("#linkFormId").submit();
},
onRemoveClick: function() {
this._model.setValue(null);
this.close();
},
hideRemoveButton:function(){
this.parent();
},
close:function () {
this.parent();
}

View File

@ -1,24 +1,30 @@
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
acceptButton: true,
removeButton: true
});
this._model = model;
var panel = this._buildPanel(model);
this.setContent(panel);
// this.onRemoveClickData = {model: this._model};
onRemoveClickData = {data:'hola'};
},
_buildPanel:function (model) {
_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'),
@ -30,14 +36,12 @@ _buildPanel:function (model) {
'height':80,
'resize':'none'
});
form.append(textArea);
if (model.getValue() != null){
if (model.getValue() != null){
textArea.val(model.getValue());
}
result.append(form);
var me = this;
$(document).ready(function () {
$(document).on('submit','#noteFormId',function (event) {
@ -49,6 +53,11 @@ _buildPanel:function (model) {
me.close();
});
});
if (typeof model.getValue() != 'undefined'){
this.showRemoveButton();
}
result.append(form);
return result;
},
@ -56,6 +65,14 @@ _buildPanel:function (model) {
$("#noteFormId").submit();
},
onRemoveClick: function(event) {
if(event.data.model){
window.alert('claudio se la come!!');
}
this._model.setValue(null);
this.close();
},
close:function () {
this.parent();
}