OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 var ItemsList = appsDevtool.ItemsList; | 5 var ItemsList = appsDevtool.ItemsList; |
6 | 6 |
7 // The list of all apps & extensions. | 7 // The list of all apps & extensions. |
8 var completeList = []; | 8 var completeList = []; |
9 | 9 |
10 // The list of all apps. | 10 // The list of all apps. |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 AppsDevTool.prototype = { | 110 AppsDevTool.prototype = { |
111 __proto__: HTMLDivElement.prototype, | 111 __proto__: HTMLDivElement.prototype, |
112 | 112 |
113 /** | 113 /** |
114 * Perform initial setup. | 114 * Perform initial setup. |
115 */ | 115 */ |
116 initialize: function() { | 116 initialize: function() { |
117 // Set up the three buttons (load unpacked, pack and update). | 117 // Set up the three buttons (load unpacked, pack and update). |
118 $('load-unpacked').addEventListener('click', | 118 $('load-unpacked').addEventListener('click', |
119 this.handleLoadUnpackedItem_.bind(this)); | 119 this.handleLoadUnpackedItem_.bind(this)); |
| 120 $('pack-item').addEventListener('click', |
| 121 this.handlePackItem_.bind(this)); |
120 $('update-items-now').addEventListener('click', | 122 $('update-items-now').addEventListener('click', |
121 this.handleUpdateItemNow_.bind(this)); | 123 this.handleUpdateItemNow_.bind(this)); |
122 | 124 |
| 125 var packItemOverlay = appsDevtool.PackItemOverlay.getInstance(); |
| 126 packItemOverlay.initializePage(); |
| 127 |
123 }, | 128 }, |
124 | 129 |
125 /** | 130 /** Handles the Load Unpacked Extension button. |
126 * Handles the Load Unpacked Extension button. | 131 * @param {Event} e Change event. |
127 * @param {!Event} e Change event. | |
128 * @private | 132 * @private |
129 */ | 133 */ |
130 handleLoadUnpackedItem_: function(e) { | 134 handleLoadUnpackedItem_: function(e) { |
131 chrome.developerPrivate.loadUnpacked(function(success) { | 135 chrome.developerPrivate.loadUnpacked(function(success) { |
132 loadItemsInfo(); | 136 loadItemsInfo(); |
133 }); | 137 }); |
134 }, | 138 }, |
135 | 139 |
| 140 /** Handles the Pack Extension button. |
| 141 * @param {Event} e Change event. |
| 142 * @private |
| 143 */ |
| 144 handlePackItem_: function(e) { |
| 145 AppsDevTool.showOverlay($('packItemOverlay')); |
| 146 }, |
| 147 |
136 /** | 148 /** |
137 * Handles the Update Extension Now Button. | 149 * Handles the Update Extension Now Button. |
138 * @param {Event} e Change event. | 150 * @param {Event} e Change event. |
139 * @private | 151 * @private |
140 */ | 152 */ |
141 handleUpdateItemNow_: function(e) { | 153 handleUpdateItemNow_: function(e) { |
142 chrome.developerPrivate.autoUpdate(function(response) {}); | 154 chrome.developerPrivate.autoUpdate(function(response) {}); |
143 }, | 155 }, |
144 }; | 156 }; |
145 | 157 |
146 /** | 158 /** |
147 * Returns the current overlay or null if one does not exist. | 159 * Returns the current overlay or null if one does not exist. |
148 * @return {Element} The overlay element. | 160 * @return {Element} The overlay element. |
149 */ | 161 */ |
150 AppsDevTool.getCurrentOverlay = function() { | 162 AppsDevTool.getCurrentOverlay = function() { |
151 return this.ownerDocument.querySelector('#overlay .page.showing'); | 163 return document.querySelector('#overlay .page.showing'); |
152 }; | 164 }; |
153 | 165 |
154 /** | 166 /** |
155 * Shows |node|. If there's another overlay showing, hide it. | 167 * Sets the given overlay to show. This hides whatever overlay is currently |
| 168 * showing, if any. |
156 * @param {HTMLElement} node The overlay page to show. If falsey, all overlays | 169 * @param {HTMLElement} node The overlay page to show. If falsey, all overlays |
157 * are hidden. | 170 * are hidden. |
158 */ | 171 */ |
159 AppsDevTool.showOverlay = function(node) { | 172 AppsDevTool.showOverlay = function(node) { |
160 var currentlyShowingOverlay = AppsDevTool.getCurrentOverlay(); | 173 var currentlyShowingOverlay = AppsDevTool.getCurrentOverlay(); |
161 if (currentlyShowingOverlay) | 174 if (currentlyShowingOverlay) |
162 currentlyShowingOverlay.classList.remove('showing'); | 175 currentlyShowingOverlay.classList.remove('showing'); |
163 if (node) | 176 if (node) |
164 node.classList.add('showing'); | 177 node.classList.add('showing'); |
165 overlay.hidden = !node; | 178 overlay.hidden = !node; |
166 uber.invokeMethodOnParent(node ? 'beginInterceptingEvents' : | 179 uber.invokeMethodOnParent(node ? 'beginInterceptingEvents' : |
167 'stopInterceptingEvents'); | 180 'stopInterceptingEvents'); |
168 }; | 181 }; |
OLD | NEW |