From 909e73270a9df007ae61f42df4ae555910274e7e Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Thu, 21 Dec 2017 11:44:06 +0300 Subject: [PATCH] [DE] Added methods for table of content. --- apps/common/main/lib/component/TreeView.js | 1 + apps/common/main/resources/less/treeview.less | 1 + .../main/app/controller/Navigation.js | 47 ++++++++++++------- 3 files changed, 32 insertions(+), 17 deletions(-) diff --git a/apps/common/main/lib/component/TreeView.js b/apps/common/main/lib/component/TreeView.js index e28c9fae2..63b1f36a6 100644 --- a/apps/common/main/lib/component/TreeView.js +++ b/apps/common/main/lib/component/TreeView.js @@ -50,6 +50,7 @@ define([ return { id: Common.UI.getId(), name: '', + isNotHeader: false, hasSubItems: false, isExpanded: true, isVisible: true, diff --git a/apps/common/main/resources/less/treeview.less b/apps/common/main/resources/less/treeview.less index e47c2303e..fd3e64104 100644 --- a/apps/common/main/resources/less/treeview.less +++ b/apps/common/main/resources/less/treeview.less @@ -28,6 +28,7 @@ .tree-item { width: 100%; + min-height: 32px; padding: 0px 0 0 26px; } diff --git a/apps/documenteditor/main/app/controller/Navigation.js b/apps/documenteditor/main/app/controller/Navigation.js index 52d0349cf..b01236190 100644 --- a/apps/documenteditor/main/app/controller/Navigation.js +++ b/apps/documenteditor/main/app/controller/Navigation.js @@ -82,6 +82,7 @@ define([ setApi: function(api) { this.api = api; this.api.asc_registerCallback('asc_onDocumentOutlineUpdate', _.bind(this.updateNavigation, this)); + this.api.asc_registerCallback('asc_onDocumentOutlineCurrentPosition', _.bind(this.onChangeOutlinePosition, this)); return this; }, @@ -111,11 +112,19 @@ define([ index: i })); prev_level = level; - + } + if (count>0 && this._navigationObject.isFirstItemNotHeader()) { + arr[0].set('hasSubItems', false); + arr[0].set('isNotHeader', true); + arr[0].set('tip', this.txtGotoBeginning); } this.getApplication().getCollection('Navigation').reset(arr); }, + onChangeOutlinePosition: function(index) { + this.panelNavigation.viewNavigationList.selectByIndex(index); + }, + onItemContextMenu: function(picker, item, record, e){ var showPoint; var menu = this.panelNavigation.navigationMenu; @@ -127,11 +136,11 @@ define([ top = e.clientY*Common.Utils.zoom(); showPoint = [e.clientX*Common.Utils.zoom() + 5, top - parentOffset.top + 5]; - if (record != undefined) { - //itemMenu - // menu.items[0].setVisible(true); - } else { - } + var isNotHeader = record.get('isNotHeader'); + menu.items[0].setDisabled(isNotHeader); + menu.items[1].setDisabled(isNotHeader); + menu.items[3].setDisabled(isNotHeader); + menu.items[7].setDisabled(isNotHeader); if (showPoint != undefined) { var menuContainer = this.panelNavigation.$el.find('#menu-navigation-container'); @@ -143,7 +152,7 @@ define([ menu.render(menuContainer); menu.cmpEl.attr({tabindex: "-1"}); } - + menu.cmpEl.attr('data-value', record.get('index')); menuContainer.css({ left: showPoint[0], top: showPoint[1] @@ -154,24 +163,26 @@ define([ }, onSelectItem: function(picker, item, record, e){ - // this.api.asc_gotoHeader(); + if (!this._navigationObject) return; + this._navigationObject.goto(record.get('index')); }, onMenuItemClick: function (menu, item) { + if (!this._navigationObject) return; + + var index = parseInt(menu.cmpEl.attr('data-value')); if (item.value == 'promote') { - - } else if (item.value == 'promote') { - + this._navigationObject.promote(index); } else if (item.value == 'indent') { - + this._navigationObject.demote(index); } else if (item.value == 'before') { - + this._navigationObject.insertHeader(index, true); } else if (item.value == 'after') { - + this._navigationObject.insertHeader(index, false); } else if (item.value == 'new') { - + this._navigationObject.insertSubHeader(index); } else if (item.value == 'select') { - + this._navigationObject.selectContent(index); } else if (item.value == 'expand') { this.panelNavigation.viewNavigationList.expandAll(); } else if (item.value == 'collapse') { @@ -181,7 +192,9 @@ define([ onMenuLevelsItemClick: function (menu, item) { this.panelNavigation.viewNavigationList.expandToLevel(item.value-1); - } + }, + + txtGotoBeginning: 'Go to the beginning of the document' }, DE.Controllers.Navigation || {})); });