зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1024932 - Removes unneeded originalValue handling in swatch-based tooltips; r=miker
This commit is contained in:
Родитель
dc11e1c5e2
Коммит
5aa17d3e78
|
@ -835,23 +835,15 @@ SwatchBasedEditorTooltip.prototype = {
|
||||||
* - onPreview: will be called when one of the sub-classes calls preview
|
* - onPreview: will be called when one of the sub-classes calls preview
|
||||||
* - onRevert: will be called when the user ESCapes out of the tooltip
|
* - onRevert: will be called when the user ESCapes out of the tooltip
|
||||||
* - onCommit: will be called when the user presses ENTER or clicks
|
* - onCommit: will be called when the user presses ENTER or clicks
|
||||||
* outside the tooltip. If the user-defined onCommit returns a value,
|
* outside the tooltip.
|
||||||
* it will be used to replace originalValue, so that the swatch-based
|
|
||||||
* tooltip always knows what is the current originalValue and can use
|
|
||||||
* it when reverting
|
|
||||||
* @param {object} originalValue
|
|
||||||
* The original value before the editor in the tooltip makes changes
|
|
||||||
* This can be of any type, and will be passed, as is, in the revert
|
|
||||||
* callback
|
|
||||||
*/
|
*/
|
||||||
addSwatch: function(swatchEl, callbacks={}, originalValue) {
|
addSwatch: function(swatchEl, callbacks={}) {
|
||||||
if (!callbacks.onPreview) callbacks.onPreview = function() {};
|
if (!callbacks.onPreview) callbacks.onPreview = function() {};
|
||||||
if (!callbacks.onRevert) callbacks.onRevert = function() {};
|
if (!callbacks.onRevert) callbacks.onRevert = function() {};
|
||||||
if (!callbacks.onCommit) callbacks.onCommit = function() {};
|
if (!callbacks.onCommit) callbacks.onCommit = function() {};
|
||||||
|
|
||||||
this.swatches.set(swatchEl, {
|
this.swatches.set(swatchEl, {
|
||||||
callbacks: callbacks,
|
callbacks: callbacks
|
||||||
originalValue: originalValue
|
|
||||||
});
|
});
|
||||||
swatchEl.addEventListener("click", this._onSwatchClick, false);
|
swatchEl.addEventListener("click", this._onSwatchClick, false);
|
||||||
},
|
},
|
||||||
|
@ -892,7 +884,7 @@ SwatchBasedEditorTooltip.prototype = {
|
||||||
revert: function() {
|
revert: function() {
|
||||||
if (this.activeSwatch) {
|
if (this.activeSwatch) {
|
||||||
let swatch = this.swatches.get(this.activeSwatch);
|
let swatch = this.swatches.get(this.activeSwatch);
|
||||||
swatch.callbacks.onRevert(swatch.originalValue);
|
swatch.callbacks.onRevert();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -902,10 +894,7 @@ SwatchBasedEditorTooltip.prototype = {
|
||||||
commit: function() {
|
commit: function() {
|
||||||
if (this.activeSwatch) {
|
if (this.activeSwatch) {
|
||||||
let swatch = this.swatches.get(this.activeSwatch);
|
let swatch = this.swatches.get(this.activeSwatch);
|
||||||
let newValue = swatch.callbacks.onCommit();
|
swatch.callbacks.onCommit();
|
||||||
if (typeof newValue !== "undefined") {
|
|
||||||
swatch.originalValue = newValue;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче