Merge pull request #1249 from ONLYOFFICE/feature/table-templates

[DE][PE] Refactoring table templates loading
This commit is contained in:
maxkadushkin 2021-10-18 19:01:30 +03:00 committed by GitHub
commit 187c3f350f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 8 deletions

View file

@ -232,7 +232,7 @@ define([
setApi: function(o) { setApi: function(o) {
this.api = o; this.api = o;
if (o) { if (o) {
this.api.asc_registerCallback('asc_onInitTableTemplates', _.bind(this._onInitTemplates, this)); this.api.asc_registerCallback('asc_onInitTableTemplates', _.bind(this.onInitTableTemplates, this));
} }
return this; return this;
}, },
@ -240,7 +240,7 @@ define([
createDelayedControls: function() { createDelayedControls: function() {
var me = this; var me = this;
this._tableTemplates && this._onInitTemplates(this._tableTemplates); this._tableTemplates && this._onInitTemplates();
this.chHeader = new Common.UI.CheckBox({ this.chHeader = new Common.UI.CheckBox({
el: $('#table-checkbox-header'), el: $('#table-checkbox-header'),
@ -730,12 +730,16 @@ define([
!this.btnBorderColor.isAutoColor() && this.btnBorderColor.setColor(this.borderColor.getColor()); !this.btnBorderColor.isAutoColor() && this.btnBorderColor.setColor(this.borderColor.getColor());
}, },
_onInitTemplates: function(Templates){ onInitTableTemplates: function(){
if (this._initSettings) { if (this._initSettings) {
this._tableTemplates = Templates; this._tableTemplates = true;
return; return;
} }
this._onInitTemplates();
},
_onInitTemplates: function(){
var Templates = this.api.asc_getTableStylesPreviews();
var self = this; var self = this;
this._isTemplatesChanged = true; this._isTemplatesChanged = true;

View file

@ -219,7 +219,7 @@ define([
setApi: function(o) { setApi: function(o) {
this.api = o; this.api = o;
if (o) { if (o) {
this.api.asc_registerCallback('asc_onInitTableTemplates', _.bind(this._onInitTemplates, this)); this.api.asc_registerCallback('asc_onInitTableTemplates', _.bind(this.onInitTableTemplates, this));
} }
return this; return this;
}, },
@ -227,7 +227,7 @@ define([
createDelayedControls: function() { createDelayedControls: function() {
var me = this; var me = this;
this._tableTemplates && this._onInitTemplates(this._tableTemplates); this._tableTemplates && this._onInitTemplates();
this.chHeader = new Common.UI.CheckBox({ this.chHeader = new Common.UI.CheckBox({
el: $('#table-checkbox-header'), el: $('#table-checkbox-header'),
@ -671,12 +671,16 @@ define([
!this.btnBorderColor.isAutoColor() && this.btnBorderColor.setColor(this.borderColor.getColor()); !this.btnBorderColor.isAutoColor() && this.btnBorderColor.setColor(this.borderColor.getColor());
}, },
_onInitTemplates: function(Templates){ onInitTableTemplates: function(){
if (this._initSettings) { if (this._initSettings) {
this._tableTemplates = Templates; this._tableTemplates = true;
return; return;
} }
this._onInitTemplates();
},
_onInitTemplates: function(){
var Templates = this.api.asc_getTableStylesPreviews();
var self = this; var self = this;
this._isTemplatesChanged = true; this._isTemplatesChanged = true;