X-Git-Url: https://git.mdrn.pl/fnpeditor.git/blobdiff_plain/e4c529f82588395c666ab6786cc9e5cbe827fb90..bbb810b9417335d3a6fbfeb300de8f12e4cd091a:/src/editor/modules/documentCanvas/canvas/genericElement.js diff --git a/src/editor/modules/documentCanvas/canvas/genericElement.js b/src/editor/modules/documentCanvas/canvas/genericElement.js index 8d0ba87..e0fc84b 100644 --- a/src/editor/modules/documentCanvas/canvas/genericElement.js +++ b/src/editor/modules/documentCanvas/canvas/genericElement.js @@ -6,7 +6,8 @@ var $ = require('libs/jquery'), _ = require('libs/underscore'), documentElement = require('./documentElement'), utils = require('./utils'), - wlxmlUtils = require('utils/wlxml'); + wlxmlUtils = require('utils/wlxml'), + CommentsView = require('./comments/comments'); var labelWidget = function(tag, klass) { return $('') @@ -31,6 +32,16 @@ $.extend(generic, { this._container().append(el.dom); } }.bind(this)); + + this.commentsView = new CommentsView(this.wlxmlNode, {}); + this.addToGutter(this.commentsView); + this.commentTip = $('
'); + this.addWidget(this.commentTip); + + if(!this.wlxmlNode.hasChild({klass: 'comment'})) { + this.commentTip.hide(); + } + this.refresh(); }, @@ -119,8 +130,14 @@ $.extend(generic, { } referenceElement[referenceAction](actionArg); + + if(event.meta.node.is('comment')) { + this.commentTip.show(); + this.commentsView.render(); + } }, onNodeDetached: function(event) { + var isComment = event.meta.node.is('comment'); if(event.meta.node.sameNode(this)) { this.detach(); } else { @@ -130,6 +147,10 @@ $.extend(generic, { return true; } }); + if(isComment && !this.wlxmlNode.hasChild({klass: 'comment'})) { + this.commentTip.hide(); + } + this.commentsView.render(); } }, onNodeTextChange: function(event) {