mobile/android/components/ColorPicker.js

branch
TOR_BUG_9701
changeset 15
b8a032363ba2
equal deleted inserted replaced
-1:000000000000 0:864397cbbf34
1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4
5 const Ci = Components.interfaces;
6 const Cu = Components.utils;
7 const Cc = Components.classes;
8
9 Cu.import("resource://gre/modules/XPCOMUtils.jsm");
10 Cu.import("resource://gre/modules/Services.jsm");
11 Cu.import("resource://gre/modules/Prompt.jsm");
12
13 function ColorPicker() {
14 }
15
16 ColorPicker.prototype = {
17 _initial: 0,
18 _domWin: null,
19 _title: "",
20
21 get strings() {
22 delete this.strings;
23 return this.strings = Services.strings.createBundle("chrome://browser/locale/browser.properties");
24 },
25
26 init: function(aParent, aTitle, aInitial) {
27 this._domWin = aParent;
28 this._initial = aInitial;
29 this._title = aTitle;
30 },
31
32 open: function(aCallback) {
33 let p = new Prompt({ title: this._title,
34 buttons: [
35 this.strings.GetStringFromName("inputWidgetHelper.set"),
36 this.strings.GetStringFromName("inputWidgetHelper.cancel")
37 ] })
38 .addColorPicker({ value: this._initial })
39 .show((data) => {
40 if (data.button == 0)
41 aCallback.done(data.color0);
42 else
43 aCallback.done(this._initial);
44 });
45 },
46
47 classID: Components.ID("{430b987f-bb9f-46a3-99a5-241749220b29}"),
48 QueryInterface: XPCOMUtils.generateQI([Ci.nsIColorPicker])
49 };
50
51 this.NSGetFactory = XPCOMUtils.generateNSGetFactory([ColorPicker]);

mercurial