Chromium Code Reviews| 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'; |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 90 | 90 |
| 91 var a = div.appendChild(document.createElement('a')); | 91 var a = div.appendChild(document.createElement('a')); |
| 92 a.setAttribute('app-id', app['id']); | 92 a.setAttribute('app-id', app['id']); |
| 93 a.setAttribute('launch-type', app['launch_type']); | 93 a.setAttribute('launch-type', app['launch_type']); |
| 94 a.xtitle = a.textContent = app['name']; | 94 a.xtitle = a.textContent = app['name']; |
| 95 a.href = app['launch_url']; | 95 a.href = app['launch_url']; |
| 96 | 96 |
| 97 return div; | 97 return div; |
| 98 } | 98 } |
| 99 | 99 |
| 100 function createContextMenu(app) { | |
|
arv (Not doing code reviews)
2010/11/19 22:31:36
dead code
| |
| 101 var menu = new cr.ui.Menu; | |
| 102 var button = document.createElement(button); | |
| 103 } | |
| 104 | |
| 105 function launchApp(appId) { | 100 function launchApp(appId) { |
| 106 var appsSection = $('apps'); | 101 var appsSection = $('apps'); |
| 107 var expanded = !appsSection.classList.contains('hidden'); | 102 var expanded = !appsSection.classList.contains('hidden'); |
| 108 var element = document.querySelector( | 103 var element = document.querySelector( |
| 109 (expanded ? '.maxiview' : '.miniview') + ' a[app-id=' + appId + ']'); | 104 (expanded ? '.maxiview' : '.miniview') + ' a[app-id=' + appId + ']'); |
| 110 | 105 |
| 111 // TODO(arv): Handle zoom? | 106 // TODO(arv): Handle zoom? |
| 112 var rect = element.getBoundingClientRect(); | 107 var rect = element.getBoundingClientRect(); |
| 113 var cs = getComputedStyle(element); | 108 var cs = getComputedStyle(element); |
| 114 var size = cs.backgroundSize.split(/\s+/); // background-size has the | 109 var size = cs.backgroundSize.split(/\s+/); // background-size has the |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 167 el.addEventListener('keydown', cr.ui.contextMenuHandler); | 162 el.addEventListener('keydown', cr.ui.contextMenuHandler); |
| 168 el.addEventListener('keyup', cr.ui.contextMenuHandler); | 163 el.addEventListener('keyup', cr.ui.contextMenuHandler); |
| 169 | 164 |
| 170 Object.defineProperty(el, 'contextMenu', { | 165 Object.defineProperty(el, 'contextMenu', { |
| 171 get: function() { | 166 get: function() { |
| 172 currentApp = app; | 167 currentApp = app; |
| 173 | 168 |
| 174 $('apps-launch-command').label = app['name']; | 169 $('apps-launch-command').label = app['name']; |
| 175 $('apps-options-command').canExecuteChange(); | 170 $('apps-options-command').canExecuteChange(); |
| 176 | 171 |
| 177 var appLinkSel = '.app a[app-id=' + app['id'] + ']'; | 172 var launchTypeEl; |
| 178 var launchType = | 173 if (el.getAttribute('app-id') === app['id']) { |
| 179 el.querySelector(appLinkSel).getAttribute('launch-type'); | 174 launchTypeEl = el; |
| 175 } else { | |
| 176 appLinkSel = 'a[app-id=' + app['id'] + ']'; | |
| 177 launchTypeEl = el.querySelector(appLinkSel); | |
| 178 } | |
| 180 | 179 |
| 180 var launchType = launchTypeEl.getAttribute('launch-type'); | |
| 181 var launchContainer = app['launch_container']; | 181 var launchContainer = app['launch_container']; |
| 182 var isPanel = launchContainer == LaunchContainer.LAUNCH_PANEL; | 182 var isPanel = launchContainer == LaunchContainer.LAUNCH_PANEL; |
| 183 | 183 |
| 184 // Update the commands related to the launch type. | 184 // Update the commands related to the launch type. |
| 185 var launchTypeIds = ['apps-launch-type-pinned', | 185 var launchTypeIds = ['apps-launch-type-pinned', |
| 186 'apps-launch-type-regular', | 186 'apps-launch-type-regular', |
| 187 'apps-launch-type-fullscreen']; | 187 'apps-launch-type-fullscreen']; |
| 188 launchTypeIds.forEach(function(id) { | 188 launchTypeIds.forEach(function(id) { |
| 189 var command = $(id); | 189 var command = $(id); |
| 190 command.disabled = isPanel; | 190 command.disabled = isPanel; |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 297 | 297 |
| 298 createClosedMenuElement: function(app) { | 298 createClosedMenuElement: function(app) { |
| 299 var a = document.createElement('a'); | 299 var a = document.createElement('a'); |
| 300 a.setAttribute('app-id', app['id']); | 300 a.setAttribute('app-id', app['id']); |
| 301 a.textContent = app['name']; | 301 a.textContent = app['name']; |
| 302 a.href = app['launch_url']; | 302 a.href = app['launch_url']; |
| 303 a.onclick = handleClick; | 303 a.onclick = handleClick; |
| 304 a.setAttribute('ping', PING_APP_LAUNCH_PREFIX + '+' + this.showPromo); | 304 a.setAttribute('ping', PING_APP_LAUNCH_PREFIX + '+' + this.showPromo); |
| 305 a.style.backgroundImage = url(app['icon_small']); | 305 a.style.backgroundImage = url(app['icon_small']); |
| 306 a.className = 'item'; | 306 a.className = 'item'; |
| 307 | |
| 308 addContextMenu(a, app); | |
| 309 | |
| 307 return a; | 310 return a; |
| 308 }, | 311 }, |
| 309 | 312 |
| 310 createWebStoreElement: function() { | 313 createWebStoreElement: function() { |
| 311 var elm = createElement({ | 314 var elm = createElement({ |
| 312 'id': 'web-store-entry', | 315 'id': 'web-store-entry', |
| 313 'name': localStrings.getString('web_store_title'), | 316 'name': localStrings.getString('web_store_title'), |
| 314 'launch_url': localStrings.getString('web_store_url') | 317 'launch_url': localStrings.getString('web_store_url') |
| 315 }); | 318 }); |
| 316 elm.setAttribute('app-id', 'web-store-entry'); | 319 elm.setAttribute('app-id', 'web-store-entry'); |
| 317 return elm; | 320 return elm; |
| 318 } | 321 } |
| 319 }; | 322 }; |
| 320 })(); | 323 })(); |
| OLD | NEW |