diff --git a/apps/documenteditor/main/app/controller/Toolbar.js b/apps/documenteditor/main/app/controller/Toolbar.js index 46698f99a3..001ea30896 100644 --- a/apps/documenteditor/main/app/controller/Toolbar.js +++ b/apps/documenteditor/main/app/controller/Toolbar.js @@ -119,8 +119,9 @@ define([ 'home:open' : this.onHomeOpen, 'add:chart' : this.onSelectChart, 'insert:textart' : this.onInsertTextart, - 'generate:smartart' : this.generateSmartArt, - 'insert:smartart' : this.onInsertSmartArt + 'insert:smartart' : this.onInsertSmartArt, + 'smartart:mouseenter': this.mouseenterSmartArt, + 'smartart:mouseleave': this.mouseleaveSmartArt, }, 'FileMenu': { 'menu:hide': this.onFileMenu.bind(this, 'hide'), @@ -3494,11 +3495,26 @@ define([ })).show(); }, + mouseenterSmartArt: function (groupName) { + if (this.smartArtGenerating === undefined) { + this.generateSmartArt(groupName); + } else { + this.delayedSmartArt = groupName; + } + }, + + mouseleaveSmartArt: function (groupName) { + if (this.delayedSmartArt === groupName) { + this.delayedSmartArt = undefined; + } + }, + generateSmartArt: function (groupName) { this.api.asc_generateSmartArtPreviews(groupName); }, - onApiBeginSmartArtPreview: function () { + onApiBeginSmartArtPreview: function (type) { + this.smartArtGenerating = type; this.smartArtGroups = this.toolbar.btnInsertSmartArt.menu.items; this.smartArtData = Common.define.smartArt.getSmartArtData(); }, @@ -3528,9 +3544,15 @@ define([ }, onApiEndSmartArtPreview: function () { + this.smartArtGenerating = undefined; if (this.currentSmartArtMenu) { this.currentSmartArtMenu.menu.alignPosition(); } + if (this.delayedSmartArt) { + var delayedSmartArt = this.delayedSmartArt; + this.delayedSmartArt = undefined; + this.generateSmartArt(delayedSmartArt); + } }, onInsertSmartArt: function (value) { diff --git a/apps/documenteditor/main/app/view/Toolbar.js b/apps/documenteditor/main/app/view/Toolbar.js index 9da79b1c49..5fcf2ebba3 100644 --- a/apps/documenteditor/main/app/view/Toolbar.js +++ b/apps/documenteditor/main/app/view/Toolbar.js @@ -2327,10 +2327,6 @@ define([ }); var onShowBeforeSmartArt = function (menu) { // + <% if(typeof imageUrl === "undefined" || imageUrl===null || imageUrl==="") { %> style="visibility: hidden;" <% } %>/>', me.btnInsertSmartArt.menu.items.forEach(function (item, index) { - item.$el.one('mouseenter', function () { - me.fireEvent('generate:smartart', [item.value]); - item.$el.mouseenter(); - }); item.menuPicker = new Common.UI.DataView({ el: $('#' + item.options.itemId), parentMenu: me.btnInsertSmartArt.menu.items[index].menu, @@ -2350,6 +2346,14 @@ define([ } Common.NotificationCenter.trigger('edit:complete', me); }); + item.$el.on('mouseenter', function () { + if (item.menuPicker.store.length === 0) { + me.fireEvent('smartart:mouseenter', [item.value]); + } + }); + item.$el.on('mouseleave', function () { + me.fireEvent('smartart:mouseleave', [item.value]); + }); }); menu.off('show:before', onShowBeforeSmartArt); };