michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: const Ci = Components.interfaces; michael@0: const Cu = Components.utils; michael@0: const Cc = Components.classes; michael@0: michael@0: Cu.import("resource://gre/modules/XPCOMUtils.jsm"); michael@0: Cu.import("resource://gre/modules/Services.jsm"); michael@0: Cu.import("resource://gre/modules/Prompt.jsm"); michael@0: michael@0: function ColorPicker() { michael@0: } michael@0: michael@0: ColorPicker.prototype = { michael@0: _initial: 0, michael@0: _domWin: null, michael@0: _title: "", michael@0: michael@0: get strings() { michael@0: delete this.strings; michael@0: return this.strings = Services.strings.createBundle("chrome://browser/locale/browser.properties"); michael@0: }, michael@0: michael@0: init: function(aParent, aTitle, aInitial) { michael@0: this._domWin = aParent; michael@0: this._initial = aInitial; michael@0: this._title = aTitle; michael@0: }, michael@0: michael@0: open: function(aCallback) { michael@0: let p = new Prompt({ title: this._title, michael@0: buttons: [ michael@0: this.strings.GetStringFromName("inputWidgetHelper.set"), michael@0: this.strings.GetStringFromName("inputWidgetHelper.cancel") michael@0: ] }) michael@0: .addColorPicker({ value: this._initial }) michael@0: .show((data) => { michael@0: if (data.button == 0) michael@0: aCallback.done(data.color0); michael@0: else michael@0: aCallback.done(this._initial); michael@0: }); michael@0: }, michael@0: michael@0: classID: Components.ID("{430b987f-bb9f-46a3-99a5-241749220b29}"), michael@0: QueryInterface: XPCOMUtils.generateQI([Ci.nsIColorPicker]) michael@0: }; michael@0: michael@0: this.NSGetFactory = XPCOMUtils.generateNSGetFactory([ColorPicker]);