[SSE] Chart styles refactoring in the chart type dialog
This commit is contained in:
parent
337741f8b0
commit
071e3e31f3
|
@ -994,7 +994,8 @@ define([
|
||||||
},
|
},
|
||||||
|
|
||||||
onAddChartStylesPreview: function(styles){
|
onAddChartStylesPreview: function(styles){
|
||||||
var me = this;
|
if (this._isEditType) return;
|
||||||
|
|
||||||
if (styles && styles.length>0){
|
if (styles && styles.length>0){
|
||||||
var stylesStore = this.cmbChartStyle.menuPicker.store;
|
var stylesStore = this.cmbChartStyle.menuPicker.store;
|
||||||
if (stylesStore) {
|
if (stylesStore) {
|
||||||
|
|
|
@ -123,6 +123,11 @@ define([
|
||||||
this.api = this.options.api;
|
this.api = this.options.api;
|
||||||
this.chartSettings = this.options.chartSettings;
|
this.chartSettings = this.options.chartSettings;
|
||||||
this.currentChartType = Asc.c_oAscChartTypeSettings.barNormal;
|
this.currentChartType = Asc.c_oAscChartTypeSettings.barNormal;
|
||||||
|
|
||||||
|
this.wrapEvents = {
|
||||||
|
onAddChartStylesPreview: _.bind(this.onAddChartStylesPreview, this)
|
||||||
|
};
|
||||||
|
this.api.asc_registerCallback('asc_onAddChartStylesPreview', this.wrapEvents.onAddChartStylesPreview);
|
||||||
},
|
},
|
||||||
|
|
||||||
render: function() {
|
render: function() {
|
||||||
|
@ -173,7 +178,7 @@ define([
|
||||||
enableKeyEvents: this.options.enableKeyEvents,
|
enableKeyEvents: this.options.enableKeyEvents,
|
||||||
itemTemplate : _.template([
|
itemTemplate : _.template([
|
||||||
'<div class="style" id="<%= id %>">',
|
'<div class="style" id="<%= id %>">',
|
||||||
'<img src="<%= imageUrl %>" width="50" height="50"/>',
|
'<img src="<%= imageUrl %>" width="50" height="50" <% if(typeof imageUrl === "undefined" || imageUrl===null || imageUrl==="") { %> style="visibility: hidden;" <% } %>/>',
|
||||||
'<% if (typeof title !== "undefined") {%>',
|
'<% if (typeof title !== "undefined") {%>',
|
||||||
'<span class="title"><%= title %></span>',
|
'<span class="title"><%= title %></span>',
|
||||||
'<% } %>',
|
'<% } %>',
|
||||||
|
@ -221,6 +226,7 @@ define([
|
||||||
|
|
||||||
close: function () {
|
close: function () {
|
||||||
this.api.asc_onCloseChartFrame();
|
this.api.asc_onCloseChartFrame();
|
||||||
|
this.api.asc_unregisterCallback('asc_onAddChartStylesPreview', this.wrapEvents.onAddChartStylesPreview);
|
||||||
Common.Views.AdvancedSettingsWindow.prototype.close.apply(this, arguments);
|
Common.Views.AdvancedSettingsWindow.prototype.close.apply(this, arguments);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -258,8 +264,10 @@ define([
|
||||||
if (this.currentChartType==Asc.c_oAscChartTypeSettings.comboBarLine || this.currentChartType==Asc.c_oAscChartTypeSettings.comboBarLineSecondary ||
|
if (this.currentChartType==Asc.c_oAscChartTypeSettings.comboBarLine || this.currentChartType==Asc.c_oAscChartTypeSettings.comboBarLineSecondary ||
|
||||||
this.currentChartType==Asc.c_oAscChartTypeSettings.comboAreaBar || this.currentChartType==Asc.c_oAscChartTypeSettings.comboCustom) {
|
this.currentChartType==Asc.c_oAscChartTypeSettings.comboAreaBar || this.currentChartType==Asc.c_oAscChartTypeSettings.comboCustom) {
|
||||||
this.updateSeriesList(this.chartSettings.getSeries());
|
this.updateSeriesList(this.chartSettings.getSeries());
|
||||||
} else
|
} else {
|
||||||
this.updateChartStyles(this.api.asc_getChartPreviews(this.currentChartType));
|
this.updateChartStyles(this.api.asc_getChartPreviews(this.currentChartType, undefined, true));
|
||||||
|
this.api.asc_generateChartPreviews(this.currentChartType);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -310,8 +318,10 @@ define([
|
||||||
this.ShowHideSettings(this.currentChartType);
|
this.ShowHideSettings(this.currentChartType);
|
||||||
if (isCombo)
|
if (isCombo)
|
||||||
this.updateSeriesList(this.chartSettings.getSeries());
|
this.updateSeriesList(this.chartSettings.getSeries());
|
||||||
else
|
else {
|
||||||
this.updateChartStyles(this.api.asc_getChartPreviews(this.currentChartType));
|
this.updateChartStyles(this.api.asc_getChartPreviews(this.currentChartType, undefined, true));
|
||||||
|
this.api.asc_generateChartPreviews(this.currentChartType);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
picker.selectRecord(picker.store.findWhere({type: this.currentChartType}), true);
|
picker.selectRecord(picker.store.findWhere({type: this.currentChartType}), true);
|
||||||
}
|
}
|
||||||
|
@ -323,24 +333,15 @@ define([
|
||||||
if (styles && styles.length>0){
|
if (styles && styles.length>0){
|
||||||
var stylesStore = this.stylesList.store;
|
var stylesStore = this.stylesList.store;
|
||||||
if (stylesStore) {
|
if (stylesStore) {
|
||||||
var count = stylesStore.length;
|
var stylearray = [];
|
||||||
if (count>0 && count==styles.length) {
|
_.each(styles, function(item, index){
|
||||||
var data = stylesStore.models;
|
stylearray.push({
|
||||||
_.each(styles, function(style, index){
|
imageUrl: item.asc_getImage(),
|
||||||
data[index].set('imageUrl', style.asc_getImage());
|
data : item.asc_getName(),
|
||||||
|
tip : me.textStyle + ' ' + item.asc_getName()
|
||||||
});
|
});
|
||||||
} else {
|
});
|
||||||
var stylearray = [],
|
stylesStore.reset(stylearray, {silent: false});
|
||||||
selectedIdx = -1;
|
|
||||||
_.each(styles, function(item, index){
|
|
||||||
stylearray.push({
|
|
||||||
imageUrl: item.asc_getImage(),
|
|
||||||
data : item.asc_getName(),
|
|
||||||
tip : me.textStyle + ' ' + item.asc_getName()
|
|
||||||
});
|
|
||||||
});
|
|
||||||
stylesStore.reset(stylearray, {silent: false});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
this.stylesList.store.reset();
|
this.stylesList.store.reset();
|
||||||
|
@ -353,6 +354,21 @@ define([
|
||||||
this.chartSettings.putStyle(record.get('data'));
|
this.chartSettings.putStyle(record.get('data'));
|
||||||
},
|
},
|
||||||
|
|
||||||
|
onAddChartStylesPreview: function(styles){
|
||||||
|
var me = this;
|
||||||
|
if (styles && styles.length>0){
|
||||||
|
var stylesStore = this.stylesList.store;
|
||||||
|
if (stylesStore) {
|
||||||
|
_.each(styles, function(item, index){
|
||||||
|
var rec = stylesStore.findWhere({
|
||||||
|
data: item.asc_getName()
|
||||||
|
});
|
||||||
|
rec && rec.set('imageUrl', item.asc_getImage());
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
updateSeriesList: function(series, index) {
|
updateSeriesList: function(series, index) {
|
||||||
var arr = [];
|
var arr = [];
|
||||||
var store = this.seriesList.store;
|
var store = this.seriesList.store;
|
||||||
|
|
Loading…
Reference in a new issue