From 2f82ce6d5497a18e11c8afca9aaafa2188316846 Mon Sep 17 00:00:00 2001 From: Mariela Michalek Date: Fri, 18 Apr 2014 17:13:44 -0300 Subject: [PATCH] update editors with remove button --- .../src/main/javascript/widget/LinkEditor.js | 21 +++++++++++---- .../src/main/javascript/widget/NoteEditor.js | 27 +++++++++++++++---- 2 files changed, 38 insertions(+), 10 deletions(-) diff --git a/mindplot/src/main/javascript/widget/LinkEditor.js b/mindplot/src/main/javascript/widget/LinkEditor.js index f7fa25df..e66f852a 100644 --- a/mindplot/src/main/javascript/widget/LinkEditor.js +++ b/mindplot/src/main/javascript/widget/LinkEditor.js @@ -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(); } diff --git a/mindplot/src/main/javascript/widget/NoteEditor.js b/mindplot/src/main/javascript/widget/NoteEditor.js index 7ac0a809..0b516a46 100644 --- a/mindplot/src/main/javascript/widget/NoteEditor.js +++ b/mindplot/src/main/javascript/widget/NoteEditor.js @@ -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 = $('
').css("padding-top", "5px"); var form = $('
').attr({ 'action':'none', 'id':'noteFormId' }); + // Add textarea var 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(); }