[SSE] Update sparkline styles.

This commit is contained in:
Julia Radzhabova 2016-09-27 13:43:59 +03:00
parent a440a825ce
commit 998f6f48d5

View file

@ -213,28 +213,18 @@ define([
this._originalProps = props; this._originalProps = props;
this.isChart = false; this.isChart = false;
var type = props.asc_getType(); var type = props.asc_getType(),
styleChanged = false;
if (this._state.SparkType !== type) { if (this._state.SparkType !== type) {
var record = this.mnuSparkTypePicker.store.findWhere({type: type}); var record = this.mnuSparkTypePicker.store.findWhere({type: type});
this.mnuSparkTypePicker.selectRecord(record, true); this.mnuSparkTypePicker.selectRecord(record, true);
if (record) { if (record) {
this.btnSparkType.setIconCls('item-chartlist ' + record.get('iconCls')); this.btnSparkType.setIconCls('item-chartlist ' + record.get('iconCls'));
} }
this.updateSparkStyles(props.asc_getStyles());
this._state.SparkType = type; this._state.SparkType = type;
styleChanged = true;
} }
// var value = props.asc_getStyle();
// if (this._state.SparkStyle!==value) {
// var record = this.mnuSparkStylePicker.store.findWhere({data: value});
// this.mnuSparkStylePicker.selectRecord(record, true);
// if (record) {
// var btnIconEl = this.btnSparkStyle.cmpEl.find('span.btn-icon');
// btnIconEl.css('background-image', 'url(' + record.get('imageUrl') + ')');
// }
// this._state.SparkStyle=value;
// }
var w = props.asc_getLineWeight(), var w = props.asc_getLineWeight(),
check_value = (Math.abs(this._state.LineWeight-w)<0.001) && !((new RegExp(this.txtPt + '\\s*$')).test(this.cmbBorderSize.getRawValue())); check_value = (Math.abs(this._state.LineWeight-w)<0.001) && !((new RegExp(this.txtPt + '\\s*$')).test(this.cmbBorderSize.getRawValue()));
if ( Math.abs(this._state.LineWeight-w)>0.001 || check_value || if ( Math.abs(this._state.LineWeight-w)>0.001 || check_value ||
@ -289,6 +279,7 @@ define([
if ( this._state.MarkersPoint!==point ) { if ( this._state.MarkersPoint!==point ) {
this.chMarkersPoint.setValue((point !== null && point !== undefined) ? point : 'indeterminate', true); this.chMarkersPoint.setValue((point !== null && point !== undefined) ? point : 'indeterminate', true);
this._state.MarkersPoint=point; this._state.MarkersPoint=point;
styleChanged = true;
} }
this.chMarkersPoint.setDisabled(this._locked || this._state.SparkType!==Asc.c_oAscSparklineType.Line); this.chMarkersPoint.setDisabled(this._locked || this._state.SparkType!==Asc.c_oAscSparklineType.Line);
this.btnMarkersColor.setDisabled(this._locked || this._state.SparkType!==Asc.c_oAscSparklineType.Line); this.btnMarkersColor.setDisabled(this._locked || this._state.SparkType!==Asc.c_oAscSparklineType.Line);
@ -318,6 +309,7 @@ define([
this.colorsMarkers.select(this.MarkersColor,true); this.colorsMarkers.select(this.MarkersColor,true);
this._state.MarkersColor = this.MarkersColor; this._state.MarkersColor = this.MarkersColor;
styleChanged = true;
} }
} }
@ -326,6 +318,7 @@ define([
if ( this._state.HighPoint!==point ) { if ( this._state.HighPoint!==point ) {
this.chHighPoint.setValue((point !== null && point !== undefined) ? point : 'indeterminate', true); this.chHighPoint.setValue((point !== null && point !== undefined) ? point : 'indeterminate', true);
this._state.HighPoint=point; this._state.HighPoint=point;
styleChanged = true;
} }
if (color) { if (color) {
this.HighColor = (color.asc_getType() == Asc.c_oAscColor.COLOR_TYPE_SCHEME) ? this.HighColor = (color.asc_getType() == Asc.c_oAscColor.COLOR_TYPE_SCHEME) ?
@ -352,6 +345,7 @@ define([
this.colorsHigh.select(this.HighColor,true); this.colorsHigh.select(this.HighColor,true);
this._state.HighColor = this.HighColor; this._state.HighColor = this.HighColor;
styleChanged = true;
} }
} }
@ -360,6 +354,7 @@ define([
if ( this._state.LowPoint!==point ) { if ( this._state.LowPoint!==point ) {
this.chLowPoint.setValue((point !== null && point !== undefined) ? point : 'indeterminate', true); this.chLowPoint.setValue((point !== null && point !== undefined) ? point : 'indeterminate', true);
this._state.LowPoint=point; this._state.LowPoint=point;
styleChanged = true;
} }
if (color) { if (color) {
this.LowColor = (color.asc_getType() == Asc.c_oAscColor.COLOR_TYPE_SCHEME) ? this.LowColor = (color.asc_getType() == Asc.c_oAscColor.COLOR_TYPE_SCHEME) ?
@ -386,6 +381,7 @@ define([
this.colorsLow.select(this.LowColor,true); this.colorsLow.select(this.LowColor,true);
this._state.LowColor = this.LowColor; this._state.LowColor = this.LowColor;
styleChanged = true;
} }
} }
@ -394,6 +390,7 @@ define([
if ( this._state.FirstPoint!==point ) { if ( this._state.FirstPoint!==point ) {
this.chFirstPoint.setValue((point !== null && point !== undefined) ? point : 'indeterminate', true); this.chFirstPoint.setValue((point !== null && point !== undefined) ? point : 'indeterminate', true);
this._state.FirstPoint=point; this._state.FirstPoint=point;
styleChanged = true;
} }
if (color) { if (color) {
this.FirstColor = (color.asc_getType() == Asc.c_oAscColor.COLOR_TYPE_SCHEME) ? this.FirstColor = (color.asc_getType() == Asc.c_oAscColor.COLOR_TYPE_SCHEME) ?
@ -420,6 +417,7 @@ define([
this.colorsFirst.select(this.FirstColor,true); this.colorsFirst.select(this.FirstColor,true);
this._state.FirstColor = this.FirstColor; this._state.FirstColor = this.FirstColor;
styleChanged = true;
} }
} }
@ -428,6 +426,7 @@ define([
if ( this._state.LastPoint!==point ) { if ( this._state.LastPoint!==point ) {
this.chLastPoint.setValue((point !== null && point !== undefined) ? point : 'indeterminate', true); this.chLastPoint.setValue((point !== null && point !== undefined) ? point : 'indeterminate', true);
this._state.LastPoint=point; this._state.LastPoint=point;
styleChanged = true;
} }
if (color) { if (color) {
this.LastColor = (color.asc_getType() == Asc.c_oAscColor.COLOR_TYPE_SCHEME) ? this.LastColor = (color.asc_getType() == Asc.c_oAscColor.COLOR_TYPE_SCHEME) ?
@ -454,6 +453,7 @@ define([
this.colorsLast.select(this.LastColor,true); this.colorsLast.select(this.LastColor,true);
this._state.LastColor = this.LastColor; this._state.LastColor = this.LastColor;
styleChanged = true;
} }
} }
@ -462,6 +462,7 @@ define([
if ( this._state.NegativePoint!==point ) { if ( this._state.NegativePoint!==point ) {
this.chNegativePoint.setValue((point !== null && point !== undefined) ? point : 'indeterminate', true); this.chNegativePoint.setValue((point !== null && point !== undefined) ? point : 'indeterminate', true);
this._state.NegativePoint=point; this._state.NegativePoint=point;
styleChanged = true;
} }
if (color) { if (color) {
this.NegativeColor = (color.asc_getType() == Asc.c_oAscColor.COLOR_TYPE_SCHEME) ? this.NegativeColor = (color.asc_getType() == Asc.c_oAscColor.COLOR_TYPE_SCHEME) ?
@ -488,8 +489,12 @@ define([
this.colorsNegative.select(this.NegativeColor,true); this.colorsNegative.select(this.NegativeColor,true);
this._state.NegativeColor = this.NegativeColor; this._state.NegativeColor = this.NegativeColor;
styleChanged = true;
} }
} }
if (styleChanged)
this.updateSparkStyles(props.asc_getStyles());
} }
} }
}, },
@ -1071,7 +1076,6 @@ define([
if (this.btnSparkStyle.menu) { if (this.btnSparkStyle.menu) {
this.btnSparkStyle.menu.on('show:after', function () { this.btnSparkStyle.menu.on('show:after', function () {
me.updateSparkStyles(me._originalProps.asc_getStyles());
me.mnuSparkStylePicker.scroller.update({alwaysVisibleY: true}); me.mnuSparkStylePicker.scroller.update({alwaysVisibleY: true});
}); });
} }
@ -1082,29 +1086,17 @@ define([
var stylesStore = this.mnuSparkStylePicker.store; var stylesStore = this.mnuSparkStylePicker.store;
if (stylesStore) { if (stylesStore) {
var stylearray = [], var stylearray = [],
selectedIdx = -1, selectedIdx = styles[styles.length-1];
selectedUrl; for (var i=0; i<styles.length-1; i++) {
_.each(styles, function(item, index){
stylearray.push({ stylearray.push({
imageUrl: item[1], imageUrl: styles[i],
data : item[0] data : i
// tip : me.textStyle + ' ' + item.asc_getStyle()
}); });
// if (me._state.SparkStyle == item.asc_getStyle()) { }
// selectedIdx = index;
// selectedUrl = item[1];
// }
});
stylesStore.reset(stylearray, {silent: false}); stylesStore.reset(stylearray, {silent: false});
}
}
this.mnuSparkStylePicker.selectByIndex(selectedIdx, true); this.mnuSparkStylePicker.selectByIndex(selectedIdx, true);
if (selectedIdx>=0 && this.btnSparkStyle.cmpEl) { }
var style = 'url(' + selectedUrl + ')';
var btnIconEl = this.btnSparkStyle.cmpEl.find('span.btn-icon');
btnIconEl.css('background-image', style);
} }
}, },