Commit c3f3da85 authored by Julia Radzhabova's avatar Julia Radzhabova

Fix Bug 34088, Bug 34064.

parent d23c3951
...@@ -54,7 +54,8 @@ define([ ...@@ -54,7 +54,8 @@ define([
var _stack = [], var _stack = [],
_chartObject = undefined, _chartObject = undefined,
_shapeObject = undefined, _shapeObject = undefined,
_metricText = Common.Utils.Metric.getCurrentMetricName(); _metricText = Common.Utils.Metric.getCurrentMetricName(),
_borderColor = 'transparent';
var wrapTypesTransform = (function() { var wrapTypesTransform = (function() {
var map = [ var map = [
...@@ -80,7 +81,7 @@ define([ ...@@ -80,7 +81,7 @@ define([
return obj.ui === type; return obj.ui === type;
})[0]; })[0];
return record ? record.sdk : 0; return record ? record.sdk : 0;
}, }
} }
})(); })();
...@@ -260,13 +261,18 @@ define([ ...@@ -260,13 +261,18 @@ define([
paletteFillColor && paletteFillColor.select(color); paletteFillColor && paletteFillColor.select(color);
// Init border color // Init border color
var stroke = shapeProperties.get_stroke(), me._initBorderColorView();
strokeType = stroke.get_type(); },
color = 'transparent'; _initBorderColorView: function () {
var me = this,
paletteBorderColor = me.getView('EditChart').paletteBorderColor,
stroke = _shapeObject.get_ShapeProperties().get_stroke();
var color = 'transparent';
if (stroke && strokeType == Asc.c_oAscStrokeType.STROKE_COLOR) { if (stroke && stroke.get_type() == Asc.c_oAscStrokeType.STROKE_COLOR) {
sdkColor = stroke.get_color(); var sdkColor = stroke.get_color();
if (sdkColor) { if (sdkColor) {
if (sdkColor.get_type() == Asc.c_oAscColor.COLOR_TYPE_SCHEME) { if (sdkColor.get_type() == Asc.c_oAscColor.COLOR_TYPE_SCHEME) {
...@@ -277,6 +283,7 @@ define([ ...@@ -277,6 +283,7 @@ define([
} }
} }
} }
_borderColor = color;
paletteBorderColor && paletteBorderColor.select(color); paletteBorderColor && paletteBorderColor.select(color);
$('#edit-chart-bordercolor .color-preview').css('background-color', ('transparent' == color) ? color : ('#' + (_.isObject(color) ? color.color : color))) $('#edit-chart-bordercolor .color-preview').css('background-color', ('transparent' == color) ? color : ('#' + (_.isObject(color) ? color.color : color)))
...@@ -440,29 +447,20 @@ define([ ...@@ -440,29 +447,20 @@ define([
var me = this, var me = this,
$target = $(e.currentTarget), $target = $(e.currentTarget),
value = $target.val(), value = $target.val(),
currentShape = _shapeObject.get_ShapeProperties(),
image = new Asc.asc_CImgProperty(), image = new Asc.asc_CImgProperty(),
shape = new Asc.asc_CShapeProperty(), shape = new Asc.asc_CShapeProperty(),
stroke = new Asc.asc_CStroke(), stroke = new Asc.asc_CStroke();
currentColor = Common.Utils.ThemeColor.getRgbColor('000000');
value = borderSizeTransform.sizeByIndex(parseInt(value)); value = borderSizeTransform.sizeByIndex(parseInt(value));
var currentStroke = currentShape.get_stroke();
if (currentStroke) {
var currentStrokeType = currentStroke.get_type();
if (currentStrokeType == Asc.c_oAscStrokeType.STROKE_COLOR) {
currentColor = currentStroke.get_color();
}
}
if (value < 0.01) { if (value < 0.01) {
stroke.put_type(Asc.c_oAscStrokeType.STROKE_NONE); stroke.put_type(Asc.c_oAscStrokeType.STROKE_NONE);
} else { } else {
stroke.put_type(Asc.c_oAscStrokeType.STROKE_COLOR); stroke.put_type(Asc.c_oAscStrokeType.STROKE_COLOR);
stroke.put_color(currentColor); if (_borderColor == 'transparent')
stroke.put_color(Common.Utils.ThemeColor.getRgbColor({color: '000000', effectId: 29}));
else
stroke.put_color(Common.Utils.ThemeColor.getRgbColor(Common.Utils.ThemeColor.colorValue2EffectId(_borderColor)));
stroke.put_width(value * 25.4 / 72.0); stroke.put_width(value * 25.4 / 72.0);
} }
...@@ -470,6 +468,7 @@ define([ ...@@ -470,6 +468,7 @@ define([
image.put_ShapeProperties(shape); image.put_ShapeProperties(shape);
me.api.ImgApply(image); me.api.ImgApply(image);
me._initBorderColorView(); // when select STROKE_NONE or change from STROKE_NONE to STROKE_COLOR
}, },
onBorderSizeChanging: function (e) { onBorderSizeChanging: function (e) {
...@@ -506,8 +505,9 @@ define([ ...@@ -506,8 +505,9 @@ define([
currentShape = _shapeObject.get_ShapeProperties(); currentShape = _shapeObject.get_ShapeProperties();
$('#edit-chart-bordercolor .color-preview').css('background-color', ('transparent' == color) ? color : ('#' + (_.isObject(color) ? color.color : color))); $('#edit-chart-bordercolor .color-preview').css('background-color', ('transparent' == color) ? color : ('#' + (_.isObject(color) ? color.color : color)));
_borderColor = color;
if (me.api && currentShape) { if (me.api && currentShape && currentShape.get_stroke().get_type() == Asc.c_oAscStrokeType.STROKE_COLOR) {
var image = new Asc.asc_CImgProperty(), var image = new Asc.asc_CImgProperty(),
shape = new Asc.asc_CShapeProperty(), shape = new Asc.asc_CShapeProperty(),
stroke = new Asc.asc_CStroke(); stroke = new Asc.asc_CStroke();
......
...@@ -53,7 +53,8 @@ define([ ...@@ -53,7 +53,8 @@ define([
// Private // Private
var _stack = [], var _stack = [],
_shapeObject = undefined, _shapeObject = undefined,
_metricText = Common.Utils.Metric.getCurrentMetricName(); _metricText = Common.Utils.Metric.getCurrentMetricName(),
_borderColor = 'transparent';
var wrapTypesTransform = (function() { var wrapTypesTransform = (function() {
var map = [ var map = [
...@@ -79,7 +80,7 @@ define([ ...@@ -79,7 +80,7 @@ define([
return obj.ui === type; return obj.ui === type;
})[0]; })[0];
return record ? record.sdk : 0; return record ? record.sdk : 0;
}, }
} }
})(); })();
...@@ -101,7 +102,7 @@ define([ ...@@ -101,7 +102,7 @@ define([
} }
}); });
return index return index;
}, },
sizeByValue: function (value) { sizeByValue: function (value) {
...@@ -254,13 +255,18 @@ define([ ...@@ -254,13 +255,18 @@ define([
paletteFillColor && paletteFillColor.select(color); paletteFillColor && paletteFillColor.select(color);
// Init border color // Init border color
var stroke = shapeProperties.get_stroke(), me._initBorderColorView();
strokeType = stroke.get_type(); },
color = 'transparent'; _initBorderColorView: function () {
var me = this,
paletteBorderColor = me.getView('EditShape').paletteBorderColor,
stroke = _shapeObject.get_ShapeProperties().get_stroke();
var color = 'transparent';
if (stroke && strokeType == Asc.c_oAscStrokeType.STROKE_COLOR) { if (stroke && stroke.get_type() == Asc.c_oAscStrokeType.STROKE_COLOR) {
sdkColor = stroke.get_color(); var sdkColor = stroke.get_color();
if (sdkColor) { if (sdkColor) {
if (sdkColor.get_type() == Asc.c_oAscColor.COLOR_TYPE_SCHEME) { if (sdkColor.get_type() == Asc.c_oAscColor.COLOR_TYPE_SCHEME) {
...@@ -271,6 +277,7 @@ define([ ...@@ -271,6 +277,7 @@ define([
} }
} }
} }
_borderColor = color;
paletteBorderColor && paletteBorderColor.select(color); paletteBorderColor && paletteBorderColor.select(color);
$('#edit-shape-bordercolor .color-preview').css('background-color', ('transparent' == color) ? color : ('#' + (_.isObject(color) ? color.color : color))) $('#edit-shape-bordercolor .color-preview').css('background-color', ('transparent' == color) ? color : ('#' + (_.isObject(color) ? color.color : color)))
...@@ -407,29 +414,20 @@ define([ ...@@ -407,29 +414,20 @@ define([
var me = this, var me = this,
$target = $(e.currentTarget), $target = $(e.currentTarget),
value = $target.val(), value = $target.val(),
currentShape = _shapeObject.get_ShapeProperties(),
image = new Asc.asc_CImgProperty(), image = new Asc.asc_CImgProperty(),
shape = new Asc.asc_CShapeProperty(), shape = new Asc.asc_CShapeProperty(),
stroke = new Asc.asc_CStroke(), stroke = new Asc.asc_CStroke();
currentColor = Common.Utils.ThemeColor.getRgbColor('000000');
value = borderSizeTransform.sizeByIndex(parseInt(value)); value = borderSizeTransform.sizeByIndex(parseInt(value));
var currentStroke = currentShape.get_stroke();
if (currentStroke) {
var currentStrokeType = currentStroke.get_type();
if (currentStrokeType == Asc.c_oAscStrokeType.STROKE_COLOR) {
currentColor = currentStroke.get_color();
}
}
if (value < 0.01) { if (value < 0.01) {
stroke.put_type(Asc.c_oAscStrokeType.STROKE_NONE); stroke.put_type(Asc.c_oAscStrokeType.STROKE_NONE);
} else { } else {
stroke.put_type(Asc.c_oAscStrokeType.STROKE_COLOR); stroke.put_type(Asc.c_oAscStrokeType.STROKE_COLOR);
stroke.put_color(currentColor); if (_borderColor == 'transparent')
stroke.put_color(Common.Utils.ThemeColor.getRgbColor({color: '000000', effectId: 29}));
else
stroke.put_color(Common.Utils.ThemeColor.getRgbColor(Common.Utils.ThemeColor.colorValue2EffectId(_borderColor)));
stroke.put_width(value * 25.4 / 72.0); stroke.put_width(value * 25.4 / 72.0);
} }
...@@ -437,6 +435,7 @@ define([ ...@@ -437,6 +435,7 @@ define([
image.put_ShapeProperties(shape); image.put_ShapeProperties(shape);
me.api.ImgApply(image); me.api.ImgApply(image);
me._initBorderColorView(); // when select STROKE_NONE or change from STROKE_NONE to STROKE_COLOR
}, },
onBorderSizeChanging: function (e) { onBorderSizeChanging: function (e) {
...@@ -494,8 +493,9 @@ define([ ...@@ -494,8 +493,9 @@ define([
currentShape = _shapeObject.get_ShapeProperties(); currentShape = _shapeObject.get_ShapeProperties();
$('#edit-shape-bordercolor .color-preview').css('background-color', ('transparent' == color) ? color : ('#' + (_.isObject(color) ? color.color : color))); $('#edit-shape-bordercolor .color-preview').css('background-color', ('transparent' == color) ? color : ('#' + (_.isObject(color) ? color.color : color)));
_borderColor = color;
if (me.api && currentShape) { if (me.api && currentShape && currentShape.get_stroke().get_type() == Asc.c_oAscStrokeType.STROKE_COLOR) {
var image = new Asc.asc_CImgProperty(), var image = new Asc.asc_CImgProperty(),
shape = new Asc.asc_CShapeProperty(), shape = new Asc.asc_CShapeProperty(),
stroke = new Asc.asc_CStroke(); stroke = new Asc.asc_CStroke();
......
...@@ -54,7 +54,8 @@ define([ ...@@ -54,7 +54,8 @@ define([
var _stack = [], var _stack = [],
_chartObject = undefined, _chartObject = undefined,
_shapeObject = undefined, _shapeObject = undefined,
_metricText = Common.Utils.Metric.getCurrentMetricName(); _metricText = Common.Utils.Metric.getCurrentMetricName(),
_borderColor = 'transparent';
var borderSizeTransform = (function() { var borderSizeTransform = (function() {
var _sizes = [0, 0.5, 1, 1.5, 2.25, 3, 4.5, 6]; var _sizes = [0, 0.5, 1, 1.5, 2.25, 3, 4.5, 6];
...@@ -66,14 +67,19 @@ define([ ...@@ -66,14 +67,19 @@ define([
return _sizes[index]; return _sizes[index];
}, },
sizeByValue: function (value) { indexSizeByValue: function (value) {
var index = 0; var index = 0;
_.each(_sizes, function (size, idx) { _.each(_sizes, function (size, idx) {
if (Math.abs(size - value) < 0.25) { if (Math.abs(size - value) < 0.25) {
index = idx; index = idx;
} }
}); });
return _sizes[index];
return index
},
sizeByValue: function (value) {
return _sizes[this.indexSizeByValue(value)];
} }
} }
})(); })();
...@@ -157,9 +163,10 @@ define([ ...@@ -157,9 +163,10 @@ define([
$('.chart-types li[data-type=' + type + ']').addClass('active'); $('.chart-types li[data-type=' + type + ']').addClass('active');
// Init style border size // Init style border size
var borderSize = shapeProperties.get_stroke().get_width() * 72.0 / 25.4; var borderSize = shapeProperties.get_stroke().get_width() * 72.0 / 25.4,
$('#edit-chart-bordersize input').val([borderSizeTransform.sizeByIndex(borderSize)]); borderType = _shapeObject.get_stroke().get_type();
$('#edit-chart-bordersize .item-after').text(borderSizeTransform.sizeByValue(borderSize) + ' ' + _metricText); $('#edit-chart-bordersize input').val([(borderType == Asc.c_oAscStrokeType.STROKE_NONE) ? 0 : borderSizeTransform.indexSizeByValue(borderSize)]);
$('#edit-chart-bordersize .item-after').text(((borderType == Asc.c_oAscStrokeType.STROKE_NONE) ? 0 : borderSizeTransform.sizeByValue(borderSize)) + ' ' + _metricText);
paletteFillColor && paletteFillColor.on('select', _.bind(me.onFillColor, me)); paletteFillColor && paletteFillColor.on('select', _.bind(me.onFillColor, me));
paletteBorderColor && paletteBorderColor.on('select', _.bind(me.onBorderColor, me)); paletteBorderColor && paletteBorderColor.on('select', _.bind(me.onBorderColor, me));
...@@ -188,13 +195,18 @@ define([ ...@@ -188,13 +195,18 @@ define([
paletteFillColor && paletteFillColor.select(color); paletteFillColor && paletteFillColor.select(color);
// Init border color // Init border color
var stroke = shapeProperties.get_stroke(), me._initBorderColorView();
strokeType = stroke.get_type(); },
color = 'transparent'; _initBorderColorView: function () {
var me = this,
paletteBorderColor = me.getView('EditChart').paletteBorderColor,
stroke = _shapeObject.get_stroke();
var color = 'transparent';
if (stroke && strokeType == Asc.c_oAscStrokeType.STROKE_COLOR) { if (stroke && stroke.get_type() == Asc.c_oAscStrokeType.STROKE_COLOR) {
sdkColor = stroke.get_color(); var sdkColor = stroke.get_color();
if (sdkColor) { if (sdkColor) {
if (sdkColor.get_type() == Asc.c_oAscColor.COLOR_TYPE_SCHEME) { if (sdkColor.get_type() == Asc.c_oAscColor.COLOR_TYPE_SCHEME) {
...@@ -205,6 +217,7 @@ define([ ...@@ -205,6 +217,7 @@ define([
} }
} }
} }
_borderColor = color;
paletteBorderColor && paletteBorderColor.select(color); paletteBorderColor && paletteBorderColor.select(color);
$('#edit-chart-bordercolor .color-preview').css('background-color', ('transparent' == color) ? color : ('#' + (_.isObject(color) ? color.color : color))) $('#edit-chart-bordercolor .color-preview').css('background-color', ('transparent' == color) ? color : ('#' + (_.isObject(color) ? color.color : color)))
...@@ -292,33 +305,25 @@ define([ ...@@ -292,33 +305,25 @@ define([
$target = $(e.currentTarget), $target = $(e.currentTarget),
value = $target.val(), value = $target.val(),
shape = new Asc.asc_CShapeProperty(), shape = new Asc.asc_CShapeProperty(),
stroke = new Asc.asc_CStroke(), stroke = new Asc.asc_CStroke();
currentColor = Common.Utils.ThemeColor.getRgbColor('000000');
value = borderSizeTransform.sizeByIndex(parseInt(value)); value = borderSizeTransform.sizeByIndex(parseInt(value));
var currentStroke = _shapeObject.get_stroke();
if (currentStroke) {
var currentStrokeType = currentStroke.get_type();
if (currentStrokeType == Asc.c_oAscStrokeType.STROKE_COLOR) {
currentColor = currentStroke.get_color();
}
}
if (value < 0.01) { if (value < 0.01) {
stroke.put_type(Asc.c_oAscStrokeType.STROKE_NONE); stroke.put_type(Asc.c_oAscStrokeType.STROKE_NONE);
} else { } else {
stroke.put_type(Asc.c_oAscStrokeType.STROKE_COLOR); stroke.put_type(Asc.c_oAscStrokeType.STROKE_COLOR);
stroke.put_color(currentColor); if (_borderColor == 'transparent')
stroke.asc_putPrstDash(currentStroke.asc_getPrstDash()); stroke.put_color(Common.Utils.ThemeColor.getRgbColor({color: '000000', effectId: 29}));
else
stroke.put_color(Common.Utils.ThemeColor.getRgbColor(Common.Utils.ThemeColor.colorValue2EffectId(_borderColor)));
stroke.put_width(value * 25.4 / 72.0); stroke.put_width(value * 25.4 / 72.0);
} }
shape.put_stroke(stroke); shape.put_stroke(stroke);
me.api.ShapeApply(shape); me.api.ShapeApply(shape);
me._initBorderColorView(); // when select STROKE_NONE or change from STROKE_NONE to STROKE_COLOR
}, },
onBorderSizeChanging: function (e) { onBorderSizeChanging: function (e) {
...@@ -352,8 +357,9 @@ define([ ...@@ -352,8 +357,9 @@ define([
var me = this; var me = this;
$('#edit-chart-bordercolor .color-preview').css('background-color', ('transparent' == color) ? color : ('#' + (_.isObject(color) ? color.color : color))); $('#edit-chart-bordercolor .color-preview').css('background-color', ('transparent' == color) ? color : ('#' + (_.isObject(color) ? color.color : color)));
_borderColor = color;
if (me.api && _shapeObject) { if (me.api && _shapeObject && _shapeObject.get_stroke().get_type() == Asc.c_oAscStrokeType.STROKE_COLOR) {
var shape = new Asc.asc_CShapeProperty(), var shape = new Asc.asc_CShapeProperty(),
stroke = new Asc.asc_CStroke(); stroke = new Asc.asc_CStroke();
......
...@@ -53,7 +53,8 @@ define([ ...@@ -53,7 +53,8 @@ define([
// Private // Private
var _stack = [], var _stack = [],
_shapeObject = undefined, _shapeObject = undefined,
_metricText = Common.Utils.Metric.getCurrentMetricName(); _metricText = Common.Utils.Metric.getCurrentMetricName(),
_borderColor = 'transparent';
var borderSizeTransform = (function() { var borderSizeTransform = (function() {
var _sizes = [0, 0.5, 1, 1.5, 2.25, 3, 4.5, 6]; var _sizes = [0, 0.5, 1, 1.5, 2.25, 3, 4.5, 6];
...@@ -151,8 +152,8 @@ define([ ...@@ -151,8 +152,8 @@ define([
paletteBorderColor = me.getView('EditShape').paletteBorderColor; paletteBorderColor = me.getView('EditShape').paletteBorderColor;
// Init style border size // Init style border size
var borderSize = _shapeObject.get_stroke().get_width() * 72.0 / 25.4; var borderSize = _shapeObject.get_stroke().get_width() * 72.0 / 25.4,
var borderType = _shapeObject.get_stroke().get_type(); borderType = _shapeObject.get_stroke().get_type();
$('#edit-shape-bordersize input').val([(borderType == Asc.c_oAscStrokeType.STROKE_NONE) ? 0 : borderSizeTransform.indexSizeByValue(borderSize)]); $('#edit-shape-bordersize input').val([(borderType == Asc.c_oAscStrokeType.STROKE_NONE) ? 0 : borderSizeTransform.indexSizeByValue(borderSize)]);
$('#edit-shape-bordersize .item-after').text(((borderType == Asc.c_oAscStrokeType.STROKE_NONE) ? 0 : borderSizeTransform.sizeByValue(borderSize)) + ' ' + _metricText); $('#edit-shape-bordersize .item-after').text(((borderType == Asc.c_oAscStrokeType.STROKE_NONE) ? 0 : borderSizeTransform.sizeByValue(borderSize)) + ' ' + _metricText);
...@@ -187,13 +188,18 @@ define([ ...@@ -187,13 +188,18 @@ define([
paletteFillColor && paletteFillColor.select(color); paletteFillColor && paletteFillColor.select(color);
// Init border color // Init border color
var stroke = _shapeObject.get_stroke(), me._initBorderColorView();
strokeType = stroke.get_type(); },
color = 'transparent'; _initBorderColorView: function () {
var me = this,
paletteBorderColor = me.getView('EditShape').paletteBorderColor,
stroke = _shapeObject.get_stroke();
if (stroke && strokeType == Asc.c_oAscStrokeType.STROKE_COLOR) { var color = 'transparent';
sdkColor = stroke.get_color();
if (stroke && stroke.get_type() == Asc.c_oAscStrokeType.STROKE_COLOR) {
var sdkColor = stroke.get_color();
if (sdkColor) { if (sdkColor) {
if (sdkColor.get_type() == Asc.c_oAscColor.COLOR_TYPE_SCHEME) { if (sdkColor.get_type() == Asc.c_oAscColor.COLOR_TYPE_SCHEME) {
...@@ -204,6 +210,7 @@ define([ ...@@ -204,6 +210,7 @@ define([
} }
} }
} }
_borderColor = color;
paletteBorderColor && paletteBorderColor.select(color); paletteBorderColor && paletteBorderColor.select(color);
$('#edit-shape-bordercolor .color-preview').css('background-color', ('transparent' == color) ? color : ('#' + (_.isObject(color) ? color.color : color))) $('#edit-shape-bordercolor .color-preview').css('background-color', ('transparent' == color) ? color : ('#' + (_.isObject(color) ? color.color : color)))
...@@ -272,33 +279,25 @@ define([ ...@@ -272,33 +279,25 @@ define([
$target = $(e.currentTarget), $target = $(e.currentTarget),
value = $target.val(), value = $target.val(),
shape = new Asc.asc_CShapeProperty(), shape = new Asc.asc_CShapeProperty(),
stroke = new Asc.asc_CStroke(), stroke = new Asc.asc_CStroke();
currentColor = Common.Utils.ThemeColor.getRgbColor('000000');
value = borderSizeTransform.sizeByIndex(parseInt(value)); value = borderSizeTransform.sizeByIndex(parseInt(value));
var currentStroke = _shapeObject.get_stroke();
if (currentStroke) {
var currentStrokeType = currentStroke.get_type();
if (currentStrokeType == Asc.c_oAscStrokeType.STROKE_COLOR) {
currentColor = currentStroke.get_color();
}
}
if (value < 0.01) { if (value < 0.01) {
stroke.put_type(Asc.c_oAscStrokeType.STROKE_NONE); stroke.put_type(Asc.c_oAscStrokeType.STROKE_NONE);
} else { } else {
stroke.put_type(Asc.c_oAscStrokeType.STROKE_COLOR); stroke.put_type(Asc.c_oAscStrokeType.STROKE_COLOR);
stroke.put_color(currentColor); if (_borderColor == 'transparent')
stroke.asc_putPrstDash(currentStroke.asc_getPrstDash()); stroke.put_color(Common.Utils.ThemeColor.getRgbColor({color: '000000', effectId: 29}));
else
stroke.put_color(Common.Utils.ThemeColor.getRgbColor(Common.Utils.ThemeColor.colorValue2EffectId(_borderColor)));
stroke.put_width(value * 25.4 / 72.0); stroke.put_width(value * 25.4 / 72.0);
} }
shape.put_stroke(stroke); shape.put_stroke(stroke);
me.api.ShapeApply(shape); me.api.ShapeApply(shape);
me._initBorderColorView(); // when select STROKE_NONE or change from STROKE_NONE to STROKE_COLOR
}, },
onBorderSizeChanging: function (e) { onBorderSizeChanging: function (e) {
...@@ -350,8 +349,9 @@ define([ ...@@ -350,8 +349,9 @@ define([
var me = this; var me = this;
$('#edit-shape-bordercolor .color-preview').css('background-color', ('transparent' == color) ? color : ('#' + (_.isObject(color) ? color.color : color))); $('#edit-shape-bordercolor .color-preview').css('background-color', ('transparent' == color) ? color : ('#' + (_.isObject(color) ? color.color : color)));
_borderColor = color;
if (me.api && _shapeObject) { if (me.api && _shapeObject && _shapeObject.get_stroke().get_type() == Asc.c_oAscStrokeType.STROKE_COLOR) {
var shape = new Asc.asc_CShapeProperty(), var shape = new Asc.asc_CShapeProperty(),
stroke = new Asc.asc_CStroke(); stroke = new Asc.asc_CStroke();
......
...@@ -69,14 +69,19 @@ define([ ...@@ -69,14 +69,19 @@ define([
return _sizes[index]; return _sizes[index];
}, },
sizeByValue: function (value) { indexSizeByValue: function (value) {
var index = 0; var index = 0;
_.each(_sizes, function (size, idx) { _.each(_sizes, function (size, idx) {
if (Math.abs(size - value) < 0.25) { if (Math.abs(size - value) < 0.25) {
index = idx; index = idx;
} }
}); });
return _sizes[index];
return index
},
sizeByValue: function (value) {
return _sizes[this.indexSizeByValue(value)];
} }
} }
})(); })();
...@@ -212,25 +217,29 @@ define([ ...@@ -212,25 +217,29 @@ define([
// Init border // Init border
var borderSize = shapeProperties.get_stroke().get_width() * 72.0 / 25.4; var borderSize = shapeProperties.get_stroke().get_width() * 72.0 / 25.4,
$('#edit-chart-bordersize input').val([borderSizeTransform.sizeByIndex(borderSize)]); borderType = shapeProperties.get_stroke().get_type();
$('#edit-chart-bordersize .item-after').text(borderSizeTransform.sizeByValue(borderSize) + ' ' + _metricText); $('#edit-chart-bordersize input').val([(borderType == Asc.c_oAscStrokeType.STROKE_NONE) ? 0 : borderSizeTransform.indexSizeByValue(borderSize)]);
$('#edit-chart-bordersize .item-after').text(((borderType == Asc.c_oAscStrokeType.STROKE_NONE) ? 0 : borderSizeTransform.sizeByValue(borderSize)) + ' ' + _metricText);
$('#edit-chart-bordersize input').single('change touchend', _.buffered(me.onBorderSize, 100, me)); $('#edit-chart-bordersize input').single('change touchend', _.buffered(me.onBorderSize, 100, me));
$('#edit-chart-bordersize input').single('input', _.bind(me.onBorderSizeChanging, me)); $('#edit-chart-bordersize input').single('input', _.bind(me.onBorderSizeChanging, me));
var stroke = shapeProperties.get_stroke(), // Init border color
strokeType = stroke.get_type(); me._initBorderColorView();
},
if (stroke && strokeType == Asc.c_oAscStrokeType.STROKE_COLOR) { _initBorderColorView: function () {
_borderInfo.color = me._sdkToThemeColor(stroke.get_color()); var me = this,
} stroke = _shapeObject.get_ShapeProperties().get_stroke();
_borderInfo.color = (stroke && stroke.get_type() == Asc.c_oAscStrokeType.STROKE_COLOR) ? me._sdkToThemeColor(stroke.get_color()) : 'transparent';
$('#edit-chart-bordercolor .color-preview').css('background-color', $('#edit-chart-bordercolor .color-preview').css('background-color',
('transparent' == _borderInfo.color) ('transparent' == _borderInfo.color)
? _borderInfo.color ? _borderInfo.color
: ('#' + (_.isObject(_borderInfo.color) ? _borderInfo.color.color : _borderInfo.color)) : ('#' + (_.isObject(_borderInfo.color) ? _borderInfo.color.color : _borderInfo.color))
) );
}, },
initLayoutPage: function () { initLayoutPage: function () {
...@@ -618,29 +627,20 @@ define([ ...@@ -618,29 +627,20 @@ define([
var me = this, var me = this,
$target = $(e.currentTarget), $target = $(e.currentTarget),
value = $target.val(), value = $target.val(),
currentShape = _shapeObject.get_ShapeProperties(),
image = new Asc.asc_CImgProperty(), image = new Asc.asc_CImgProperty(),
shape = new Asc.asc_CShapeProperty(), shape = new Asc.asc_CShapeProperty(),
stroke = new Asc.asc_CStroke(), stroke = new Asc.asc_CStroke();
currentColor = Common.Utils.ThemeColor.getRgbColor('000000');
value = borderSizeTransform.sizeByIndex(parseInt(value)); value = borderSizeTransform.sizeByIndex(parseInt(value));
var currentStroke = currentShape.get_stroke();
if (currentStroke) {
var currentStrokeType = currentStroke.get_type();
if (currentStrokeType == Asc.c_oAscStrokeType.STROKE_COLOR) {
currentColor = currentStroke.get_color();
}
}
if (value < 0.01) { if (value < 0.01) {
stroke.put_type(Asc.c_oAscStrokeType.STROKE_NONE); stroke.put_type(Asc.c_oAscStrokeType.STROKE_NONE);
} else { } else {
stroke.put_type(Asc.c_oAscStrokeType.STROKE_COLOR); stroke.put_type(Asc.c_oAscStrokeType.STROKE_COLOR);
stroke.put_color(currentColor); if (_borderInfo.color == 'transparent')
stroke.put_color(Common.Utils.ThemeColor.getRgbColor({color: '000000', effectId: 29}));
else
stroke.put_color(Common.Utils.ThemeColor.getRgbColor(Common.Utils.ThemeColor.colorValue2EffectId(_borderInfo.color)));
stroke.put_width(value * 25.4 / 72.0); stroke.put_width(value * 25.4 / 72.0);
} }
...@@ -648,6 +648,7 @@ define([ ...@@ -648,6 +648,7 @@ define([
image.put_ShapeProperties(shape); image.put_ShapeProperties(shape);
me.api.asc_setGraphicObjectProps(image); me.api.asc_setGraphicObjectProps(image);
me._initBorderColorView(); // when select STROKE_NONE or change from STROKE_NONE to STROKE_COLOR
}, },
onBorderSizeChanging: function (e) { onBorderSizeChanging: function (e) {
...@@ -660,14 +661,13 @@ define([ ...@@ -660,14 +661,13 @@ define([
currentShape = _shapeObject.get_ShapeProperties(); currentShape = _shapeObject.get_ShapeProperties();
$('#edit-chart-bordercolor .color-preview').css('background-color', ('transparent' == color) ? color : ('#' + (_.isObject(color) ? color.color : color))); $('#edit-chart-bordercolor .color-preview').css('background-color', ('transparent' == color) ? color : ('#' + (_.isObject(color) ? color.color : color)));
_borderInfo.color = color;
if (me.api && currentShape) { if (me.api && currentShape && currentShape.get_stroke().get_type() == Asc.c_oAscStrokeType.STROKE_COLOR) {
var image = new Asc.asc_CImgProperty(), var image = new Asc.asc_CImgProperty(),
shape = new Asc.asc_CShapeProperty(), shape = new Asc.asc_CShapeProperty(),
stroke = new Asc.asc_CStroke(); stroke = new Asc.asc_CStroke();
_borderInfo.color = Common.Utils.ThemeColor.getRgbColor(color);
if (currentShape.get_stroke().get_width() < 0.01) { if (currentShape.get_stroke().get_width() < 0.01) {
stroke.put_type(Asc.c_oAscStrokeType.STROKE_NONE); stroke.put_type(Asc.c_oAscStrokeType.STROKE_NONE);
} else { } else {
......
...@@ -67,14 +67,19 @@ define([ ...@@ -67,14 +67,19 @@ define([
return _sizes[index]; return _sizes[index];
}, },
sizeByValue: function (value) { indexSizeByValue: function (value) {
var index = 0; var index = 0;
_.each(_sizes, function (size, idx) { _.each(_sizes, function (size, idx) {
if (Math.abs(size - value) < 0.25) { if (Math.abs(size - value) < 0.25) {
index = idx; index = idx;
} }
}); });
return _sizes[index];
return index;
},
sizeByValue: function (value) {
return _sizes[this.indexSizeByValue(value)];
} }
} }
})(); })();
...@@ -173,25 +178,16 @@ define([ ...@@ -173,25 +178,16 @@ define([
// Init border // Init border
var borderSize = this._mm2pt(shapeProperties.get_stroke().get_width()); var borderSize = me._mm2pt(shapeProperties.get_stroke().get_width()),
$('#edit-shape-bordersize input').val([borderSizeTransform.sizeByIndex(borderSize)]); borderType = shapeProperties.get_stroke().get_type();
$('#edit-shape-bordersize .item-after').text(borderSizeTransform.sizeByValue(borderSize) + ' ' + _metricText); $('#edit-shape-bordersize input').val([(borderType == Asc.c_oAscStrokeType.STROKE_NONE) ? 0 : borderSizeTransform.indexSizeByValue(borderSize)]);
$('#edit-shape-bordersize .item-after').text(((borderType == Asc.c_oAscStrokeType.STROKE_NONE) ? 0 : borderSizeTransform.sizeByValue(borderSize)) + ' ' + _metricText);
$('#edit-shape-bordersize input').single('change touchend', _.buffered(me.onBorderSize, 100, me)); $('#edit-shape-bordersize input').single('change touchend', _.buffered(me.onBorderSize, 100, me));
$('#edit-shape-bordersize input').single('input', _.bind(me.onBorderSizeChanging, me)); $('#edit-shape-bordersize input').single('input', _.bind(me.onBorderSizeChanging, me));
var stroke = shapeProperties.get_stroke(), // Init border color
strokeType = stroke.get_type(); me._initBorderColorView();
if (stroke && strokeType == Asc.c_oAscStrokeType.STROKE_COLOR) {
_borderInfo.color = me._sdkToThemeColor(stroke.get_color());
}
$('#edit-shape-bordercolor .color-preview').css('background-color',
('transparent' == _borderInfo.color)
? _borderInfo.color
: ('#' + (_.isObject(_borderInfo.color) ? _borderInfo.color.color : _borderInfo.color))
)
// Effect // Effect
// Init style opacity // Init style opacity
...@@ -201,6 +197,19 @@ define([ ...@@ -201,6 +197,19 @@ define([
$('#edit-shape-effect input').single('input', _.bind(me.onOpacityChanging, me)); $('#edit-shape-effect input').single('input', _.bind(me.onOpacityChanging, me));
}, },
_initBorderColorView: function () {
var me = this,
stroke = _shapeObject.get_ShapeProperties().get_stroke();
_borderInfo.color = (stroke && stroke.get_type() == Asc.c_oAscStrokeType.STROKE_COLOR) ? me._sdkToThemeColor(stroke.get_color()) : 'transparent';
$('#edit-shape-bordercolor .color-preview').css('background-color',
('transparent' == _borderInfo.color)
? _borderInfo.color
: ('#' + (_.isObject(_borderInfo.color) ? _borderInfo.color.color : _borderInfo.color))
);
},
initReplacePage: function () { initReplacePage: function () {
$('.shape-replace li').single('click', _.buffered(this.onReplace, 100, this)); $('.shape-replace li').single('click', _.buffered(this.onReplace, 100, this));
}, },
...@@ -263,36 +272,28 @@ define([ ...@@ -263,36 +272,28 @@ define([
var me = this, var me = this,
$target = $(e.currentTarget), $target = $(e.currentTarget),
value = $target.val(), value = $target.val(),
currentShape = _shapeObject.get_ShapeProperties(),
image = new Asc.asc_CImgProperty(), image = new Asc.asc_CImgProperty(),
shape = new Asc.asc_CShapeProperty(), shape = new Asc.asc_CShapeProperty(),
stroke = new Asc.asc_CStroke(), stroke = new Asc.asc_CStroke();
currentColor = Common.Utils.ThemeColor.getRgbColor('000000');
value = borderSizeTransform.sizeByIndex(parseInt(value)); value = borderSizeTransform.sizeByIndex(parseInt(value));
var currentStroke = currentShape.get_stroke();
if (currentStroke) {
var currentStrokeType = currentStroke.get_type();
if (currentStrokeType == Asc.c_oAscStrokeType.STROKE_COLOR) {
currentColor = currentStroke.get_color();
}
}
if (value < 0.01) { if (value < 0.01) {
stroke.put_type(Asc.c_oAscStrokeType.STROKE_NONE); stroke.put_type(Asc.c_oAscStrokeType.STROKE_NONE);
} else { } else {
stroke.put_type(Asc.c_oAscStrokeType.STROKE_COLOR); stroke.put_type(Asc.c_oAscStrokeType.STROKE_COLOR);
stroke.put_color(currentColor); if (_borderInfo.color == 'transparent')
stroke.put_width(this._pt2mm(value)); stroke.put_color(Common.Utils.ThemeColor.getRgbColor({color: '000000', effectId: 29}));
else
stroke.put_color(Common.Utils.ThemeColor.getRgbColor(Common.Utils.ThemeColor.colorValue2EffectId(_borderInfo.color)));
stroke.put_width(me._pt2mm(value));
} }
shape.put_stroke(stroke); shape.put_stroke(stroke);
image.asc_putShapeProperties(shape); image.asc_putShapeProperties(shape);
me.api.asc_setGraphicObjectProps(image); me.api.asc_setGraphicObjectProps(image);
me._initBorderColorView(); // when select STROKE_NONE or change from STROKE_NONE to STROKE_COLOR
}, },
onBorderSizeChanging: function (e) { onBorderSizeChanging: function (e) {
...@@ -350,8 +351,9 @@ define([ ...@@ -350,8 +351,9 @@ define([
currentShape = _shapeObject.get_ShapeProperties(); currentShape = _shapeObject.get_ShapeProperties();
$('#edit-shape-bordercolor .color-preview').css('background-color', ('transparent' == color) ? color : ('#' + (_.isObject(color) ? color.color : color))); $('#edit-shape-bordercolor .color-preview').css('background-color', ('transparent' == color) ? color : ('#' + (_.isObject(color) ? color.color : color)));
_borderInfo.color = color;
if (me.api && currentShape) { if (me.api && currentShape && currentShape.get_stroke().get_type() == Asc.c_oAscStrokeType.STROKE_COLOR) {
var image = new Asc.asc_CImgProperty(), var image = new Asc.asc_CImgProperty(),
shape = new Asc.asc_CShapeProperty(), shape = new Asc.asc_CShapeProperty(),
stroke = new Asc.asc_CStroke(); stroke = new Asc.asc_CStroke();
...@@ -370,8 +372,6 @@ define([ ...@@ -370,8 +372,6 @@ define([
me.api.asc_setGraphicObjectProps(image); me.api.asc_setGraphicObjectProps(image);
} }
}, },
// API handlers // API handlers
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment