| 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 // 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 Loading... |
| 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 Loading... |
| 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 845 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1421 updateAttribution(); | 1428 updateAttribution(); |
| 1422 | 1429 |
| 1423 function initializeLogin() { | 1430 function initializeLogin() { |
| 1424 chrome.send('initializeLogin', []); | 1431 chrome.send('initializeLogin', []); |
| 1425 } | 1432 } |
| 1426 | 1433 |
| 1427 function updateLogin(login) { | 1434 function updateLogin(login) { |
| 1428 $('login-container').style.display = login ? 'block' : ''; | 1435 $('login-container').style.display = login ? 'block' : ''; |
| 1429 if (login) | 1436 if (login) |
| 1430 $('login-username').textContent = login; | 1437 $('login-username').textContent = login; |
| 1431 | |
| 1432 } | 1438 } |
| 1433 | 1439 |
| 1434 var mostVisited = new MostVisited( | 1440 var mostVisited = new MostVisited( |
| 1435 $('most-visited-maxiview'), | 1441 $('most-visited-maxiview'), |
| 1436 document.querySelector('#most-visited .miniview'), | 1442 document.querySelector('#most-visited .miniview'), |
| 1437 $('most-visited-menu'), | 1443 $('most-visited-menu'), |
| 1438 useSmallGrid(), | 1444 useSmallGrid(), |
| 1439 shownSections & Section.THUMB); | 1445 shownSections & Section.THUMB); |
| 1440 | 1446 |
| 1441 function setMostVisitedPages(data, firstRun, hasBlacklistedUrls) { | 1447 function setMostVisitedPages(data, firstRun, hasBlacklistedUrls) { |
| (...skipping 30 matching lines...) Expand all Loading... |
| 1472 | 1478 |
| 1473 // 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 |
| 1474 // 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 |
| 1475 // NTP load. | 1481 // NTP load. |
| 1476 $('apps-promo-hide').addEventListener('click', function() { | 1482 $('apps-promo-hide').addEventListener('click', function() { |
| 1477 chrome.send('hideAppsPromo', []); | 1483 chrome.send('hideAppsPromo', []); |
| 1478 document.documentElement.classList.remove('apps-promo-visible'); | 1484 document.documentElement.classList.remove('apps-promo-visible'); |
| 1479 layoutSections(); | 1485 layoutSections(); |
| 1480 }); | 1486 }); |
| 1481 }); | 1487 }); |
| OLD | NEW |