OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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('ntp4', function() { | 5 cr.define('ntp4', function() { |
6 'use strict'; | 6 'use strict'; |
7 | 7 |
8 var localStrings = new LocalStrings; | 8 var localStrings = new LocalStrings; |
9 | 9 |
10 var APP_LAUNCH = { | 10 var APP_LAUNCH = { |
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
220 // this.contextMenu. | 220 // this.contextMenu. |
221 var self = this; | 221 var self = this; |
222 appContents.__defineGetter__('contextMenu', function() { | 222 appContents.__defineGetter__('contextMenu', function() { |
223 return self.contextMenu; | 223 return self.contextMenu; |
224 }); | 224 }); |
225 appContents.addEventListener('contextmenu', cr.ui.contextMenuHandler); | 225 appContents.addEventListener('contextmenu', cr.ui.contextMenuHandler); |
226 | 226 |
227 this.isStore_ = this.appData_.is_webstore; | 227 this.isStore_ = this.appData_.is_webstore; |
228 if (this.isStore_) | 228 if (this.isStore_) |
229 this.createAppsPromoExtras_(); | 229 this.createAppsPromoExtras_(); |
| 230 |
| 231 this.addEventListener('mousedown', this.onMousedown_, true); |
230 }, | 232 }, |
231 | 233 |
232 /** | 234 /** |
233 * Removes the app tile from the page. Should be called after the app has | 235 * Removes the app tile from the page. Should be called after the app has |
234 * been uninstalled. | 236 * been uninstalled. |
235 */ | 237 */ |
236 remove: function() { | 238 remove: function() { |
237 // Unset the ID immediately, because the app is already gone. But leave | 239 // Unset the ID immediately, because the app is already gone. But leave |
238 // the tile on the page as it animates out. | 240 // the tile on the page as it animates out. |
239 this.id = ''; | 241 this.id = ''; |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
325 onClick_: function(e) { | 327 onClick_: function(e) { |
326 chrome.send('launchApp', | 328 chrome.send('launchApp', |
327 [this.appId, APP_LAUNCH.NTP_APPS_MAXIMIZED, | 329 [this.appId, APP_LAUNCH.NTP_APPS_MAXIMIZED, |
328 e.altKey, e.ctrlKey, e.metaKey, e.shiftKey, e.button]); | 330 e.altKey, e.ctrlKey, e.metaKey, e.shiftKey, e.button]); |
329 | 331 |
330 // Don't allow the click to trigger a link or anything | 332 // Don't allow the click to trigger a link or anything |
331 e.preventDefault(); | 333 e.preventDefault(); |
332 }, | 334 }, |
333 | 335 |
334 /** | 336 /** |
| 337 * Handler for mousedown on the App. Adds a class that allows us to |
| 338 * not display as :active for right clicks (specifically, don't pulse |
| 339 * on right click). |
| 340 * @param {Event} e The mousedown event. |
| 341 */ |
| 342 onMousedown_: function(e) { |
| 343 if (e.button == 2) |
| 344 this.classList.add('right-mouse-down'); |
| 345 else |
| 346 this.classList.remove('right-mouse-down'); |
| 347 }, |
| 348 |
| 349 /** |
335 * The data and preferences for this app. | 350 * The data and preferences for this app. |
336 * @type {Object} | 351 * @type {Object} |
337 */ | 352 */ |
338 set appData(data) { | 353 set appData(data) { |
339 this.appData_ = data; | 354 this.appData_ = data; |
340 }, | 355 }, |
341 get appData() { | 356 get appData() { |
342 return this.appData_; | 357 return this.appData_; |
343 }, | 358 }, |
344 | 359 |
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
550 var store = document.querySelector('.webstore'); | 565 var store = document.querySelector('.webstore'); |
551 if (store) | 566 if (store) |
552 store.setAppsPromoData(data); | 567 store.setAppsPromoData(data); |
553 }; | 568 }; |
554 | 569 |
555 return { | 570 return { |
556 APP_LAUNCH: APP_LAUNCH, | 571 APP_LAUNCH: APP_LAUNCH, |
557 AppsPage: AppsPage, | 572 AppsPage: AppsPage, |
558 }; | 573 }; |
559 }); | 574 }); |
OLD | NEW |