Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(261)

Side by Side Diff: chrome/browser/resources/ntp_search/new_tab.js

Issue 10907065: NTP5: Fix page blacklisting and remove recently closed tabs when they're clicked. Fix the styling … (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase. Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 308 matching lines...) Expand 10 before | Expand all | Expand 10 after
319 function closeFunc(e) { 319 function closeFunc(e) {
320 if (opt_closeHandler) 320 if (opt_closeHandler)
321 opt_closeHandler(); 321 opt_closeHandler();
322 hideNotification(); 322 hideNotification();
323 } 323 }
324 324
325 document.querySelector('#notification button').onclick = closeFunc; 325 document.querySelector('#notification button').onclick = closeFunc;
326 document.addEventListener('dragstart', closeFunc); 326 document.addEventListener('dragstart', closeFunc);
327 327
328 notificationContainer.hidden = false; 328 notificationContainer.hidden = false;
329 showNotificationOnCurrentPage(); 329 window.setTimeout(function() {
pedro (no code reviews) 2012/09/06 00:28:49 Do you really need this inside a setTimeout?
jeremycho 2012/09/06 04:40:08 Without it, the fade-in transition isn't seen.
330 notificationContainer.classList.remove('inactive');
331 }, 0);
330 332
331 newTabView.cardSlider.frame.addEventListener( 333 newTabView.cardSlider.frame.addEventListener(
332 'cardSlider:card_change_ended', onCardChangeEnded); 334 'cardSlider:card_change_ended', onCardChangeEnded);
333 335
334 var timeout = opt_timeout || 10000; 336 var timeout = opt_timeout || 10000;
335 notificationTimeout = window.setTimeout(hideNotification, timeout); 337 notificationTimeout = window.setTimeout(hideNotification, timeout);
336 } 338 }
337 339
338 /** 340 /**
339 * Hide the notification bubble. 341 * Hide the notification bubble.
340 */ 342 */
341 function hideNotification() { 343 function hideNotification() {
342 notificationContainer.classList.add('inactive'); 344 notificationContainer.classList.add('inactive');
343 345
344 newTabView.cardSlider.frame.removeEventListener( 346 newTabView.cardSlider.frame.removeEventListener(
345 'cardSlider:card_change_ended', onCardChangeEnded); 347 'cardSlider:card_change_ended', onCardChangeEnded);
346 } 348 }
347 349
348 /** 350 /**
349 * Happens when 1 or more consecutive card changes end. 351 * Happens when 1 or more consecutive card changes end.
350 * @param {Event} e The cardSlider:card_change_ended event. 352 * @param {Event} e The cardSlider:card_change_ended event.
351 */ 353 */
352 function onCardChangeEnded(e) { 354 function onCardChangeEnded(e) {
353 // If we ended on the same page as we started, ignore. 355 // If we ended on the same page as we started, ignore.
354 if (newTabView.cardSlider.currentCardValue.notification) 356 if (newTabView.cardSlider.currentCardValue.notification)
355 return; 357 return;
356 358
357 // Hide the notification the old page. 359 // Fade the notification out then in whenever the card has changed.
360 // TODO(jeremycho): Add card-changed as soon as the dot is clicked?
358 notificationContainer.classList.add('card-changed'); 361 notificationContainer.classList.add('card-changed');
359 362 window.setTimeout(function() {
360 showNotificationOnCurrentPage(); 363 notificationContainer.classList.remove('card-changed');
364 }, 0);
361 } 365 }
362 366
363 /** 367 /**
364 * Move and show the notification on the current page.
365 */
366 function showNotificationOnCurrentPage() {
367 var page = newTabView.cardSlider.currentCardValue;
368 doWhenAllSectionsReady(function() {
369 if (page != newTabView.cardSlider.currentCardValue)
370 return;
371
372 // NOTE: This moves the notification to inside of the current page.
373 page.notification = notificationContainer;
374
375 // Reveal the notification and instruct it to hide itself if ignored.
376 notificationContainer.classList.remove('inactive');
377
378 // Gives the browser time to apply this rule before we remove it (causing
379 // a transition).
380 window.setTimeout(function() {
381 notificationContainer.classList.remove('card-changed');
382 }, 0);
383 });
384 }
385
386 /**
387 * When done fading out, set hidden to true so the notification can't be 368 * When done fading out, set hidden to true so the notification can't be
388 * tabbed to or clicked. 369 * tabbed to or clicked.
389 * @param {Event} e The webkitTransitionEnd event. 370 * @param {Event} e The webkitTransitionEnd event.
390 */ 371 */
391 function onNotificationTransitionEnd(e) { 372 function onNotificationTransitionEnd(e) {
392 if (notificationContainer.classList.contains('inactive')) 373 if (notificationContainer.classList.contains('inactive'))
393 notificationContainer.hidden = true; 374 notificationContainer.hidden = true;
394 } 375 }
395 376
396 function setRecentlyClosedTabs(data) { 377 function setRecentlyClosedTabs(data) {
397 newTabView.recentlyClosedPage.data = data; 378 newTabView.recentlyClosedPage.setData(data);
398 } 379 }
399 380
400 function setMostVisitedPages(data, hasBlacklistedUrls) { 381 function setMostVisitedPages(data, hasBlacklistedUrls) {
401 newTabView.mostVisitedPage.data = data; 382 newTabView.mostVisitedPage.setData(data);
402 cr.dispatchSimpleEvent(document, 'sectionready', true, true); 383 cr.dispatchSimpleEvent(document, 'sectionready', true, true);
403 } 384 }
404 385
405 function setSuggestionsPages(data, hasBlacklistedUrls) { 386 function setSuggestionsPages(data, hasBlacklistedUrls) {
406 newTabView.suggestionsPage.data = data; 387 newTabView.suggestionsPage.data = data;
407 } 388 }
408 389
409 function getThumbnailUrl(url) { 390 function getThumbnailUrl(url) {
410 return 'chrome://thumb/' + url; 391 return 'chrome://thumb/' + url;
411 } 392 }
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
523 setRecentlyClosedTabs: setRecentlyClosedTabs, 504 setRecentlyClosedTabs: setRecentlyClosedTabs,
524 showNotification: showNotification, 505 showNotification: showNotification,
525 themeChanged: themeChanged, 506 themeChanged: themeChanged,
526 updateLogin: updateLogin 507 updateLogin: updateLogin
527 }; 508 };
528 }); 509 });
529 510
530 document.addEventListener('DOMContentLoaded', ntp.onLoad); 511 document.addEventListener('DOMContentLoaded', ntp.onLoad);
531 512
532 var toCssPx = cr.ui.toCssPx; 513 var toCssPx = cr.ui.toCssPx;
OLDNEW
« no previous file with comments | « chrome/browser/resources/ntp_search/new_tab.html ('k') | chrome/browser/resources/ntp_search/recently_closed_page.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698