Backed out changeset 00681f1336d5 (bug 1024932) for failures in test_bug455906.js

This commit is contained in:
Ed Morley 2014-06-23 16:31:38 +01:00
Родитель 369999f127
Коммит cedcb46dc6
1 изменённых файлов: 16 добавлений и 5 удалений

Просмотреть файл

@ -835,15 +835,23 @@ SwatchBasedEditorTooltip.prototype = {
* - onPreview: will be called when one of the sub-classes calls preview
* - onRevert: will be called when the user ESCapes out of the tooltip
* - onCommit: will be called when the user presses ENTER or clicks
* outside the tooltip.
* outside the tooltip. If the user-defined onCommit returns a value,
* 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={}) {
addSwatch: function(swatchEl, callbacks={}, originalValue) {
if (!callbacks.onPreview) callbacks.onPreview = function() {};
if (!callbacks.onRevert) callbacks.onRevert = function() {};
if (!callbacks.onCommit) callbacks.onCommit = function() {};
this.swatches.set(swatchEl, {
callbacks: callbacks
callbacks: callbacks,
originalValue: originalValue
});
swatchEl.addEventListener("click", this._onSwatchClick, false);
},
@ -884,7 +892,7 @@ SwatchBasedEditorTooltip.prototype = {
revert: function() {
if (this.activeSwatch) {
let swatch = this.swatches.get(this.activeSwatch);
swatch.callbacks.onRevert();
swatch.callbacks.onRevert(swatch.originalValue);
}
},
@ -894,7 +902,10 @@ SwatchBasedEditorTooltip.prototype = {
commit: function() {
if (this.activeSwatch) {
let swatch = this.swatches.get(this.activeSwatch);
swatch.callbacks.onCommit();
let newValue = swatch.callbacks.onCommit();
if (typeof newValue !== "undefined") {
swatch.originalValue = newValue;
}
}
},