Merge pull request #1574 from ONLYOFFICE/fix/chart-styles-load-v2
Fix/chart styles load v2 Bug 52347
This commit is contained in:
commit
b6eef2f865
|
@ -95,7 +95,7 @@ define([
|
||||||
this.delayRenderTips = this.options.delayRenderTips || false;
|
this.delayRenderTips = this.options.delayRenderTips || false;
|
||||||
this.itemTemplate = this.options.itemTemplate || _.template([
|
this.itemTemplate = this.options.itemTemplate || _.template([
|
||||||
'<div class="style" id="<%= id %>">',
|
'<div class="style" id="<%= id %>">',
|
||||||
'<img src="<%= imageUrl %>" width="' + this.itemWidth + '" height="' + this.itemHeight + '"/>',
|
'<img src="<%= imageUrl %>" width="' + this.itemWidth + '" height="' + this.itemHeight + '" + <% 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>',
|
||||||
'<% } %>',
|
'<% } %>',
|
||||||
|
@ -456,6 +456,7 @@ define([
|
||||||
me.resumeEvents();
|
me.resumeEvents();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return me.fieldPicker.store.models; // return list of visible items
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
@ -102,6 +102,7 @@ define([
|
||||||
if (this.api) {
|
if (this.api) {
|
||||||
this.api.asc_registerCallback('asc_onImgWrapStyleChanged', _.bind(this._ChartWrapStyleChanged, this));
|
this.api.asc_registerCallback('asc_onImgWrapStyleChanged', _.bind(this._ChartWrapStyleChanged, this));
|
||||||
this.api.asc_registerCallback('asc_onUpdateChartStyles', _.bind(this._onUpdateChartStyles, this));
|
this.api.asc_registerCallback('asc_onUpdateChartStyles', _.bind(this._onUpdateChartStyles, this));
|
||||||
|
this.api.asc_registerCallback('asc_onAddChartStylesPreview', _.bind(this.onAddChartStylesPreview, this));
|
||||||
}
|
}
|
||||||
return this;
|
return this;
|
||||||
},
|
},
|
||||||
|
@ -150,7 +151,7 @@ define([
|
||||||
this.btnChartType.setIconCls('svgicon');
|
this.btnChartType.setIconCls('svgicon');
|
||||||
this.ShowCombinedProps(type);
|
this.ShowCombinedProps(type);
|
||||||
!(type===null || type==Asc.c_oAscChartTypeSettings.comboBarLine || type==Asc.c_oAscChartTypeSettings.comboBarLineSecondary ||
|
!(type===null || type==Asc.c_oAscChartTypeSettings.comboBarLine || type==Asc.c_oAscChartTypeSettings.comboBarLineSecondary ||
|
||||||
type==Asc.c_oAscChartTypeSettings.comboAreaBar || type==Asc.c_oAscChartTypeSettings.comboCustom) && this.updateChartStyles(this.api.asc_getChartPreviews(type));
|
type==Asc.c_oAscChartTypeSettings.comboAreaBar || type==Asc.c_oAscChartTypeSettings.comboCustom) && this.updateChartStyles(this.api.asc_getChartPreviews(type, undefined, true));
|
||||||
this._state.ChartType = type;
|
this._state.ChartType = type;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -165,18 +166,9 @@ define([
|
||||||
} else {
|
} else {
|
||||||
value = this.chartProps.getStyle();
|
value = this.chartProps.getStyle();
|
||||||
if (this._state.ChartStyle !== value || this._isChartStylesChanged) {
|
if (this._state.ChartStyle !== value || this._isChartStylesChanged) {
|
||||||
this.cmbChartStyle.suspendEvents();
|
|
||||||
var rec = this.cmbChartStyle.menuPicker.store.findWhere({data: value});
|
|
||||||
this.cmbChartStyle.menuPicker.selectRecord(rec);
|
|
||||||
this.cmbChartStyle.resumeEvents();
|
|
||||||
|
|
||||||
if (this._isChartStylesChanged) {
|
|
||||||
if (rec)
|
|
||||||
this.cmbChartStyle.fillComboView(this.cmbChartStyle.menuPicker.getSelectedRec(), true);
|
|
||||||
else
|
|
||||||
this.cmbChartStyle.fillComboView(this.cmbChartStyle.menuPicker.store.at(0), true);
|
|
||||||
}
|
|
||||||
this._state.ChartStyle = value;
|
this._state.ChartStyle = value;
|
||||||
|
var arr = this.selectCurrentChartStyle();
|
||||||
|
this._isChartStylesChanged && this.api.asc_generateChartPreviews(this._state.ChartType, arr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this._isChartStylesChanged = false;
|
this._isChartStylesChanged = false;
|
||||||
|
@ -427,11 +419,52 @@ define([
|
||||||
this.fireEvent('editcomplete', this);
|
this.fireEvent('editcomplete', this);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
selectCurrentChartStyle: function() {
|
||||||
|
if (!this.cmbChartStyle) return;
|
||||||
|
|
||||||
|
this.cmbChartStyle.suspendEvents();
|
||||||
|
var rec = this.cmbChartStyle.menuPicker.store.findWhere({data: this._state.ChartStyle});
|
||||||
|
this.cmbChartStyle.menuPicker.selectRecord(rec);
|
||||||
|
this.cmbChartStyle.resumeEvents();
|
||||||
|
|
||||||
|
if (this._isChartStylesChanged) {
|
||||||
|
var currentRecords;
|
||||||
|
if (rec)
|
||||||
|
currentRecords = this.cmbChartStyle.fillComboView(this.cmbChartStyle.menuPicker.getSelectedRec(), true);
|
||||||
|
else
|
||||||
|
currentRecords = this.cmbChartStyle.fillComboView(this.cmbChartStyle.menuPicker.store.at(0), true);
|
||||||
|
if (currentRecords && currentRecords.length>0) {
|
||||||
|
var arr = [];
|
||||||
|
_.each(currentRecords, function(style, index){
|
||||||
|
arr.push(style.get('data'));
|
||||||
|
});
|
||||||
|
return arr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
onAddChartStylesPreview: function(styles){
|
||||||
|
var me = this;
|
||||||
|
if (styles && styles.length>0){
|
||||||
|
var stylesStore = this.cmbChartStyle.menuPicker.store;
|
||||||
|
if (stylesStore) {
|
||||||
|
_.each(styles, function(item, index){
|
||||||
|
var rec = stylesStore.findWhere({
|
||||||
|
data: item.asc_getName()
|
||||||
|
});
|
||||||
|
rec && rec.set('imageUrl', item.asc_getImage());
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
_onUpdateChartStyles: function() {
|
_onUpdateChartStyles: function() {
|
||||||
if (this.api && this._state.ChartType!==null && this._state.ChartType>-1 &&
|
if (this.api && this._state.ChartType!==null && this._state.ChartType>-1 &&
|
||||||
!(this._state.ChartType==Asc.c_oAscChartTypeSettings.comboBarLine || this._state.ChartType==Asc.c_oAscChartTypeSettings.comboBarLineSecondary ||
|
!(this._state.ChartType==Asc.c_oAscChartTypeSettings.comboBarLine || this._state.ChartType==Asc.c_oAscChartTypeSettings.comboBarLineSecondary ||
|
||||||
this._state.ChartType==Asc.c_oAscChartTypeSettings.comboAreaBar || this._state.ChartType==Asc.c_oAscChartTypeSettings.comboCustom))
|
this._state.ChartType==Asc.c_oAscChartTypeSettings.comboAreaBar || this._state.ChartType==Asc.c_oAscChartTypeSettings.comboCustom)) {
|
||||||
this.updateChartStyles(this.api.asc_getChartPreviews(this._state.ChartType));
|
this.updateChartStyles(this.api.asc_getChartPreviews(this._state.ChartType, undefined, true));
|
||||||
|
this.api.asc_generateChartPreviews(this._state.ChartType, this.selectCurrentChartStyle());
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
updateChartStyles: function(styles) {
|
updateChartStyles: function(styles) {
|
||||||
|
@ -465,15 +498,7 @@ define([
|
||||||
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) {
|
||||||
var count = stylesStore.length;
|
var stylearray = [];
|
||||||
if (count>0 && count==styles.length) {
|
|
||||||
var data = stylesStore.models;
|
|
||||||
_.each(styles, function(style, index){
|
|
||||||
data[index].set('imageUrl', style.asc_getImage());
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
var stylearray = [],
|
|
||||||
selectedIdx = -1;
|
|
||||||
_.each(styles, function(item, index){
|
_.each(styles, function(item, index){
|
||||||
stylearray.push({
|
stylearray.push({
|
||||||
imageUrl: item.asc_getImage(),
|
imageUrl: item.asc_getImage(),
|
||||||
|
@ -483,7 +508,6 @@ define([
|
||||||
});
|
});
|
||||||
stylesStore.reset(stylearray, {silent: false});
|
stylesStore.reset(stylearray, {silent: false});
|
||||||
}
|
}
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
this.cmbChartStyle.menuPicker.store.reset();
|
this.cmbChartStyle.menuPicker.store.reset();
|
||||||
this.cmbChartStyle.clearComboView();
|
this.cmbChartStyle.clearComboView();
|
||||||
|
|
|
@ -97,6 +97,7 @@ define([
|
||||||
this.api = api;
|
this.api = api;
|
||||||
if (this.api) {
|
if (this.api) {
|
||||||
this.api.asc_registerCallback('asc_onUpdateChartStyles', _.bind(this._onUpdateChartStyles, this));
|
this.api.asc_registerCallback('asc_onUpdateChartStyles', _.bind(this._onUpdateChartStyles, this));
|
||||||
|
this.api.asc_registerCallback('asc_onAddChartStylesPreview', _.bind(this.onAddChartStylesPreview, this));
|
||||||
}
|
}
|
||||||
return this;
|
return this;
|
||||||
},
|
},
|
||||||
|
@ -133,7 +134,7 @@ define([
|
||||||
this.btnChartType.setIconCls('svgicon');
|
this.btnChartType.setIconCls('svgicon');
|
||||||
this.ShowCombinedProps(type);
|
this.ShowCombinedProps(type);
|
||||||
!(type===null || type==Asc.c_oAscChartTypeSettings.comboBarLine || type==Asc.c_oAscChartTypeSettings.comboBarLineSecondary ||
|
!(type===null || type==Asc.c_oAscChartTypeSettings.comboBarLine || type==Asc.c_oAscChartTypeSettings.comboBarLineSecondary ||
|
||||||
type==Asc.c_oAscChartTypeSettings.comboAreaBar || type==Asc.c_oAscChartTypeSettings.comboCustom) && this.updateChartStyles(this.api.asc_getChartPreviews(type));
|
type==Asc.c_oAscChartTypeSettings.comboAreaBar || type==Asc.c_oAscChartTypeSettings.comboCustom) && this.updateChartStyles(this.api.asc_getChartPreviews(type, undefined, true));
|
||||||
this._state.ChartType = type;
|
this._state.ChartType = type;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -148,18 +149,9 @@ define([
|
||||||
} else {
|
} else {
|
||||||
value = props.getStyle();
|
value = props.getStyle();
|
||||||
if (this._state.ChartStyle !== value || this._isChartStylesChanged) {
|
if (this._state.ChartStyle !== value || this._isChartStylesChanged) {
|
||||||
this.cmbChartStyle.suspendEvents();
|
|
||||||
var rec = this.cmbChartStyle.menuPicker.store.findWhere({data: value});
|
|
||||||
this.cmbChartStyle.menuPicker.selectRecord(rec);
|
|
||||||
this.cmbChartStyle.resumeEvents();
|
|
||||||
|
|
||||||
if (this._isChartStylesChanged) {
|
|
||||||
if (rec)
|
|
||||||
this.cmbChartStyle.fillComboView(this.cmbChartStyle.menuPicker.getSelectedRec(), true);
|
|
||||||
else
|
|
||||||
this.cmbChartStyle.fillComboView(this.cmbChartStyle.menuPicker.store.at(0), true);
|
|
||||||
}
|
|
||||||
this._state.ChartStyle = value;
|
this._state.ChartStyle = value;
|
||||||
|
var arr = this.selectCurrentChartStyle();
|
||||||
|
this._isChartStylesChanged && this.api.asc_generateChartPreviews(this._state.ChartType, arr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this._isChartStylesChanged = false;
|
this._isChartStylesChanged = false;
|
||||||
|
@ -368,11 +360,52 @@ define([
|
||||||
this.fireEvent('editcomplete', this);
|
this.fireEvent('editcomplete', this);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
selectCurrentChartStyle: function() {
|
||||||
|
if (!this.cmbChartStyle) return;
|
||||||
|
|
||||||
|
this.cmbChartStyle.suspendEvents();
|
||||||
|
var rec = this.cmbChartStyle.menuPicker.store.findWhere({data: this._state.ChartStyle});
|
||||||
|
this.cmbChartStyle.menuPicker.selectRecord(rec);
|
||||||
|
this.cmbChartStyle.resumeEvents();
|
||||||
|
|
||||||
|
if (this._isChartStylesChanged) {
|
||||||
|
var currentRecords;
|
||||||
|
if (rec)
|
||||||
|
currentRecords = this.cmbChartStyle.fillComboView(this.cmbChartStyle.menuPicker.getSelectedRec(), true);
|
||||||
|
else
|
||||||
|
currentRecords = this.cmbChartStyle.fillComboView(this.cmbChartStyle.menuPicker.store.at(0), true);
|
||||||
|
if (currentRecords && currentRecords.length>0) {
|
||||||
|
var arr = [];
|
||||||
|
_.each(currentRecords, function(style, index){
|
||||||
|
arr.push(style.get('data'));
|
||||||
|
});
|
||||||
|
return arr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
onAddChartStylesPreview: function(styles){
|
||||||
|
var me = this;
|
||||||
|
if (styles && styles.length>0){
|
||||||
|
var stylesStore = this.cmbChartStyle.menuPicker.store;
|
||||||
|
if (stylesStore) {
|
||||||
|
_.each(styles, function(item, index){
|
||||||
|
var rec = stylesStore.findWhere({
|
||||||
|
data: item.asc_getName()
|
||||||
|
});
|
||||||
|
rec && rec.set('imageUrl', item.asc_getImage());
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
_onUpdateChartStyles: function() {
|
_onUpdateChartStyles: function() {
|
||||||
if (this.api && this._state.ChartType!==null && this._state.ChartType>-1 &&
|
if (this.api && this._state.ChartType!==null && this._state.ChartType>-1 &&
|
||||||
!(this._state.ChartType==Asc.c_oAscChartTypeSettings.comboBarLine || this._state.ChartType==Asc.c_oAscChartTypeSettings.comboBarLineSecondary ||
|
!(this._state.ChartType==Asc.c_oAscChartTypeSettings.comboBarLine || this._state.ChartType==Asc.c_oAscChartTypeSettings.comboBarLineSecondary ||
|
||||||
this._state.ChartType==Asc.c_oAscChartTypeSettings.comboAreaBar || this._state.ChartType==Asc.c_oAscChartTypeSettings.comboCustom))
|
this._state.ChartType==Asc.c_oAscChartTypeSettings.comboAreaBar || this._state.ChartType==Asc.c_oAscChartTypeSettings.comboCustom)) {
|
||||||
this.updateChartStyles(this.api.asc_getChartPreviews(this._state.ChartType));
|
this.updateChartStyles(this.api.asc_getChartPreviews(this._state.ChartType, undefined, true));
|
||||||
|
this.api.asc_generateChartPreviews(this._state.ChartType, this.selectCurrentChartStyle());
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
updateChartStyles: function(styles) {
|
updateChartStyles: function(styles) {
|
||||||
|
@ -406,15 +439,7 @@ define([
|
||||||
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) {
|
||||||
var count = stylesStore.length;
|
var stylearray = [];
|
||||||
if (count>0 && count==styles.length) {
|
|
||||||
var data = stylesStore.models;
|
|
||||||
_.each(styles, function(style, index){
|
|
||||||
data[index].set('imageUrl', style.asc_getImage());
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
var stylearray = [],
|
|
||||||
selectedIdx = -1;
|
|
||||||
_.each(styles, function(item, index){
|
_.each(styles, function(item, index){
|
||||||
stylearray.push({
|
stylearray.push({
|
||||||
imageUrl: item.asc_getImage(),
|
imageUrl: item.asc_getImage(),
|
||||||
|
@ -424,7 +449,6 @@ define([
|
||||||
});
|
});
|
||||||
stylesStore.reset(stylearray, {silent: false});
|
stylesStore.reset(stylearray, {silent: false});
|
||||||
}
|
}
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
this.cmbChartStyle.menuPicker.store.reset();
|
this.cmbChartStyle.menuPicker.store.reset();
|
||||||
this.cmbChartStyle.clearComboView();
|
this.cmbChartStyle.clearComboView();
|
||||||
|
|
|
@ -127,6 +127,7 @@ define([
|
||||||
this.api = api;
|
this.api = api;
|
||||||
if (this.api) {
|
if (this.api) {
|
||||||
this.api.asc_registerCallback('asc_onUpdateChartStyles', _.bind(this._onUpdateChartStyles, this));
|
this.api.asc_registerCallback('asc_onUpdateChartStyles', _.bind(this._onUpdateChartStyles, this));
|
||||||
|
this.api.asc_registerCallback('asc_onAddChartStylesPreview', _.bind(this.onAddChartStylesPreview, this));
|
||||||
}
|
}
|
||||||
return this;
|
return this;
|
||||||
},
|
},
|
||||||
|
@ -162,7 +163,7 @@ define([
|
||||||
if (this._state.ChartType !== type) {
|
if (this._state.ChartType !== type) {
|
||||||
this.ShowCombinedProps(type);
|
this.ShowCombinedProps(type);
|
||||||
!(type===null || type==Asc.c_oAscChartTypeSettings.comboBarLine || type==Asc.c_oAscChartTypeSettings.comboBarLineSecondary ||
|
!(type===null || type==Asc.c_oAscChartTypeSettings.comboBarLine || type==Asc.c_oAscChartTypeSettings.comboBarLineSecondary ||
|
||||||
type==Asc.c_oAscChartTypeSettings.comboAreaBar || type==Asc.c_oAscChartTypeSettings.comboCustom) && this.updateChartStyles(this.api.asc_getChartPreviews(type));
|
type==Asc.c_oAscChartTypeSettings.comboAreaBar || type==Asc.c_oAscChartTypeSettings.comboCustom) && this.updateChartStyles(this.api.asc_getChartPreviews(type, undefined, true));
|
||||||
this._state.ChartType = type;
|
this._state.ChartType = type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -176,23 +177,9 @@ define([
|
||||||
} else {
|
} else {
|
||||||
value = this.chartProps.getStyle();
|
value = this.chartProps.getStyle();
|
||||||
if (this._state.ChartStyle!==value || this._isChartStylesChanged) {
|
if (this._state.ChartStyle!==value || this._isChartStylesChanged) {
|
||||||
this.cmbChartStyle.suspendEvents();
|
|
||||||
var rec = this.cmbChartStyle.menuPicker.store.findWhere({data: value});
|
|
||||||
if (rec)
|
|
||||||
this.cmbChartStyle.menuPicker.selectRecord(rec);
|
|
||||||
else {
|
|
||||||
this.cmbChartStyle.fieldPicker.deselectAll();
|
|
||||||
this.cmbChartStyle.menuPicker.deselectAll();
|
|
||||||
}
|
|
||||||
this.cmbChartStyle.resumeEvents();
|
|
||||||
|
|
||||||
if (this._isChartStylesChanged) {
|
|
||||||
if (rec)
|
|
||||||
this.cmbChartStyle.fillComboView(this.cmbChartStyle.menuPicker.getSelectedRec(),true);
|
|
||||||
else
|
|
||||||
this.cmbChartStyle.fillComboView(this.cmbChartStyle.menuPicker.store.at(0), false);
|
|
||||||
}
|
|
||||||
this._state.ChartStyle=value;
|
this._state.ChartStyle=value;
|
||||||
|
var arr = this.selectCurrentChartStyle();
|
||||||
|
this._isChartStylesChanged && this.api.asc_generateChartPreviews(this._state.ChartType, arr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this._isChartStylesChanged = false;
|
this._isChartStylesChanged = false;
|
||||||
|
@ -982,11 +969,53 @@ define([
|
||||||
Common.NotificationCenter.trigger('edit:complete', this);
|
Common.NotificationCenter.trigger('edit:complete', this);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
selectCurrentChartStyle: function() {
|
||||||
|
if (!this.cmbChartStyle) return;
|
||||||
|
|
||||||
|
this.cmbChartStyle.suspendEvents();
|
||||||
|
var rec = this.cmbChartStyle.menuPicker.store.findWhere({data: this._state.ChartStyle});
|
||||||
|
this.cmbChartStyle.menuPicker.selectRecord(rec);
|
||||||
|
this.cmbChartStyle.resumeEvents();
|
||||||
|
|
||||||
|
if (this._isChartStylesChanged) {
|
||||||
|
var currentRecords;
|
||||||
|
if (rec)
|
||||||
|
currentRecords = this.cmbChartStyle.fillComboView(this.cmbChartStyle.menuPicker.getSelectedRec(), true);
|
||||||
|
else
|
||||||
|
currentRecords = this.cmbChartStyle.fillComboView(this.cmbChartStyle.menuPicker.store.at(0), true);
|
||||||
|
if (currentRecords && currentRecords.length>0) {
|
||||||
|
var arr = [];
|
||||||
|
_.each(currentRecords, function(style, index){
|
||||||
|
arr.push(style.get('data'));
|
||||||
|
});
|
||||||
|
return arr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
onAddChartStylesPreview: function(styles){
|
||||||
|
if (this._isEditType) return;
|
||||||
|
|
||||||
|
if (styles && styles.length>0){
|
||||||
|
var stylesStore = this.cmbChartStyle.menuPicker.store;
|
||||||
|
if (stylesStore) {
|
||||||
|
_.each(styles, function(item, index){
|
||||||
|
var rec = stylesStore.findWhere({
|
||||||
|
data: item.asc_getName()
|
||||||
|
});
|
||||||
|
rec && rec.set('imageUrl', item.asc_getImage());
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
_onUpdateChartStyles: function() {
|
_onUpdateChartStyles: function() {
|
||||||
if (this.api && this._state.ChartType!==null && this._state.ChartType>-1 &&
|
if (this.api && this._state.ChartType!==null && this._state.ChartType>-1 &&
|
||||||
!(this._state.ChartType==Asc.c_oAscChartTypeSettings.comboBarLine || this._state.ChartType==Asc.c_oAscChartTypeSettings.comboBarLineSecondary ||
|
!(this._state.ChartType==Asc.c_oAscChartTypeSettings.comboBarLine || this._state.ChartType==Asc.c_oAscChartTypeSettings.comboBarLineSecondary ||
|
||||||
this._state.ChartType==Asc.c_oAscChartTypeSettings.comboAreaBar || this._state.ChartType==Asc.c_oAscChartTypeSettings.comboCustom))
|
this._state.ChartType==Asc.c_oAscChartTypeSettings.comboAreaBar || this._state.ChartType==Asc.c_oAscChartTypeSettings.comboCustom)) {
|
||||||
this.updateChartStyles(this.api.asc_getChartPreviews(this._state.ChartType));
|
this.updateChartStyles(this.api.asc_getChartPreviews(this._state.ChartType, undefined, true));
|
||||||
|
this.api.asc_generateChartPreviews(this._state.ChartType, this.selectCurrentChartStyle());
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
updateChartStyles: function(styles) {
|
updateChartStyles: function(styles) {
|
||||||
|
@ -1020,15 +1049,7 @@ define([
|
||||||
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) {
|
||||||
var count = stylesStore.length;
|
var stylearray = [];
|
||||||
if (count>0 && count==styles.length) {
|
|
||||||
var data = stylesStore.models;
|
|
||||||
_.each(styles, function(style, index){
|
|
||||||
data[index].set('imageUrl', style.asc_getImage());
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
var stylearray = [],
|
|
||||||
selectedIdx = -1;
|
|
||||||
_.each(styles, function(item, index){
|
_.each(styles, function(item, index){
|
||||||
stylearray.push({
|
stylearray.push({
|
||||||
imageUrl: item.asc_getImage(),
|
imageUrl: item.asc_getImage(),
|
||||||
|
@ -1038,7 +1059,6 @@ define([
|
||||||
});
|
});
|
||||||
stylesStore.reset(stylearray, {silent: false});
|
stylesStore.reset(stylearray, {silent: false});
|
||||||
}
|
}
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
this.cmbChartStyle.menuPicker.store.reset();
|
this.cmbChartStyle.menuPicker.store.reset();
|
||||||
this.cmbChartStyle.clearComboView();
|
this.cmbChartStyle.clearComboView();
|
||||||
|
|
|
@ -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,15 +333,7 @@ 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) {
|
|
||||||
var data = stylesStore.models;
|
|
||||||
_.each(styles, function(style, index){
|
|
||||||
data[index].set('imageUrl', style.asc_getImage());
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
var stylearray = [],
|
|
||||||
selectedIdx = -1;
|
|
||||||
_.each(styles, function(item, index){
|
_.each(styles, function(item, index){
|
||||||
stylearray.push({
|
stylearray.push({
|
||||||
imageUrl: item.asc_getImage(),
|
imageUrl: item.asc_getImage(),
|
||||||
|
@ -341,7 +343,6 @@ define([
|
||||||
});
|
});
|
||||||
stylesStore.reset(stylearray, {silent: false});
|
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