diff --git a/apps/documenteditor/main/app/controller/Main.js b/apps/documenteditor/main/app/controller/Main.js index 640e0b104..570309373 100644 --- a/apps/documenteditor/main/app/controller/Main.js +++ b/apps/documenteditor/main/app/controller/Main.js @@ -1020,7 +1020,6 @@ define([ if (me.needToUpdateVersion) toolbarController.onApiCoAuthoringDisconnect(); me.api.UpdateInterfaceState(); - me.fillTextArt(me.api.asc_getTextArtPreviews()); Common.NotificationCenter.trigger('document:ready', 'main'); me.applyLicense(); @@ -1835,11 +1834,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, @@ -1849,14 +1851,6 @@ define([ }); }); artStore.reset(arr); - - setTimeout(function(){ - me.getApplication().getController('Toolbar').fillTextArt(); - }, 50); - - setTimeout(function(){ - me.getApplication().getController('RightMenu').fillTextArt(); - }, 50); }, updateThemeColors: function() { @@ -1875,7 +1869,7 @@ define([ this.updateThemeColors(); var me = this; setTimeout(function(){ - me.fillTextArt(me.api.asc_getTextArtPreviews()); + me.fillTextArt(); }, 1); } }, diff --git a/apps/documenteditor/main/app/controller/RightMenu.js b/apps/documenteditor/main/app/controller/RightMenu.js index cb83937f2..fd8b9fabc 100644 --- a/apps/documenteditor/main/app/controller/RightMenu.js +++ b/apps/documenteditor/main/app/controller/RightMenu.js @@ -251,10 +251,6 @@ define([ this.rightmenu.textartSettings.UpdateThemeColors(); }, - fillTextArt: function() { - this.rightmenu.textartSettings.fillTextArt(); - }, - updateMetricUnit: function() { this.rightmenu.headerSettings.updateMetricUnit(); this.rightmenu.paragraphSettings.updateMetricUnit(); diff --git a/apps/documenteditor/main/app/controller/Toolbar.js b/apps/documenteditor/main/app/controller/Toolbar.js index f3582083f..32710d50f 100644 --- a/apps/documenteditor/main/app/controller/Toolbar.js +++ b/apps/documenteditor/main/app/controller/Toolbar.js @@ -110,7 +110,8 @@ define([ 'insert:break' : this.onClickPageBreak, 'change:compact' : this.onClickChangeCompact, 'home:open' : this.onHomeOpen, - 'add:chart' : this.onSelectChart + 'add:chart' : this.onSelectChart, + 'insert:textart' : this.onInsertTextart }, 'FileMenu': { 'menu:hide': this.onFileMenu.bind(this, 'hide'), @@ -1880,6 +1881,19 @@ define([ } }, + onInsertTextart: function (data) { + if (this.api) { + this.toolbar.fireEvent('inserttextart', this.toolbar); + this.api.AddTextArt(data); + + if (this.toolbar.btnInsertShape.pressed) + this.toolbar.btnInsertShape.toggle(false, true); + + Common.NotificationCenter.trigger('edit:complete', this.toolbar, this.toolbar.btnInsertTextArt); + Common.component.Analytics.trackEvent('ToolBar', 'Add Text Art'); + } + }, + onInsertPageNumberClick: function(picker, item, record) { if (this.api) this.api.put_PageNum(record.get('data').type, record.get('data').subtype); @@ -2558,53 +2572,6 @@ define([ } }, - fillTextArt: function() { - if (!this.toolbar.btnInsertTextArt.rendered) return; - - if (this.toolbar.mnuTextArtPicker) { - var models = this.getApplication().getCollection('Common.Collections.TextArt').models, - count = this.toolbar.mnuTextArtPicker.store.length; - if (count>0 && count==models.length) { - var data = this.toolbar.mnuTextArtPicker.store.models; - _.each(models, function(template, index){ - data[index].set('imageUrl', template.get('imageUrl')); - }); - } else { - this.toolbar.mnuTextArtPicker.store.reset(models); - } - } else if (!this.binding.onShowBeforeTextArt) { - var me = this; - me.binding.onShowBeforeTextArt = function(menu) { - me.toolbar.mnuTextArtPicker = new Common.UI.DataView({ - el: $('#id-toolbar-menu-insart'), - store: me.getApplication().getCollection('Common.Collections.TextArt'), - parentMenu: menu, - showLast: false, - itemTemplate: _.template('