diff --git a/apps/common/main/lib/component/Slider.js b/apps/common/main/lib/component/Slider.js index 2c9d61ae4..e6abb5266 100644 --- a/apps/common/main/lib/component/Slider.js +++ b/apps/common/main/lib/component/Slider.js @@ -347,6 +347,13 @@ define([ pos = Math.max(0, Math.min(100, position)), value = pos/me.delta + me.minValue; + if (me.isRemoveThumb) { + if (me.thumbs.length < 3) return; + me.trigger('removethumb', me, index); + me.trigger('change', me); + me.trigger('changecomplete', me); + } + me.setThumbPosition(index, pos); me.thumbs[index].value = value; @@ -376,6 +383,10 @@ define([ pos = Math.max(0, Math.min(100, position)), value = pos/me.delta + me.minValue; + var positionY = e.pageY*Common.Utils.zoom() - me.cmpEl.offset().top; + me.isRemoveThumb = positionY > me.cmpEl.height(); + me.setRemoveThumb(index, me.isRemoveThumb); + me.setThumbPosition(index, pos); me.thumbs[index].value = value; @@ -498,6 +509,14 @@ define([ if (suspend!==true) this.trigger('thumbclick', this, index); }, + setRemoveThumb: function(index, remove) { + if (remove) { + this.thumbs[index].thumb.addClass('remove'); + } else { + this.thumbs[index].thumb.removeClass('remove'); + } + }, + setThumbPosition: function(index, x) { this.thumbs[index].position = x; this.thumbs[index].thumb.css({left: x + '%'}); diff --git a/apps/common/main/resources/less/multislider-gradient.less b/apps/common/main/resources/less/multislider-gradient.less index d42350d94..562f15b8f 100644 --- a/apps/common/main/resources/less/multislider-gradient.less +++ b/apps/common/main/resources/less/multislider-gradient.less @@ -40,6 +40,10 @@ &.active .thumb-bottom { border-bottom-width: 2px; } + + &.remove { + opacity: 0.5; + } } .track { diff --git a/apps/spreadsheeteditor/main/app/view/ShapeSettings.js b/apps/spreadsheeteditor/main/app/view/ShapeSettings.js index 6900ef876..f3b2f6ea6 100644 --- a/apps/spreadsheeteditor/main/app/view/ShapeSettings.js +++ b/apps/spreadsheeteditor/main/app/view/ShapeSettings.js @@ -546,17 +546,16 @@ define([ }); fill.asc_getFill().asc_putPositions(arr); - if (this.OriginalFillType !== Asc.c_oAscFill.FILL_TYPE_GRAD) { - if (this.GradFillType == Asc.c_oAscFillGradType.GRAD_LINEAR) { - fill.asc_getFill().asc_putLinearAngle(this.GradLinearDirectionType * 60000); - fill.asc_getFill().asc_putLinearScale(true); - } - arr = []; - this.GradColor.colors.forEach(function(item){ - arr.push(Common.Utils.ThemeColor.getRgbColor(item)); - }); - fill.asc_getFill().asc_putColors(arr); + if (this.GradFillType == Asc.c_oAscFillGradType.GRAD_LINEAR) { + fill.asc_getFill().asc_putLinearAngle(this.GradLinearDirectionType * 60000); + fill.asc_getFill().asc_putLinearScale(true); } + arr = []; + this.GradColor.colors.forEach(function(item){ + arr.push(Common.Utils.ThemeColor.getRgbColor(item)); + }); + fill.asc_getFill().asc_putColors(arr); + props.asc_putFill(fill); this.imgprops.asc_putShapeProperties(props); this.api.asc_setGraphicObjectProps(this.imgprops); @@ -1300,6 +1299,12 @@ define([ me.GradColor.colors[index] = me.GradColor.colors[nearIndex]; me.sldrGradient.addNewThumb(index, color); }); + this.sldrGradient.on('removethumb', function(cmp, index){ + me.GradColor.colors.splice(index, 1); + me.GradColor.values.splice(index, 1); + me.sldrGradient.removeThumb(index); + me.sldrGradient.changeGradientStyle(); + }); this.fillControls.push(this.sldrGradient); this.cmbBorderSize = new Common.UI.ComboBorderSizeEditable({