editor: show comment tip next to blocks containing comments
authorAleksander Łukasz <aleksander.lukasz@nowoczesnapolska.org.pl>
Wed, 14 May 2014 14:10:25 +0000 (16:10 +0200)
committerAleksander Łukasz <aleksander.lukasz@nowoczesnapolska.org.pl>
Wed, 28 May 2014 12:45:58 +0000 (14:45 +0200)
src/editor/modules/documentCanvas/canvas/genericElement.js
src/editor/modules/documentCanvas/canvas/genericElement.less

index 8d0ba87..4f4da9b 100644 (file)
@@ -31,6 +31,14 @@ $.extend(generic, {
                 this._container().append(el.dom);
             }
         }.bind(this));
+
+        this.commentTip = $('<div class="comment-tip"><i class="icon-comment"></i></div>');
+        this.addWidget(this.commentTip);
+
+        if(!this.wlxmlNode.hasChild({klass: 'comment'})) {
+            this.commentTip.hide();
+        }
+
         this.refresh();
     },
     
@@ -119,8 +127,13 @@ $.extend(generic, {
         }
 
         referenceElement[referenceAction](actionArg);
+
+        if(event.meta.node.is('comment')) {
+            this.commentTip.show();
+        }
     },
     onNodeDetached: function(event) {
+        var isComment = event.meta.node.is('comment');
         if(event.meta.node.sameNode(this)) {
             this.detach();
         } else {
@@ -130,6 +143,9 @@ $.extend(generic, {
                     return true;
                 }
             });
+            if(isComment && !this.wlxmlNode.hasChild({klass: 'comment'})) {
+                this.commentTip.hide();
+            }
         }
     },
     onNodeTextChange: function(event) {
index c935a79..dcc23f4 100644 (file)
     font-family: monospace;
     z-index:9999;
     white-space: nowrap;
+}
+
+.comment-tip {
+    position:absolute;
+    left:-15px;
+    top:3px;
+    opacity: 0.25;
+}
+
+.current-node-element > .canvas-widgets > .comment-tip {
+    opacity: 1;
 }
\ No newline at end of file