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.
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 "use strict";
7 const gcli = require("gcli/index");
9 // Fetch TiltManager using the current loader, but don't save a
10 // reference to it, because it might change with a tool reload.
11 // We can clean this up once the command line is loadered.
12 Object.defineProperty(this, "TiltManager", {
13 get: function() {
14 return require("devtools/tilt/tilt").TiltManager;
15 },
16 enumerable: true
17 });
19 exports.items = [
20 {
21 name: 'tilt',
22 description: gcli.lookup("tiltDesc"),
23 manual: gcli.lookup("tiltManual")
24 },
25 {
26 name: 'tilt open',
27 description: gcli.lookup("tiltOpenDesc"),
28 manual: gcli.lookup("tiltOpenManual"),
29 exec: function(args, context) {
30 let chromeWindow = context.environment.chromeDocument.defaultView;
31 let Tilt = TiltManager.getTiltForBrowser(chromeWindow);
32 if (!Tilt.currentInstance) {
33 Tilt.toggle();
34 }
35 }
36 },
37 {
38 name: "tilt toggle",
39 buttonId: "command-button-tilt",
40 buttonClass: "command-button command-button-invertable",
41 tooltipText: gcli.lookup("tiltToggleTooltip"),
42 hidden: true,
43 state: {
44 isChecked: function(aTarget) {
45 let browserWindow = aTarget.tab.ownerDocument.defaultView;
46 return !!TiltManager.getTiltForBrowser(browserWindow).currentInstance;
47 },
48 onChange: function(aTarget, aChangeHandler) {
49 let browserWindow = aTarget.tab.ownerDocument.defaultView;
50 let tilt = TiltManager.getTiltForBrowser(browserWindow);
51 tilt.on("change", aChangeHandler);
52 },
53 offChange: function(aTarget, aChangeHandler) {
54 if (aTarget.tab) {
55 let browserWindow = aTarget.tab.ownerDocument.defaultView;
56 let tilt = TiltManager.getTiltForBrowser(browserWindow);
57 tilt.off("change", aChangeHandler);
58 }
59 },
60 },
61 exec: function(args, context) {
62 let chromeWindow = context.environment.chromeDocument.defaultView;
63 let Tilt = TiltManager.getTiltForBrowser(chromeWindow);
64 Tilt.toggle();
65 }
66 },
67 {
68 name: 'tilt translate',
69 description: gcli.lookup("tiltTranslateDesc"),
70 manual: gcli.lookup("tiltTranslateManual"),
71 params: [
72 {
73 name: "x",
74 type: "number",
75 defaultValue: 0,
76 description: gcli.lookup("tiltTranslateXDesc"),
77 manual: gcli.lookup("tiltTranslateXManual")
78 },
79 {
80 name: "y",
81 type: "number",
82 defaultValue: 0,
83 description: gcli.lookup("tiltTranslateYDesc"),
84 manual: gcli.lookup("tiltTranslateYManual")
85 }
86 ],
87 exec: function(args, context) {
88 let chromeWindow = context.environment.chromeDocument.defaultView;
89 let Tilt = TiltManager.getTiltForBrowser(chromeWindow);
90 if (Tilt.currentInstance) {
91 Tilt.currentInstance.controller.arcball.translate([args.x, args.y]);
92 }
93 }
94 },
95 {
96 name: 'tilt rotate',
97 description: gcli.lookup("tiltRotateDesc"),
98 manual: gcli.lookup("tiltRotateManual"),
99 params: [
100 {
101 name: "x",
102 type: { name: 'number', min: -360, max: 360, step: 10 },
103 defaultValue: 0,
104 description: gcli.lookup("tiltRotateXDesc"),
105 manual: gcli.lookup("tiltRotateXManual")
106 },
107 {
108 name: "y",
109 type: { name: 'number', min: -360, max: 360, step: 10 },
110 defaultValue: 0,
111 description: gcli.lookup("tiltRotateYDesc"),
112 manual: gcli.lookup("tiltRotateYManual")
113 },
114 {
115 name: "z",
116 type: { name: 'number', min: -360, max: 360, step: 10 },
117 defaultValue: 0,
118 description: gcli.lookup("tiltRotateZDesc"),
119 manual: gcli.lookup("tiltRotateZManual")
120 }
121 ],
122 exec: function(args, context) {
123 let chromeWindow = context.environment.chromeDocument.defaultView;
124 let Tilt = TiltManager.getTiltForBrowser(chromeWindow);
125 if (Tilt.currentInstance) {
126 Tilt.currentInstance.controller.arcball.rotate([args.x, args.y, args.z]);
127 }
128 }
129 },
130 {
131 name: 'tilt zoom',
132 description: gcli.lookup("tiltZoomDesc"),
133 manual: gcli.lookup("tiltZoomManual"),
134 params: [
135 {
136 name: "zoom",
137 type: { name: 'number' },
138 description: gcli.lookup("tiltZoomAmountDesc"),
139 manual: gcli.lookup("tiltZoomAmountManual")
140 }
141 ],
142 exec: function(args, context) {
143 let chromeWindow = context.environment.chromeDocument.defaultView;
144 let Tilt = TiltManager.getTiltForBrowser(chromeWindow);
146 if (Tilt.currentInstance) {
147 Tilt.currentInstance.controller.arcball.zoom(-args.zoom);
148 }
149 }
150 },
151 {
152 name: 'tilt reset',
153 description: gcli.lookup("tiltResetDesc"),
154 manual: gcli.lookup("tiltResetManual"),
155 exec: function(args, context) {
156 let chromeWindow = context.environment.chromeDocument.defaultView;
157 let Tilt = TiltManager.getTiltForBrowser(chromeWindow);
159 if (Tilt.currentInstance) {
160 Tilt.currentInstance.controller.arcball.reset();
161 }
162 }
163 },
164 {
165 name: 'tilt close',
166 description: gcli.lookup("tiltCloseDesc"),
167 manual: gcli.lookup("tiltCloseManual"),
168 exec: function(args, context) {
169 let chromeWindow = context.environment.chromeDocument.defaultView;
170 let Tilt = TiltManager.getTiltForBrowser(chromeWindow);
172 Tilt.destroy(Tilt.currentWindowId);
173 }
174 }
175 ];