Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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; |
| 11 | 11 |
| 12 function getSectionCloseButton(sectionId) { | 12 function getSectionCloseButton(sectionId) { |
| 13 return document.querySelector('#' + sectionId + ' .section-close-button'); | 13 return document.querySelector('#' + sectionId + ' .section-close-button'); |
| 14 } | 14 } |
| 15 | 15 |
| 16 function getSectionMenuButton(sectionId) { | 16 function getSectionMenuButton(sectionId) { |
| 17 return $(sectionId + '-button'); | 17 return $(sectionId + '-button'); |
| 18 } | 18 } |
| 19 | 19 |
| 20 function getSectionMenuButtonTextId(sectionId) { | 20 function getSectionMenuButtonTextId(sectionId) { |
| 21 return sectionId.replace(/-/g, ''); | 21 return sectionId.replace(/-/g, ''); |
| 22 } | 22 } |
| 23 | 23 |
| 24 function setSectionVisible(sectionId, section, visible, hideMask) { | 24 function setSectionMenuMode(sectionId, section, menuModeEnabled, menuModeMask) { |
| 25 if (visible && !(shownSections & hideMask) || | 25 var el = $(sectionId); |
| 26 !visible && (shownSections & hideMask)) | 26 if (!menuModeEnabled) { |
| 27 return; | 27 // Because sections are collapsed when they are in menu mode, it is not |
| 28 | |
| 29 if (visible) { | |
| 30 // Because sections are collapsed when they are minimized, it is not | |
| 31 // necessary to restore the maxiview here. It will happen if the section | 28 // necessary to restore the maxiview here. It will happen if the section |
| 32 // header is clicked. | 29 // header is clicked. |
| 33 var el = $(sectionId); | 30 // TODO(aa): Sections should maintain their collapse state when minimized. |
| 34 el.classList.remove('disabled'); | 31 el.classList.remove('menu'); |
| 35 el = getSectionMenuButton(sectionId); | 32 shownSections &= ~menuModeMask; |
|
Aaron Boodman
2011/01/22 00:38:41
updateMenuSections() (called by layoutSections())
| |
| 36 el.classList.add('disabled'); | |
| 37 shownSections &= ~hideMask; | |
| 38 } else { | 33 } else { |
| 39 if (section) { | 34 if (section) { |
| 40 hideSection(section); // To hide the maxiview. | 35 hideSection(section); // To hide the maxiview. |
| 41 } | 36 } |
| 42 var el = $(sectionId); | 37 el.classList.add('menu'); |
| 43 el.classList.add('disabled'); | 38 shownSections |= menuModeMask; |
| 44 el = getSectionMenuButton(sectionId); | |
| 45 el.classList.remove('disabled'); | |
| 46 shownSections |= hideMask; | |
| 47 } | 39 } |
| 48 layoutSections(); | 40 layoutSections(); |
| 49 } | 41 } |
| 50 | 42 |
| 51 function clearClosedMenu(menu) { | 43 function clearClosedMenu(menu) { |
| 52 menu.innerHTML = ''; | 44 menu.innerHTML = ''; |
| 53 } | 45 } |
| 54 | 46 |
| 55 function addClosedMenuEntryWithLink(menu, a) { | 47 function addClosedMenuEntryWithLink(menu, a) { |
| 56 var span = document.createElement('span'); | 48 var span = document.createElement('span'); |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 78 } else { | 70 } else { |
| 79 a.textContent = | 71 a.textContent = |
| 80 localStrings.getString(getSectionMenuButtonTextId(sectionId)); | 72 localStrings.getString(getSectionMenuButtonTextId(sectionId)); |
| 81 } | 73 } |
| 82 a.className = 'item'; | 74 a.className = 'item'; |
| 83 a.addEventListener( | 75 a.addEventListener( |
| 84 'click', | 76 'click', |
| 85 function(e) { | 77 function(e) { |
| 86 getSectionMenuButton(sectionId).hideMenu(); | 78 getSectionMenuButton(sectionId).hideMenu(); |
| 87 e.preventDefault(); | 79 e.preventDefault(); |
| 88 setSectionVisible(sectionId, opt_section, true, mask); | 80 setSectionMenuMode(sectionId, opt_section, false, mask); |
| 89 shownSections &= ~mask; | 81 shownSections &= ~mask; |
| 90 saveShownSections(); | 82 saveShownSections(); |
| 91 }); | 83 }); |
| 92 menu.appendChild(span); | 84 menu.appendChild(span); |
| 93 } | 85 } |
| 94 | 86 |
| 95 function initializeSection(sectionId, mask, opt_section) { | 87 function initializeSection(sectionId, mask, opt_section) { |
| 96 var button = getSectionCloseButton(sectionId); | 88 var button = getSectionCloseButton(sectionId); |
| 97 button.addEventListener( | 89 button.addEventListener( |
| 98 'click', | 90 'click', |
| 99 function() { | 91 function() { |
| 100 setSectionVisible(sectionId, opt_section, false, mask); | 92 setSectionMenuMode(sectionId, opt_section, true, mask); |
| 101 saveShownSections(); | 93 saveShownSections(); |
| 102 }); | 94 }); |
| 103 } | 95 } |
| 104 | 96 |
| 105 function updateSimpleSection(id, section) { | 97 function updateSimpleSection(id, section) { |
| 106 var elm = $(id); | 98 var elm = $(id); |
| 107 var maxiview = getSectionMaxiview(elm); | 99 var maxiview = getSectionMaxiview(elm); |
| 108 var miniview = getSectionMiniview(elm); | 100 var miniview = getSectionMiniview(elm); |
| 109 if (shownSections & section) { | 101 if (shownSections & section) { |
| 110 // The section is expanded, so the maxiview should be opaque (visible) and | 102 // The section is expanded, so the maxiview should be opaque (visible) and |
| 111 // the miniview should be hidden. | 103 // the miniview should be hidden. |
| 112 elm.classList.remove('hidden'); | 104 elm.classList.remove('collapsed'); |
| 113 if (maxiview) { | 105 if (maxiview) { |
| 114 maxiview.classList.remove('hidden'); | 106 maxiview.classList.remove('collapsed'); |
| 115 maxiview.classList.add('opaque'); | 107 maxiview.classList.add('opaque'); |
| 116 } | 108 } |
| 117 if (miniview) | 109 if (miniview) |
| 118 miniview.classList.remove('opaque'); | 110 miniview.classList.remove('opaque'); |
| 119 } else { | 111 } else { |
| 120 // The section is minimized, so the maxiview should be hidden and the | 112 // The section is collapsed, so the maxiview should be hidden and the |
| 121 // miniview should be opaque. | 113 // miniview should be opaque. |
| 122 elm.classList.add('hidden'); | 114 elm.classList.add('collapsed'); |
| 123 if (maxiview) { | 115 if (maxiview) { |
| 124 maxiview.classList.add('hidden'); | 116 maxiview.classList.add('collapsed'); |
| 125 maxiview.classList.remove('opaque'); | 117 maxiview.classList.remove('opaque'); |
| 126 } | 118 } |
| 127 if (miniview) | 119 if (miniview) |
| 128 miniview.classList.add('opaque'); | 120 miniview.classList.add('opaque'); |
| 129 } | 121 } |
| 130 } | 122 } |
| 131 | 123 |
| 132 var sessionItems = []; | 124 var sessionItems = []; |
| 133 | 125 |
| 134 function foreignSessions(data) { | 126 function foreignSessions(data) { |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 236 var recentElement = $('recently-closed'); | 228 var recentElement = $('recently-closed'); |
| 237 var parentEl = recentElement.lastElementChild; | 229 var parentEl = recentElement.lastElementChild; |
| 238 parentEl.textContent = ''; | 230 parentEl.textContent = ''; |
| 239 var recentMenu = $('recently-closed-menu'); | 231 var recentMenu = $('recently-closed-menu'); |
| 240 clearClosedMenu(recentMenu); | 232 clearClosedMenu(recentMenu); |
| 241 | 233 |
| 242 recentItems.forEach(function(item) { | 234 recentItems.forEach(function(item) { |
| 243 parentEl.appendChild(createRecentItem(item)); | 235 parentEl.appendChild(createRecentItem(item)); |
| 244 addRecentMenuItem(recentMenu, item); | 236 addRecentMenuItem(recentMenu, item); |
| 245 }); | 237 }); |
| 246 addClosedMenuFooter(recentMenu, 'recently-closed', MINIMIZED_RECENT); | 238 addClosedMenuFooter(recentMenu, 'recently-closed', MENU_RECENT); |
| 247 | 239 |
| 248 layoutRecentlyClosed(); | 240 layoutRecentlyClosed(); |
| 249 } | 241 } |
| 250 | 242 |
| 251 function createRecentItem(data) { | 243 function createRecentItem(data) { |
| 252 var isWindow = data.type == 'window'; | 244 var isWindow = data.type == 'window'; |
| 253 var el; | 245 var el; |
| 254 if (isWindow) { | 246 if (isWindow) { |
| 255 el = document.createElement('span'); | 247 el = document.createElement('span'); |
| 256 el.className = 'item link window'; | 248 el.className = 'item link window'; |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 325 layoutSections(); | 317 layoutSections(); |
| 326 } | 318 } |
| 327 | 319 |
| 328 // Stores some information about each section necessary to layout. A new | 320 // Stores some information about each section necessary to layout. A new |
| 329 // instance is constructed for each section on each layout. | 321 // instance is constructed for each section on each layout. |
| 330 function SectionLayoutInfo(section) { | 322 function SectionLayoutInfo(section) { |
| 331 this.section = section; | 323 this.section = section; |
| 332 this.header = section.querySelector('h2'); | 324 this.header = section.querySelector('h2'); |
| 333 this.miniview = section.querySelector('.miniview'); | 325 this.miniview = section.querySelector('.miniview'); |
| 334 this.maxiview = getSectionMaxiview(section); | 326 this.maxiview = getSectionMaxiview(section); |
| 335 this.expanded = this.maxiview && !section.classList.contains('hidden'); | 327 this.expanded = this.maxiview && !section.classList.contains('collapsed'); |
| 336 this.fixedHeight = this.section.offsetHeight; | 328 this.fixedHeight = this.section.offsetHeight; |
| 337 this.scrollingHeight = 0; | 329 this.scrollingHeight = 0; |
| 338 | 330 |
| 339 if (this.expanded) | 331 if (this.expanded) |
| 340 this.scrollingHeight = this.maxiview.offsetHeight; | 332 this.scrollingHeight = this.maxiview.offsetHeight; |
| 341 } | 333 } |
| 342 | 334 |
| 343 // Get all sections to be layed out. | 335 // Get all sections to be layed out. |
| 344 SectionLayoutInfo.getAll = function() { | 336 SectionLayoutInfo.getAll = function() { |
| 345 var sections = document.querySelectorAll('.section:not(.disabled)'); | 337 var sections = document.querySelectorAll( |
| 338 '.section:not(.disabled):not(.menu)'); | |
| 346 var result = []; | 339 var result = []; |
| 347 for (var i = 0, section; section = sections[i]; i++) { | 340 for (var i = 0, section; section = sections[i]; i++) { |
| 348 result.push(new SectionLayoutInfo(section)); | 341 result.push(new SectionLayoutInfo(section)); |
| 349 } | 342 } |
| 350 return result; | 343 return result; |
| 351 }; | 344 }; |
| 352 | 345 |
| 353 // Ensure the miniview sections don't have any clipped items. | 346 // Ensure the miniview sections don't have any clipped items. |
| 354 function updateMiniviewClipping(miniview) { | 347 function updateMiniviewClipping(miniview) { |
| 355 var clipped = false; | 348 var clipped = false; |
| 356 for (var j = 0, item; item = miniview.children[j]; j++) { | 349 for (var j = 0, item; item = miniview.children[j]; j++) { |
| 357 item.style.display = ''; | 350 item.style.display = ''; |
| 358 if (clipped || | 351 if (clipped || |
| 359 (item.offsetLeft + item.offsetWidth) > miniview.offsetWidth) { | 352 (item.offsetLeft + item.offsetWidth) > miniview.offsetWidth) { |
| 360 item.style.display = 'none'; | 353 item.style.display = 'none'; |
| 361 clipped = true; | 354 clipped = true; |
| 362 } else { | 355 } else { |
| 363 item.style.display = ''; | 356 item.style.display = ''; |
| 364 } | 357 } |
| 365 } | 358 } |
| 366 } | 359 } |
| 367 | 360 |
| 368 // Ensure none of the miniviews have any clipped items. | 361 // Ensure none of the miniviews have any clipped items. |
| 369 function updateAllMiniviewClippings() { | 362 function updateAllMiniviewClippings() { |
| 370 var miniviews = document.querySelectorAll('.section.hidden .miniview'); | 363 var miniviews = document.querySelectorAll('.section.collapsed .miniview'); |
| 371 for (var i = 0, miniview; miniview = miniviews[i]; i++) { | 364 for (var i = 0, miniview; miniview = miniviews[i]; i++) { |
| 372 updateMiniviewClipping(miniview); | 365 updateMiniviewClipping(miniview); |
| 373 } | 366 } |
| 374 } | 367 } |
| 375 | 368 |
| 376 // Returns whether or not vertical scrollbars are present. | 369 // Returns whether or not vertical scrollbars are present. |
| 377 function hasScrollBars() { | 370 function hasScrollBars() { |
| 378 return window.innerHeight != document.body.clientHeight; | 371 return window.innerHeight != document.body.clientHeight; |
| 379 } | 372 } |
| 380 | 373 |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 479 expandedSection.scrollingHeight + | 472 expandedSection.scrollingHeight + |
| 480 footerHeight + | 473 footerHeight + |
| 481 fudge + | 474 fudge + |
| 482 'px'; | 475 'px'; |
| 483 } else { | 476 } else { |
| 484 expandedSectionHeight = expandedSection.scrollingHeight; | 477 expandedSectionHeight = expandedSection.scrollingHeight; |
| 485 document.body.style.height = ''; | 478 document.body.style.height = ''; |
| 486 } | 479 } |
| 487 } else { | 480 } else { |
| 488 // We only set the document height when a section is expanded. If | 481 // We only set the document height when a section is expanded. If |
| 489 // all sections are minimized, then get rid of the previous height. | 482 // all sections are collapsed, then get rid of the previous height. |
| 490 document.body.style.height = ''; | 483 document.body.style.height = ''; |
| 491 } | 484 } |
| 492 | 485 |
| 493 // Now position all the elements. | 486 // Now position all the elements. |
| 494 var y = LAYOUT_SPACING_TOP; | 487 var y = LAYOUT_SPACING_TOP; |
| 495 for (i = 0, section; section = sections[i]; i++) { | 488 for (i = 0, section; section = sections[i]; i++) { |
| 496 section.section.style.top = y + 'px'; | 489 section.section.style.top = y + 'px'; |
| 497 y += section.fixedHeight; | 490 y += section.fixedHeight; |
| 498 | 491 |
| 499 if (section.maxiview) { | 492 if (section.maxiview) { |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 511 | 504 |
| 512 if (section.maxiview && section == expandedSection) | 505 if (section.maxiview && section == expandedSection) |
| 513 updateMask(section.maxiview, expandedSectionHeight); | 506 updateMask(section.maxiview, expandedSectionHeight); |
| 514 | 507 |
| 515 if (section == expandedSection) | 508 if (section == expandedSection) |
| 516 y += expandedSectionHeight; | 509 y += expandedSectionHeight; |
| 517 } | 510 } |
| 518 if (cr.isChromeOS) | 511 if (cr.isChromeOS) |
| 519 $('closed-sections-bar').style.top = y + 'px'; | 512 $('closed-sections-bar').style.top = y + 'px'; |
| 520 | 513 |
| 514 updateMenuSections(); | |
| 521 updateAttributionDisplay(y); | 515 updateAttributionDisplay(y); |
| 522 } | 516 } |
| 523 | 517 |
| 524 function updateMask(maxiview, visibleHeightPx) { | 518 function updateMask(maxiview, visibleHeightPx) { |
| 525 // We want to end up with 10px gradients at the top and bottom of | 519 // We want to end up with 10px gradients at the top and bottom of |
| 526 // visibleHeight, but webkit-mask only supports expression in terms of | 520 // visibleHeight, but webkit-mask only supports expression in terms of |
| 527 // percentages. | 521 // percentages. |
| 528 | 522 |
| 529 // We might not have enough room to do 10px gradients on each side. To get the | 523 // We might not have enough room to do 10px gradients on each side. To get the |
| 530 // right effect, we don't want to make the gradients smaller, but make them | 524 // right effect, we don't want to make the gradients smaller, but make them |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 550 var gradient = '-webkit-linear-gradient(' + gradientArguments.join(',') + ')'; | 544 var gradient = '-webkit-linear-gradient(' + gradientArguments.join(',') + ')'; |
| 551 maxiview.style.WebkitMaskImage = gradient; | 545 maxiview.style.WebkitMaskImage = gradient; |
| 552 } | 546 } |
| 553 | 547 |
| 554 function getColorStopString(height, color) { | 548 function getColorStopString(height, color) { |
| 555 // TODO(arv): The CSS3 gradient syntax allows px units so we should simplify | 549 // TODO(arv): The CSS3 gradient syntax allows px units so we should simplify |
| 556 // this to use pixels instead. | 550 // this to use pixels instead. |
| 557 return color + ' ' + height * 100 + '%'; | 551 return color + ' ' + height * 100 + '%'; |
| 558 } | 552 } |
| 559 | 553 |
| 554 function updateMenuSections() { | |
| 555 var elms = document.getElementsByClassName('section'); | |
| 556 for (var i = 0, elm; elm = elms[i]; i++) { | |
| 557 var button = getSectionMenuButton(elm.id); | |
| 558 if (!button) | |
| 559 continue; | |
| 560 | |
| 561 if (!elm.classList.contains('disabled') && | |
| 562 elm.classList.contains('menu')) { | |
| 563 button.style.display = 'inline-block'; | |
| 564 } else { | |
| 565 button.style.display = 'none'; | |
| 566 } | |
| 567 } | |
| 568 } | |
| 569 | |
| 560 window.addEventListener('resize', handleWindowResize); | 570 window.addEventListener('resize', handleWindowResize); |
| 561 | 571 |
| 562 var sectionToElementMap; | 572 var sectionToElementMap; |
| 563 function getSectionElement(section) { | 573 function getSectionElement(section) { |
| 564 if (!sectionToElementMap) { | 574 if (!sectionToElementMap) { |
| 565 sectionToElementMap = {}; | 575 sectionToElementMap = {}; |
| 566 for (var key in Section) { | 576 for (var key in Section) { |
| 567 sectionToElementMap[Section[key]] = | 577 sectionToElementMap[Section[key]] = |
| 568 document.querySelector('.section[section=' + key + ']'); | 578 document.querySelector('.section[section=' + key + ']'); |
| 569 } | 579 } |
| 570 } | 580 } |
| 571 return sectionToElementMap[section]; | 581 return sectionToElementMap[section]; |
| 572 } | 582 } |
| 573 | 583 |
| 574 function getSectionMaxiview(section) { | 584 function getSectionMaxiview(section) { |
| 575 return $(section.id + '-maxiview'); | 585 return $(section.id + '-maxiview'); |
| 576 } | 586 } |
| 577 | 587 |
| 578 function getSectionMiniview(section) { | 588 function getSectionMiniview(section) { |
| 579 return section.querySelector('.miniview'); | 589 return section.querySelector('.miniview'); |
| 580 } | 590 } |
| 581 | 591 |
| 582 // You usually want to call |showOnlySection()| instead of this. | 592 // You usually want to call |showOnlySection()| instead of this. |
| 583 function showSection(section) { | 593 function showSection(section) { |
| 584 if (!(section & shownSections)) { | 594 if (!(section & shownSections)) { |
| 585 shownSections |= section; | 595 shownSections |= section; |
| 586 var el = getSectionElement(section); | 596 var el = getSectionElement(section); |
| 587 if (el) { | 597 if (el) { |
| 588 el.classList.remove('hidden'); | 598 el.classList.remove('collapsed'); |
| 589 | 599 |
| 590 var maxiview = getSectionMaxiview(el); | 600 var maxiview = getSectionMaxiview(el); |
| 591 if (maxiview) { | 601 if (maxiview) { |
| 592 maxiview.classList.remove('hiding'); | 602 maxiview.classList.remove('collapsing'); |
| 593 maxiview.classList.remove('hidden'); | 603 maxiview.classList.remove('collapsed'); |
| 594 // The opacity won't transition if you toggle the display property | 604 // The opacity won't transition if you toggle the display property |
| 595 // at the same time. To get a fade effect, we set the opacity | 605 // at the same time. To get a fade effect, we set the opacity |
| 596 // asynchronously from another function, after the display is toggled. | 606 // asynchronously from another function, after the display is toggled. |
| 597 // 1) 'hidden' (display: none, opacity: 0) | 607 // 1) 'collapsed' (display: none, opacity: 0) |
| 598 // 2) none (display: block, opacity: 0) | 608 // 2) none (display: block, opacity: 0) |
| 599 // 3) 'opaque' (display: block, opacity: 1) | 609 // 3) 'opaque' (display: block, opacity: 1) |
| 600 setTimeout(function () { | 610 setTimeout(function () { |
| 601 maxiview.classList.add('opaque'); | 611 maxiview.classList.add('opaque'); |
| 602 }, 0); | 612 }, 0); |
| 603 } | 613 } |
| 604 | 614 |
| 605 var miniview = getSectionMiniview(el); | 615 var miniview = getSectionMiniview(el); |
| 606 if (miniview) { | 616 if (miniview) { |
| 607 // The miniview is hidden immediately (no need to set this async). | 617 // The miniview is hidden immediately (no need to set this async). |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 635 | 645 |
| 636 switch (section) { | 646 switch (section) { |
| 637 case Section.THUMB: | 647 case Section.THUMB: |
| 638 mostVisited.visible = false; | 648 mostVisited.visible = false; |
| 639 mostVisited.layout(); | 649 mostVisited.layout(); |
| 640 break; | 650 break; |
| 641 } | 651 } |
| 642 | 652 |
| 643 var el = getSectionElement(section); | 653 var el = getSectionElement(section); |
| 644 if (el) { | 654 if (el) { |
| 645 el.classList.add('hidden'); | 655 el.classList.add('collapsed'); |
| 646 | 656 |
| 647 var maxiview = getSectionMaxiview(el); | 657 var maxiview = getSectionMaxiview(el); |
| 648 if (maxiview) { | 658 if (maxiview) { |
| 649 maxiview.classList.add(isDoneLoading() ? 'hiding' : 'hidden'); | 659 maxiview.classList.add(isDoneLoading() ? 'collapsing' : 'collapsed'); |
| 650 maxiview.classList.remove('opaque'); | 660 maxiview.classList.remove('opaque'); |
| 651 } | 661 } |
| 652 | 662 |
| 653 var miniview = getSectionMiniview(el); | 663 var miniview = getSectionMiniview(el); |
| 654 if (miniview) { | 664 if (miniview) { |
| 655 // We need to set this asynchronously to properly get the fade effect. | 665 // We need to set this asynchronously to properly get the fade effect. |
| 656 setTimeout(function() { | 666 setTimeout(function() { |
| 657 miniview.classList.add('opaque'); | 667 miniview.classList.add('opaque'); |
| 658 }, 0); | 668 }, 0); |
| 659 updateMiniviewClipping(miniview); | 669 updateMiniviewClipping(miniview); |
| 660 } | 670 } |
| 661 } | 671 } |
| 662 } | 672 } |
| 663 } | 673 } |
| 664 | 674 |
| 665 window.addEventListener('webkitTransitionEnd', function(e) { | 675 window.addEventListener('webkitTransitionEnd', function(e) { |
| 666 if (e.target.classList.contains('hiding')) { | 676 if (e.target.classList.contains('collapsing')) { |
| 667 e.target.classList.add('hidden'); | 677 e.target.classList.add('collapsed'); |
| 668 e.target.classList.remove('hiding'); | 678 e.target.classList.remove('collapsing'); |
| 669 } | 679 } |
| 670 | 680 |
| 671 if (e.target.classList.contains('maxiview') || | 681 if (e.target.classList.contains('maxiview') || |
| 672 e.target.classList.contains('miniview')) { | 682 e.target.classList.contains('miniview')) { |
| 673 document.documentElement.removeAttribute('enable-section-animations'); | 683 document.documentElement.removeAttribute('enable-section-animations'); |
| 674 showScrollBars(); | 684 showScrollBars(); |
| 675 } | 685 } |
| 676 }); | 686 }); |
| 677 | 687 |
| 678 /** | 688 /** |
| 679 * Callback when the shown sections changes in another NTP. | 689 * Callback when the shown sections changes in another NTP. |
| 680 * @param {number} newShownSections Bitmask of the shown sections. | 690 * @param {number} newShownSections Bitmask of the shown sections. |
| 681 */ | 691 */ |
| 682 function setShownSections(newShownSections) { | 692 function setShownSections(newShownSections) { |
| 683 for (var key in Section) { | 693 for (var key in Section) { |
| 684 if (newShownSections & Section[key]) | 694 if (newShownSections & Section[key]) |
| 685 showSection(Section[key]); | 695 showSection(Section[key]); |
| 686 else | 696 else |
| 687 hideSection(Section[key]); | 697 hideSection(Section[key]); |
| 688 } | 698 } |
| 689 setSectionVisible( | 699 setSectionMenuMode('apps', Section.APPS, newShownSections & MENU_APPS, |
| 690 'apps', Section.APPS, | 700 MENU_APPS); |
| 691 !(newShownSections & MINIMIZED_APPS), MINIMIZED_APPS); | 701 setSectionMenuMode('most-visited', Section.THUMB, |
| 692 setSectionVisible( | 702 newShownSections & MENU_THUMB, MENU_THUMB); |
| 693 'most-visited', Section.THUMB, | 703 setSectionMenuMode('recently-closed', undefined, |
| 694 !(newShownSections & MINIMIZED_THUMB), MINIMIZED_THUMB); | 704 newShownSections & MENU_RECENT, MENU_RECENT); |
| 695 setSectionVisible( | |
| 696 'recently-closed', undefined, | |
| 697 !(newShownSections & MINIMIZED_RECENT), MINIMIZED_RECENT); | |
| 698 layoutSections(); | 705 layoutSections(); |
| 699 } | 706 } |
| 700 | 707 |
| 701 // Recently closed | 708 // Recently closed |
| 702 | 709 |
| 703 function layoutRecentlyClosed() { | 710 function layoutRecentlyClosed() { |
| 704 var recentElement = $('recently-closed'); | 711 var recentElement = $('recently-closed'); |
| 705 var miniview = getSectionMiniview(recentElement); | 712 var miniview = getSectionMiniview(recentElement); |
| 706 | 713 |
| 707 updateMiniviewClipping(miniview); | 714 updateMiniviewClipping(miniview); |
| 708 | 715 |
| 709 if (miniview.hasChildNodes()) { | 716 if (miniview.hasChildNodes()) { |
| 710 if (!(shownSections & MINIMIZED_RECENT)) { | 717 recentElement.classList.remove('disabled'); |
|
Aaron Boodman
2011/01/22 00:38:41
No longer need to protect removing 'disabled' here
| |
| 711 recentElement.classList.remove('disabled'); | 718 miniview.classList.add('opaque'); |
| 712 miniview.classList.add('opaque'); | |
| 713 } | |
| 714 } else { | 719 } else { |
| 715 recentElement.classList.add('disabled'); | 720 recentElement.classList.add('disabled'); |
| 716 miniview.classList.remove('opaque'); | 721 miniview.classList.remove('opaque'); |
| 717 } | 722 } |
| 723 | |
| 724 layoutSections(); | |
| 718 } | 725 } |
| 719 | 726 |
| 720 /** | 727 /** |
| 721 * This function is called by the backend whenever the sync status section | 728 * This function is called by the backend whenever the sync status section |
| 722 * needs to be updated to reflect recent sync state changes. The backend passes | 729 * needs to be updated to reflect recent sync state changes. The backend passes |
| 723 * the new status information in the newMessage parameter. The state includes | 730 * the new status information in the newMessage parameter. The state includes |
| 724 * the following: | 731 * the following: |
| 725 * | 732 * |
| 726 * syncsectionisvisible: true if the sync section needs to show up on the new | 733 * syncsectionisvisible: true if the sync section needs to show up on the new |
| 727 * tab page and false otherwise. | 734 * tab page and false otherwise. |
| (...skipping 654 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1382 var promoLink = document.querySelector('#apps-promo-text1 a'); | 1389 var promoLink = document.querySelector('#apps-promo-text1 a'); |
| 1383 promoLink.id = 'apps-promo-link'; | 1390 promoLink.id = 'apps-promo-link'; |
| 1384 promoLink.href = localStrings.getString('web_store_url'); | 1391 promoLink.href = localStrings.getString('web_store_url'); |
| 1385 | 1392 |
| 1386 $('apps-promo-hide').addEventListener('click', function() { | 1393 $('apps-promo-hide').addEventListener('click', function() { |
| 1387 chrome.send('hideAppsPromo', []); | 1394 chrome.send('hideAppsPromo', []); |
| 1388 document.documentElement.classList.remove('apps-promo-visible'); | 1395 document.documentElement.classList.remove('apps-promo-visible'); |
| 1389 layoutSections(); | 1396 layoutSections(); |
| 1390 }); | 1397 }); |
| 1391 }); | 1398 }); |
| OLD | NEW |