From 3ef2cd48b9aaf42c2893e5b67688187a9ecf1fe9 Mon Sep 17 00:00:00 2001 From: Mariela Michalek Date: Sat, 19 Apr 2014 16:28:28 -0300 Subject: [PATCH] refactor note and link editors --- .../src/main/javascript/widget/LinkEditor.js | 62 +++++++++---------- .../src/main/javascript/widget/NoteEditor.js | 62 ++++++++----------- 2 files changed, 55 insertions(+), 69 deletions(-) diff --git a/mindplot/src/main/javascript/widget/LinkEditor.js b/mindplot/src/main/javascript/widget/LinkEditor.js index 509021dd..ec4411c0 100644 --- a/mindplot/src/main/javascript/widget/LinkEditor.js +++ b/mindplot/src/main/javascript/widget/LinkEditor.js @@ -21,14 +21,15 @@ mindplot.widget.LinkEditor = new Class({ initialize:function (model) { $assert(model, "model can not be null"); + this._model = model; this.parent($msg("LINK"), { cancelButton: true, closeButton: true, acceptButton: true, - removeButton: true + removeButton: true, + onRemoveClickData: {model: this._model} }); - this.setStyle("500px"); - this._model = model; + this.css({width:"600px"}); var panel = this._buildPanel(model); this.setContent(panel); }, @@ -36,23 +37,27 @@ mindplot.widget.LinkEditor = new Class({ _buildPanel:function (model) { var result = $('
').css("padding-top", "5px"); var form = $('
').attr({ - 'action':'none', - 'id':'linkFormId' + 'action': 'none', + 'id': 'linkFormId' }); var text = $('

').text("Paste your url here:"); - text.css('margin','0px 0px 10px'); + text.css('margin','0px 0px 20px'); form.append(text); - // Add Input - - var input = $('').attr({ - 'placeholder':'http://www.example.com/', - 'type':'url', //FIXME: THIS not work on IE, see workaround below - 'required':'true', - 'autofocus':'autofocus' + var section = $('
').attr({ + 'class': 'input-group' }); - input.css('width','70%').css('margin','0px 20px'); + + // Add Input + var input = $('').attr({ + 'placeholder': 'http://www.example.com/', + 'type': 'url', //FIXME: THIS not work on IE, see workaround below + 'required': 'true', + 'autofocus': 'autofocus', + 'class': 'form-control' + }); + //input.css('width','70%').css('margin','0px 30px'); if (model.getValue() != null){ input.val(model.getValue()); @@ -60,17 +65,21 @@ mindplot.widget.LinkEditor = new Class({ // type:Browser.ie ? 'text' : 'url', // IE workaround // Open Button - var open = $('').attr({ - 'type':'button', - 'value':$msg('OPEN_LINK') + var openButton = $('').attr({ + 'type': 'button', + 'class': 'btn btn-default' }); - open.click(function(){ + openButton.html($msg('OPEN_LINK')).css('margin-left', '0px'); + //FIXME: remove this! + openButton.click(function(){ alert('clicked!'); }); + var spanControl = $('').append(openButton) - form.append(input); - form.append(open); + section.append(input); + section.append(spanControl); + form.append(section); $(document).ready(function () { var me = this; @@ -96,18 +105,5 @@ mindplot.widget.LinkEditor = new Class({ onAcceptClick: function() { $("#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 72eaff6e..83210d7b 100644 --- a/mindplot/src/main/javascript/widget/NoteEditor.js +++ b/mindplot/src/main/javascript/widget/NoteEditor.js @@ -1,21 +1,38 @@ +/* + * Copyright [2012] [wisemapping] + * + * Licensed under WiseMapping Public License, Version 1.0 (the "License"). + * It is basically the Apache License, Version 2.0 (the "License") plus the + * "powered by wisemapping" text requirement on every single page; + * you may not use this file except in compliance with the License. + * You may obtain a copy of the license at + * + * http://www.wisemapping.org/license + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + mindplot.widget.NoteEditor = new Class({ Extends:BootstrapDialog, initialize:function (model) { $assert(model, "model can not be null"); + this._model = model; this.parent($msg("Note"), { cancelButton: true, closeButton: true, acceptButton: true, - removeButton: true + removeButton: true, + onRemoveClickData: {model: this._model} }); - this.setStyle("500px"); - this._model = model; + this.css({width:"600px"}); var panel = this._buildPanel(model); this.setContent(panel); -// this.onRemoveClickData = {model: this._model}; - onRemoveClickData = {data:'hola'}; - }, + }, _buildPanel:function (model) { @@ -30,7 +47,8 @@ mindplot.widget.NoteEditor = new Class({ var textArea = $('').attr({ 'placeholder':$msg('WRITE_YOUR_TEXT_HERE'), 'required':'true', - 'autofocus':'autofocus' + 'autofocus':'autofocus', + 'class':'form-control' }); textArea.css({ 'width':'100%', @@ -64,35 +82,7 @@ mindplot.widget.NoteEditor = new Class({ onAcceptClick: function() { $("#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(); } }); -/* - * Copyright [2012] [wisemapping] - * - * Licensed under WiseMapping Public License, Version 1.0 (the "License"). - * It is basically the Apache License, Version 2.0 (the "License") plus the - * "powered by wisemapping" text requirement on every single page; - * you may not use this file except in compliance with the License. - * You may obtain a copy of the license at - * - * http://www.wisemapping.org/license - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +