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 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
294 this.appImgSrc_ = null; | 294 this.appImgSrc_ = null; |
295 } | 295 } |
296 this.classList.remove('icon-loading'); | 296 this.classList.remove('icon-loading'); |
297 }, | 297 }, |
298 | 298 |
299 // Shows a notification text below the app icon and stuffs the attributes | 299 // Shows a notification text below the app icon and stuffs the attributes |
300 // necessary to show the bubble when the user clicks on the notification | 300 // necessary to show the bubble when the user clicks on the notification |
301 // text. | 301 // text. |
302 setupNotification_: function(notification) { | 302 setupNotification_: function(notification) { |
303 // Remove the old notification from this node (if any). | 303 // Remove the old notification from this node (if any). |
304 if (this.appNotification_) | 304 if (this.appNotification_ && this.appNotification_.parentNode) |
305 this.appNotification_.parentNode.removeChild(this.appNotification_); | 305 this.appNotification_.parentNode.removeChild(this.appNotification_); |
306 | 306 |
307 if (notification) { | 307 if (notification) { |
308 // Add a new notification to this node. | 308 // Add a new notification to this node. |
309 var appNotification = this.ownerDocument.createElement('span'); | 309 var appNotification = this.ownerDocument.createElement('span'); |
310 appNotification.className = 'app-notification'; | 310 appNotification.className = 'app-notification'; |
311 appNotification.textContent = notification['title']; | 311 appNotification.textContent = notification['title']; |
312 appNotification.addEventListener('click', | 312 appNotification.addEventListener('click', |
313 this.onNotificationClick_.bind(this)); | 313 this.onNotificationClick_.bind(this)); |
314 appNotification.notificationTitle = notification['title']; | 314 appNotification.notificationTitle = notification['title']; |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
448 messageDiv.textContent = message; | 448 messageDiv.textContent = message; |
449 container.appendChild(messageDiv); | 449 container.appendChild(messageDiv); |
450 if (link && linkMessage) { | 450 if (link && linkMessage) { |
451 var anchor = this.ownerDocument.createElement('a'); | 451 var anchor = this.ownerDocument.createElement('a'); |
452 anchor.href = link; | 452 anchor.href = link; |
453 anchor.textContent = linkMessage; | 453 anchor.textContent = linkMessage; |
454 container.appendChild(anchor); | 454 container.appendChild(anchor); |
455 } | 455 } |
456 | 456 |
457 var infoBubble = new cr.ui.Bubble; | 457 var infoBubble = new cr.ui.Bubble; |
| 458 infoBubble.appId = this.appData_.id; |
458 infoBubble.anchorNode = e.target; | 459 infoBubble.anchorNode = e.target; |
459 infoBubble.content = container; | 460 infoBubble.content = container; |
| 461 infoBubble.handleCloseEvent = function() { |
| 462 chrome.send('closeNotification', [this.appId]); |
| 463 this.hide(); |
| 464 }; |
460 infoBubble.show(); | 465 infoBubble.show(); |
461 }, | 466 }, |
462 | 467 |
463 /** | 468 /** |
464 * Adds a node to the list of targets that will launch the app. This list | 469 * Adds a node to the list of targets that will launch the app. This list |
465 * is also used in onMousedown to determine whether the app contents should | 470 * is also used in onMousedown to determine whether the app contents should |
466 * be shown as active (if we don't do this, then clicking anywhere in | 471 * be shown as active (if we don't do this, then clicking anywhere in |
467 * appContents, even a part that is outside the ideally clickable region, | 472 * appContents, even a part that is outside the ideally clickable region, |
468 * will cause the app icon to look active). | 473 * will cause the app icon to look active). |
469 * @param {HTMLElement} node The node that should be clickable. | 474 * @param {HTMLElement} node The node that should be clickable. |
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
791 appNotificationChanged: appNotificationChanged, | 796 appNotificationChanged: appNotificationChanged, |
792 AppsPage: AppsPage, | 797 AppsPage: AppsPage, |
793 launchAppAfterEnable: launchAppAfterEnable, | 798 launchAppAfterEnable: launchAppAfterEnable, |
794 }; | 799 }; |
795 }); | 800 }); |
796 | 801 |
797 // TODO(estade): update the content handlers to use ntp namespace instead of | 802 // TODO(estade): update the content handlers to use ntp namespace instead of |
798 // making these global. | 803 // making these global. |
799 var appNotificationChanged = ntp4.appNotificationChanged; | 804 var appNotificationChanged = ntp4.appNotificationChanged; |
800 var launchAppAfterEnable = ntp4.launchAppAfterEnable; | 805 var launchAppAfterEnable = ntp4.launchAppAfterEnable; |
OLD | NEW |