Skip to content

Commit

Permalink
Fix: Show the appropriate buttons in mobile create highlight dialog (#75
Browse files Browse the repository at this point in the history
)
  • Loading branch information
pramodsum committed Dec 19, 2017
1 parent 1e92025 commit 05dba16
Show file tree
Hide file tree
Showing 5 changed files with 115 additions and 154 deletions.
36 changes: 18 additions & 18 deletions src/AnnotationDialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class AnnotationDialog extends EventEmitter {
/**
* [constructor]
*
* @param {AnnotationDialogData} data - Data for constructing thread
* @param {AnnotationDialogData} data Data for constructing thread
* @return {AnnotationDialog} Annotation dialog instance
*/
constructor(data) {
Expand Down Expand Up @@ -220,7 +220,7 @@ class AnnotationDialog extends EventEmitter {
/**
* Adds an annotation to the dialog.
*
* @param {Annotation} annotation - Annotation to add
* @param {Annotation} annotation Annotation to add
* @return {void}
*/
addAnnotation(annotation) {
Expand All @@ -239,7 +239,7 @@ class AnnotationDialog extends EventEmitter {
/**
* Removes an annotation from the dialog.
*
* @param {string} annotationID - ID of annotation to remove
* @param {string} annotationID ID of annotation to remove
* @return {void}
*/
removeAnnotation(annotationID) {
Expand All @@ -257,7 +257,7 @@ class AnnotationDialog extends EventEmitter {
/**
* Posts an annotation in the dialog.
*
* @param {string} [textInput] - Annotation text to post
* @param {string} [textInput] Annotation text to post
* @return {void}
*/
postAnnotation(textInput) {
Expand Down Expand Up @@ -291,8 +291,8 @@ class AnnotationDialog extends EventEmitter {
/**
* Sets up the dialog element.
*
* @param {Object} annotations - Annotations to show in the dialog
* @param {HTMLElement} threadEl - Annotation icon element
* @param {Object} annotations Annotations to show in the dialog
* @param {HTMLElement} threadEl Annotation icon element
* @return {void}
* @protected
*/
Expand Down Expand Up @@ -327,7 +327,7 @@ class AnnotationDialog extends EventEmitter {
/**
* Sorts and adds annotations to the dialog
*
* @param {Object} annotations - Annotations to show in the dialog
* @param {Object} annotations Annotations to show in the dialog
* @return {void}
* @protected
*/
Expand Down Expand Up @@ -498,7 +498,7 @@ class AnnotationDialog extends EventEmitter {
* Keydown handler for dialog.
*
* @private
* @param {Event} event - DOM event
* @param {Event} event DOM event
* @return {void}
*/
keydownHandler(event) {
Expand All @@ -519,7 +519,7 @@ class AnnotationDialog extends EventEmitter {
* Stops propagation of DOM event.
*
* @private
* @param {Event} event - DOM event
* @param {Event} event DOM event
* @return {void}
*/
stopPropagation(event) {
Expand All @@ -530,7 +530,7 @@ class AnnotationDialog extends EventEmitter {
* Click handler on dialog.
*
* @private
* @param {Event} event - DOM event
* @param {Event} event DOM event
* @return {void}
*/
clickHandler(event) {
Expand Down Expand Up @@ -591,7 +591,7 @@ class AnnotationDialog extends EventEmitter {
* Adds an annotation to the dialog.
*
* @private
* @param {Annotation} annotation - Annotation to add
* @param {Annotation} annotation Annotation to add
* @return {void}
*/
addAnnotationElement(annotation) {
Expand Down Expand Up @@ -770,7 +770,7 @@ class AnnotationDialog extends EventEmitter {
* Deactivate reply textarea.
*
* @private
* @param {boolean} clearText - Whether or not text in text area should be cleared
* @param {boolean} clearText Whether or not text in text area should be cleared
* @return {void}
*/
deactivateReply(clearText) {
Expand Down Expand Up @@ -819,7 +819,7 @@ class AnnotationDialog extends EventEmitter {
* Shows delete confirmation.
*
* @private
* @param {string} annotationID - ID of annotation to delete
* @param {string} annotationID ID of annotation to delete
* @return {void}
*/
showDeleteConfirmation(annotationID) {
Expand All @@ -836,7 +836,7 @@ class AnnotationDialog extends EventEmitter {
* Hides delete confirmation.
*
* @private
* @param {string} annotationID - ID of annotation to delete
* @param {string} annotationID ID of annotation to delete
* @return {void}
*/
hideDeleteConfirmation(annotationID) {
Expand All @@ -852,7 +852,7 @@ class AnnotationDialog extends EventEmitter {
* Broadcasts message to delete an annotation.
*
* @private
* @param {string} annotationID - ID of annotation to delete
* @param {string} annotationID ID of annotation to delete
* @return {void}
*/
deleteAnnotation(annotationID) {
Expand All @@ -863,7 +863,7 @@ class AnnotationDialog extends EventEmitter {
* Generates the annotation dialog DOM element
*
* @private
* @param {number} numAnnotations - length of annotations array
* @param {number} numAnnotations length of annotations array
* @return {HTMLElement} Annotation dialog DOM element
*/
generateDialogEl(numAnnotations) {
Expand Down Expand Up @@ -961,8 +961,8 @@ class AnnotationDialog extends EventEmitter {
* half of the viewer
*
* @private
* @param {number} yPos - y coordinate for the top of the dialog
* @param {number} containerHeight - height of the current annotation
* @param {number} yPos y coordinate for the top of the dialog
* @param {number} containerHeight height of the current annotation
* container/page
* @return {void}
*/
Expand Down
54 changes: 27 additions & 27 deletions src/doc/DocAnnotator.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ const ANNOTATION_LAYER_CLASSES = [CLASS_ANNOTATION_LAYER_HIGHLIGHT, CLASS_ANNOTA
/**
* Check if a thread is in a hover state.
*
* @param {Object} thread - The thread to check the state of
* @param {Object} thread The thread to check the state of
* @return {boolean} True if the thread is in a state of hover
*/
function isThreadInHoverState(thread) {
Expand Down Expand Up @@ -125,7 +125,7 @@ class DocAnnotator extends Annotator {
/**
* Determines the annotated element in the viewer
*
* @param {HTMLElement} containerEl - Container element for the viewer
* @param {HTMLElement} containerEl Container element for the viewer
* @return {HTMLElement} Annotated element in the viewer
*/
getAnnotatedEl(containerEl) {
Expand All @@ -141,8 +141,8 @@ class DocAnnotator extends Annotator {
* as defined by the PDF spec and page the highlight is on.
*
* @override
* @param {Event} event - DOM event
* @param {string} annotationType - Type of annotation
* @param {Event} event DOM event
* @param {string} annotationType Type of annotation
* @return {Object|null} Location object
*/
getLocationFromEvent(event, annotationType) {
Expand Down Expand Up @@ -250,9 +250,9 @@ class DocAnnotator extends Annotator {
* Creates the proper type of thread, adds it to in-memory map, and returns it.
*
* @override
* @param {Object} annotations - Annotations in thread
* @param {Object} location - Location object
* @param {string} [type] - Optional annotation type
* @param {Object} annotations Annotations in thread
* @param {Object} location Location object
* @param {string} [type] Optional annotation type
* @return {AnnotationThread} Created annotation thread
*/
createAnnotationThread(annotations, location, type) {
Expand All @@ -264,7 +264,7 @@ class DocAnnotator extends Annotator {
}

if (util.isHighlightAnnotation(type)) {
thread = new DocHighlightThread(threadParams);
thread = new DocHighlightThread(threadParams, this.commentHighlightEnabled);
} else if (type === TYPES.draw) {
thread = new DocDrawingThread(threadParams);
} else if (type === TYPES.point) {
Expand All @@ -284,7 +284,7 @@ class DocAnnotator extends Annotator {
* Override to factor in highlight types being filtered out, if disabled. Also scales annotation canvases.
*
* @override
* @param {number} pageNum - Page number
* @param {number} pageNum Page number
* @return {void}
*/
renderAnnotationsOnPage(pageNum) {
Expand Down Expand Up @@ -327,7 +327,7 @@ class DocAnnotator extends Annotator {
* Scales all annotation canvases for a specified page.
*
* @override
* @param {number} pageNum - Page number
* @param {number} pageNum Page number
* @return {void}
*/
scaleAnnotationCanvases(pageNum) {
Expand Down Expand Up @@ -511,7 +511,7 @@ class DocAnnotator extends Annotator {
* Creates an highlight annotation thread, adds it to in-memory map, and returns it.
*
* @private
* @param {string} [commentText] - If provided, this will save a highlight comment annotation, with commentText
* @param {string} [commentText] If provided, this will save a highlight comment annotation, with commentText
* being the text as the first comment in the thread.
* @return {DocHighlightThread} Created doc highlight annotation thread
*/
Expand Down Expand Up @@ -551,7 +551,7 @@ class DocAnnotator extends Annotator {
}

thread.state = STATES.hover;
thread.show(this.plainHighlightEnabled, this.commentHighlightEnabled);
thread.show();
thread.dialog.postAnnotation(commentText);

const controller = this.modeControllers[highlightType];
Expand All @@ -567,7 +567,7 @@ class DocAnnotator extends Annotator {
* Handles changes in text selection. Used for mobile highlight creation.
*
* @private
* @param {Event} event - The DOM event coming from interacting with the element.
* @param {Event} event The DOM event coming from interacting with the element.
* @return {void}
*/
onSelectionChange(event) {
Expand Down Expand Up @@ -638,7 +638,7 @@ class DocAnnotator extends Annotator {
* thread.
*
* @private
* @param {Event} event - DOM event
* @param {Event} event DOM event
* @return {void}
*/
highlightMousedownHandler(event) {
Expand Down Expand Up @@ -765,7 +765,7 @@ class DocAnnotator extends Annotator {
* Mouse move handler. Paired with throttle mouse move handler to check for annotation highlights.
*
* @private
* @param {Event} event - DDOM event fired by mouse move event
* @param {Event} event DOM event fired by mouse move event
* @return {void}
*/
onHighlightMouseMove(event) {
Expand All @@ -790,7 +790,7 @@ class DocAnnotator extends Annotator {
* Drawing selection handler. Delegates to the drawing controller
*
* @private
* @param {Event} event - DOM event
* @param {Event} event DOM event
* @return {void}
*/
drawingSelectionHandler(event) {
Expand Down Expand Up @@ -825,7 +825,7 @@ class DocAnnotator extends Annotator {
* mousedown.
*
* @private
* @param {Event} event - DOM event
* @param {Event} event DOM event
* @return {void}
*/
highlightMouseupHandler(event) {
Expand Down Expand Up @@ -865,7 +865,7 @@ class DocAnnotator extends Annotator {
* ANNOTATION_TYPE_HIGHLIGHT_COMMENT.
*
* @private
* @param {Event} event - DOM event
* @param {Event} event DOM event
* @return {void}
*/
highlightCreateHandler(event) {
Expand Down Expand Up @@ -909,7 +909,7 @@ class DocAnnotator extends Annotator {
* threads on the page.
*
* @private
* @param {Event} event - DOM event
* @param {Event} event DOM event
* @return {void}
*/
highlightClickHandler(event) {
Expand Down Expand Up @@ -997,7 +997,7 @@ class DocAnnotator extends Annotator {
* highlight annotations currently in memory for the specified page.
*
* @private
* @param {number} page - Page to draw annotations for
* @param {number} page Page to draw annotations for
* @return {void}
*/
showHighlightsOnPage(page) {
Expand All @@ -1021,7 +1021,7 @@ class DocAnnotator extends Annotator {
* not be a true Rangy highlight object.
*
* @private
* @param {Object} highlight - Highlight to delete.
* @param {Object} highlight Highlight to delete.
* @return {void}
*/
removeRangyHighlight(highlight) {
Expand All @@ -1041,9 +1041,9 @@ class DocAnnotator extends Annotator {
* Handle events emitted by the annotaiton service
*
* @private
* @param {Object} [data] - Annotation service event data
* @param {string} [data.event] - Annotation service event
* @param {string} [data.data] -
* @param {Object} [data] Annotation service event data
* @param {string} [data.event] Annotation service event
* @param {string} [data.data] Annotation event data
* @return {void}
*/
handleControllerEvents(data) {
Expand Down Expand Up @@ -1073,13 +1073,13 @@ class DocAnnotator extends Annotator {
* For filtering out and only showing the first thread in a list of threads.
*
* @private
* @param {Object} thread - The annotation thread to either hide or show
* @param {number} index - The index of the annotation thread
* @param {Object} thread The annotation thread to either hide or show
* @param {number} index The index of the annotation thread
* @return {void}
*/
showFirstDialogFilter(thread, index) {
if (index === 0) {
thread.show(this.plainHighlightEnabled, this.commentHighlightEnabled); // TODO(@jholdstock): remove flags on refactor.
thread.show();
} else {
thread.hideDialog();
}
Expand Down
Loading

0 comments on commit 05dba16

Please sign in to comment.