ep_comments_page 11.0.17 → 11.0.19

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/static/js/index.js +37 -36
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "description": "Adds comments on sidebar and link it to the text. For no-skin use ep_page_view.",
3
3
  "name": "ep_comments_page",
4
- "version": "11.0.17",
4
+ "version": "11.0.19",
5
5
  "author": {
6
6
  "name": "Nicolas Lescop",
7
7
  "email": "limplementeur@gmail.com"
@@ -19,8 +19,8 @@ const preCommentMark = require('ep_comments_page/static/js/preCommentMark');
19
19
  const getCommentIdOnFirstPositionSelected = events.getCommentIdOnFirstPositionSelected;
20
20
  const hasCommentOnSelection = events.hasCommentOnSelection;
21
21
  const Security = require('ep_etherpad-lite/static/js/security');
22
- // eslint-disable-next-line no-redeclare
23
- const io = require('socket.io-client');
22
+ const socketIoClient = require('socket.io-client');
23
+ const io = socketIoClient.default || socketIoClient;
24
24
 
25
25
  const cssFiles = [
26
26
  'ep_comments_page/static/css/comment.css',
@@ -459,46 +459,47 @@ EpComments.prototype.collectComments = function (callback) {
459
459
  commentElm.css({top: commentPos});
460
460
  });
461
461
 
462
- // HOVER SIDEBAR COMMENT
463
- let hideCommentTimer;
464
- this.container.on('mouseover', '.sidebar-comment', (e) => {
465
- // highlight comment
466
- clearTimeout(hideCommentTimer);
467
- commentBoxes.highlightComment(e.currentTarget.id, e);
468
- }).on('mouseout', '.sidebar-comment', (e) => {
469
- // do not hide directly the comment, because sometime the mouse get out accidently
470
- hideCommentTimer = setTimeout(() => {
471
- commentBoxes.hideComment(e.currentTarget.id);
472
- }, 1000);
473
- });
462
+ // Bind event handlers only once — collectComments is called repeatedly
463
+ // and re-binding causes handlers to stack up (fixes #214).
464
+ if (!this._eventsBound) {
465
+ this._eventsBound = true;
466
+ let hideCommentTimer;
474
467
 
475
- // HOVER OR CLICK THE COMMENTED TEXT IN THE EDITOR
476
- // hover event
477
- this.padInner.contents().on('mouseover', '.comment', function (e) {
478
- if (container.is(':visible')) { // not on mobile
468
+ // HOVER SIDEBAR COMMENT
469
+ this.container.on('mouseover', '.sidebar-comment', (e) => {
479
470
  clearTimeout(hideCommentTimer);
471
+ commentBoxes.highlightComment(e.currentTarget.id, e);
472
+ }).on('mouseout', '.sidebar-comment', (e) => {
473
+ hideCommentTimer = setTimeout(() => {
474
+ commentBoxes.hideComment(e.currentTarget.id);
475
+ }, 1000);
476
+ });
477
+
478
+ // HOVER OR CLICK THE COMMENTED TEXT IN THE EDITOR
479
+ this.padInner.contents().on('mouseover', '.comment', function (e) {
480
+ if (container.is(':visible')) {
481
+ clearTimeout(hideCommentTimer);
482
+ const commentId = self.commentIdOf(e);
483
+ commentBoxes.highlightComment(commentId, e, $(this));
484
+ }
485
+ });
486
+
487
+ this.padInner.contents().on('click', '.comment', function (e) {
480
488
  const commentId = self.commentIdOf(e);
481
489
  commentBoxes.highlightComment(commentId, e, $(this));
482
- }
483
- });
484
-
485
- // click event
486
- this.padInner.contents().on('click', '.comment', function (e) {
487
- const commentId = self.commentIdOf(e);
488
- commentBoxes.highlightComment(commentId, e, $(this));
489
- });
490
+ });
490
491
 
491
- this.padInner.contents().on('mouseleave', '.comment', (e) => {
492
- const commentOpenedByClickOnIcon = commentIcons.isCommentOpenedByClickOnIcon();
493
- // only closes comment if it was not opened by a click on the icon
494
- if (!commentOpenedByClickOnIcon && container.is(':visible')) {
495
- hideCommentTimer = setTimeout(() => {
496
- self.closeOpenedComment(e);
497
- }, 1000);
498
- }
499
- });
492
+ this.padInner.contents().on('mouseleave', '.comment', (e) => {
493
+ const commentOpenedByClickOnIcon = commentIcons.isCommentOpenedByClickOnIcon();
494
+ if (!commentOpenedByClickOnIcon && container.is(':visible')) {
495
+ hideCommentTimer = setTimeout(() => {
496
+ self.closeOpenedComment(e);
497
+ }, 1000);
498
+ }
499
+ });
500
500
 
501
- this.addListenersToCloseOpenedComment();
501
+ this.addListenersToCloseOpenedComment();
502
+ }
502
503
 
503
504
  this.setYofComments();
504
505
  if (callback) callback();