Skip to content

Commit

Permalink
Register buttons (#130)
Browse files Browse the repository at this point in the history
* register addComment command and button, added accessControlAllowOrigin and accessControlAllowCredential settings options

* modifications, commentreplies count

* add displayCommentsInModal option to settings

* display add new comment in modal

* modal display/hide events

* html elements change, display reply time

* time text based on momentjs

* update translations file

* fix comment accept/revert change

* fix comment accept/revert change

* close modal on comment delete

* remove hardcoded menu button

* remove time strings from translations, fix html structire

* remove showing comment modal on hover

* FIX citizenos/citizenos-fe#255

* .gitignore - add .idea

* Update to work with 1.8.4

* Update layout

* Disable editing others comments

* Update to sync with main plugin code

* Register toolbar button

* Replace timeformat with momentjs

* Fix timeFormat tests

* update localization strings

* Igonre copy pasted comments

* Add new translations

Co-authored-by: Mikk Andresen <[email protected]>
  • Loading branch information
ilmartyrk and tiblu committed Nov 6, 2020
1 parent a4cd0ae commit 48a03ae
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 9 deletions.
3 changes: 2 additions & 1 deletion ep.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"pre": ["ep_etherpad-lite/webaccess", "ep_page_view/page_view"],
"post": ["ep_etherpad-lite/static"],
"client_hooks": {
"postToolbarInit": "ep_comments_page/static/js/index",
"postAceInit": "ep_comments_page/static/js/index",
"collectContentPre": "ep_comments_page/static/js/shared",
"aceAttribsToClasses": "ep_comments_page/static/js/index",
Expand All @@ -13,13 +14,13 @@
"aceInitialized": "ep_comments_page/static/js/index"
},
"hooks": {
"padInitToolbar": "ep_comments_page/index",
"padRemove": "ep_comments_page/index",
"padCopy": "ep_comments_page/index",
"socketio": "ep_comments_page/index",
"expressCreateServer": "ep_comments_page/index",
"collectContentPre": "ep_comments_page/static/js/shared",
"eejsBlock_editbarMenuLeft": "ep_comments_page/index",
"eejsBlock_dd_insert": "ep_comments_page/index",
"eejsBlock_scripts": "ep_comments_page/index",
"eejsBlock_mySettings": "ep_comments_page/index",
"eejsBlock_styles": "ep_comments_page/index",
Expand Down
21 changes: 16 additions & 5 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,17 +126,28 @@ exports.socketio = function (hook_name, args, cb){
return cb();
};

exports.eejsBlock_dd_insert = function (hook_name, args, cb) {
args.content = args.content + eejs.require("ep_comments_page/templates/menuButtons.ejs");
return cb();
};

exports.eejsBlock_mySettings = function (hook_name, args, cb) {
args.content = args.content + eejs.require("ep_comments_page/templates/settings.ejs");
return cb();
};

exports.padInitToolbar = function (hookName, args) {
var toolbar = args.toolbar;

var button = toolbar.button({
command: 'addComment',
localizationId: 'ep_comments_page.add_comment.title',
class: 'buttonicon buttonicon-comment-medical'
});

toolbar.registerButton('addComment', button);
};

exports.eejsBlock_editbarMenuLeft = function (hook_name, args, cb) {
//check if custom button is used
if (JSON.stringify(settings.toolbar).indexOf('addComment') > -1 ) {
return cb();
}
args.content = args.content + eejs.require("ep_comments_page/templates/commentBarButtons.ejs");
return cb();
};
Expand Down
10 changes: 10 additions & 0 deletions static/js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -1204,6 +1204,15 @@ var hooks = {
return cb();
},

postToolbarInit: function (hookName, args, cb) {
var editbar = args.toolbar;

editbar.registerCommand('addComment', function () {
pad.plugins.ep_comments_page.displayNewCommentForm();
});
return cb();
},

aceEditEvent: function(hookName, context, cb) {
if(!pad.plugins) pad.plugins = {};
// first check if some text is being marked/unmarked to add comment to it
Expand Down Expand Up @@ -1255,6 +1264,7 @@ var hooks = {

exports.aceEditorCSS = hooks.aceEditorCSS;
exports.postAceInit = hooks.postAceInit;
exports.postToolbarInit = hooks.postToolbarInit;
exports.aceAttribsToClasses = hooks.aceAttribsToClasses;
exports.aceEditEvent = hooks.aceEditEvent;

Expand Down
3 changes: 0 additions & 3 deletions templates/menuButtons.ejs

This file was deleted.

0 comments on commit 48a03ae

Please sign in to comment.