diff --git a/apps/presentationeditor/main/app/controller/Main.js b/apps/presentationeditor/main/app/controller/Main.js index 21bd005156..939e1acccb 100644 --- a/apps/presentationeditor/main/app/controller/Main.js +++ b/apps/presentationeditor/main/app/controller/Main.js @@ -761,7 +761,6 @@ define([ me.api.asc_registerCallback('asc_onFocusObject', _.bind(me.onFocusObject, me)); - me.fillTextArt(me.api.asc_getTextArtPreviews()); toolbarController.activateControls(); if (me.needToUpdateVersion) toolbarController.onApiCoAuthoringDisconnect(); @@ -1558,7 +1557,7 @@ define([ this.updateThemeColors(); var me = this; setTimeout(function(){ - me.fillTextArt(me.api.asc_getTextArtPreviews()); + me.fillTextArt(); }, 1); } }, @@ -1642,11 +1641,14 @@ define([ }, fillTextArt: function(shapes){ - if (_.isEmpty(shapes)) return; - - var me = this, arr = [], + var arr = [], artStore = this.getCollection('Common.Collections.TextArt'); + if (!shapes && artStore.length>0) {// shapes == undefined when update textart collection (from asc_onSendThemeColors) + shapes = this.api.asc_getTextArtPreviews(); + } + if (_.isEmpty(shapes)) return; + _.each(shapes, function(shape, index){ arr.push({ imageUrl : shape, @@ -1656,11 +1658,6 @@ define([ }); }); artStore.reset(arr); - - setTimeout(function(){ - me.getApplication().getController('RightMenu').fillTextArt(); - }, 50); - }, loadLanguages: function(apiLangs) { diff --git a/apps/presentationeditor/main/app/controller/RightMenu.js b/apps/presentationeditor/main/app/controller/RightMenu.js index 8c17848738..646a27be8e 100644 --- a/apps/presentationeditor/main/app/controller/RightMenu.js +++ b/apps/presentationeditor/main/app/controller/RightMenu.js @@ -278,10 +278,6 @@ define([ this.rightmenu.tableSettings.updateMetricUnit(); }, - fillTextArt: function() { - this.rightmenu.textartSettings.fillTextArt(); - }, - createDelayedElements: function() { if (this.editMode && this.api) { this.api.asc_registerCallback('asc_doubleClickOnObject', _.bind(this.onDoubleClickOnObject, this)); diff --git a/apps/presentationeditor/main/app/controller/Toolbar.js b/apps/presentationeditor/main/app/controller/Toolbar.js index 8ffba11301..41b028a80f 100644 --- a/apps/presentationeditor/main/app/controller/Toolbar.js +++ b/apps/presentationeditor/main/app/controller/Toolbar.js @@ -234,10 +234,6 @@ define([ Common.NotificationCenter.on('app:ready', me.onAppReady.bind(me)); Common.NotificationCenter.on('app:face', me.onAppShowed.bind(me)); - PE.getCollection('Common.Collections.TextArt').bind({ - reset: me.onResetTextArt.bind(this) - }); - PE.getCollection('ShapeGroups').bind({ reset: me.onResetAutoshapes.bind(this) }); @@ -1720,14 +1716,6 @@ define([ }); }, - onResetTextArt: function (collection, opts) { - (new Promise(function (resolve, reject) { - resolve(); - })).then(function () { - this.toolbar.updateTextartMenu(collection); - }.bind(this)); - }, - onResetSlides: function () { setTimeout(function () { this.toolbar.updateAddSlideMenu(PE.getCollection('SlideLayouts')); diff --git a/apps/presentationeditor/main/app/view/TextArtSettings.js b/apps/presentationeditor/main/app/view/TextArtSettings.js index eccff24a6d..7d16908294 100644 --- a/apps/presentationeditor/main/app/view/TextArtSettings.js +++ b/apps/presentationeditor/main/app/view/TextArtSettings.js @@ -123,6 +123,10 @@ define([ this.FillPatternContainer = $('#textart-panel-pattern-fill'); this.FillGradientContainer = $('#textart-panel-gradient-fill'); this.TransparencyContainer = $('#textart-panel-transparent-fill'); + + PE.getCollection('Common.Collections.TextArt').bind({ + reset: this.fillTextArt.bind(this) + }); }, render: function () { @@ -1431,6 +1435,10 @@ define([ var models = this.application.getCollection('Common.Collections.TextArt').models, count = this.cmbTextArt.menuPicker.store.length; + if (models.length<1) { + PE.getController('Main').fillTextArt(this.api.asc_getTextArtPreviews()); + return; + } if (count>0 && count==models.length) { var data = this.cmbTextArt.menuPicker.store.models; _.each(models, function(template, index){ diff --git a/apps/presentationeditor/main/app/view/Toolbar.js b/apps/presentationeditor/main/app/view/Toolbar.js index a7e499d945..133fe8ce43 100644 --- a/apps/presentationeditor/main/app/view/Toolbar.js +++ b/apps/presentationeditor/main/app/view/Toolbar.js @@ -1148,6 +1148,26 @@ define([ }; this.btnInsertChart.menu.on('show:before', onShowBefore); + var onShowBeforeTextArt = function (menu) { + var collection = PE.getCollection('Common.Collections.TextArt'); + if (collection.length<1) + PE.getController('Main').fillTextArt(me.api.asc_getTextArtPreviews()); + me.btnInsertTextArt.textartPicker = new Common.UI.DataView({ + el: $('#view-insert-art', menu.$el), + store: collection, + parentMenu: menu, + showLast: false, + itemTemplate: _.template('