TNL-1132: Fix viewer behaviour on hover.

This commit is contained in:
polesye
2015-01-19 15:40:55 +02:00
parent fdb490d121
commit df86a3312f
2 changed files with 25 additions and 0 deletions

View File

@@ -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',

View File

@@ -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);