TNL-1132: Fix viewer behaviour on hover.
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user