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

View File

@ -1,24 +1,30 @@
mindplot.widget.NoteEditor = new Class({ mindplot.widget.NoteEditor = new Class({
Extends:BootstrapDialog, Extends:BootstrapDialog,
initialize:function (model) { initialize:function (model) {
$assert(model, "model can not be null"); $assert(model, "model can not be null");
this.parent($msg("Note"), { this.parent($msg("Note"), {
cancelButton: true, cancelButton: true,
closeButton: true, closeButton: true,
acceptButton: true acceptButton: true,
removeButton: true
}); });
this._model = model;
var panel = this._buildPanel(model); var panel = this._buildPanel(model);
this.setContent(panel); 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 result = $('<div></div>').css("padding-top", "5px");
var form = $('<form></form>').attr({ var form = $('<form></form>').attr({
'action':'none', 'action':'none',
'id':'noteFormId' 'id':'noteFormId'
}); });
// Add textarea // Add textarea
var textArea = $('<textarea></textarea>').attr({ var textArea = $('<textarea></textarea>').attr({
'placeholder':$msg('WRITE_YOUR_TEXT_HERE'), 'placeholder':$msg('WRITE_YOUR_TEXT_HERE'),
@ -30,14 +36,12 @@ _buildPanel:function (model) {
'height':80, 'height':80,
'resize':'none' 'resize':'none'
}); });
form.append(textArea); form.append(textArea);
if (model.getValue() != null){ if (model.getValue() != null){
textArea.val(model.getValue()); textArea.val(model.getValue());
} }
result.append(form);
var me = this; var me = this;
$(document).ready(function () { $(document).ready(function () {
$(document).on('submit','#noteFormId',function (event) { $(document).on('submit','#noteFormId',function (event) {
@ -49,6 +53,11 @@ _buildPanel:function (model) {
me.close(); me.close();
}); });
}); });
if (typeof model.getValue() != 'undefined'){
this.showRemoveButton();
}
result.append(form);
return result; return result;
}, },
@ -56,6 +65,14 @@ _buildPanel:function (model) {
$("#noteFormId").submit(); $("#noteFormId").submit();
}, },
onRemoveClick: function(event) {
if(event.data.model){
window.alert('claudio se la come!!');
}
this._model.setValue(null);
this.close();
},
close:function () { close:function () {
this.parent(); this.parent();
} }