mobile/android/components/ColorPicker.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

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

mercurial