[DE ios] Fixed display table styles.

This commit is contained in:
Alexander Yuzhin 2016-11-30 15:42:44 +03:00
parent f0562c554d
commit 58534c42c3
4 changed files with 30 additions and 18 deletions

View file

@ -155,8 +155,8 @@ define([
// API handlers
onApiInitTemplates: function(templates){
_styles = [];
onApiInitTemplates: function(templates) {
if (_styles.length < 1) {
_.each(templates, function(template){
_styles.push({
imageUrl : template.get_Image(),
@ -164,8 +164,8 @@ define([
});
});
Common.SharedSettings.set('tablestyles', _styles);
Common.NotificationCenter.trigger('tablestyles:load', _styles);
this.getView('AddTable').render();
}
},
textTableSize: 'Table Size',

View file

@ -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 () {

View file

@ -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 = $('<div/>').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());
}

View file

@ -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 = [];