1 // Copyright 2013 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.
6 * @fileoverview Implement the recommended apps card in the launcher start page.
9 cr.define('appList.startPage', function() {
13 * Create a view with icon and label for the given app data.
15 * @extends {HTMLDivElement}
17 var AppItemView = cr.ui.define('div');
19 AppItemView.prototype = {
20 __proto__: HTMLDivElement.prototype,
23 * The app id of the app displayed by this view. Used to launch
24 * the app when the view is clicked.
30 * Sets the icon URL to display the app icon.
34 this.style.backgroundImage = 'url(' + url + ')';
38 * Sets the text title.
41 set textTitle(title) {
42 this.textContent = title;
46 decorate: function() {
47 this.className = 'app';
48 this.addEventListener('click', this.handleClick_.bind(this));
52 * Handles 'click' event.
55 handleClick_: function() {
57 chrome.send('launchApp', [this.appId]);
62 * Create recommended apps card.
64 * @extends {HTMLDivElement}
66 var RecommendedApps = cr.ui.define('div');
68 RecommendedApps.prototype = {
69 __proto__: HTMLDivElement.prototype,
72 decorate: function() {
73 this.className = 'recommended-apps';
77 * Sets the apps to be displayed in this card.
79 setApps: function(apps) {
80 this.textContent = '';
81 for (var i = 0; i < apps.length; ++i) {
82 this.appendChild(new AppItemView(apps[i]));
88 RecommendedApps: RecommendedApps