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; |
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 // Updates the visibility of the menu buttons for each section, based on |
| 555 // whether they are currently enabled and in menu mode. |
| 556 function updateMenuSections() { |
| 557 var elms = document.getElementsByClassName('section'); |
| 558 for (var i = 0, elm; elm = elms[i]; i++) { |
| 559 var button = getSectionMenuButton(elm.id); |
| 560 if (!button) |
| 561 continue; |
| 562 |
| 563 if (!elm.classList.contains('disabled') && |
| 564 elm.classList.contains('menu')) { |
| 565 button.style.display = 'inline-block'; |
| 566 } else { |
| 567 button.style.display = 'none'; |
| 568 } |
| 569 } |
| 570 } |
| 571 |
560 window.addEventListener('resize', handleWindowResize); | 572 window.addEventListener('resize', handleWindowResize); |
561 | 573 |
562 var sectionToElementMap; | 574 var sectionToElementMap; |
563 function getSectionElement(section) { | 575 function getSectionElement(section) { |
564 if (!sectionToElementMap) { | 576 if (!sectionToElementMap) { |
565 sectionToElementMap = {}; | 577 sectionToElementMap = {}; |
566 for (var key in Section) { | 578 for (var key in Section) { |
567 sectionToElementMap[Section[key]] = | 579 sectionToElementMap[Section[key]] = |
568 document.querySelector('.section[section=' + key + ']'); | 580 document.querySelector('.section[section=' + key + ']'); |
569 } | 581 } |
570 } | 582 } |
571 return sectionToElementMap[section]; | 583 return sectionToElementMap[section]; |
572 } | 584 } |
573 | 585 |
574 function getSectionMaxiview(section) { | 586 function getSectionMaxiview(section) { |
575 return $(section.id + '-maxiview'); | 587 return $(section.id + '-maxiview'); |
576 } | 588 } |
577 | 589 |
578 function getSectionMiniview(section) { | 590 function getSectionMiniview(section) { |
579 return section.querySelector('.miniview'); | 591 return section.querySelector('.miniview'); |
580 } | 592 } |
581 | 593 |
582 // You usually want to call |showOnlySection()| instead of this. | 594 // You usually want to call |showOnlySection()| instead of this. |
583 function showSection(section) { | 595 function showSection(section) { |
584 if (!(section & shownSections)) { | 596 if (!(section & shownSections)) { |
585 shownSections |= section; | 597 shownSections |= section; |
586 var el = getSectionElement(section); | 598 var el = getSectionElement(section); |
587 if (el) { | 599 if (el) { |
588 el.classList.remove('hidden'); | 600 el.classList.remove('collapsed'); |
589 | 601 |
590 var maxiview = getSectionMaxiview(el); | 602 var maxiview = getSectionMaxiview(el); |
591 if (maxiview) { | 603 if (maxiview) { |
592 maxiview.classList.remove('hiding'); | 604 maxiview.classList.remove('collapsing'); |
593 maxiview.classList.remove('hidden'); | 605 maxiview.classList.remove('collapsed'); |
594 // The opacity won't transition if you toggle the display property | 606 // 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 | 607 // at the same time. To get a fade effect, we set the opacity |
596 // asynchronously from another function, after the display is toggled. | 608 // asynchronously from another function, after the display is toggled. |
597 // 1) 'hidden' (display: none, opacity: 0) | 609 // 1) 'collapsed' (display: none, opacity: 0) |
598 // 2) none (display: block, opacity: 0) | 610 // 2) none (display: block, opacity: 0) |
599 // 3) 'opaque' (display: block, opacity: 1) | 611 // 3) 'opaque' (display: block, opacity: 1) |
600 setTimeout(function () { | 612 setTimeout(function () { |
601 maxiview.classList.add('opaque'); | 613 maxiview.classList.add('opaque'); |
602 }, 0); | 614 }, 0); |
603 } | 615 } |
604 | 616 |
605 var miniview = getSectionMiniview(el); | 617 var miniview = getSectionMiniview(el); |
606 if (miniview) { | 618 if (miniview) { |
607 // The miniview is hidden immediately (no need to set this async). | 619 // The miniview is hidden immediately (no need to set this async). |
(...skipping 27 matching lines...) Expand all Loading... |
635 | 647 |
636 switch (section) { | 648 switch (section) { |
637 case Section.THUMB: | 649 case Section.THUMB: |
638 mostVisited.visible = false; | 650 mostVisited.visible = false; |
639 mostVisited.layout(); | 651 mostVisited.layout(); |
640 break; | 652 break; |
641 } | 653 } |
642 | 654 |
643 var el = getSectionElement(section); | 655 var el = getSectionElement(section); |
644 if (el) { | 656 if (el) { |
645 el.classList.add('hidden'); | 657 el.classList.add('collapsed'); |
646 | 658 |
647 var maxiview = getSectionMaxiview(el); | 659 var maxiview = getSectionMaxiview(el); |
648 if (maxiview) { | 660 if (maxiview) { |
649 maxiview.classList.add(isDoneLoading() ? 'hiding' : 'hidden'); | 661 maxiview.classList.add(isDoneLoading() ? 'collapsing' : 'collapsed'); |
650 maxiview.classList.remove('opaque'); | 662 maxiview.classList.remove('opaque'); |
651 } | 663 } |
652 | 664 |
653 var miniview = getSectionMiniview(el); | 665 var miniview = getSectionMiniview(el); |
654 if (miniview) { | 666 if (miniview) { |
655 // We need to set this asynchronously to properly get the fade effect. | 667 // We need to set this asynchronously to properly get the fade effect. |
656 setTimeout(function() { | 668 setTimeout(function() { |
657 miniview.classList.add('opaque'); | 669 miniview.classList.add('opaque'); |
658 }, 0); | 670 }, 0); |
659 updateMiniviewClipping(miniview); | 671 updateMiniviewClipping(miniview); |
660 } | 672 } |
661 } | 673 } |
662 } | 674 } |
663 } | 675 } |
664 | 676 |
665 window.addEventListener('webkitTransitionEnd', function(e) { | 677 window.addEventListener('webkitTransitionEnd', function(e) { |
666 if (e.target.classList.contains('hiding')) { | 678 if (e.target.classList.contains('collapsing')) { |
667 e.target.classList.add('hidden'); | 679 e.target.classList.add('collapsed'); |
668 e.target.classList.remove('hiding'); | 680 e.target.classList.remove('collapsing'); |
669 } | 681 } |
670 | 682 |
671 if (e.target.classList.contains('maxiview') || | 683 if (e.target.classList.contains('maxiview') || |
672 e.target.classList.contains('miniview')) { | 684 e.target.classList.contains('miniview')) { |
673 document.documentElement.removeAttribute('enable-section-animations'); | 685 document.documentElement.removeAttribute('enable-section-animations'); |
674 showScrollBars(); | 686 showScrollBars(); |
675 } | 687 } |
676 }); | 688 }); |
677 | 689 |
678 /** | 690 /** |
679 * Callback when the shown sections changes in another NTP. | 691 * Callback when the shown sections changes in another NTP. |
680 * @param {number} newShownSections Bitmask of the shown sections. | 692 * @param {number} newShownSections Bitmask of the shown sections. |
681 */ | 693 */ |
682 function setShownSections(newShownSections) { | 694 function setShownSections(newShownSections) { |
683 for (var key in Section) { | 695 for (var key in Section) { |
684 if (newShownSections & Section[key]) | 696 if (newShownSections & Section[key]) |
685 showSection(Section[key]); | 697 showSection(Section[key]); |
686 else | 698 else |
687 hideSection(Section[key]); | 699 hideSection(Section[key]); |
688 } | 700 } |
689 setSectionVisible( | 701 setSectionMenuMode('apps', Section.APPS, newShownSections & MENU_APPS, |
690 'apps', Section.APPS, | 702 MENU_APPS); |
691 !(newShownSections & MINIMIZED_APPS), MINIMIZED_APPS); | 703 setSectionMenuMode('most-visited', Section.THUMB, |
692 setSectionVisible( | 704 newShownSections & MENU_THUMB, MENU_THUMB); |
693 'most-visited', Section.THUMB, | 705 setSectionMenuMode('recently-closed', undefined, |
694 !(newShownSections & MINIMIZED_THUMB), MINIMIZED_THUMB); | 706 newShownSections & MENU_RECENT, MENU_RECENT); |
695 setSectionVisible( | |
696 'recently-closed', undefined, | |
697 !(newShownSections & MINIMIZED_RECENT), MINIMIZED_RECENT); | |
698 layoutSections(); | 707 layoutSections(); |
699 } | 708 } |
700 | 709 |
701 // Recently closed | 710 // Recently closed |
702 | 711 |
703 function layoutRecentlyClosed() { | 712 function layoutRecentlyClosed() { |
704 var recentElement = $('recently-closed'); | 713 var recentElement = $('recently-closed'); |
705 var miniview = getSectionMiniview(recentElement); | 714 var miniview = getSectionMiniview(recentElement); |
706 | 715 |
707 updateMiniviewClipping(miniview); | 716 updateMiniviewClipping(miniview); |
708 | 717 |
709 if (miniview.hasChildNodes()) { | 718 if (miniview.hasChildNodes()) { |
710 if (!(shownSections & MINIMIZED_RECENT)) { | 719 recentElement.classList.remove('disabled'); |
711 recentElement.classList.remove('disabled'); | 720 miniview.classList.add('opaque'); |
712 miniview.classList.add('opaque'); | |
713 } | |
714 } else { | 721 } else { |
715 recentElement.classList.add('disabled'); | 722 recentElement.classList.add('disabled'); |
716 miniview.classList.remove('opaque'); | 723 miniview.classList.remove('opaque'); |
717 } | 724 } |
| 725 |
| 726 layoutSections(); |
718 } | 727 } |
719 | 728 |
720 /** | 729 /** |
721 * This function is called by the backend whenever the sync status section | 730 * 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 | 731 * 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 | 732 * the new status information in the newMessage parameter. The state includes |
724 * the following: | 733 * the following: |
725 * | 734 * |
726 * syncsectionisvisible: true if the sync section needs to show up on the new | 735 * syncsectionisvisible: true if the sync section needs to show up on the new |
727 * tab page and false otherwise. | 736 * 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'); | 1391 var promoLink = document.querySelector('#apps-promo-text1 a'); |
1383 promoLink.id = 'apps-promo-link'; | 1392 promoLink.id = 'apps-promo-link'; |
1384 promoLink.href = localStrings.getString('web_store_url'); | 1393 promoLink.href = localStrings.getString('web_store_url'); |
1385 | 1394 |
1386 $('apps-promo-hide').addEventListener('click', function() { | 1395 $('apps-promo-hide').addEventListener('click', function() { |
1387 chrome.send('hideAppsPromo', []); | 1396 chrome.send('hideAppsPromo', []); |
1388 document.documentElement.classList.remove('apps-promo-visible'); | 1397 document.documentElement.classList.remove('apps-promo-visible'); |
1389 layoutSections(); | 1398 layoutSections(); |
1390 }); | 1399 }); |
1391 }); | 1400 }); |
OLD | NEW |