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

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

Issue 7745032: ntp4: don't set shownPageIndex during startup (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 /** 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 594 matching lines...) Expand 10 before | Expand all | Expand 10 after
605 attribution.hidden = true; 605 attribution.hidden = true;
606 } 606 }
607 } 607 }
608 608
609 /** 609 /**
610 * Handler for CARD_CHANGED on cardSlider. 610 * Handler for CARD_CHANGED on cardSlider.
611 * @param {Event} e The CARD_CHANGED event. 611 * @param {Event} e The CARD_CHANGED event.
612 */ 612 */
613 function cardChangedHandler(e) { 613 function cardChangedHandler(e) {
614 var page = e.cardSlider.currentCardValue; 614 var page = e.cardSlider.currentCardValue;
615 if (page.classList.contains('apps-page')) { 615
616 shownPage = templateData['apps_page_id']; 616 // Don't change shownPage until startup is done (and page changes actually
617 shownPageIndex = getAppsPageIndex(page); 617 // reflect user actions).
618 } else if (page.classList.contains('most-visited-page')) { 618 if (!document.documentElement.classList.contains('starting-up')) {
619 shownPage = templateData['most_visited_page_id']; 619 if (page.classList.contains('apps-page')) {
620 shownPageIndex = 0; 620 shownPage = templateData['apps_page_id'];
621 } else if (page.classList.contains('bookmarks-page')) { 621 shownPageIndex = getAppsPageIndex(page);
622 shownPage = templateData['bookmarks_page_id']; 622 } else if (page.classList.contains('most-visited-page')) {
623 shownPageIndex = 0; 623 shownPage = templateData['most_visited_page_id'];
624 } else { 624 shownPageIndex = 0;
625 console.error('unknown page selected'); 625 } else if (page.classList.contains('bookmarks-page')) {
626 shownPage = templateData['bookmarks_page_id'];
627 shownPageIndex = 0;
628 } else {
629 console.error('unknown page selected');
630 }
631 chrome.send('pageSelected', [shownPage, shownPageIndex]);
626 } 632 }
627 chrome.send('pageSelected', [shownPage, shownPageIndex]);
628 633
629 // Update the active dot 634 // Update the active dot
630 var curDot = dotList.getElementsByClassName('selected')[0]; 635 var curDot = dotList.getElementsByClassName('selected')[0];
631 if (curDot) 636 if (curDot)
632 curDot.classList.remove('selected'); 637 curDot.classList.remove('selected');
633 var newPageIndex = e.cardSlider.currentCard; 638 var newPageIndex = e.cardSlider.currentCard;
634 dots[newPageIndex].classList.add('selected'); 639 dots[newPageIndex].classList.add('selected');
635 updatePageSwitchers(); 640 updatePageSwitchers();
636 } 641 }
637 642
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
746 // TODO(estade): update the content handlers to use ntp namespace instead of 751 // TODO(estade): update the content handlers to use ntp namespace instead of
747 // making these global. 752 // making these global.
748 var assert = ntp4.assert; 753 var assert = ntp4.assert;
749 var getAppsCallback = ntp4.getAppsCallback; 754 var getAppsCallback = ntp4.getAppsCallback;
750 var appsPrefChangeCallback = ntp4.appsPrefChangeCallback; 755 var appsPrefChangeCallback = ntp4.appsPrefChangeCallback;
751 var themeChanged = ntp4.themeChanged; 756 var themeChanged = ntp4.themeChanged;
752 var recentlyClosedTabs = ntp4.setRecentlyClosedTabs; 757 var recentlyClosedTabs = ntp4.setRecentlyClosedTabs;
753 var setMostVisitedPages = ntp4.setMostVisitedPages; 758 var setMostVisitedPages = ntp4.setMostVisitedPages;
754 759
755 document.addEventListener('DOMContentLoaded', ntp4.initialize); 760 document.addEventListener('DOMContentLoaded', ntp4.initialize);
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698