From 24fa55325f570f5cd5cb87daf30c7fc6a32bfd8d Mon Sep 17 00:00:00 2001 From: "Julia.Svinareva" Date: Fri, 10 Nov 2023 00:26:40 +0300 Subject: [PATCH] [DE] Add loading preview for smart arts --- apps/common/main/resources/less/common.less | 23 ++++++++++++++++ .../main/app/controller/Toolbar.js | 21 +++++++-------- apps/documenteditor/main/app/view/Toolbar.js | 26 ++++++++++++++----- 3 files changed, 52 insertions(+), 18 deletions(-) diff --git a/apps/common/main/resources/less/common.less b/apps/common/main/resources/less/common.less index ccf7f15f42..6ee3ec18b4 100644 --- a/apps/common/main/resources/less/common.less +++ b/apps/common/main/resources/less/common.less @@ -388,4 +388,27 @@ body { .color-btn-wrap { display: flex; align-items: center; +} + +.menu-add-smart-art { + .loading-item { + .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); + display: flex; + justify-content: center; + align-items: center; + + .loading-spinner { + display: block; + width: 28px; + height: 28px; + background-image: ~"url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAyMCAyMCI+PGNpcmNsZSBjeD0iMTAiIGN5PSIxMCIgZmlsbD0ibm9uZSIgc3Ryb2tlPSIjNDQ0IiBzdHJva2Utd2lkdGg9IjEuNSIgcj0iNy4yNSIgc3Ryb2tlLWRhc2hhcnJheT0iMTYwJSwgNDAlIiAvPjwvc3ZnPg==)"; + background-color: transparent; + opacity: 0.8; + animation-duration: .8s; + animation-name: rotation; + animation-iteration-count: infinite; + animation-timing-function: linear; + } + } } \ No newline at end of file diff --git a/apps/documenteditor/main/app/controller/Toolbar.js b/apps/documenteditor/main/app/controller/Toolbar.js index a779d27062..045f61e850 100644 --- a/apps/documenteditor/main/app/controller/Toolbar.js +++ b/apps/documenteditor/main/app/controller/Toolbar.js @@ -3592,6 +3592,8 @@ define([ onApiBeginSmartArtPreview: function (type) { this.smartArtGenerating = type; this.smartArtGroups = this.toolbar.btnInsertSmartArt.menu.items; + var menuPicker = _.findWhere(this.smartArtGroups, {value: type}).menuPicker; + menuPicker.loaded = true; this.smartArtData = Common.define.smartArt.getSmartArtData(); }, @@ -3602,18 +3604,13 @@ define([ section = _.findWhere(this.smartArtData, {sectionId: sectionId}), item = _.findWhere(section.items, {type: image.asc_getName()}), menu = _.findWhere(this.smartArtGroups, {value: sectionId}), - menuPicker = menu.menuPicker; - if (item) { - var arr = [{ - tip: item.tip, - value: item.type, - imageUrl: image.asc_getImage() - }]; - //if (menuPicker.store.length < 1) { - //menuPicker.store.reset(arr); - //} else { - menuPicker.store.add(arr); - //} + menuPicker = menu.menuPicker, + pickerItem = menuPicker.store.findWhere({isLoading: true}); + if (pickerItem) { + pickerItem.set('tip', item.tip, {silent: true}); + pickerItem.set('value', item.type, {silent: true}); + pickerItem.set('imageUrl', image.asc_getImage(), {silent: true}); + pickerItem.set('isLoading', false); } this.currentSmartArtMenu = menu; }, this)); diff --git a/apps/documenteditor/main/app/view/Toolbar.js b/apps/documenteditor/main/app/view/Toolbar.js index d47ba6674f..091b80873f 100644 --- a/apps/documenteditor/main/app/view/Toolbar.js +++ b/apps/documenteditor/main/app/view/Toolbar.js @@ -2364,6 +2364,7 @@ define([ caption: item.caption, value: item.sectionId, itemId: item.id, + itemsLength: length, iconCls: item.icon ? 'menu__icon ' + item.icon : undefined, menu: new Common.UI.Menu({ items: [ @@ -2374,15 +2375,27 @@ define([ }); var onShowBeforeSmartArt = function (menu) { // + <% if(typeof imageUrl === "undefined" || imageUrl===null || imageUrl==="") { %> style="visibility: hidden;" <% } %>/>', me.btnInsertSmartArt.menu.items.forEach(function (item, index) { + var items = []; + for (var i=0; i', - '', - '' - ].join('')), - store: new Common.UI.DataViewStore(), + '<% if (isLoading) { %>', + '
', + '', + '
', + '<% } else { %>', + '
', + '', + '
', + '<% } %>' + ].join('')), + store: new Common.UI.DataViewStore(items), delayRenderTips: true, scrollAlwaysVisible: true, showLast: false @@ -2393,8 +2406,9 @@ define([ } Common.NotificationCenter.trigger('edit:complete', me); }); + item.menuPicker.loaded = false; item.$el.on('mouseenter', function () { - if (item.menuPicker.store.length === 0) { + if (!item.menuPicker.loaded) { me.fireEvent('smartart:mouseenter', [item.value]); } });