diff --git a/apps/documenteditor/mobile/app/controller/add/AddTable.js b/apps/documenteditor/mobile/app/controller/add/AddTable.js index 04ff5ca0a..015e743e9 100644 --- a/apps/documenteditor/mobile/app/controller/add/AddTable.js +++ b/apps/documenteditor/mobile/app/controller/add/AddTable.js @@ -155,17 +155,17 @@ define([ // API handlers - onApiInitTemplates: function(templates){ - _styles = []; - _.each(templates, function(template){ - _styles.push({ - imageUrl : template.get_Image(), - templateId : template.get_Id() + onApiInitTemplates: function(templates) { + if (_styles.length < 1) { + _.each(templates, function(template){ + _styles.push({ + imageUrl : template.get_Image(), + templateId : template.get_Id() + }); }); - }); - Common.SharedSettings.set('tablestyles', _styles); - Common.NotificationCenter.trigger('tablestyles:load', _styles); + this.getView('AddTable').render(); + } }, textTableSize: 'Table Size', diff --git a/apps/documenteditor/mobile/app/controller/edit/EditTable.js b/apps/documenteditor/mobile/app/controller/edit/EditTable.js index 1950fa701..9d4ea5a8a 100644 --- a/apps/documenteditor/mobile/app/controller/edit/EditTable.js +++ b/apps/documenteditor/mobile/app/controller/edit/EditTable.js @@ -111,6 +111,7 @@ define([ me.api = api; me.api.asc_registerCallback('asc_onFocusObject', _.bind(me.onApiFocusObject, me)); + me.api.asc_registerCallback('asc_onInitTableTemplates', _.bind(me.onApiInitTemplates, me)); }, onLaunch: function () { @@ -613,6 +614,19 @@ define([ } }, + onApiInitTemplates: function(templates) { + var styles = []; + + _.each(templates, function(template){ + styles.push({ + imageUrl : template.get_Image(), + templateId : template.get_Id() + }); + }); + + this.getView('EditTable').updateStyles(styles); + }, + // Helpers _closeIfNeed: function () { diff --git a/apps/documenteditor/mobile/app/view/add/AddTable.js b/apps/documenteditor/mobile/app/view/add/AddTable.js index d4c5b3bc4..d5ac8f522 100644 --- a/apps/documenteditor/mobile/app/view/add/AddTable.js +++ b/apps/documenteditor/mobile/app/view/add/AddTable.js @@ -61,7 +61,6 @@ define([ initialize: function () { Common.NotificationCenter.on('addcontainer:show', _.bind(this.initEvents, this)); - Common.NotificationCenter.on('tablestyles:load', _.bind(this.render, this)); }, initEvents: function () { @@ -75,10 +74,10 @@ define([ this.layout = $('
').append(this.template({ android : Common.SharedSettings.get('android'), phone : Common.SharedSettings.get('phone'), - styles : Common.SharedSettings.get('tablestyles') + styles : DE.getController('AddTable').getStyles() })); - var $tableStyles = $('.table-styles'); + var $tableStyles = $('.container-add .table-styles'); if ($tableStyles) { $tableStyles.replaceWith(this.layout.find('#add-table-root').html()); } diff --git a/apps/documenteditor/mobile/app/view/edit/EditTable.js b/apps/documenteditor/mobile/app/view/edit/EditTable.js index 5a0d862f5..393751e73 100644 --- a/apps/documenteditor/mobile/app/view/edit/EditTable.js +++ b/apps/documenteditor/mobile/app/view/edit/EditTable.js @@ -64,7 +64,6 @@ define([ initialize: function () { Common.NotificationCenter.on('editcontainer:show', _.bind(this.initEvents, this)); Common.NotificationCenter.on('editcategory:show', _.bind(this.categoryShow, this)); - Common.NotificationCenter.on('tablestyles:load', _.bind(this.onStylesLoad, this)); }, initEvents: function () { @@ -108,15 +107,15 @@ define([ // }, - onStylesLoad: function () { - _styles = Common.SharedSettings.get('tablestyles'); + updateStyles: function (styles) { + _styles = styles; + this.renderStyles(); }, renderStyles: function() { - var $editTableStyle = $('#edit-table-styles .item-inner .dataview.table-styles'), - $styleContainer = $('#edit-table-styles .item-inner'); + var $styleContainer = $('#edit-table-styles .item-inner'); - if ($editTableStyle.length < 1 && $styleContainer.length > 0) { + if ($styleContainer.length > 0) { var columns = parseInt($styleContainer.width() / 70), // magic row = -1, styles = [];