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.

     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/. */
     5 const Ci = Components.interfaces;
     6 const Cu = Components.utils;
     7 const Cc = Components.classes;
     9 Cu.import("resource://gre/modules/XPCOMUtils.jsm");
    10 Cu.import("resource://gre/modules/Services.jsm");
    11 Cu.import("resource://gre/modules/Prompt.jsm");
    13 function ColorPicker() {
    14 }
    16 ColorPicker.prototype = {
    17   _initial: 0,
    18   _domWin: null,
    19   _title: "",
    21   get strings() {
    22     delete this.strings;
    23     return this.strings = Services.strings.createBundle("chrome://browser/locale/browser.properties");
    24   },
    26   init: function(aParent, aTitle, aInitial) {
    27     this._domWin = aParent;
    28     this._initial = aInitial;
    29     this._title = aTitle;
    30   },
    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   },
    47   classID: Components.ID("{430b987f-bb9f-46a3-99a5-241749220b29}"),
    48   QueryInterface: XPCOMUtils.generateQI([Ci.nsIColorPicker])
    49 };
    51 this.NSGetFactory = XPCOMUtils.generateNSGetFactory([ColorPicker]);

mercurial