OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 New tab page | 6 * @fileoverview New tab page |
7 * This is the main code for the new tab page used by touch-enabled Chrome | 7 * This is the main code for the new tab page used by touch-enabled Chrome |
8 * browsers. For now this is still a prototype. | 8 * browsers. For now this is still a prototype. |
9 */ | 9 */ |
10 | 10 |
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
292 }, 60000); | 292 }, 60000); |
293 chrome.send('notificationPromoViewed'); | 293 chrome.send('notificationPromoViewed'); |
294 } | 294 } |
295 | 295 |
296 cr.dispatchSimpleEvent(document, 'ntpLoaded', true, true); | 296 cr.dispatchSimpleEvent(document, 'ntpLoaded', true, true); |
297 document.documentElement.classList.remove('starting-up'); | 297 document.documentElement.classList.remove('starting-up'); |
298 | 298 |
299 startTime = Date.now(); | 299 startTime = Date.now(); |
300 }); | 300 }); |
301 | 301 |
302 preventDefaultOnPoundLinkClicks(); // From webui/js/util.js. | |
303 cr.ui.FocusManager.disableMouseFocusOnButtons(); | 302 cr.ui.FocusManager.disableMouseFocusOnButtons(); |
304 } | 303 } |
305 | 304 |
306 /** | 305 /** |
307 * Launches the chrome web store app with the chrome-ntp-launcher | 306 * Launches the chrome web store app with the chrome-ntp-launcher |
308 * source. | 307 * source. |
309 * @param {Event} e The click event. | 308 * @param {Event} e The click event. |
310 */ | 309 */ |
311 function onChromeWebStoreButtonClick(e) { | 310 function onChromeWebStoreButtonClick(e) { |
312 chrome.send('recordAppLaunchByURL', | 311 chrome.send('recordAppLaunchByURL', |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
456 if (typeof message == 'string') { | 455 if (typeof message == 'string') { |
457 span.textContent = message; | 456 span.textContent = message; |
458 } else { | 457 } else { |
459 span.textContent = ''; // Remove all children. | 458 span.textContent = ''; // Remove all children. |
460 span.appendChild(message); | 459 span.appendChild(message); |
461 } | 460 } |
462 | 461 |
463 var linksBin = $('notificationLinks'); | 462 var linksBin = $('notificationLinks'); |
464 linksBin.textContent = ''; | 463 linksBin.textContent = ''; |
465 for (var i = 0; i < links.length; i++) { | 464 for (var i = 0; i < links.length; i++) { |
466 var link = linksBin.ownerDocument.createElement('div'); | 465 var link = linksBin.ownerDocument.createElement('a', 'action-link'); |
aboxhall
2014/10/22 21:33:31
This is a clear improvement!
Dan Beam
2014/10/23 03:05:44
yay!
| |
467 link.textContent = links[i].text; | 466 link.textContent = links[i].text; |
468 link.action = links[i].action; | 467 link.action = links[i].action; |
469 link.onclick = function() { | 468 link.onclick = function() { |
470 this.action(); | 469 this.action(); |
471 hideNotification(); | 470 hideNotification(); |
472 }; | 471 }; |
473 link.setAttribute('role', 'button'); | |
474 link.setAttribute('tabindex', 0); | |
475 link.className = 'link-button'; | |
476 linksBin.appendChild(link); | 472 linksBin.appendChild(link); |
477 } | 473 } |
478 | 474 |
479 function closeFunc(e) { | 475 function closeFunc(e) { |
480 if (opt_closeHandler) | 476 if (opt_closeHandler) |
481 opt_closeHandler(); | 477 opt_closeHandler(); |
482 hideNotification(); | 478 hideNotification(); |
483 } | 479 } |
484 | 480 |
485 document.querySelector('#notification button').onclick = closeFunc; | 481 document.querySelector('#notification button').onclick = closeFunc; |
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
787 setFaviconDominantColor: setFaviconDominantColor, | 783 setFaviconDominantColor: setFaviconDominantColor, |
788 showNotification: showNotification, | 784 showNotification: showNotification, |
789 themeChanged: themeChanged, | 785 themeChanged: themeChanged, |
790 updateLogin: updateLogin | 786 updateLogin: updateLogin |
791 }; | 787 }; |
792 }); | 788 }); |
793 | 789 |
794 document.addEventListener('DOMContentLoaded', ntp.onLoad); | 790 document.addEventListener('DOMContentLoaded', ntp.onLoad); |
795 | 791 |
796 var toCssPx = cr.ui.toCssPx; | 792 var toCssPx = cr.ui.toCssPx; |
OLD | NEW |