Refactoring advanced settings

This commit is contained in:
Julia Radzhabova 2020-10-01 22:25:59 +03:00
parent 6eca14710b
commit 2e8bb981a6
3 changed files with 23 additions and 9 deletions

View file

@ -96,7 +96,7 @@ define([
allowDepress: false,
contentTarget: btnEl.attr('content-target')
});
btn.on('click', _.bind(me.onCategoryClick, me));
btn.on('click', _.bind(me.onCategoryClick, me, btn, index));
me.btnsCategory.push(btn);
});
var cnt_panel = $window.find('.content-panel'),
@ -125,7 +125,7 @@ define([
this.close();
},
onCategoryClick: function(btn, event) {
onCategoryClick: function(btn, index) {
this.content_panels.filter('.active').removeClass('active');
$("#" + btn.options.contentTarget).addClass("active");
},
@ -144,19 +144,21 @@ define([
setActiveCategory: function(index) {
if (this.btnsCategory.length<1) return;
var btnActive = this.btnsCategory[(index>=0 && index<this.btnsCategory.length) ? index : 0];
index = (index>=0 && index<this.btnsCategory.length) ? index : 0;
var btnActive = this.btnsCategory[index];
if (!btnActive.isVisible() || btnActive.isDisabled()) {
for (var i = 0; i<this.btnsCategory.length; i++){
var btn = this.btnsCategory[i];
if (btn.isVisible() && !btn.isDisabled()) {
btnActive = btn;
index = i;
break;
}
}
}
btnActive.toggle(true);
this.onCategoryClick(btnActive);
this.onCategoryClick(btnActive, index);
},
getActiveCategory: function() {

View file

@ -995,10 +995,16 @@ define([ 'text!documenteditor/main/app/template/TableSettingsAdvanced.templat
this.CellBackContainer = $('#tableadv-panel-cell-back');
this.TableBackContainer = $('#tableadv-panel-table-back');
this.btnsCategory[1].on('click', _.bind(this.onCellCategoryClick, this));
this.afterRender();
},
onCategoryClick: function(btn, index) {
Common.Views.AdvancedSettingsWindow.prototype.onCategoryClick.call(this, btn, index);
if (index==1)
this.onCellCategoryClick(btn);
},
afterRender: function() {
this.updateMetricUnit();
this.updateThemeColors();

View file

@ -729,9 +729,6 @@ define([ 'text!spreadsheeteditor/main/app/template/ChartSettingsDlg.template'
}
}, this));
this.btnsCategory[2].on('click', _.bind(this.onVCategoryClick, this));
this.btnsCategory[3].on('click', _.bind(this.onHCategoryClick, this));
// Sparklines
this.btnSparkType = new Common.UI.Button({
cls : 'btn-large-dataview',
@ -1000,6 +997,15 @@ define([ 'text!spreadsheeteditor/main/app/template/ChartSettingsDlg.template'
}
},
onCategoryClick: function(btn, index) {
Common.Views.AdvancedSettingsWindow.prototype.onCategoryClick.call(this, btn, index);
if (index==2)
this.onVCategoryClick(btn);
else if (index==3)
this.onHCategoryClick(btn);
},
onSelectType: function(btn, picker, itemView, record) {
if (this._noApply) return;