diff --git a/src/lib/annotations/AnnotationDialog.js b/src/lib/annotations/AnnotationDialog.js index 27b22868e..af0ae863c 100644 --- a/src/lib/annotations/AnnotationDialog.js +++ b/src/lib/annotations/AnnotationDialog.js @@ -2,7 +2,6 @@ import autobind from 'autobind-decorator'; import EventEmitter from 'events'; import * as annotatorUtil from './annotatorUtil'; import * as constants from './annotationConstants'; -import { CLASS_ACTIVE, CLASS_HIDDEN } from '../constants'; import { ICON_CLOSE, ICON_DELETE } from '../icons/icons'; const CLASS_ANNOTATION_PLAIN_HIGHLIGHT = 'bp-plain-highlight'; @@ -86,7 +85,7 @@ class AnnotationDialog extends EventEmitter { this.element.classList.add(CLASS_ANNOTATION_PLAIN_HIGHLIGHT); const headerEl = this.element.querySelector(constants.SELECTOR_MOBILE_DIALOG_HEADER); - headerEl.classList.add(CLASS_HIDDEN); + headerEl.classList.add(constants.CLASS_HIDDEN); } const dialogCloseButtonEl = this.element.querySelector(constants.SELECTOR_DIALOG_CLOSE); @@ -102,7 +101,7 @@ class AnnotationDialog extends EventEmitter { : this.element.querySelector(constants.SELECTOR_ANNOTATION_TEXTAREA); // Don't re-position if reply textarea is already active - const textareaIsActive = textAreaEl.classList.contains(CLASS_ACTIVE); + const textareaIsActive = textAreaEl.classList.contains(constants.CLASS_ACTIVE); if (textareaIsActive && this.element.parentNode) { return; } @@ -117,7 +116,7 @@ class AnnotationDialog extends EventEmitter { if (this.hasAnnotations) { this.activateReply(); } else { - textAreaEl.classList.add(CLASS_ACTIVE); + textAreaEl.classList.add(constants.CLASS_ACTIVE); } // Move cursor to end of text area @@ -357,7 +356,7 @@ class AnnotationDialog extends EventEmitter { * @return {void} */ mouseenterHandler() { - if (this.element.classList.contains(CLASS_HIDDEN)) { + if (this.element.classList.contains(constants.CLASS_HIDDEN)) { annotatorUtil.showElement(this.element); const replyTextArea = this.element.querySelector(`.${CLASS_REPLY_TEXTAREA}`); @@ -490,10 +489,10 @@ class AnnotationDialog extends EventEmitter {
${text}
-
+
${__('annotation_delete_confirmation_message')}
@@ -535,13 +534,13 @@ class AnnotationDialog extends EventEmitter { const replyTextEl = this.dialogEl.querySelector(`.${CLASS_REPLY_TEXTAREA}`); // Don't activate if reply textarea is already active - const isActive = replyTextEl.classList.contains(CLASS_ACTIVE); + const isActive = replyTextEl.classList.contains(constants.CLASS_ACTIVE); if (isActive) { return; } const replyButtonEls = replyTextEl.parentNode.querySelector(constants.SELECTOR_BUTTON_CONTAINER); - replyTextEl.classList.add(CLASS_ACTIVE); + replyTextEl.classList.add(constants.CLASS_ACTIVE); annotatorUtil.showElement(replyButtonEls); // Auto scroll annotations dialog to bottom where new comment was added @@ -652,7 +651,7 @@ class AnnotationDialog extends EventEmitter { generateDialogEl(numAnnotations) { const dialogEl = document.createElement('div'); dialogEl.innerHTML = ` -
+
@@ -664,14 +663,14 @@ class AnnotationDialog extends EventEmitter {
-
+
-
+
diff --git a/src/lib/annotations/Annotator.js b/src/lib/annotations/Annotator.js index d23ab8c54..2bfa807d6 100644 --- a/src/lib/annotations/Annotator.js +++ b/src/lib/annotations/Annotator.js @@ -2,15 +2,11 @@ import EventEmitter from 'events'; import autobind from 'autobind-decorator'; import AnnotationService from './AnnotationService'; import * as annotatorUtil from './annotatorUtil'; -import { - CLASS_ACTIVE, - CLASS_HIDDEN, - SELECTOR_BOX_PREVIEW_BTN_ANNOTATE_POINT, - SELECTOR_BOX_PREVIEW_BTN_ANNOTATE_DRAW -} from '../constants'; import { ICON_CLOSE } from '../icons/icons'; import './Annotator.scss'; import { + CLASS_ACTIVE, + CLASS_HIDDEN, DATA_TYPE_ANNOTATION_DIALOG, CLASS_MOBILE_ANNOTATION_DIALOG, CLASS_ANNOTATION_DIALOG, @@ -59,6 +55,7 @@ class Annotator extends EventEmitter { this.validationErrorEmitted = false; this.isMobile = data.isMobile; this.previewUI = data.previewUI; + this.modeButtons = data.modeButtons; this.annotationModeHandlers = []; } @@ -223,7 +220,8 @@ class Annotator extends EventEmitter { } // Hide create annotations button if image is rotated - const pointAnnotateButton = this.previewUI.getAnnotateButton(SELECTOR_BOX_PREVIEW_BTN_ANNOTATE_POINT); + const pointButtonSelector = this.modeButtons[TYPES.point].selector; + const pointAnnotateButton = this.previewUI.getAnnotateButton(pointButtonSelector); if (rotationAngle !== 0) { annotatorUtil.hideElement(pointAnnotateButton); @@ -251,7 +249,8 @@ class Annotator extends EventEmitter { */ togglePointAnnotationHandler(event = {}) { this.destroyPendingThreads(); - const buttonEl = event.target || this.previewUI.getAnnotateButton(SELECTOR_BOX_PREVIEW_BTN_ANNOTATE_POINT); + const pointButtonSelector = this.modeButtons[TYPES.point].selector; + const buttonEl = event.target || this.previewUI.getAnnotateButton(pointButtonSelector); if (this.isInDrawMode()) { this.toggleDrawAnnotationHandler(); @@ -294,7 +293,8 @@ class Annotator extends EventEmitter { this.togglePointAnnotationHandler(); } - const buttonEl = event.target || this.previewUI.getAnnotateButton(SELECTOR_BOX_PREVIEW_BTN_ANNOTATE_DRAW); + const drawButtonSelector = this.modeButtons[TYPES.draw].selector; + const buttonEl = event.target || this.previewUI.getAnnotateButton(drawButtonSelector); const postButtonEl = this.previewUI.getAnnotateButton(SELECTOR_ANNOTATION_BUTTON_DRAW_POST); // Exit if in draw mode diff --git a/src/lib/annotations/CommentBox.js b/src/lib/annotations/CommentBox.js index 37d263650..5130f0230 100644 --- a/src/lib/annotations/CommentBox.js +++ b/src/lib/annotations/CommentBox.js @@ -1,5 +1,4 @@ import EventEmitter from 'events'; -import { CLASS_ACTIVE } from '../constants'; import * as constants from './annotationConstants'; import { hideElement, showElement } from './annotatorUtil'; @@ -178,7 +177,7 @@ class CommentBox extends EventEmitter { const containerEl = document.createElement('section'); containerEl.classList.add('bp-create-highlight-comment'); containerEl.innerHTML = ` -