[DE] [PE] [SSE] Gradient Slider: add, remove thumb

This commit is contained in:
Julia Svinareva 2019-11-15 14:05:50 +03:00
parent cd45eec7ca
commit 310033f575
9 changed files with 64 additions and 13 deletions

View file

@ -161,9 +161,6 @@ define([
addNewThumb: function(index, color) { addNewThumb: function(index, color) {
var me = this; var me = this;
me.thumbs[index].thumb.on('dblclick', null, function() {
me.trigger('thumbdblclick', me);
});
me.thumbs[index].thumbcolor = me.thumbs[index].thumb.find('> div'); me.thumbs[index].thumbcolor = me.thumbs[index].thumb.find('> div');
(index>0) && this.setColorValue(color, index); (index>0) && this.setColorValue(color, index);
me.sortThumbs(); me.sortThumbs();

View file

@ -419,8 +419,7 @@ define([
}; };
var onTrackMouseUp = function (e) { var onTrackMouseUp = function (e) {
if ( me.disabled ) return; if ( me.disabled || !_.isUndefined(me._dragstart) || me.thumbs.length > 9) return;
if ( me.thumbs.length > 9 ) return;
var pos = Math.max(0, Math.min(100, (Math.round((e.pageX*Common.Utils.zoom() - me.cmpEl.offset().left) / me.width * 100)))), var pos = Math.max(0, Math.min(100, (Math.round((e.pageX*Common.Utils.zoom() - me.cmpEl.offset().left) / me.width * 100)))),
nearIndex = findThumb(pos), nearIndex = findThumb(pos),
@ -517,9 +516,9 @@ define([
var ind = _.findIndex(this.thumbs, {index: index}); var ind = _.findIndex(this.thumbs, {index: index});
if (ind !== -1) { if (ind !== -1) {
if (remove && this.thumbs.length > 2) { if (remove && this.thumbs.length > 2) {
this.thumbs[index].thumb.addClass('remove'); this.$el.find('.active').addClass('remove');
} else { } else {
this.thumbs[index].thumb.removeClass('remove'); this.$el.find('.remove').removeClass('remove');
} }
} }
}, },

View file

@ -957,9 +957,10 @@ define([
me.sldrGradient.setColorValue(Common.Utils.String.format('#{0}', (typeof(me.GradColor.colors[index]) == 'object') ? me.GradColor.colors[index].color : me.GradColor.colors[index]), index); me.sldrGradient.setColorValue(Common.Utils.String.format('#{0}', (typeof(me.GradColor.colors[index]) == 'object') ? me.GradColor.colors[index].color : me.GradColor.colors[index]), index);
me.sldrGradient.setValue(index, me.GradColor.values[index]); me.sldrGradient.setValue(index, me.GradColor.values[index]);
} }
if (me.GradColor.currentIdx) { if (_.isUndefined(me.GradColor.currentIdx) || me.GradColor.currentIdx >= this.GradColor.colors.length) {
me.sldrGradient.setActiveThumb(me.GradColor.currentIdx); me.GradColor.currentIdx = 0;
} }
me.sldrGradient.setActiveThumb(me.GradColor.currentIdx);
this.OriginalFillType = Asc.c_oAscFill.FILL_TYPE_GRAD; this.OriginalFillType = Asc.c_oAscFill.FILL_TYPE_GRAD;
this.FGColor = {Value: 1, Color: this.GradColor.colors[0]}; this.FGColor = {Value: 1, Color: this.GradColor.colors[0]};
this.BGColor = {Value: 1, Color: 'ffffff'}; this.BGColor = {Value: 1, Color: 'ffffff'};

View file

@ -650,6 +650,10 @@ define([
me.sldrGradient.setColorValue(Common.Utils.String.format('#{0}', (typeof(me.GradColor.colors[index]) == 'object') ? me.GradColor.colors[index].color : me.GradColor.colors[index]), index); me.sldrGradient.setColorValue(Common.Utils.String.format('#{0}', (typeof(me.GradColor.colors[index]) == 'object') ? me.GradColor.colors[index].color : me.GradColor.colors[index]), index);
me.sldrGradient.setValue(index, me.GradColor.values[index]); me.sldrGradient.setValue(index, me.GradColor.values[index]);
} }
if (_.isUndefined(me.GradColor.currentIdx) || me.GradColor.currentIdx >= this.GradColor.colors.length) {
me.GradColor.currentIdx = 0;
}
me.sldrGradient.setActiveThumb(me.GradColor.currentIdx);
this.OriginalFillType = Asc.c_oAscFill.FILL_TYPE_GRAD; this.OriginalFillType = Asc.c_oAscFill.FILL_TYPE_GRAD;
this.ShapeColor = {Value: 1, Color: this.GradColor.colors[0]}; this.ShapeColor = {Value: 1, Color: this.GradColor.colors[0]};
} }
@ -944,6 +948,15 @@ define([
me.GradColor.colors = colors; me.GradColor.colors = colors;
me.GradColor.currentIdx = currentIdx; me.GradColor.currentIdx = currentIdx;
}); });
this.sldrGradient.on('addthumb', function(cmp, index, nearIndex, color){
me.GradColor.colors[index] = me.GradColor.colors[nearIndex];
me.sldrGradient.addNewThumb(index, color);
});
this.sldrGradient.on('removethumb', function(cmp, index){
me.sldrGradient.removeThumb(index);
me.GradColor.values.splice(index, 1);
me.sldrGradient.changeGradientStyle();
});
this.lockedControls.push(this.sldrGradient); this.lockedControls.push(this.sldrGradient);
this.cmbBorderSize = new Common.UI.ComboBorderSizeEditable({ this.cmbBorderSize = new Common.UI.ComboBorderSizeEditable({

View file

@ -870,9 +870,10 @@ define([
me.sldrGradient.setColorValue(Common.Utils.String.format('#{0}', (typeof(me.GradColor.colors[index]) == 'object') ? me.GradColor.colors[index].color : me.GradColor.colors[index]), index); me.sldrGradient.setColorValue(Common.Utils.String.format('#{0}', (typeof(me.GradColor.colors[index]) == 'object') ? me.GradColor.colors[index].color : me.GradColor.colors[index]), index);
me.sldrGradient.setValue(index, me.GradColor.values[index]); me.sldrGradient.setValue(index, me.GradColor.values[index]);
} }
if (me.GradColor.currentIdx) { if (_.isUndefined(me.GradColor.currentIdx) || me.GradColor.currentIdx >= this.GradColor.colors.length) {
me.sldrGradient.setActiveThumb(me.GradColor.currentIdx); me.GradColor.currentIdx = 0;
} }
me.sldrGradient.setActiveThumb(me.GradColor.currentIdx);
this.OriginalFillType = Asc.c_oAscFill.FILL_TYPE_GRAD; this.OriginalFillType = Asc.c_oAscFill.FILL_TYPE_GRAD;
this.FGColor = {Value: 1, Color: this.GradColor.colors[0]}; this.FGColor = {Value: 1, Color: this.GradColor.colors[0]};
this.BGColor = {Value: 1, Color: 'ffffff'}; this.BGColor = {Value: 1, Color: 'ffffff'};

View file

@ -804,6 +804,15 @@ define([
me.GradColor.colors = colors; me.GradColor.colors = colors;
me.GradColor.currentIdx = currentIdx; me.GradColor.currentIdx = currentIdx;
}); });
this.sldrGradient.on('addthumb', function(cmp, index, nearIndex, color){
me.GradColor.colors[index] = me.GradColor.colors[nearIndex];
me.sldrGradient.addNewThumb(index, color);
});
this.sldrGradient.on('removethumb', function(cmp, index){
me.sldrGradient.removeThumb(index);
me.GradColor.values.splice(index, 1);
me.sldrGradient.changeGradientStyle();
});
this.FillItems.push(this.sldrGradient); this.FillItems.push(this.sldrGradient);
}, },
@ -1282,6 +1291,10 @@ define([
me.sldrGradient.setColorValue(Common.Utils.String.format('#{0}', (typeof(me.GradColor.colors[index]) == 'object') ? me.GradColor.colors[index].color : me.GradColor.colors[index]), index); me.sldrGradient.setColorValue(Common.Utils.String.format('#{0}', (typeof(me.GradColor.colors[index]) == 'object') ? me.GradColor.colors[index].color : me.GradColor.colors[index]), index);
me.sldrGradient.setValue(index, me.GradColor.values[index]); me.sldrGradient.setValue(index, me.GradColor.values[index]);
} }
if (_.isUndefined(me.GradColor.currentIdx) || me.GradColor.currentIdx >= this.GradColor.colors.length) {
me.GradColor.currentIdx = 0;
}
me.sldrGradient.setActiveThumb(me.GradColor.currentIdx);
this.OriginalFillType = Asc.c_oAscFill.FILL_TYPE_GRAD; this.OriginalFillType = Asc.c_oAscFill.FILL_TYPE_GRAD;
this.FGColor = {Value: 1, Color: this.GradColor.colors[0]}; this.FGColor = {Value: 1, Color: this.GradColor.colors[0]};
this.BGColor = {Value: 1, Color: 'ffffff'}; this.BGColor = {Value: 1, Color: 'ffffff'};

View file

@ -846,6 +846,10 @@ define([
me.sldrGradient.setColorValue(Common.Utils.String.format('#{0}', (typeof(me.GradColor.colors[index]) == 'object') ? me.GradColor.colors[index].color : me.GradColor.colors[index]), index); me.sldrGradient.setColorValue(Common.Utils.String.format('#{0}', (typeof(me.GradColor.colors[index]) == 'object') ? me.GradColor.colors[index].color : me.GradColor.colors[index]), index);
me.sldrGradient.setValue(index, me.GradColor.values[index]); me.sldrGradient.setValue(index, me.GradColor.values[index]);
} }
if (_.isUndefined(me.GradColor.currentIdx) || me.GradColor.currentIdx >= this.GradColor.colors.length) {
me.GradColor.currentIdx = 0;
}
me.sldrGradient.setActiveThumb(me.GradColor.currentIdx);
this.OriginalFillType = Asc.c_oAscFill.FILL_TYPE_GRAD; this.OriginalFillType = Asc.c_oAscFill.FILL_TYPE_GRAD;
this.FGColor = {Value: 1, Color: this.GradColor.colors[0]}; this.FGColor = {Value: 1, Color: this.GradColor.colors[0]};
this.BGColor = {Value: 1, Color: 'ffffff'}; this.BGColor = {Value: 1, Color: 'ffffff'};
@ -1253,6 +1257,15 @@ define([
me.GradColor.colors = colors; me.GradColor.colors = colors;
me.GradColor.currentIdx = currentIdx; me.GradColor.currentIdx = currentIdx;
}); });
this.sldrGradient.on('addthumb', function(cmp, index, nearIndex, color){
me.GradColor.colors[index] = me.GradColor.colors[nearIndex];
me.sldrGradient.addNewThumb(index, color);
});
this.sldrGradient.on('removethumb', function(cmp, index){
me.sldrGradient.removeThumb(index);
me.GradColor.values.splice(index, 1);
me.sldrGradient.changeGradientStyle();
});
this.lockedControls.push(this.sldrGradient); this.lockedControls.push(this.sldrGradient);
this.cmbBorderSize = new Common.UI.ComboBorderSizeEditable({ this.cmbBorderSize = new Common.UI.ComboBorderSizeEditable({

View file

@ -894,9 +894,10 @@ define([
me.sldrGradient.setColorValue(Common.Utils.String.format('#{0}', (typeof(me.GradColor.colors[index]) == 'object') ? me.GradColor.colors[index].color : me.GradColor.colors[index]), index); me.sldrGradient.setColorValue(Common.Utils.String.format('#{0}', (typeof(me.GradColor.colors[index]) == 'object') ? me.GradColor.colors[index].color : me.GradColor.colors[index]), index);
me.sldrGradient.setValue(index, me.GradColor.values[index]); me.sldrGradient.setValue(index, me.GradColor.values[index]);
} }
if (me.GradColor.currentIdx) { if (_.isUndefined(me.GradColor.currentIdx) || me.GradColor.currentIdx >= this.GradColor.colors.length) {
me.sldrGradient.setActiveThumb(me.GradColor.currentIdx); me.GradColor.currentIdx = 0;
} }
me.sldrGradient.setActiveThumb(me.GradColor.currentIdx);
this.OriginalFillType = Asc.c_oAscFill.FILL_TYPE_GRAD; this.OriginalFillType = Asc.c_oAscFill.FILL_TYPE_GRAD;
this.FGColor = {Value: 1, Color: this.GradColor.colors[0]}; this.FGColor = {Value: 1, Color: this.GradColor.colors[0]};
this.BGColor = {Value: 1, Color: 'ffffff'}; this.BGColor = {Value: 1, Color: 'ffffff'};

View file

@ -850,6 +850,10 @@ define([
me.sldrGradient.setColorValue(Common.Utils.String.format('#{0}', (typeof(me.GradColor.colors[index]) == 'object') ? me.GradColor.colors[index].color : me.GradColor.colors[index]), index); me.sldrGradient.setColorValue(Common.Utils.String.format('#{0}', (typeof(me.GradColor.colors[index]) == 'object') ? me.GradColor.colors[index].color : me.GradColor.colors[index]), index);
me.sldrGradient.setValue(index, me.GradColor.values[index]); me.sldrGradient.setValue(index, me.GradColor.values[index]);
} }
if (_.isUndefined(me.GradColor.currentIdx) || me.GradColor.currentIdx >= this.GradColor.colors.length) {
me.GradColor.currentIdx = 0;
}
me.sldrGradient.setActiveThumb(me.GradColor.currentIdx);
this.OriginalFillType = Asc.c_oAscFill.FILL_TYPE_GRAD; this.OriginalFillType = Asc.c_oAscFill.FILL_TYPE_GRAD;
this.FGColor = {Value: 1, Color: this.GradColor.colors[0]}; this.FGColor = {Value: 1, Color: this.GradColor.colors[0]};
this.BGColor = {Value: 1, Color: 'ffffff'}; this.BGColor = {Value: 1, Color: 'ffffff'};
@ -1257,6 +1261,15 @@ define([
me.GradColor.colors = colors; me.GradColor.colors = colors;
me.GradColor.currentIdx = currentIdx; me.GradColor.currentIdx = currentIdx;
}); });
this.sldrGradient.on('addthumb', function(cmp, index, nearIndex, color){
me.GradColor.colors[index] = me.GradColor.colors[nearIndex];
me.sldrGradient.addNewThumb(index, color);
});
this.sldrGradient.on('removethumb', function(cmp, index){
me.sldrGradient.removeThumb(index);
me.GradColor.values.splice(index, 1);
me.sldrGradient.changeGradientStyle();
});
this.lockedControls.push(this.sldrGradient); this.lockedControls.push(this.sldrGradient);
this.cmbBorderSize = new Common.UI.ComboBorderSizeEditable({ this.cmbBorderSize = new Common.UI.ComboBorderSizeEditable({