diff --git a/apps/documenteditor/main/app/controller/Toolbar.js b/apps/documenteditor/main/app/controller/Toolbar.js index 46698f99a3..c87eac405c 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 !== undefined) { + 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); }; diff --git a/apps/presentationeditor/main/app/controller/Toolbar.js b/apps/presentationeditor/main/app/controller/Toolbar.js index 0546a784f3..15d2a440db 100644 --- a/apps/presentationeditor/main/app/controller/Toolbar.js +++ b/apps/presentationeditor/main/app/controller/Toolbar.js @@ -138,8 +138,9 @@ define([ 'change:slide' : this.onChangeSlide.bind(this), 'change:compact' : this.onClickChangeCompact, 'add:chart' : this.onSelectChart, - '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'), @@ -2787,11 +2788,26 @@ define([ } }, + 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(); }, @@ -2821,9 +2837,15 @@ define([ }, onApiEndSmartArtPreview: function () { + this.smartArtGenerating = undefined; if (this.currentSmartArtMenu) { this.currentSmartArtMenu.menu.alignPosition(); } + if (this.delayedSmartArt !== undefined) { + var delayedSmartArt = this.delayedSmartArt; + this.delayedSmartArt = undefined; + this.generateSmartArt(delayedSmartArt); + } }, onInsertSmartArt: function (value) { diff --git a/apps/presentationeditor/main/app/view/Toolbar.js b/apps/presentationeditor/main/app/view/Toolbar.js index 0dd5eaddb3..12f077ffc1 100644 --- a/apps/presentationeditor/main/app/view/Toolbar.js +++ b/apps/presentationeditor/main/app/view/Toolbar.js @@ -1572,10 +1572,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, @@ -1595,6 +1591,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); }; diff --git a/apps/spreadsheeteditor/main/app/controller/Toolbar.js b/apps/spreadsheeteditor/main/app/controller/Toolbar.js index 161ae9c67a..5953fbcde9 100644 --- a/apps/spreadsheeteditor/main/app/controller/Toolbar.js +++ b/apps/spreadsheeteditor/main/app/controller/Toolbar.js @@ -85,8 +85,9 @@ define([ 'change:scalespn': this.onClickChangeScaleInMenu.bind(me), 'click:customscale': this.onScaleClick.bind(me), 'home:open' : this.onHomeOpen, - 'generate:smartart' : this.generateSmartArt, - 'insert:smartart' : this.onInsertSmartArt + 'insert:smartart' : this.onInsertSmartArt, + 'smartart:mouseenter': this.mouseenterSmartArt, + 'smartart:mouseleave': this.mouseleaveSmartArt, }, 'FileMenu': { 'menu:hide': me.onFileMenu.bind(me, 'hide'), @@ -5019,11 +5020,26 @@ define([ Common.component.Analytics.trackEvent('ToolBar', 'Vertical align'); }, + 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(); }, @@ -5053,9 +5069,15 @@ define([ }, onApiEndSmartArtPreview: function () { + this.smartArtGenerating = undefined; if (this.currentSmartArtMenu) { this.currentSmartArtMenu.menu.alignPosition(); } + if (this.delayedSmartArt !== undefined) { + var delayedSmartArt = this.delayedSmartArt; + this.delayedSmartArt = undefined; + this.generateSmartArt(delayedSmartArt); + } }, onInsertSmartArt: function (value) { diff --git a/apps/spreadsheeteditor/main/app/view/Toolbar.js b/apps/spreadsheeteditor/main/app/view/Toolbar.js index 49d9fca87b..4fce06449f 100644 --- a/apps/spreadsheeteditor/main/app/view/Toolbar.js +++ b/apps/spreadsheeteditor/main/app/view/Toolbar.js @@ -2638,10 +2638,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, @@ -2661,6 +2657,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); };