From 291c29706e6729bd8bb874b2b1c7a78a045420e5 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Mon, 3 Oct 2022 11:28:30 +0300 Subject: [PATCH] [PE] Show guide position --- .../main/app/controller/DocumentHolder.js | 53 +++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/apps/presentationeditor/main/app/controller/DocumentHolder.js b/apps/presentationeditor/main/app/controller/DocumentHolder.js index 4e25af86b..f4f7eac4f 100644 --- a/apps/presentationeditor/main/app/controller/DocumentHolder.js +++ b/apps/presentationeditor/main/app/controller/DocumentHolder.js @@ -126,6 +126,7 @@ define([ onKeyUp: _.bind(me.onKeyUp, me) }; + me.guideTip = { ttHeight: 20 }; // Hotkeys // --------------------- var keymap = {}; @@ -219,6 +220,7 @@ define([ me.api.asc_registerPlaceholderCallback(AscCommon.PlaceholderButtonType.Table, _.bind(me.onClickPlaceholderTable, me)); me.api.asc_registerPlaceholderCallback(AscCommon.PlaceholderButtonType.Video, _.bind(me.onClickPlaceholder, me, AscCommon.PlaceholderButtonType.Video)); me.api.asc_registerPlaceholderCallback(AscCommon.PlaceholderButtonType.Audio, _.bind(me.onClickPlaceholder, me, AscCommon.PlaceholderButtonType.Audio)); + me.api.asc_registerCallback('asc_onTrackGuide', _.bind(me.onTrackGuide, me)); } me.api.asc_registerCallback('asc_onCoAuthoringDisconnect', _.bind(me.onCoAuthoringDisconnect, me)); Common.NotificationCenter.on('api:disconnect', _.bind(me.onCoAuthoringDisconnect, me)); @@ -2147,6 +2149,57 @@ define([ this.documentHolder.fireEvent('rulers:change', [item.isChecked()]); }, + onTrackGuide: function(dPos, x, y) { + var tip = this.guideTip; + if (dPos === undefined) { + if (!tip.isHidden && tip.ref) { + tip.ref.hide(); + tip.ref = undefined; + tip.text = ''; + tip.isHidden = true; + } + } else { + if (!tip.parentEl) { + tip.parentEl = $('
'); + this.documentHolder.cmpEl.append(tip.parentEl); + } + + var str = dPos.toFixed(2); + if (tip.ref && tip.ref.isVisible()) { + if (tip.text != str) { + tip.text = str; + tip.ref.setTitle(str); + tip.ref.updateTitle(); + } + } + + if (!tip.ref || !tip.ref.isVisible()) { + tip.text = str; + tip.ref = new Common.UI.Tooltip({ + owner : tip.parentEl, + html : true, + title : str + }); + + tip.ref.show([-10000, -10000]); + tip.isHidden = false; + + var showPoint = [x, y]; + showPoint[0] += (this._XY[0] + 6); + showPoint[1] += (this._XY[1] - 20 - tip.ttHeight); + + var tipwidth = tip.ref.getBSTip().$tip.width(); + if (showPoint[0] + tipwidth > this._BodyWidth ) + showPoint[0] = this._BodyWidth - tipwidth - 20; + + tip.ref.getBSTip().$tip.css({ + top : showPoint[1] + 'px', + left: showPoint[0] + 'px' + }); + } + } + }, + SetDisabled: function(state) { this._isDisabled = state; this.documentHolder.SetDisabled(state);