diff --git a/apps/presentationeditor/main/app/controller/Main.js b/apps/presentationeditor/main/app/controller/Main.js index 21bd00515..939e1accc 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 8c1784873..646a27be8 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 8ffba1130..41b028a80 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 eccff24a6..7d1690829 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 a7e499d94..133fe8ce4 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('
') + }); + me.btnInsertTextArt.textartPicker.on('item:click', function (picker, item, record, e) { + if (record) + me.fireEvent('insert:textart', [record.get('data')]); + if (e.type !== 'click') menu.hide(); + }); + menu.off('show:before', onShowBeforeTextArt); + }; + this.btnInsertTextArt.menu.on('show:before', onShowBeforeTextArt); + // set dataviews var _conf = this.mnuMarkersPicker.conf; @@ -1420,40 +1440,6 @@ define([ } }, - updateTextartMenu: function (collection) { - var me = this; - - var btn = me.btnInsertTextArt; - if ( btn.textartPicker ) { - if ( btn.textartPicker.store.size() == collection.size() ) { - btn.textartPicker.store.each(function (model, index) { - model.set('imageUrl', collection.at(index).get('imageUrl')); - }); - } else { - btn.textartPicker.store.reset( collection.models ); - } - } else if (!this.binding.onShowBeforeTextArt) { - me.binding.onShowBeforeTextArt = function(menu) { - btn.textartPicker = new Common.UI.DataView({ - el: $('#view-insert-art', btn.menu.$el), - store: collection, - parentMenu: btn.menu, - showLast: false, - itemTemplate: _.template('
') - }); - - btn.textartPicker.on('item:click', function(picker, item, record, e) { - if (record) - me.fireEvent('insert:textart', [record.get('data')]); - - if (e.type !== 'click') btn.menu.hide(); - }); - menu.off('show:before', me.binding.onShowBeforeTextArt); - }; - me.btnInsertTextArt.menu.on('show:before', me.binding.onShowBeforeTextArt); - } - }, - updateAutoshapeMenu: function (menuShape, collection) { var me = this; var onShowAfter = function(menu) {