From 1799fb270c801a713529f5d949a886812b3ba77b Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Tue, 13 Apr 2021 12:14:15 +0300 Subject: [PATCH 1/2] [DE] Preview for TOC menu --- .../main/app/controller/Links.js | 6 ++++ apps/documenteditor/main/app/view/Links.js | 14 +++++++--- .../main/resources/less/toolbar.less | 28 +++++++++---------- 3 files changed, 30 insertions(+), 18 deletions(-) diff --git a/apps/documenteditor/main/app/controller/Links.js b/apps/documenteditor/main/app/controller/Links.js index 9c5e43e65..e68fd3772 100644 --- a/apps/documenteditor/main/app/controller/Links.js +++ b/apps/documenteditor/main/app/controller/Links.js @@ -67,6 +67,7 @@ define([ this.addListeners({ 'Links': { 'links:contents': this.onTableContents, + 'links:contents-open': this.onTableContentsOpen, 'links:update': this.onTableContentsUpdate, 'links:notes': this.onNotesClick, 'links:hyperlink': this.onHyperlinkClick, @@ -79,6 +80,7 @@ define([ 'DocumentHolder': { 'links:contents': this.onTableContents, 'links:update': this.onTableContentsUpdate, + 'links:contents-open': this.onTableContentsOpen, 'links:caption': this.onCaptionClick } }); @@ -309,6 +311,10 @@ define([ Common.NotificationCenter.trigger('edit:complete', this.toolbar); }, + onTableContentsOpen: function(menu) { + this.api.asc_getButtonsTOC(menu.items[0].id, menu.items[1].id); + }, + onNotesClick: function(type) { var me = this; switch (type) { diff --git a/apps/documenteditor/main/app/view/Links.js b/apps/documenteditor/main/app/view/Links.js index 28939bc82..c02f2178c 100644 --- a/apps/documenteditor/main/app/view/Links.js +++ b/apps/documenteditor/main/app/view/Links.js @@ -56,12 +56,18 @@ define([ button.on('click', function (b, e) { me.fireEvent('links:contents', [0]); }); + button.menu.on('show:after', function (menu, e) { + me.fireEvent('links:contents-open', [menu]); + }); }); this.contentsMenu.on('item:click', function (menu, item, e) { setTimeout(function(){ me.fireEvent('links:contents', [item.value, true]); }, 10); }); + this.contentsMenu.on('show:after', function (menu, e) { + me.fireEvent('links:contents-open', [menu]); + }); this.btnContentsUpdate.menu.on('item:click', function (menu, item, e) { me.fireEvent('links:update', [item.value]); @@ -236,8 +242,8 @@ define([ var _menu = new Common.UI.Menu({ cls: 'toc-menu shifted-left', items: [ - {template: contentsTemplate, offsety: 0, value: 0}, - {template: contentsTemplate, offsety: 72, value: 1}, + {template: contentsTemplate, offsety: 0, value: 0, id: 'id-toolbar-toc-0'}, + {template: contentsTemplate, offsety: 72, value: 1, id: 'id-toolbar-toc-1'}, {caption: me.textContentsSettings, value: 'settings'}, {caption: me.textContentsRemove, value: 'remove'} ] @@ -249,8 +255,8 @@ define([ me.contentsMenu = new Common.UI.Menu({ cls: 'toc-menu shifted-left', items: [ - {template: contentsTemplate, offsety: 0, value: 0}, - {template: contentsTemplate, offsety: 72, value: 1}, + {template: contentsTemplate, offsety: 0, value: 0, id: 'id-toolbar-toc-menu-0'}, + {template: contentsTemplate, offsety: 72, value: 1, id: 'id-toolbar-toc-menu-1'}, {caption: me.textContentsSettings, value: 'settings'}, {caption: me.textContentsRemove, value: 'remove'} ] diff --git a/apps/documenteditor/main/resources/less/toolbar.less b/apps/documenteditor/main/resources/less/toolbar.less index 2e9523dc0..4e4009863 100644 --- a/apps/documenteditor/main/resources/less/toolbar.less +++ b/apps/documenteditor/main/resources/less/toolbar.less @@ -44,10 +44,10 @@ > li > a.item-contents { div { - .background-ximage-v2('toolbar/contents.png', 246px, @commonimage: false); + //.background-ximage-v2('toolbar/contents.png', 246px, @commonimage: false); background-color: #fff; - width: 246px; - height: @contents-menu-item-height; + width: 248px; + //height: @contents-menu-item-height; .box-shadow(0 0 0 @scaled-one-px-value-ie @border-regular-control-ie); .box-shadow(0 0 0 @scaled-one-px-value @border-regular-control); @@ -68,18 +68,18 @@ } } } + // + //.loop(@counter) when (@counter > 0) { + // .loop((@counter - 1)); + // li:nth-child(@{counter}) > a.item-contents { + // div { + // @incr-height: (@counter - 1)*@contents-menu-item-height; + // background-position: 0 ~"calc(var(--bckgHOffset) - @{incr-height})"; + // } + // } + //} - .loop(@counter) when (@counter > 0) { - .loop((@counter - 1)); - li:nth-child(@{counter}) > a.item-contents { - div { - @incr-height: (@counter - 1)*@contents-menu-item-height; - background-position: 0 ~"calc(var(--bckgHOffset) - @{incr-height})"; - } - } - } - - .loop(2); + //.loop(2); } // page number position From e0ceb8a8415a5d90349b6b7fce26fce3383d4cb9 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Tue, 13 Apr 2021 12:52:19 +0300 Subject: [PATCH 2/2] [DE] Fix preview toc --- apps/documenteditor/main/app/controller/Links.js | 2 +- apps/documenteditor/main/app/view/Links.js | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/apps/documenteditor/main/app/controller/Links.js b/apps/documenteditor/main/app/controller/Links.js index e68fd3772..4a76a9bbf 100644 --- a/apps/documenteditor/main/app/controller/Links.js +++ b/apps/documenteditor/main/app/controller/Links.js @@ -312,7 +312,7 @@ define([ }, onTableContentsOpen: function(menu) { - this.api.asc_getButtonsTOC(menu.items[0].id, menu.items[1].id); + this.api.asc_getButtonsTOC(menu.items[0].options.previewId, menu.items[1].options.previewId); }, onNotesClick: function(type) { diff --git a/apps/documenteditor/main/app/view/Links.js b/apps/documenteditor/main/app/view/Links.js index c02f2178c..04b925479 100644 --- a/apps/documenteditor/main/app/view/Links.js +++ b/apps/documenteditor/main/app/view/Links.js @@ -235,15 +235,15 @@ define([ (new Promise(function (accept, reject) { accept(); })).then(function(){ - var contentsTemplate = _.template('
'); + var contentsTemplate = _.template('
'); me.btnsContents.forEach( function(btn) { btn.updateHint( me.tipContents ); var _menu = new Common.UI.Menu({ cls: 'toc-menu shifted-left', items: [ - {template: contentsTemplate, offsety: 0, value: 0, id: 'id-toolbar-toc-0'}, - {template: contentsTemplate, offsety: 72, value: 1, id: 'id-toolbar-toc-1'}, + {template: contentsTemplate, offsety: 0, value: 0, previewId: 'id-toolbar-toc-0'}, + {template: contentsTemplate, offsety: 72, value: 1, previewId: 'id-toolbar-toc-1'}, {caption: me.textContentsSettings, value: 'settings'}, {caption: me.textContentsRemove, value: 'remove'} ] @@ -255,8 +255,8 @@ define([ me.contentsMenu = new Common.UI.Menu({ cls: 'toc-menu shifted-left', items: [ - {template: contentsTemplate, offsety: 0, value: 0, id: 'id-toolbar-toc-menu-0'}, - {template: contentsTemplate, offsety: 72, value: 1, id: 'id-toolbar-toc-menu-1'}, + {template: contentsTemplate, offsety: 0, value: 0, previewId: 'id-toolbar-toc-menu-0'}, + {template: contentsTemplate, offsety: 72, value: 1, previewId: 'id-toolbar-toc-menu-1'}, {caption: me.textContentsSettings, value: 'settings'}, {caption: me.textContentsRemove, value: 'remove'} ]