| 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 cr.define('apps_dev_tool', function() { | 5 cr.define('apps_dev_tool', function() { |
| 6 'use strict'; | 6 'use strict'; |
| 7 | 7 |
| 8 /** | 8 /** |
| 9 * AppsDevTool constructor. | 9 * AppsDevTool constructor. |
| 10 * @constructor | 10 * @constructor |
| 11 * @extends {HTMLDivElement} | 11 * @extends {HTMLDivElement} |
| 12 */ | 12 */ |
| 13 function AppsDevTool() {} | 13 function AppsDevTool() {} |
| 14 | 14 |
| 15 AppsDevTool.prototype = { | 15 AppsDevTool.prototype = { |
| 16 __proto__: HTMLDivElement.prototype, | 16 __proto__: HTMLDivElement.prototype, |
| 17 | 17 |
| 18 /** | 18 /** |
| 19 * Perform initial setup. | 19 * Perform initial setup. |
| 20 */ | 20 */ |
| 21 initialize: function() { | 21 initialize: function() { |
| 22 // Set up the three buttons (load unpacked, pack and update). | 22 // Set up the three buttons (load unpacked, pack and update). |
| 23 $('load-unpacked').addEventListener('click', | 23 $('load-unpacked').addEventListener('click', |
| 24 this.handleLoadUnpackedItem_.bind(this)); | 24 this.handleLoadUnpackedItem_.bind(this)); |
| 25 $('pack-item').addEventListener('click', |
| 26 this.handlePackItem_.bind(this)); |
| 25 $('update-items-now').addEventListener('click', | 27 $('update-items-now').addEventListener('click', |
| 26 this.handleUpdateItemNow_.bind(this)); | 28 this.handleUpdateItemNow_.bind(this)); |
| 29 var packItemOverlay = |
| 30 apps_dev_tool.PackItemOverlay.getInstance().initializePage(); |
| 27 }, | 31 }, |
| 28 | 32 |
| 29 /** | 33 /** |
| 30 * Handles the Load Unpacked Extension button. | 34 * Handles the Load Unpacked Extension button. |
| 31 * @param {!Event} e Click event. | 35 * @param {!Event} e Click event. |
| 32 * @private | 36 * @private |
| 33 */ | 37 */ |
| 34 handleLoadUnpackedItem_: function(e) { | 38 handleLoadUnpackedItem_: function(e) { |
| 35 chrome.developerPrivate.loadUnpacked(function(success) { | 39 chrome.developerPrivate.loadUnpacked(function(success) { |
| 36 apps_dev_tool.ItemsList.loadItemsInfo(); | 40 apps_dev_tool.ItemsList.loadItemsInfo(); |
| 37 }); | 41 }); |
| 38 }, | 42 }, |
| 39 | 43 |
| 44 /** Handles the Pack Extension button. |
| 45 * @param {Event} e Change event. |
| 46 * @private |
| 47 */ |
| 48 handlePackItem_: function(e) { |
| 49 AppsDevTool.showOverlay($('packItemOverlay')); |
| 50 }, |
| 51 |
| 40 /** | 52 /** |
| 41 * Handles the Update Extension Now Button. | 53 * Handles the Update Extension Now Button. |
| 42 * @param {!Event} e Click event. | 54 * @param {!Event} e Click event. |
| 43 * @private | 55 * @private |
| 44 */ | 56 */ |
| 45 handleUpdateItemNow_: function(e) { | 57 handleUpdateItemNow_: function(e) { |
| 46 chrome.developerPrivate.autoUpdate(function(response) {}); | 58 chrome.developerPrivate.autoUpdate(function(response) {}); |
| 47 }, | 59 }, |
| 48 }; | 60 }; |
| 49 | 61 |
| 50 /** | 62 /** |
| 51 * Returns the current overlay or null if one does not exist. | 63 * Returns the current overlay or null if one does not exist. |
| 52 * @return {Element} The overlay element. | 64 * @return {Element} The overlay element. |
| 53 */ | 65 */ |
| 54 AppsDevTool.getCurrentOverlay = function() { | 66 AppsDevTool.getCurrentOverlay = function() { |
| 55 return document.querySelector('#overlay .page.showing'); | 67 return document.querySelector('#overlay .page.showing'); |
| 56 }; | 68 }; |
| 57 | 69 |
| 58 /** | 70 /** |
| 59 * Shows |el|. If there's another overlay showing, hide it. | 71 * Shows |el|. If there's another overlay showing, hide it. |
| 60 * @param {HTMLElement} el The overlay page to show. If falsey, all overlays | 72 * @param {HTMLElement} el The overlay page to show. If falsey, all overlays |
| 61 * are hidden. | 73 * are hidden. |
| 62 */ | 74 */ |
| 63 AppsDevTool.showOverlay = function(el) { | 75 AppsDevTool.showOverlay = function(el) { |
| 64 var currentlyShowingOverlay = AppsDevTool.getCurrentOverlay(); | 76 var currentlyShowingOverlay = AppsDevTool.getCurrentOverlay(); |
| 65 if (currentlyShowingOverlay) | 77 if (currentlyShowingOverlay) |
| 66 currentlyShowingOverlay.classList.remove('showing'); | 78 currentlyShowingOverlay.classList.remove('showing'); |
| 67 | |
| 68 if (el) | 79 if (el) |
| 69 el.classList.add('showing'); | 80 el.classList.add('showing'); |
| 70 | |
| 71 overlay.hidden = !el; | 81 overlay.hidden = !el; |
| 72 uber.invokeMethodOnParent(el ? 'beginInterceptingEvents' : | 82 uber.invokeMethodOnParent(el ? 'beginInterceptingEvents' : |
| 73 'stopInterceptingEvents'); | 83 'stopInterceptingEvents'); |
| 74 }; | 84 }; |
| 75 | 85 |
| 76 /** | 86 /** |
| 77 * Loads translated strings. | 87 * Loads translated strings. |
| 78 */ | 88 */ |
| 79 AppsDevTool.initStrings = function() { | 89 AppsDevTool.initStrings = function() { |
| 80 chrome.developerPrivate.getStrings(function(strings) { | 90 chrome.developerPrivate.getStrings(function(strings) { |
| 81 loadTimeData.data = strings; | 91 loadTimeData.data = strings; |
| 82 i18nTemplate.process(document, loadTimeData); | 92 i18nTemplate.process(document, loadTimeData); |
| 83 }); | 93 }); |
| 84 }; | 94 }; |
| 85 | 95 |
| 86 return { | 96 return { |
| 87 AppsDevTool: AppsDevTool, | 97 AppsDevTool: AppsDevTool, |
| 88 }; | 98 }; |
| 89 }); | 99 }); |
| OLD | NEW |