| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 MAX_APPS_PER_ROW = []; | 5 var MAX_APPS_PER_ROW = []; |
| 6 MAX_APPS_PER_ROW[LayoutMode.SMALL] = 4; | 6 MAX_APPS_PER_ROW[LayoutMode.SMALL] = 4; |
| 7 MAX_APPS_PER_ROW[LayoutMode.NORMAL] = 6; | 7 MAX_APPS_PER_ROW[LayoutMode.NORMAL] = 6; |
| 8 | 8 |
| 9 // The URL prefix used in the app link 'ping' attributes. | 9 // The URL prefix used in the app link 'ping' attributes. |
| 10 var PING_APP_LAUNCH_PREFIX = 'record-app-launch'; | 10 var PING_APP_LAUNCH_PREFIX = 'record-app-launch'; |
| 11 | 11 |
| 12 // The URL prefix used in the webstore link 'ping' attributes. | 12 // The URL prefix used in the webstore link 'ping' attributes. |
| 13 var PING_WEBSTORE_LAUNCH_PREFIX = 'record-webstore-launch'; | 13 var PING_WEBSTORE_LAUNCH_PREFIX = 'record-webstore-launch'; |
| 14 | 14 |
| 15 function getAppsCallback(data) { | 15 function getAppsCallback(data) { |
| 16 logEvent('received apps'); | 16 logEvent('received apps'); |
| 17 var appsSection = $('apps'); | 17 var appsSection = $('apps'); |
| 18 var appsSectionContent = $('apps-content'); | 18 var appsSectionContent = $('apps-content'); |
| 19 var appsMiniview = appsSection.getElementsByClassName('miniview')[0]; | 19 var appsMiniview = appsSection.getElementsByClassName('miniview')[0]; |
| 20 var appsPromo = $('apps-promo'); | 20 var appsPromo = $('apps-promo'); |
| 21 var appsPromoPing = PING_WEBSTORE_LAUNCH_PREFIX + '+' + data.showPromo; | 21 var appsPromoPing = PING_WEBSTORE_LAUNCH_PREFIX + '+' + data.showPromo; |
| 22 var webStoreEntry; | 22 var webStoreEntry; |
| 23 | 23 |
| 24 // Hide the app window menu option on platforms that do not support it. | |
| 25 $('apps-launch-type-window-menu-item').style.display = | |
| 26 (data.disableAppWindowLaunch ? 'none' : 'inline'); | |
| 27 | |
| 28 appsMiniview.textContent = ''; | 24 appsMiniview.textContent = ''; |
| 29 appsSectionContent.textContent = ''; | 25 appsSectionContent.textContent = ''; |
| 30 | 26 |
| 31 apps.showPromo = data.showPromo; | 27 apps.showPromo = data.showPromo; |
| 32 | 28 |
| 33 data.apps.sort(function(a,b) { | 29 data.apps.sort(function(a,b) { |
| 34 return a.app_launch_index - b.app_launch_index; | 30 return a.app_launch_index - b.app_launch_index; |
| 35 }); | 31 }); |
| 36 | 32 |
| 37 clearClosedMenu(apps.menu); | 33 clearClosedMenu(apps.menu); |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 147 function handleClick(e) { | 143 function handleClick(e) { |
| 148 var appId = e.currentTarget.getAttribute('app-id'); | 144 var appId = e.currentTarget.getAttribute('app-id'); |
| 149 launchApp(appId); | 145 launchApp(appId); |
| 150 return false; | 146 return false; |
| 151 } | 147 } |
| 152 | 148 |
| 153 // Keep in sync with LaunchType in extension_prefs.h | 149 // Keep in sync with LaunchType in extension_prefs.h |
| 154 var LaunchType = { | 150 var LaunchType = { |
| 155 LAUNCH_PINNED: 0, | 151 LAUNCH_PINNED: 0, |
| 156 LAUNCH_REGULAR: 1, | 152 LAUNCH_REGULAR: 1, |
| 157 LAUNCH_FULLSCREEN: 2, | 153 LAUNCH_FULLSCREEN: 2 |
| 158 LAUNCH_WINDOW: 3 | |
| 159 }; | 154 }; |
| 160 | 155 |
| 161 // Keep in sync with LaunchContainer in extension_constants.h | 156 // Keep in sync with LaunchContainer in extension.h |
| 162 var LaunchContainer = { | 157 var LaunchContainer = { |
| 163 LAUNCH_WINDOW: 0, | 158 LAUNCH_WINDOW: 0, |
| 164 LAUNCH_PANEL: 1, | 159 LAUNCH_PANEL: 1, |
| 165 LAUNCH_TAB: 2 | 160 LAUNCH_TAB: 2 |
| 166 }; | 161 }; |
| 167 | 162 |
| 168 var currentApp; | 163 var currentApp; |
| 169 | 164 |
| 170 function addContextMenu(el, app) { | 165 function addContextMenu(el, app) { |
| 171 el.addEventListener('contextmenu', cr.ui.contextMenuHandler); | 166 el.addEventListener('contextmenu', cr.ui.contextMenuHandler); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 182 var appLinkSel = '.app a[app-id=' + app['id'] + ']'; | 177 var appLinkSel = '.app a[app-id=' + app['id'] + ']'; |
| 183 var launchType = | 178 var launchType = |
| 184 el.querySelector(appLinkSel).getAttribute('launch-type'); | 179 el.querySelector(appLinkSel).getAttribute('launch-type'); |
| 185 | 180 |
| 186 var launchContainer = app['launch_container']; | 181 var launchContainer = app['launch_container']; |
| 187 var isPanel = launchContainer == LaunchContainer.LAUNCH_PANEL; | 182 var isPanel = launchContainer == LaunchContainer.LAUNCH_PANEL; |
| 188 | 183 |
| 189 // Update the commands related to the launch type. | 184 // Update the commands related to the launch type. |
| 190 var launchTypeIds = ['apps-launch-type-pinned', | 185 var launchTypeIds = ['apps-launch-type-pinned', |
| 191 'apps-launch-type-regular', | 186 'apps-launch-type-regular', |
| 192 'apps-launch-type-fullscreen', | 187 'apps-launch-type-fullscreen']; |
| 193 'apps-launch-type-window']; | |
| 194 launchTypeIds.forEach(function(id) { | 188 launchTypeIds.forEach(function(id) { |
| 195 var command = $(id); | 189 var command = $(id); |
| 196 command.disabled = isPanel; | 190 command.disabled = isPanel; |
| 197 command.checked = !isPanel && | 191 command.checked = !isPanel && |
| 198 launchType == command.getAttribute('launch-type'); | 192 launchType == command.getAttribute('launch-type'); |
| 199 }); | 193 }); |
| 200 | 194 |
| 201 return $('app-context-menu'); | 195 return $('app-context-menu'); |
| 202 } | 196 } |
| 203 }); | 197 }); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 214 break; | 208 break; |
| 215 case 'apps-launch-command': | 209 case 'apps-launch-command': |
| 216 launchApp(currentApp['id']); | 210 launchApp(currentApp['id']); |
| 217 break; | 211 break; |
| 218 case 'apps-uninstall-command': | 212 case 'apps-uninstall-command': |
| 219 chrome.send('uninstallApp', [currentApp['id']]); | 213 chrome.send('uninstallApp', [currentApp['id']]); |
| 220 break; | 214 break; |
| 221 case 'apps-launch-type-pinned': | 215 case 'apps-launch-type-pinned': |
| 222 case 'apps-launch-type-regular': | 216 case 'apps-launch-type-regular': |
| 223 case 'apps-launch-type-fullscreen': | 217 case 'apps-launch-type-fullscreen': |
| 224 case 'apps-launch-type-window': | |
| 225 chrome.send('setLaunchType', | 218 chrome.send('setLaunchType', |
| 226 [currentApp['id'], e.command.getAttribute('launch-type')]); | 219 [currentApp['id'], e.command.getAttribute('launch-type')]); |
| 227 break; | 220 break; |
| 228 } | 221 } |
| 229 }); | 222 }); |
| 230 | 223 |
| 231 document.addEventListener('canExecute', function(e) { | 224 document.addEventListener('canExecute', function(e) { |
| 232 switch (e.command.id) { | 225 switch (e.command.id) { |
| 233 case 'apps-options-command': | 226 case 'apps-options-command': |
| 234 e.canExecute = currentApp && currentApp['options_url']; | 227 e.canExecute = currentApp && currentApp['options_url']; |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 318 var elm = createElement({ | 311 var elm = createElement({ |
| 319 'id': 'web-store-entry', | 312 'id': 'web-store-entry', |
| 320 'name': localStrings.getString('web_store_title'), | 313 'name': localStrings.getString('web_store_title'), |
| 321 'launch_url': localStrings.getString('web_store_url') | 314 'launch_url': localStrings.getString('web_store_url') |
| 322 }); | 315 }); |
| 323 elm.setAttribute('app-id', 'web-store-entry'); | 316 elm.setAttribute('app-id', 'web-store-entry'); |
| 324 return elm; | 317 return elm; |
| 325 } | 318 } |
| 326 }; | 319 }; |
| 327 })(); | 320 })(); |
| OLD | NEW |