Feature/gradient slider change markers Fix Bug 34376
This commit is contained in:
parent
0d3f0a88f9
commit
26c44db2fe
|
@ -150,6 +150,18 @@ define([
|
||||||
}
|
}
|
||||||
style = Common.Utils.String.format('linear-gradient(to right, {0} {1}%, {2} {3}%)', this.colorValues[0], this.getValue(0), this.colorValues[1], this.getValue(1));
|
style = Common.Utils.String.format('linear-gradient(to right, {0} {1}%, {2} {3}%)', this.colorValues[0], this.getValue(0), this.colorValues[1], this.getValue(1));
|
||||||
this.trackEl.css('background', style);
|
this.trackEl.css('background', style);
|
||||||
|
},
|
||||||
|
|
||||||
|
sortThumbs: function() {
|
||||||
|
var recalc_indexes = Common.UI.MultiSlider.prototype.sortThumbs.call(this),
|
||||||
|
new_colors = [],
|
||||||
|
me = this;
|
||||||
|
_.each (recalc_indexes, function(recalc_index) {
|
||||||
|
new_colors.push(me.colorValues[recalc_index]);
|
||||||
|
});
|
||||||
|
this.colorValues = new_colors;
|
||||||
|
this.trigger('sortthumbs', me, recalc_indexes);
|
||||||
|
return recalc_indexes;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -338,16 +338,21 @@ define([
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
|
|
||||||
var index = e.data,
|
var index = e.data.index,
|
||||||
lastValue = me.thumbs[index].value,
|
lastValue = me.thumbs[index].value,
|
||||||
minValue = (index-1<0) ? 0 : me.thumbs[index-1].position,
|
minValue = (index-1<0) ? 0 : me.thumbs[index-1].position,
|
||||||
maxValue = (index+1<me.thumbs.length) ? me.thumbs[index+1].position : 100,
|
maxValue = (index+1<me.thumbs.length) ? me.thumbs[index+1].position : 100,
|
||||||
pos = Math.max(minValue, Math.min(maxValue, (Math.round((e.pageX*Common.Utils.zoom() - me.cmpEl.offset().left - me._dragstart) / me.width * 100)))),
|
position = Math.round((e.pageX*Common.Utils.zoom() - me.cmpEl.offset().left - me._dragstart) / me.width * 100),
|
||||||
|
need_sort = position < minValue || position > maxValue,
|
||||||
|
pos = Math.max(0, Math.min(100, position)),
|
||||||
value = pos/me.delta + me.minValue;
|
value = pos/me.delta + me.minValue;
|
||||||
|
|
||||||
me.setThumbPosition(index, pos);
|
me.setThumbPosition(index, pos);
|
||||||
me.thumbs[index].value = value;
|
me.thumbs[index].value = value;
|
||||||
|
|
||||||
|
if (need_sort)
|
||||||
|
me.sortThumbs();
|
||||||
|
|
||||||
$(document).off('mouseup', onMouseUp);
|
$(document).off('mouseup', onMouseUp);
|
||||||
$(document).off('mousemove', onMouseMove);
|
$(document).off('mousemove', onMouseMove);
|
||||||
|
|
||||||
|
@ -362,16 +367,21 @@ define([
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
|
|
||||||
var index = e.data,
|
var index = e.data.index,
|
||||||
lastValue = me.thumbs[index].value,
|
lastValue = me.thumbs[index].value,
|
||||||
minValue = (index-1<0) ? 0 : me.thumbs[index-1].position,
|
minValue = (index-1<0) ? 0 : me.thumbs[index-1].position,
|
||||||
maxValue = (index+1<me.thumbs.length) ? me.thumbs[index+1].position : 100,
|
maxValue = (index+1<me.thumbs.length) ? me.thumbs[index+1].position : 100,
|
||||||
pos = Math.max(minValue, Math.min(maxValue, (Math.round((e.pageX*Common.Utils.zoom() - me.cmpEl.offset().left - me._dragstart) / me.width * 100)))),
|
position = Math.round((e.pageX*Common.Utils.zoom() - me.cmpEl.offset().left - me._dragstart) / me.width * 100),
|
||||||
|
need_sort = position < minValue || position > maxValue,
|
||||||
|
pos = Math.max(0, Math.min(100, position)),
|
||||||
value = pos/me.delta + me.minValue;
|
value = pos/me.delta + me.minValue;
|
||||||
|
|
||||||
me.setThumbPosition(index, pos);
|
me.setThumbPosition(index, pos);
|
||||||
me.thumbs[index].value = value;
|
me.thumbs[index].value = value;
|
||||||
|
|
||||||
|
if (need_sort)
|
||||||
|
me.sortThumbs();
|
||||||
|
|
||||||
if (Math.abs(value-lastValue)>0.001)
|
if (Math.abs(value-lastValue)>0.001)
|
||||||
me.trigger('change', me, value, lastValue);
|
me.trigger('change', me, value, lastValue);
|
||||||
};
|
};
|
||||||
|
@ -379,7 +389,7 @@ define([
|
||||||
var onMouseDown = function (e) {
|
var onMouseDown = function (e) {
|
||||||
if ( me.disabled ) return;
|
if ( me.disabled ) return;
|
||||||
|
|
||||||
var index = e.data,
|
var index = e.data.index,
|
||||||
thumb = me.thumbs[index].thumb;
|
thumb = me.thumbs[index].thumb;
|
||||||
|
|
||||||
me._dragstart = e.pageX*Common.Utils.zoom() - thumb.offset().left - thumb.width()/2;
|
me._dragstart = e.pageX*Common.Utils.zoom() - thumb.offset().left - thumb.width()/2;
|
||||||
|
@ -389,8 +399,8 @@ define([
|
||||||
(index == idx) ? item.thumb.css('z-index', 500) : item.thumb.css('z-index', '');
|
(index == idx) ? item.thumb.css('z-index', 500) : item.thumb.css('z-index', '');
|
||||||
});
|
});
|
||||||
|
|
||||||
$(document).on('mouseup', null, index, onMouseUp);
|
$(document).on('mouseup', null, e.data, onMouseUp);
|
||||||
$(document).on('mousemove', null, index, onMouseMove);
|
$(document).on('mousemove', null, e.data, onMouseMove);
|
||||||
};
|
};
|
||||||
|
|
||||||
var onTrackMouseDown = function (e) {
|
var onTrackMouseDown = function (e) {
|
||||||
|
@ -441,7 +451,7 @@ define([
|
||||||
index: index
|
index: index
|
||||||
});
|
});
|
||||||
me.setValue(index, me.options.values[index]);
|
me.setValue(index, me.options.values[index]);
|
||||||
thumb.on('mousedown', null, index, onMouseDown);
|
thumb.on('mousedown', null, me.thumbs[index], onMouseDown);
|
||||||
});
|
});
|
||||||
me.setActiveThumb(0, true);
|
me.setActiveThumb(0, true);
|
||||||
|
|
||||||
|
@ -489,6 +499,18 @@ define([
|
||||||
if (disabled !== this.disabled)
|
if (disabled !== this.disabled)
|
||||||
this.cmpEl.toggleClass('disabled', disabled);
|
this.cmpEl.toggleClass('disabled', disabled);
|
||||||
this.disabled = disabled;
|
this.disabled = disabled;
|
||||||
|
},
|
||||||
|
|
||||||
|
sortThumbs: function() {
|
||||||
|
this.thumbs.sort(function(a, b) {
|
||||||
|
return (a.position - b.position);
|
||||||
|
});
|
||||||
|
var recalc_indexes = [];
|
||||||
|
_.each (this.thumbs, function(thumb, index) {
|
||||||
|
recalc_indexes.push(thumb.index);
|
||||||
|
thumb.index = index;
|
||||||
|
});
|
||||||
|
return recalc_indexes;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -1341,6 +1341,18 @@ define([
|
||||||
this.sldrGradient.on('thumbdblclick', function(cmp){
|
this.sldrGradient.on('thumbdblclick', function(cmp){
|
||||||
me.btnGradColor.cmpEl.find('button').dropdown('toggle');
|
me.btnGradColor.cmpEl.find('button').dropdown('toggle');
|
||||||
});
|
});
|
||||||
|
this.sldrGradient.on('sortthumbs', function(cmp, recalc_indexes){
|
||||||
|
var colors = [],
|
||||||
|
currentIdx;
|
||||||
|
_.each (recalc_indexes, function(recalc_index, index) {
|
||||||
|
colors.push(me.GradColor.colors[recalc_index]);
|
||||||
|
if (me.GradColor.currentIdx == recalc_index)
|
||||||
|
currentIdx = index;
|
||||||
|
});
|
||||||
|
me.OriginalFillType = null;
|
||||||
|
me.GradColor.colors = colors;
|
||||||
|
me.GradColor.currentIdx = currentIdx;
|
||||||
|
});
|
||||||
this.fillControls.push(this.sldrGradient);
|
this.fillControls.push(this.sldrGradient);
|
||||||
|
|
||||||
this.cmbBorderSize = new Common.UI.ComboBorderSizeEditable({
|
this.cmbBorderSize = new Common.UI.ComboBorderSizeEditable({
|
||||||
|
|
|
@ -916,6 +916,18 @@ define([
|
||||||
this.sldrGradient.on('thumbdblclick', function(cmp){
|
this.sldrGradient.on('thumbdblclick', function(cmp){
|
||||||
me.btnGradColor.cmpEl.find('button').dropdown('toggle');
|
me.btnGradColor.cmpEl.find('button').dropdown('toggle');
|
||||||
});
|
});
|
||||||
|
this.sldrGradient.on('sortthumbs', function(cmp, recalc_indexes){
|
||||||
|
var colors = [],
|
||||||
|
currentIdx;
|
||||||
|
_.each (recalc_indexes, function(recalc_index, index) {
|
||||||
|
colors.push(me.GradColor.colors[recalc_index]);
|
||||||
|
if (me.GradColor.currentIdx == recalc_index)
|
||||||
|
currentIdx = index;
|
||||||
|
});
|
||||||
|
me.OriginalFillType = null;
|
||||||
|
me.GradColor.colors = colors;
|
||||||
|
me.GradColor.currentIdx = currentIdx;
|
||||||
|
});
|
||||||
this.lockedControls.push(this.sldrGradient);
|
this.lockedControls.push(this.sldrGradient);
|
||||||
|
|
||||||
this.cmbBorderSize = new Common.UI.ComboBorderSizeEditable({
|
this.cmbBorderSize = new Common.UI.ComboBorderSizeEditable({
|
||||||
|
|
Loading…
Reference in a new issue