Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
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 | "use strict"; |
michael@0 | 6 | |
michael@0 | 7 | const { Cc, Ci, Cu } = require("chrome"); |
michael@0 | 8 | |
michael@0 | 9 | const BRAND_SHORT_NAME = Cc["@mozilla.org/intl/stringbundle;1"]. |
michael@0 | 10 | getService(Ci.nsIStringBundleService). |
michael@0 | 11 | createBundle("chrome://branding/locale/brand.properties"). |
michael@0 | 12 | GetStringFromName("brandShortName"); |
michael@0 | 13 | |
michael@0 | 14 | const gcli = require("gcli/index"); |
michael@0 | 15 | |
michael@0 | 16 | exports.items = [ |
michael@0 | 17 | { |
michael@0 | 18 | name: 'resize', |
michael@0 | 19 | description: gcli.lookup('resizeModeDesc') |
michael@0 | 20 | }, |
michael@0 | 21 | { |
michael@0 | 22 | name: 'resize on', |
michael@0 | 23 | description: gcli.lookup('resizeModeOnDesc'), |
michael@0 | 24 | manual: gcli.lookupFormat('resizeModeManual2', [BRAND_SHORT_NAME]), |
michael@0 | 25 | exec: gcli_cmd_resize |
michael@0 | 26 | }, |
michael@0 | 27 | { |
michael@0 | 28 | name: 'resize off', |
michael@0 | 29 | description: gcli.lookup('resizeModeOffDesc'), |
michael@0 | 30 | manual: gcli.lookupFormat('resizeModeManual2', [BRAND_SHORT_NAME]), |
michael@0 | 31 | exec: gcli_cmd_resize |
michael@0 | 32 | }, |
michael@0 | 33 | { |
michael@0 | 34 | name: 'resize toggle', |
michael@0 | 35 | buttonId: "command-button-responsive", |
michael@0 | 36 | buttonClass: "command-button command-button-invertable", |
michael@0 | 37 | tooltipText: gcli.lookup("resizeModeToggleTooltip"), |
michael@0 | 38 | description: gcli.lookup('resizeModeToggleDesc'), |
michael@0 | 39 | manual: gcli.lookupFormat('resizeModeManual2', [BRAND_SHORT_NAME]), |
michael@0 | 40 | state: { |
michael@0 | 41 | isChecked: function(aTarget) { |
michael@0 | 42 | let browserWindow = aTarget.tab.ownerDocument.defaultView; |
michael@0 | 43 | let mgr = browserWindow.ResponsiveUI.ResponsiveUIManager; |
michael@0 | 44 | return mgr.isActiveForTab(aTarget.tab); |
michael@0 | 45 | }, |
michael@0 | 46 | onChange: function(aTarget, aChangeHandler) { |
michael@0 | 47 | let browserWindow = aTarget.tab.ownerDocument.defaultView; |
michael@0 | 48 | let mgr = browserWindow.ResponsiveUI.ResponsiveUIManager; |
michael@0 | 49 | mgr.on("on", aChangeHandler); |
michael@0 | 50 | mgr.on("off", aChangeHandler); |
michael@0 | 51 | }, |
michael@0 | 52 | offChange: function(aTarget, aChangeHandler) { |
michael@0 | 53 | if (aTarget.tab) { |
michael@0 | 54 | let browserWindow = aTarget.tab.ownerDocument.defaultView; |
michael@0 | 55 | let mgr = browserWindow.ResponsiveUI.ResponsiveUIManager; |
michael@0 | 56 | mgr.off("on", aChangeHandler); |
michael@0 | 57 | mgr.off("off", aChangeHandler); |
michael@0 | 58 | } |
michael@0 | 59 | }, |
michael@0 | 60 | }, |
michael@0 | 61 | exec: gcli_cmd_resize |
michael@0 | 62 | }, |
michael@0 | 63 | { |
michael@0 | 64 | name: 'resize to', |
michael@0 | 65 | description: gcli.lookup('resizeModeToDesc'), |
michael@0 | 66 | params: [ |
michael@0 | 67 | { |
michael@0 | 68 | name: 'width', |
michael@0 | 69 | type: 'number', |
michael@0 | 70 | description: gcli.lookup("resizePageArgWidthDesc"), |
michael@0 | 71 | }, |
michael@0 | 72 | { |
michael@0 | 73 | name: 'height', |
michael@0 | 74 | type: 'number', |
michael@0 | 75 | description: gcli.lookup("resizePageArgHeightDesc"), |
michael@0 | 76 | }, |
michael@0 | 77 | ], |
michael@0 | 78 | exec: gcli_cmd_resize |
michael@0 | 79 | } |
michael@0 | 80 | ]; |
michael@0 | 81 | |
michael@0 | 82 | function gcli_cmd_resize(args, context) { |
michael@0 | 83 | let browserWindow = context.environment.chromeWindow; |
michael@0 | 84 | let mgr = browserWindow.ResponsiveUI.ResponsiveUIManager; |
michael@0 | 85 | mgr.handleGcliCommand(browserWindow, |
michael@0 | 86 | browserWindow.gBrowser.selectedTab, |
michael@0 | 87 | this.name, |
michael@0 | 88 | args); |
michael@0 | 89 | } |