From 4336036d5cd716e6418e52bcb82c3ee0dc0b42e7 Mon Sep 17 00:00:00 2001 From: George Berezhnoy Date: Thu, 2 Feb 2017 14:07:29 +0300 Subject: [PATCH] codex -> codex.editor --- codex.js | 2 +- modules/comments.js | 27 +++++++++++++++------------ modules/ui.js | 6 +++--- 3 files changed, 19 insertions(+), 16 deletions(-) diff --git a/codex.js b/codex.js index d349bcb2..c792b1ca 100644 --- a/codex.js +++ b/codex.js @@ -26,7 +26,7 @@ module.exports = (function (editor) { editor.notifications = require('./modules/notifications'); editor.parser = require('./modules/parser'); editor.sanitizer = require('./modules/sanitizer'); - codex.comments = require('./modules/comments'); + editor.comments = require('./modules/comments'); }; diff --git a/modules/comments.js b/modules/comments.js index 7c811953..a84457e1 100644 --- a/modules/comments.js +++ b/modules/comments.js @@ -1,10 +1,13 @@ + +let editor = codex.editor; + var comments = function(comments) { var draw = { commentsField: function(blockId) { - var field = codex.draw.node('DIV', 'ce-comments-field'); + var field = editor.draw.node('DIV', 'ce-comments-field'); field.dataset.blockId = blockId; @@ -14,10 +17,10 @@ var comments = function(comments) { input: function(text) { - var wrapper = codex.draw.node('DIV', 'ce-comment'), - input = codex.draw.node('DIV', 'ce-comment__input', {'contentEditable': 'true', 'textContent':text||''}), - deleteBtn = codex.draw.node('DIV', 'ce-comment__delete', {'textContent': 'Delete'}), - postBtn = codex.draw.node('DIV', 'ce-comment__post', {'textContent': text?'Save':'Comment'}); + var wrapper = editor.draw.node('DIV', 'ce-comment'), + input = editor.draw.node('DIV', 'ce-comment__input', {'contentEditable': 'true', 'textContent':text||''}), + deleteBtn = editor.draw.node('DIV', 'ce-comment__delete', {'textContent': 'Delete'}), + postBtn = editor.draw.node('DIV', 'ce-comment__post', {'textContent': text?'Save':'Comment'}); postBtn.addEventListener('click', callbacks.commentClicked); deleteBtn.addEventListener('click', callbacks.deleteClicked); @@ -36,8 +39,8 @@ var comments = function(comments) { if (!data.text) return; - var wrapper = codex.draw.node('DIV', 'ce-comment'), - text = codex.draw.node('DIV', 'ce-comment__text', {'textContent': data.text}), + var wrapper = editor.draw.node('DIV', 'ce-comment'), + text = editor.draw.node('DIV', 'ce-comment__text', {'textContent': data.text}), date = new Date().toLocaleDateString('en-US',{ month: 'short', day: 'numeric', @@ -45,9 +48,9 @@ var comments = function(comments) { minute: 'numeric', hour12: false }), - time = codex.draw.node('DIV', 'ce-comment__time', {'textContent': date}), - deleteBtn = codex.draw.node('DIV', 'ce-comment__delete', {'textContent': 'Delete'}), - editBtn = codex.draw.node('DIV', 'ce-comment__edit', {'textContent': 'Edit'}); + time = editor.draw.node('DIV', 'ce-comment__time', {'textContent': date}), + deleteBtn = editor.draw.node('DIV', 'ce-comment__delete', {'textContent': 'Delete'}), + editBtn = editor.draw.node('DIV', 'ce-comment__edit', {'textContent': 'Edit'}); editBtn.addEventListener('click', callbacks.editClicked); deleteBtn.addEventListener('click', callbacks.deleteClicked); @@ -128,7 +131,7 @@ var comments = function(comments) { var blockId = block.dataset.id; - var field = codex.nodes.commentsSidebar.querySelector('.ce-comments-field[data-block-id="'+blockId+'"]') || + var field = editor.nodes.commentsSidebar.querySelector('.ce-comments-field[data-block-id="'+blockId+'"]') || draw.commentsField(blockId); var comment = draw.input(); @@ -141,7 +144,7 @@ var comments = function(comments) { field.style.top = blockCoords.y + 'px'; - codex.nodes.commentsSidebar.appendChild(field); + editor.nodes.commentsSidebar.appendChild(field); }; diff --git a/modules/ui.js b/modules/ui.js index a57cbd1a..a262d805 100644 --- a/modules/ui.js +++ b/modules/ui.js @@ -133,8 +133,8 @@ module.exports = (function (ui) { editor.nodes.defaultSettings = defaultSettings; editor.nodes.showSettingsButton = showSettingsButton; editor.nodes.showTrashButton = showTrashButton; - codex.nodes.showCommentButton = showCommentButton; - codex.nodes.commentsSidebar = commentsSidebar; + editor.nodes.showCommentButton = showCommentButton; + editor.nodes.commentsSidebar = commentsSidebar; editor.nodes.redactor = redactor; @@ -305,7 +305,7 @@ module.exports = (function (ui) { /** * Clicks to COMMENT button in toolbar */ - codex.nodes.showCommentButton.addEventListener('click', codex.callback.showCommentButtonClicked, false ); + editor.nodes.showCommentButton.addEventListener('click', editor.callback.showCommentButtonClicked, false ); /** * @deprecated ( but now in use for syncronization );