From ffee243d9e4d55de54c6685a25d02fa3cf759918 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Thu, 10 Feb 2022 22:42:09 +0300 Subject: [PATCH] [DE] Refactoring navigation list: show full name, update tips on updating names --- apps/common/main/lib/component/TreeView.js | 59 +++++++++++++++---- .../main/app/controller/Navigation.js | 6 ++ .../main/app/view/Navigation.js | 3 +- .../main/resources/less/navigation.less | 6 ++ 4 files changed, 60 insertions(+), 14 deletions(-) diff --git a/apps/common/main/lib/component/TreeView.js b/apps/common/main/lib/component/TreeView.js index d6ac4c4b4..d362f44de 100644 --- a/apps/common/main/lib/component/TreeView.js +++ b/apps/common/main/lib/component/TreeView.js @@ -212,19 +212,7 @@ define([ this.dataViewItems.push(view); } - var name = record.get('name'); - if (name.length > 37 - record.get('level')*2) - record.set('tip', name); - if (record.get('tip')) { - var view_el = $(view.el); - view_el.attr('data-toggle', 'tooltip'); - view_el.tooltip({ - title : record.get('tip'), - placement : 'cursor', - zIndex : this.tipZIndex - }); - } - + this.updateTip(view); this.listenTo(view, 'change', this.onChangeItem); this.listenTo(view, 'remove', this.onRemoveItem); this.listenTo(view, 'click', this.onClickItem); @@ -361,6 +349,51 @@ define([ focus: function() { this.cmpEl && this.cmpEl.find('.treeview').focus(); + }, + + updateTip: function(item) { + var record = item.model, + name = record.get('name'), + me = this; + + if (name.length > 37 - record.get('level')*2) + record.set('tip', name); + else + record.set('tip', ''); + + var el = item.$el || $(item.el); + var tip = el.data('bs.tooltip'); + if (tip) { + if (tip.dontShow===undefined) + tip.dontShow = true; + el.removeData('bs.tooltip'); + } + if (record.get('tip')) { + el.attr('data-toggle', 'tooltip'); + el.tooltip({ + title : record.get('tip'), + placement : 'cursor', + zIndex : this.tipZIndex + }); + if (this.delayRenderTips) + el.one('mouseenter', function(){ + el.attr('data-toggle', 'tooltip'); + el.tooltip({ + title : record.get('tip'), + placement : 'cursor', + zIndex : me.tipZIndex + }); + el.mouseenter(); + }); + else { + el.attr('data-toggle', 'tooltip'); + el.tooltip({ + title : record.get('tip'), + placement : 'cursor', + zIndex : me.tipZIndex + }); + } + } } } })()); diff --git a/apps/documenteditor/main/app/controller/Navigation.js b/apps/documenteditor/main/app/controller/Navigation.js index d80f24d10..bbb6a0caa 100644 --- a/apps/documenteditor/main/app/controller/Navigation.js +++ b/apps/documenteditor/main/app/controller/Navigation.js @@ -106,6 +106,7 @@ define([ onAfterRender: function(panelNavigation) { panelNavigation.viewNavigationList.on('item:click', _.bind(this.onSelectItem, this)); panelNavigation.viewNavigationList.on('item:contextmenu', _.bind(this.onItemContextMenu, this)); + panelNavigation.viewNavigationList.on('item:add', _.bind(this.onItemAdd, this)); panelNavigation.navigationMenu.on('item:click', _.bind(this.onMenuItemClick, this)); panelNavigation.navigationMenu.items[11].menu.on('item:click', _.bind(this.onMenuLevelsItemClick, this)); }, @@ -157,6 +158,7 @@ define([ } else { item.set('name', this._navigationObject.get_Text(index)); item.set('isEmptyItem', this._navigationObject.isEmptyItem(index)); + this.panelNavigation.viewNavigationList.updateTip(item.get('dataItem')); } }, @@ -222,6 +224,10 @@ define([ Common.NotificationCenter.trigger('edit:complete', this.panelNavigation); }, + onItemAdd: function(picker, item, record, e){ + record.set('dataItem', item); + }, + onMenuItemClick: function (menu, item) { if (!this._navigationObject && !this._viewerNavigationObject) return; diff --git a/apps/documenteditor/main/app/view/Navigation.js b/apps/documenteditor/main/app/view/Navigation.js index d4e4de775..68269cf72 100644 --- a/apps/documenteditor/main/app/view/Navigation.js +++ b/apps/documenteditor/main/app/view/Navigation.js @@ -71,7 +71,8 @@ define([ enableKeyEvents: false, emptyText: this.txtEmpty, emptyItemText: this.txtEmptyItem, - style: 'border: none;' + style: 'border: none;', + delayRenderTips: true }); this.viewNavigationList.cmpEl.off('click'); this.navigationMenu = new Common.UI.Menu({ diff --git a/apps/documenteditor/main/resources/less/navigation.less b/apps/documenteditor/main/resources/less/navigation.less index 0a3726fad..cec0754ec 100644 --- a/apps/documenteditor/main/resources/less/navigation.less +++ b/apps/documenteditor/main/resources/less/navigation.less @@ -35,5 +35,11 @@ .name.not-header { font-style: italic; } + + .name { + white-space: pre-wrap; + word-break: break-all; + max-height: 350px; + } } }