Refactoring
authorAleksander Łukasz <aleksander.lukasz@nowoczesnapolska.org.pl>
Thu, 1 Aug 2013 08:53:46 +0000 (10:53 +0200)
committerAleksander Łukasz <aleksander.lukasz@nowoczesnapolska.org.pl>
Mon, 5 Aug 2013 10:20:07 +0000 (12:20 +0200)
modules/documentCanvas/canvas/documentElement.js
modules/documentCanvas/canvas/widgets.js [new file with mode: 0644]
modules/documentCanvas/canvas/widgets.less [new file with mode: 0644]
modules/documentCanvas/documentCanvas.less

index 384186f..0ecde71 100644 (file)
@@ -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 = $('<div class="canvas-widgets" contenteditable="false">');
-        widgets.append($('<span class="canvas-widget canvas-widget-label">').text(params.tag + (params.klass ? ' / ' + params.klass : '')));
-        dom.append(widgets);
+        var widgetsContainer = $('<div class="canvas-widgets" contenteditable="false">');
+        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 (file)
index 0000000..9563785
--- /dev/null
@@ -0,0 +1,15 @@
+define([
+'libs/jquery-1.9.1.min'
+], function($) {
+    
+'use strict';
+
+return {
+    labelWidget: function(tag, klass) {
+        return $('<span>')
+            .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 (file)
index 0000000..484385f
--- /dev/null
@@ -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
index 69808ea..41405b3 100644 (file)
@@ -1,4 +1,5 @@
 @import 'nodes.less';
+@import 'canvas/widgets.less';
 
 #rng-module-documentCanvas {
    height: 100%;
     .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 {