OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 /** |
| 6 * @fileoverview App list UI. |
| 7 * For now, most of its logic is borrowed from ntp4. |
| 8 */ |
| 9 |
| 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 |
| 12 cr.define('appList', function() { |
| 13 'use strict'; |
| 14 |
| 15 /** |
| 16 * AppsView instance. |
| 17 * @type {!Object|undefined} |
| 18 */ |
| 19 var appsView; |
| 20 |
| 21 /** |
| 22 * Invoked at startup once the DOM is available to initialize the app. |
| 23 */ |
| 24 function load() { |
| 25 appsView = new appList.AppsView(); |
| 26 } |
| 27 |
| 28 /** |
| 29 * Wrappers to forward the callback to corresponding PageListView member. |
| 30 */ |
| 31 function appAdded(appData, opt_highlight) { |
| 32 appsView.appAdded(appData, opt_highlight); |
| 33 } |
| 34 |
| 35 function appRemoved(appData, isUninstall) { |
| 36 appsView.appRemoved(appData, isUninstall); |
| 37 } |
| 38 |
| 39 function appsPrefChangeCallback(data) { |
| 40 appsView.appsPrefChangedCallback(data); |
| 41 } |
| 42 |
| 43 function enterRearrangeMode() { |
| 44 appsView.enterRearrangeMode(); |
| 45 } |
| 46 |
| 47 function getAppsCallback(data) { |
| 48 appsView.getAppsCallback(data); |
| 49 } |
| 50 |
| 51 function getAppsPageIndex(page) { |
| 52 appsView.getAppsPageIndex(page); |
| 53 } |
| 54 |
| 55 function getCardSlider() { |
| 56 return appsView.cardSlider; |
| 57 } |
| 58 |
| 59 function leaveRearrangeMode(e) { |
| 60 appsView.leaveRearrangeMode(e); |
| 61 } |
| 62 |
| 63 function saveAppPageName(appPage, name) { |
| 64 appsView.saveAppPageName(appPage, name); |
| 65 } |
| 66 |
| 67 function setAppToBeHighlighted(appId) { |
| 68 appsView.highlightAppId = appId; |
| 69 } |
| 70 |
| 71 // Return an object with all the exports |
| 72 return { |
| 73 appAdded: appAdded, |
| 74 appRemoved: appRemoved, |
| 75 appsPrefChangeCallback: appsPrefChangeCallback, |
| 76 enterRearrangeMode: enterRearrangeMode, |
| 77 getAppsPageIndex: getAppsPageIndex, |
| 78 getAppsCallback: getAppsCallback, |
| 79 getCardSlider: getCardSlider, |
| 80 leaveRearrangeMode: leaveRearrangeMode, |
| 81 load: load, |
| 82 saveAppPageName: saveAppPageName, |
| 83 setAppToBeHighlighted: setAppToBeHighlighted |
| 84 }; |
| 85 }); |
| 86 |
| 87 // publish ntp globals |
| 88 // TODO(xiyuan): update the following when content handlers are changed to use |
| 89 // ntp namespace. |
| 90 var appsPrefChangeCallback = appList.appsPrefChangeCallback; |
| 91 var getAppsCallback = appList.getAppsCallback; |
| 92 |
| 93 var ntp4 = ntp4 || {}; |
| 94 ntp4.appAdded = appList.appAdded; |
| 95 ntp4.appRemoved = appList.appRemoved; |
| 96 ntp4.enterRearrangeMode = appList.enterRearrangeMode; |
| 97 ntp4.getAppsPageIndex = appList.getAppsPageIndex; |
| 98 ntp4.getCardSlider = appList.getCardSlider; |
| 99 ntp4.leaveRearrangeMode = appList.leaveRearrangeMode; |
| 100 ntp4.saveAppPageName = appList.saveAppPageName; |
| 101 ntp4.setAppToBeHighlighted = appList.setAppToBeHighlighted; |
| 102 |
| 103 document.addEventListener('DOMContentLoaded', appList.load); |
OLD | NEW |