From: Aleksander Ɓukasz Date: Thu, 1 Aug 2013 08:53:46 +0000 (+0200) Subject: Refactoring X-Git-Url: https://git.mdrn.pl/fnpeditor.git/commitdiff_plain/1d56a243018175d9f384e995e1cf4531fcf0c648 Refactoring --- diff --git a/modules/documentCanvas/canvas/documentElement.js b/modules/documentCanvas/canvas/documentElement.js index 384186f..0ecde71 100644 --- a/modules/documentCanvas/canvas/documentElement.js +++ b/modules/documentCanvas/canvas/documentElement.js @@ -2,8 +2,9 @@ define([ 'libs/jquery-1.9.1.min', 'libs/underscore-min', 'modules/documentCanvas/classAttributes', -'modules/documentCanvas/canvas/utils' -], function($, _, classAttributes, utils) { +'modules/documentCanvas/canvas/utils', +'modules/documentCanvas/canvas/widgets' +], function($, _, classAttributes, utils, widgets) { 'use strict'; @@ -140,12 +141,12 @@ $.extend(DocumentNodeElement, { dom.css('display', displayStyle); container.css('display', displayStyle); - var widgets = $('
'); - widgets.append($('').text(params.tag + (params.klass ? ' / ' + params.klass : ''))); - dom.append(widgets); + var widgetsContainer = $('
'); + widgetsContainer.append(widgets.labelWidget(params.tag, params.klass)); + dom.append(widgetsContainer); // Make sure widgets aren't navigable with arrow keys - widgets.find('*').add(widgets).attr('tabindex', -1); + widgetsContainer.find('*').add(widgetsContainer).attr('tabindex', -1); dom.append(container); diff --git a/modules/documentCanvas/canvas/widgets.js b/modules/documentCanvas/canvas/widgets.js new file mode 100644 index 0000000..9563785 --- /dev/null +++ b/modules/documentCanvas/canvas/widgets.js @@ -0,0 +1,15 @@ +define([ +'libs/jquery-1.9.1.min' +], function($) { + +'use strict'; + +return { + labelWidget: function(tag, klass) { + return $('') + .addClass('canvas-widget canvas-widget-label') + .text(tag + (klass ? ' / ' + klass : '')); + } +}; + +}); \ No newline at end of file diff --git a/modules/documentCanvas/canvas/widgets.less b/modules/documentCanvas/canvas/widgets.less new file mode 100644 index 0000000..484385f --- /dev/null +++ b/modules/documentCanvas/canvas/widgets.less @@ -0,0 +1,26 @@ +[document-node-element] { + .canvas-widgets { + display: inline; + } + + .canvas-widget { + display: none; + } + + .canvas-widget-label { + position: absolute; + display: none; + top: -20px; + left:0; + background-color: red; + color: white; + font-size:12px; + font-weight: bold; + padding: 1px 3px; + //width:300px; + opacity: 0.65; + font-family: monospace; + z-index:9999; + white-space: nowrap; + } +} \ No newline at end of file diff --git a/modules/documentCanvas/documentCanvas.less b/modules/documentCanvas/documentCanvas.less index 69808ea..41405b3 100644 --- a/modules/documentCanvas/documentCanvas.less +++ b/modules/documentCanvas/documentCanvas.less @@ -1,4 +1,5 @@ @import 'nodes.less'; +@import 'canvas/widgets.less'; #rng-module-documentCanvas { height: 100%; @@ -49,32 +50,6 @@ .highlighted-element { border: 1px solid red; } - - - .canvas-widgets { - display: inline; - } - - .canvas-widget { - display: none; - } - - .canvas-widget-label { - position: absolute; - display: none; - top: -20px; - left:0; - background-color: red; - color: white; - font-size:12px; - font-weight: bold; - padding: 1px 3px; - //width:300px; - opacity: 0.65; - font-family: monospace; - z-index:9999; - white-space: nowrap; - } } .rng-module-documentCanvas-currentNode {