Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New: drawing dialog #364

Merged
merged 21 commits into from
Sep 8, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/i18n/en-US.properties
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,8 @@ annotation_add_comment_placeholder=Add a comment here...
annotation_reply_placeholder=Post a reply...
# Text for cancel annotation button
annotation_cancel=Cancel
# Text for save annotation button
annotation_save=Save
# Text for post annotation button
annotation_post=Post
# Text for delete annotation button
Expand Down
1 change: 1 addition & 0 deletions src/lib/annotations/AnnotationDialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ class AnnotationDialog extends EventEmitter {
this.hasAnnotations = data.annotations.length > 0;
this.canAnnotate = data.canAnnotate;
this.locale = data.locale;
this.isMobile = data.isMobile;
}

/**
Expand Down
1 change: 1 addition & 0 deletions src/lib/annotations/AnnotationThread.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ class AnnotationThread extends EventEmitter {
this.type = data.type;
this.locale = data.locale;
this.isMobile = data.isMobile;
this.hasTouch = data.hasTouch;
this.permissions = data.permissions;

this.setup();
Expand Down
12 changes: 12 additions & 0 deletions src/lib/annotations/Annotator.scss
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ $avatar-color-9: #f22c44;
}
}

.bp-annotation-drawing-dialog,
.bp-annotation-highlight-dialog .bp-btn-plain,
.bp-annotation-highlight-dialog .bp-btn-plain:hover {
padding-left: 5px;
Expand Down Expand Up @@ -362,6 +363,7 @@ $avatar-color-9: #f22c44;
}
}

.bp-annotation-drawing-dialog,
.bp-annotation-highlight-dialog,
.bp-annotation-highlight-dialog:hover {
background-color: $white;
Expand All @@ -374,6 +376,15 @@ $avatar-color-9: #f22c44;
padding-top: 1px;
}

.bp-btn-annotate-draw-add {
padding-bottom: 3px;
padding-right: 6px;
}

.bp-btn-annotate-draw-delete {
padding-bottom: 3px;
}

.bp-highlight-comment-btn {
padding-top: 3px;
}
Expand Down Expand Up @@ -430,6 +441,7 @@ $avatar-color-9: #f22c44;
}
}

.bp-annotation-drawing-label,
.bp-annotation-highlight-label {
padding-left: 5px;
padding-right: 5px;
Expand Down
2 changes: 1 addition & 1 deletion src/lib/annotations/__tests__/annotatorUtil-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,7 @@ describe('lib/annotations/annotatorUtil', () => {

it('should do nothing when the target exists and it is not the textLayer', () => {
event.target = {
className: 'button'
nodeName: 'BUTTON'
};
locationHandler(event);
expect(callback).to.not.be.called;
Expand Down
2 changes: 2 additions & 0 deletions src/lib/annotations/annotationConstants.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ export const CLASS_ANNOTATION_BUTTON_DRAW_POST = 'bp-btn-annotate-draw-post';
export const CLASS_ANNOTATION_BUTTON_DRAW_CANCEL = 'bp-btn-annotate-draw-cancel';
export const CLASS_ANNOTATION_BUTTON_DRAW_ENTER = 'bp-btn-annotate-draw-enter';
export const CLASS_ANNOTATION_DRAWING_LABEL = 'bp-annotation-drawing-label';
export const CLASS_ANNOTATION_DRAWING_DIALOG = 'bp-annotation-drawing-dialog';
export const CLASS_ANNOTATION_DRAWING_BTNS = 'bp-annotation-drawing-btns';
export const CLASS_ADD_DRAWING_BTN = 'bp-btn-annotate-draw-add';
export const CLASS_DELETE_DRAWING_BTN = 'bp-btn-annotate-draw-delete';

Expand Down
6 changes: 4 additions & 2 deletions src/lib/annotations/annotatorUtil.js
Original file line number Diff line number Diff line change
Expand Up @@ -449,8 +449,9 @@ export function eventToLocationHandler(locationFunction, callback) {
return (event) => {
const evt = event || window.event;
// Do nothing when the target isn't the text layer in case the text layer receives event precedence over buttons
// NOTE: Currently only applicable to documents. Need to find a better way to ensure button event precedence.
if (!evt || (event.target && event.target.className !== 'textLayer')) {
// NOTE: @jpress Currently only applicable to documents.
// Need to find a better way to ensure button event precedence.
if (!evt || (evt.target && evt.target.nodeName === 'BUTTON')) {
return;
}

Expand All @@ -475,6 +476,7 @@ export function prevDefAndStopProp(event) {
event.preventDefault();
event.stopPropagation();
}

/**
* Create a JSON object containing x/y coordinates and optionally dimensional information
*
Expand Down
5 changes: 1 addition & 4 deletions src/lib/annotations/doc/DocAnnotator.js
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,7 @@ class DocAnnotator extends Annotator {
container: this.container,
fileVersionId: this.fileVersionId,
isMobile: this.isMobile,
hasTouch: this.hasTouch,
locale: this.locale,
location,
type,
Expand Down Expand Up @@ -548,10 +549,6 @@ class DocAnnotator extends Annotator {
this.highlightThrottleHandle = null;
}

if (!this.permissions.canAnnotate) {
return;
}

Object.keys(this.modeControllers).forEach((mode) => {
const controller = this.modeControllers[mode];
controller.removeSelection();
Expand Down
Loading