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

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

Issue 7399015: Sync Promo: Add a way to collapse the sync promo (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: remove extra changes Created 9 years, 5 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) 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 // To avoid creating tons of unnecessary nodes. We assume we cannot fit more 5 // To avoid creating tons of unnecessary nodes. We assume we cannot fit more
6 // than this many items in the miniview. 6 // than this many items in the miniview.
7 var MAX_MINIVIEW_ITEMS = 15; 7 var MAX_MINIVIEW_ITEMS = 15;
8 8
9 // Extra spacing at the top of the layout. 9 // Extra spacing at the top of the layout.
10 var LAYOUT_SPACING_TOP = 25; 10 var LAYOUT_SPACING_TOP = 25;
(...skipping 470 matching lines...) Expand 10 before | Expand all | Expand 10 after
481 var section; 481 var section;
482 for (i = 0; section = sections[i]; i++) { 482 for (i = 0; section = sections[i]; i++) {
483 headerHeight += section.fixedHeight; 483 headerHeight += section.fixedHeight;
484 if (section.expanded) { 484 if (section.expanded) {
485 expandedSection = section; 485 expandedSection = section;
486 i++; 486 i++;
487 break; 487 break;
488 } 488 }
489 } 489 }
490 490
491 // Include the height of the sync promo bar.
492 var sync_promo_height = $('sync-promo').offsetHeight;
493 headerHeight += sync_promo_height;
494
491 // Calculate the height of the fixed elements below the expanded section, if 495 // Calculate the height of the fixed elements below the expanded section, if
492 // any. 496 // any.
493 for (; section = sections[i]; i++) { 497 for (; section = sections[i]; i++) {
494 footerHeight += section.fixedHeight; 498 footerHeight += section.fixedHeight;
495 } 499 }
496 // Leave room for bottom bar if it's visible. 500 // Leave room for bottom bar if it's visible.
497 footerHeight += $('closed-sections-bar').offsetHeight; 501 footerHeight += $('closed-sections-bar').offsetHeight;
498 502
499 503
500 // Determine the height to use for the expanded section. If there isn't enough 504 // Determine the height to use for the expanded section. If there isn't enough
(...skipping 27 matching lines...) Expand all
528 } 532 }
529 } else { 533 } else {
530 // We only set the document height when a section is expanded. If 534 // We only set the document height when a section is expanded. If
531 // all sections are collapsed, then get rid of the previous height. 535 // all sections are collapsed, then get rid of the previous height.
532 document.body.style.height = ''; 536 document.body.style.height = '';
533 } 537 }
534 538
535 maxiviewVisibleHeight = expandedSectionHeight; 539 maxiviewVisibleHeight = expandedSectionHeight;
536 540
537 // Now position all the elements. 541 // Now position all the elements.
538 var y = LAYOUT_SPACING_TOP; 542 var y = LAYOUT_SPACING_TOP + sync_promo_height;
539 for (i = 0, section; section = sections[i]; i++) { 543 for (i = 0, section; section = sections[i]; i++) {
540 section.section.style.top = y + 'px'; 544 section.section.style.top = y + 'px';
541 y += section.fixedHeight; 545 y += section.fixedHeight;
542 546
543 if (section.maxiview) { 547 if (section.maxiview) {
544 if (section == expandedSection) { 548 if (section == expandedSection) {
545 section.maxiview.style.top = y + 'px'; 549 section.maxiview.style.top = y + 'px';
546 } else { 550 } else {
547 // The miniviews fade out gradually, so it may have height at this 551 // The miniviews fade out gradually, so it may have height at this
548 // point. We position the maxiview as if the miniview was not displayed 552 // point. We position the maxiview as if the miniview was not displayed
549 // by subtracting off the miniview's total height (height + margin). 553 // by subtracting off the miniview's total height (height + margin).
550 var miniviewFudge = 40; // miniview margin-bottom + margin-top 554 var miniviewFudge = 40; // miniview margin-bottom + margin-top
551 var miniviewHeight = section.miniview.offsetHeight + miniviewFudge; 555 var miniviewHeight = section.miniview.offsetHeight + miniviewFudge;
552 section.maxiview.style.top = y - miniviewHeight + 'px'; 556 section.maxiview.style.top = y - miniviewHeight + 'px';
553 } 557 }
554 } 558 }
555 559
556 if (section.maxiview && section == expandedSection) 560 if (section.maxiview && section == expandedSection)
557 updateMask( 561 updateMask(
558 section.maxiview, expandedSectionHeight, expandedSectionIsClipped); 562 section.maxiview, expandedSectionHeight, expandedSectionIsClipped);
559 563
560 if (section == expandedSection) 564 if (section == expandedSection)
561 y += expandedSectionHeight; 565 y += expandedSectionHeight;
562 } 566 }
563 if (cr.isChromeOS) 567 if (cr.isChromeOS)
564 $('closed-sections-bar').style.top = y + 'px'; 568 $('closed-sections-bar').style.top = y + 'px';
565 569
570 // Position the notification container below the sync promo.
571 $('notification-container').style.top = sync_promo_height + 'px';
572
566 updateMenuSections(); 573 updateMenuSections();
567 updateAttributionDisplay(y); 574 updateAttributionDisplay(y);
568 } 575 }
569 576
570 function updateMask(maxiview, visibleHeightPx, isClipped) { 577 function updateMask(maxiview, visibleHeightPx, isClipped) {
571 // If the section isn't actually clipped, then we don't want to use a mask at 578 // If the section isn't actually clipped, then we don't want to use a mask at
572 // all, since enabling one turns off subpixel anti-aliasing. 579 // all, since enabling one turns off subpixel anti-aliasing.
573 if (!isClipped) { 580 if (!isClipped) {
574 maxiview.style.WebkitMaskImage = 'none'; 581 maxiview.style.WebkitMaskImage = 'none';
575 return; 582 return;
(...skipping 895 matching lines...) Expand 10 before | Expand all | Expand 10 after
1471 1478
1472 // Initialize the listener for the "hide this" link on the apps promo. We do 1479 // Initialize the listener for the "hide this" link on the apps promo. We do
1473 // this outside of getAppsCallback because it only needs to be done once per 1480 // this outside of getAppsCallback because it only needs to be done once per
1474 // NTP load. 1481 // NTP load.
1475 $('apps-promo-hide').addEventListener('click', function() { 1482 $('apps-promo-hide').addEventListener('click', function() {
1476 chrome.send('hideAppsPromo', []); 1483 chrome.send('hideAppsPromo', []);
1477 document.documentElement.classList.remove('apps-promo-visible'); 1484 document.documentElement.classList.remove('apps-promo-visible');
1478 layoutSections(); 1485 layoutSections();
1479 }); 1486 });
1480 }); 1487 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698