Wed, 31 Dec 2014 06:09:35 +0100
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 gcli = require("gcli/index"); |
michael@0 | 6 | const EventEmitter = require("devtools/toolkit/event-emitter"); |
michael@0 | 7 | const eventEmitter = new EventEmitter(); |
michael@0 | 8 | |
michael@0 | 9 | let { Eyedropper, EyedropperManager } = require("devtools/eyedropper/eyedropper"); |
michael@0 | 10 | |
michael@0 | 11 | /** |
michael@0 | 12 | * 'eyedropper' command |
michael@0 | 13 | */ |
michael@0 | 14 | exports.items = [{ |
michael@0 | 15 | name: "eyedropper", |
michael@0 | 16 | description: gcli.lookup("eyedropperDesc"), |
michael@0 | 17 | manual: gcli.lookup("eyedropperManual"), |
michael@0 | 18 | buttonId: "command-button-eyedropper", |
michael@0 | 19 | buttonClass: "command-button command-button-invertable", |
michael@0 | 20 | tooltipText: gcli.lookup("eyedropperTooltip"), |
michael@0 | 21 | state: { |
michael@0 | 22 | isChecked: function(target) { |
michael@0 | 23 | let chromeWindow = target.tab.ownerDocument.defaultView; |
michael@0 | 24 | let dropper = EyedropperManager.getInstance(chromeWindow); |
michael@0 | 25 | if (dropper) { |
michael@0 | 26 | return true; |
michael@0 | 27 | } |
michael@0 | 28 | return false; |
michael@0 | 29 | }, |
michael@0 | 30 | onChange: function(target, changeHandler) { |
michael@0 | 31 | eventEmitter.on("changed", changeHandler); |
michael@0 | 32 | }, |
michael@0 | 33 | offChange: function(target, changeHandler) { |
michael@0 | 34 | eventEmitter.off("changed", changeHandler); |
michael@0 | 35 | }, |
michael@0 | 36 | }, |
michael@0 | 37 | exec: function(args, context) { |
michael@0 | 38 | let chromeWindow = context.environment.chromeWindow; |
michael@0 | 39 | let target = context.environment.target; |
michael@0 | 40 | |
michael@0 | 41 | let dropper = EyedropperManager.createInstance(chromeWindow); |
michael@0 | 42 | dropper.open(); |
michael@0 | 43 | |
michael@0 | 44 | eventEmitter.emit("changed", target.tab); |
michael@0 | 45 | |
michael@0 | 46 | dropper.once("destroy", () => { |
michael@0 | 47 | eventEmitter.emit("changed", target.tab); |
michael@0 | 48 | }); |
michael@0 | 49 | } |
michael@0 | 50 | }]; |