Merge pull request #1553 from ONLYOFFICE/fix/fix-navigation

Fix/fix navigation
This commit is contained in:
Julia Radzhabova 2022-02-10 23:04:01 +03:00 committed by GitHub
commit e856207e21
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 63 additions and 14 deletions

View file

@ -212,19 +212,7 @@ define([
this.dataViewItems.push(view); this.dataViewItems.push(view);
} }
var name = record.get('name'); this.updateTip(view);
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.listenTo(view, 'change', this.onChangeItem); this.listenTo(view, 'change', this.onChangeItem);
this.listenTo(view, 'remove', this.onRemoveItem); this.listenTo(view, 'remove', this.onRemoveItem);
this.listenTo(view, 'click', this.onClickItem); this.listenTo(view, 'click', this.onClickItem);
@ -361,6 +349,51 @@ define([
focus: function() { focus: function() {
this.cmpEl && this.cmpEl.find('.treeview').focus(); 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
});
}
}
} }
} }
})()); })());

View file

@ -106,6 +106,7 @@ define([
onAfterRender: function(panelNavigation) { onAfterRender: function(panelNavigation) {
panelNavigation.viewNavigationList.on('item:click', _.bind(this.onSelectItem, this)); panelNavigation.viewNavigationList.on('item:click', _.bind(this.onSelectItem, this));
panelNavigation.viewNavigationList.on('item:contextmenu', _.bind(this.onItemContextMenu, 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.on('item:click', _.bind(this.onMenuItemClick, this));
panelNavigation.navigationMenu.items[11].menu.on('item:click', _.bind(this.onMenuLevelsItemClick, this)); panelNavigation.navigationMenu.items[11].menu.on('item:click', _.bind(this.onMenuLevelsItemClick, this));
}, },
@ -157,6 +158,7 @@ define([
} else { } else {
item.set('name', this._navigationObject.get_Text(index)); item.set('name', this._navigationObject.get_Text(index));
item.set('isEmptyItem', this._navigationObject.isEmptyItem(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); Common.NotificationCenter.trigger('edit:complete', this.panelNavigation);
}, },
onItemAdd: function(picker, item, record, e){
record.set('dataItem', item);
},
onMenuItemClick: function (menu, item) { onMenuItemClick: function (menu, item) {
if (!this._navigationObject && !this._viewerNavigationObject) return; if (!this._navigationObject && !this._viewerNavigationObject) return;

View file

@ -71,7 +71,8 @@ define([
enableKeyEvents: false, enableKeyEvents: false,
emptyText: this.txtEmpty, emptyText: this.txtEmpty,
emptyItemText: this.txtEmptyItem, emptyItemText: this.txtEmptyItem,
style: 'border: none;' style: 'border: none;',
delayRenderTips: true
}); });
this.viewNavigationList.cmpEl.off('click'); this.viewNavigationList.cmpEl.off('click');
this.navigationMenu = new Common.UI.Menu({ this.navigationMenu = new Common.UI.Menu({

View file

@ -1317,6 +1317,7 @@ define([
dataHintOffset: '-16, -4', dataHintOffset: '-16, -4',
enableKeyEvents: true, enableKeyEvents: true,
additionalMenuItems: [this.listStylesAdditionalMenuItem], additionalMenuItems: [this.listStylesAdditionalMenuItem],
delayRenderTips: true,
itemTemplate: _.template([ itemTemplate: _.template([
'<div class="style" id="<%= id %>">', '<div class="style" id="<%= id %>">',
'<div style="background-image: url(<%= imageUrl %>); width: ' + itemWidth + 'px; height: ' + itemHeight + 'px;"></div>', '<div style="background-image: url(<%= imageUrl %>); width: ' + itemWidth + 'px; height: ' + itemHeight + 'px;"></div>',

View file

@ -35,5 +35,11 @@
.name.not-header { .name.not-header {
font-style: italic; font-style: italic;
} }
.name {
white-space: pre-wrap;
word-break: break-all;
max-height: 350px;
}
} }
} }

View file

@ -1029,6 +1029,7 @@ define([
dataHint: '1', dataHint: '1',
dataHintDirection: 'bottom', dataHintDirection: 'bottom',
dataHintOffset: '-16, -4', dataHintOffset: '-16, -4',
delayRenderTips: true,
itemTemplate: _.template([ itemTemplate: _.template([
'<div class="style" id="<%= id %>">', '<div class="style" id="<%= id %>">',
'<div class="item-theme" style="' + '<% if (typeof imageUrl !== "undefined") { %>' + 'background-image: url(<%= imageUrl %>);' + '<% } %> background-position: 0 -<%= offsety %>px;"></div>', '<div class="item-theme" style="' + '<% if (typeof imageUrl !== "undefined") { %>' + 'background-image: url(<%= imageUrl %>);' + '<% } %> background-position: 0 -<%= offsety %>px;"></div>',

View file

@ -940,6 +940,7 @@ define([
dataHint : '1', dataHint : '1',
dataHintDirection: 'bottom', dataHintDirection: 'bottom',
dataHintOffset : '-16, -4', dataHintOffset : '-16, -4',
delayRenderTips: true,
beforeOpenHandler: function(e) { beforeOpenHandler: function(e) {
var cmp = this, var cmp = this,
menu = cmp.openButton.menu, menu = cmp.openButton.menu,