From 85c47206bd356ba97a4c36757393dd728cefdf1e Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Wed, 6 Mar 2019 16:41:54 +0300 Subject: [PATCH] [SSE] Refactoring tooltips for filters, hyperlinks --- .../main/app/controller/DocumentHolder.js | 125 +++++++++++------- 1 file changed, 79 insertions(+), 46 deletions(-) diff --git a/apps/spreadsheeteditor/main/app/controller/DocumentHolder.js b/apps/spreadsheeteditor/main/app/controller/DocumentHolder.js index f42b5c824..27a559702 100644 --- a/apps/spreadsheeteditor/main/app/controller/DocumentHolder.js +++ b/apps/spreadsheeteditor/main/app/controller/DocumentHolder.js @@ -841,14 +841,15 @@ define([ } }, - hideHyperlinkTip: function() { + hideHyperlinkTip: function(callback) { if (!this.tooltips.hyperlink.isHidden && this.tooltips.hyperlink.ref) { - this.tooltips.hyperlink.ref.hide(); + this.tooltips.hyperlink.ref.hide(callback); this.tooltips.hyperlink.isHidden = true; } }, onApiMouseMove: function(dataarray) { + var darray = dataarray; if (!this._isFullscreenMenu && dataarray.length) { var index_hyperlink, /** coauthoring begin **/ @@ -894,11 +895,66 @@ define([ pos = [ me.documentHolder.cmpEl.offset().left - $(window).scrollLeft(), me.documentHolder.cmpEl.offset().top - $(window).scrollTop() - ]; + ], + need_return = false; - hyperlinkTip.isHidden = false; - row_columnTip.isHidden = false; - filterTip.isHidden = false; + if (this._state.index_hyperlink !== index_hyperlink ||this._state.index_comments !== index_comments || + this._state.index_locked !== index_locked || this._state.index_column !== index_column || + this._state.index_row !== index_row || this._state.index_filter !== index_filter) { + if (!index_hyperlink) { + need_return = true; + me.hideHyperlinkTip(function () { + me.onApiMouseMove(darray); + }); + } + if (index_column===undefined && index_row===undefined) { + if (!row_columnTip.isHidden && row_columnTip.ref) { + need_return = true; + row_columnTip.ref.hide(function () { + me.onApiMouseMove(darray); + }); + row_columnTip.isHidden = true; + } + } + if (me.permissions.isEdit || me.permissions.canViewComments) { + if (!index_comments || this.popupmenu) { + commentTip.moveCommentId = undefined; + if (commentTip.viewCommentId != undefined) { + commentTip = {}; + + var commentsController = this.getApplication().getController('Common.Controllers.Comments'); + if (commentsController) { + if (this.permissions.canCoAuthoring && this.permissions.canViewComments) + setTimeout(function() {commentsController.onApiHideComment(true);}, 200); + else + commentsController.onApiHideComment(true); + } + } + } + } + if (me.permissions.isEdit) { + if (!index_locked) { + me.hideCoAuthTips(); + } + } + if (index_filter===undefined || (me.dlgFilter && me.dlgFilter.isVisible()) || (me.currentMenu && me.currentMenu.isVisible())) { + if (!filterTip.isHidden && filterTip.ref) { + need_return = true; + filterTip.ref.hide(function () { + me.onApiMouseMove(darray); + }); + filterTip.isHidden = true; + } + } + this._state.index_hyperlink = index_hyperlink; + this._state.index_comments = index_comments; + this._state.index_locked = index_locked; + this._state.index_column = index_column; + this._state.index_row = index_row; + this._state.index_filter = index_filter; + + if (need_return) return; + } /** coauthoring begin **/ var getUserName = function(id){ @@ -942,28 +998,28 @@ define([ html : true, title : linkstr }).on('tooltip:hide', function(tip) { + if (tip !== hyperlinkTip) return; hyperlinkTip.ref = undefined; hyperlinkTip.text = ''; }); hyperlinkTip.ref.show([-10000, -10000]); hyperlinkTip.isHidden = false; + + showPoint = [data.asc_getX(), data.asc_getY()]; + showPoint[0] += (pos[0] + 6); + showPoint[1] += (pos[1] - 20); + showPoint[1] -= hyperlinkTip.ref.getBSTip().$tip.height(); + var tipwidth = hyperlinkTip.ref.getBSTip().$tip.width(); + if (showPoint[0] + tipwidth > me.tooltips.coauth.bodyWidth ) + showPoint[0] = me.tooltips.coauth.bodyWidth - tipwidth; + + hyperlinkTip.ref.getBSTip().$tip.css({ + top : showPoint[1] + 'px', + left: showPoint[0] + 'px' + }); } - showPoint = [data.asc_getX(), data.asc_getY()]; - showPoint[0] += (pos[0] + 6); - showPoint[1] += (pos[1] - 20); - showPoint[1] -= hyperlinkTip.ref.getBSTip().$tip.height(); - var tipwidth = hyperlinkTip.ref.getBSTip().$tip.width(); - if (showPoint[0] + tipwidth > me.tooltips.coauth.bodyWidth ) - showPoint[0] = me.tooltips.coauth.bodyWidth - tipwidth; - - hyperlinkTip.ref.getBSTip().$tip.css({ - top : showPoint[1] + 'px', - left: showPoint[0] + 'px' - }); - } else { - me.hideHyperlinkTip(); } if (index_column!==undefined || index_row!==undefined) { @@ -984,6 +1040,7 @@ define([ html : true, title : str }).on('tooltip:hide', function(tip) { + if (tip !== row_columnTip) return; row_columnTip.ref = undefined; row_columnTip.text = ''; }); @@ -1004,12 +1061,7 @@ define([ left: showPoint[0] + 'px' }); } - } else { - if (!row_columnTip.isHidden && row_columnTip.ref) { - row_columnTip.ref.hide(); - row_columnTip.isHidden = true; - } - } + } else if (me.permissions.isEdit || me.permissions.canViewComments) { if (index_comments && !this.popupmenu) { @@ -1039,19 +1091,6 @@ define([ } }, 400); } - } else { - commentTip.moveCommentId = undefined; - if (commentTip.viewCommentId != undefined) { - commentTip = {}; - - var commentsController = this.getApplication().getController('Common.Controllers.Comments'); - if (commentsController) { - if (this.permissions.canCoAuthoring && this.permissions.canViewComments) - setTimeout(function() {commentsController.onApiHideComment(true);}, 200); - else - commentsController.onApiHideComment(true); - } - } } } @@ -1105,8 +1144,6 @@ define([ }); } } - } else { - me.hideCoAuthTips(); } } @@ -1129,6 +1166,7 @@ define([ title : str, cls: 'auto-tooltip' }).on('tooltip:hide', function(tip) { + if (tip !== filterTip) return; filterTip.ref = undefined; filterTip.text = ''; }); @@ -1153,11 +1191,6 @@ define([ left: showPoint[0] + 'px' }); } - } else { - if (!filterTip.isHidden && filterTip.ref) { - filterTip.ref.hide(); - filterTip.isHidden = true; - } } } },