| 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 /** | 5 /** |
| 6 * @fileoverview App list UI. | 6 * @fileoverview App list UI. |
| 7 * For now, most of its logic is borrowed from ntp4. | 7 * For now, most of its logic is borrowed from ntp4. |
| 8 */ | 8 */ |
| 9 | 9 |
| 10 // Use an anonymous function to enable strict mode just for this file (which | 10 // Use an anonymous function to enable strict mode just for this file (which |
| 11 // will be concatenated with other files when embedded in Chrome | 11 // will be concatenated with other files when embedded in Chrome |
| 12 cr.define('appList', function() { | 12 cr.define('appList', function() { |
| 13 'use strict'; | 13 'use strict'; |
| 14 | 14 |
| 15 /** | 15 /** |
| 16 * AppsView instance. | 16 * AppsView instance. |
| 17 * @type {!Object|undefined} | 17 * @type {!Object|undefined} |
| 18 */ | 18 */ |
| 19 var appsView; | 19 var appsView; |
| 20 | 20 |
| 21 /** | 21 /** |
| 22 * Invoked at startup once the DOM is available to initialize the app. | 22 * Invoked at startup once the DOM is available to initialize the app. |
| 23 */ | 23 */ |
| 24 function load() { | 24 function load() { |
| 25 appsView = new appList.AppsView(); | 25 appsView = new appList.AppsView(); |
| 26 |
| 27 document.addEventListener('click', onDocClick); |
| 26 } | 28 } |
| 27 | 29 |
| 28 /** | 30 /** |
| 31 * Document click event handler. |
| 32 */ |
| 33 function onDocClick(e) { |
| 34 // Close if click is on body, or not on app, paging dot or its children. |
| 35 if (e.target == document.body || |
| 36 (!e.target.classList.contains('app') && |
| 37 !e.target.classList.contains('dot') && |
| 38 !findAncestorByClass(e.target, 'dot'))) { |
| 39 chrome.send('close'); |
| 40 } |
| 41 } |
| 42 |
| 43 /** |
| 29 * Wrappers to forward the callback to corresponding PageListView member. | 44 * Wrappers to forward the callback to corresponding PageListView member. |
| 30 */ | 45 */ |
| 31 function appAdded(appData, opt_highlight) { | 46 function appAdded(appData, opt_highlight) { |
| 32 appsView.appAdded(appData, opt_highlight); | 47 appsView.appAdded(appData, opt_highlight); |
| 33 } | 48 } |
| 34 | 49 |
| 35 function appRemoved(appData, isUninstall) { | 50 function appRemoved(appData, isUninstall) { |
| 36 appsView.appRemoved(appData, isUninstall); | 51 appsView.appRemoved(appData, isUninstall); |
| 37 } | 52 } |
| 38 | 53 |
| 39 function appsPrefChangeCallback(data) { | 54 function appsPrefChangeCallback(data) { |
| 40 appsView.appsPrefChangedCallback(data); | 55 appsView.appsPrefChangedCallback(data); |
| 41 } | 56 } |
| 42 | 57 |
| 43 function enterRearrangeMode() { | 58 function enterRearrangeMode() { |
| 44 appsView.enterRearrangeMode(); | 59 appsView.enterRearrangeMode(); |
| 45 } | 60 } |
| 46 | 61 |
| 47 function getAppsCallback(data) { | 62 function getAppsCallback(data) { |
| 48 appsView.getAppsCallback(data); | 63 appsView.getAppsCallback(data); |
| 64 chrome.send('onAppsLoaded'); |
| 49 } | 65 } |
| 50 | 66 |
| 51 function getAppsPageIndex(page) { | 67 function getAppsPageIndex(page) { |
| 52 return appsView.getAppsPageIndex(page); | 68 return appsView.getAppsPageIndex(page); |
| 53 } | 69 } |
| 54 | 70 |
| 55 function getCardSlider() { | 71 function getCardSlider() { |
| 56 return appsView.cardSlider; | 72 return appsView.cardSlider; |
| 57 } | 73 } |
| 58 | 74 |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 ntp4.appAdded = appList.appAdded; | 110 ntp4.appAdded = appList.appAdded; |
| 95 ntp4.appRemoved = appList.appRemoved; | 111 ntp4.appRemoved = appList.appRemoved; |
| 96 ntp4.enterRearrangeMode = appList.enterRearrangeMode; | 112 ntp4.enterRearrangeMode = appList.enterRearrangeMode; |
| 97 ntp4.getAppsPageIndex = appList.getAppsPageIndex; | 113 ntp4.getAppsPageIndex = appList.getAppsPageIndex; |
| 98 ntp4.getCardSlider = appList.getCardSlider; | 114 ntp4.getCardSlider = appList.getCardSlider; |
| 99 ntp4.leaveRearrangeMode = appList.leaveRearrangeMode; | 115 ntp4.leaveRearrangeMode = appList.leaveRearrangeMode; |
| 100 ntp4.saveAppPageName = appList.saveAppPageName; | 116 ntp4.saveAppPageName = appList.saveAppPageName; |
| 101 ntp4.setAppToBeHighlighted = appList.setAppToBeHighlighted; | 117 ntp4.setAppToBeHighlighted = appList.setAppToBeHighlighted; |
| 102 | 118 |
| 103 document.addEventListener('DOMContentLoaded', appList.load); | 119 document.addEventListener('DOMContentLoaded', appList.load); |
| OLD | NEW |