Commit 5d5d28e6 by Anton Stupak

Merge pull request #6688 from edx/anton/edxnotes-fix-viewer

TNL-1132: Fix viewer behaviour on hover.
parents fdb490d1 df86a331
......@@ -125,6 +125,24 @@ define(['jquery', 'underscore', 'annotator'], function ($, _, Annotator) {
Annotator.prototype._setupViewer
);
Annotator.Editor.prototype.isShown = Annotator.Viewer.prototype.isShown;
/**
* Modifies Annotator.onHighlightMouseover to avoid showing the viewer if the
* editor is opened.
**/
Annotator.prototype.onHighlightMouseover = _.wrap(
Annotator.prototype.onHighlightMouseover,
function (func, event) {
// Do nothing if the editor is opened.
if (this.editor.isShown()) {
return false;
}
return func.call(this, event);
},
Annotator.prototype._setupViewer
);
$.extend(true, Annotator.prototype, {
events: {
'.annotator-hl click': 'onHighlightClick',
......
......@@ -49,6 +49,13 @@ define([
_.invoke(Annotator._instances, 'destroy');
});
it('does not show the viewer if the editor is opened', function() {
annotators[0].showEditor({}, {});
highlights[0].mouseover();
expect($('#edx-notes-wrapper-123 .annotator-editor')).not.toHaveClass('annotator-hide');
expect($('#edx-notes-wrapper-123 .annotator-viewer')).toHaveClass('annotator-hide');
});
it('clicking a highlight freezes mouseover and mouseout in all highlighted text', function() {
_.each(annotators, function(annotator) {
expect(annotator.isFrozen).toBe(false);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment