| 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. |
| 10 var LAYOUT_SPACING_TOP = 5; |
| 11 |
| 9 var loading = true; | 12 var loading = true; |
| 10 | 13 |
| 11 function updateSimpleSection(id, section) { | 14 function updateSimpleSection(id, section) { |
| 12 if (shownSections & section) | 15 if (shownSections & section) |
| 13 $(id).classList.remove('hidden'); | 16 $(id).classList.remove('hidden'); |
| 14 else | 17 else |
| 15 $(id).classList.add('hidden'); | 18 $(id).classList.add('hidden'); |
| 16 } | 19 } |
| 17 | 20 |
| 18 function recentlyClosedTabs(data) { | 21 function recentlyClosedTabs(data) { |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 145 // of the viewport. | 148 // of the viewport. |
| 146 // | 149 // |
| 147 // There is a final twist: If the intrinsic height of the expanded section is | 150 // There is a final twist: If the intrinsic height of the expanded section is |
| 148 // less than the available height (because the window is tall), any collapsed | 151 // less than the available height (because the window is tall), any collapsed |
| 149 // sections sinch up and sit below the expanded section. This is so that we | 152 // sections sinch up and sit below the expanded section. This is so that we |
| 150 // don't have a bunch of dead whitespace in the case of expanded sections that | 153 // don't have a bunch of dead whitespace in the case of expanded sections that |
| 151 // aren't very tall. | 154 // aren't very tall. |
| 152 function layoutSections() { | 155 function layoutSections() { |
| 153 var sections = SectionLayoutInfo.getAll(); | 156 var sections = SectionLayoutInfo.getAll(); |
| 154 var expandedSection = null; | 157 var expandedSection = null; |
| 155 var headerHeight = 0; | 158 var headerHeight = LAYOUT_SPACING_TOP; |
| 156 var footerHeight = 0; | 159 var footerHeight = 0; |
| 157 | 160 |
| 158 // Calculate the height of the fixed elements above the expanded section. Also | 161 // Calculate the height of the fixed elements above the expanded section. Also |
| 159 // take note of the expanded section, if there is one. | 162 // take note of the expanded section, if there is one. |
| 160 var i; | 163 var i; |
| 161 var section; | 164 var section; |
| 162 for (i = 0; section = sections[i]; i++) { | 165 for (i = 0; section = sections[i]; i++) { |
| 163 headerHeight += section.fixedHeight; | 166 headerHeight += section.fixedHeight; |
| 164 if (section.expanded) { | 167 if (section.expanded) { |
| 165 expandedSection = section; | 168 expandedSection = section; |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 197 footerHeight + | 200 footerHeight + |
| 198 fudge + | 201 fudge + |
| 199 'px'; | 202 'px'; |
| 200 } else { | 203 } else { |
| 201 expandedSectionHeight = expandedSection.scrollingHeight; | 204 expandedSectionHeight = expandedSection.scrollingHeight; |
| 202 document.body.style.height = ''; | 205 document.body.style.height = ''; |
| 203 } | 206 } |
| 204 } | 207 } |
| 205 | 208 |
| 206 // Now position all the elements. | 209 // Now position all the elements. |
| 207 var y = 0; | 210 var y = LAYOUT_SPACING_TOP; |
| 208 for (i = 0, section; section = sections[i]; i++) { | 211 for (i = 0, section; section = sections[i]; i++) { |
| 209 section.header.style.top = y + 'px'; | 212 section.header.style.top = y + 'px'; |
| 210 y += section.header.offsetHeight; | 213 y += section.header.offsetHeight; |
| 211 | 214 |
| 212 if (section.miniview) { | 215 if (section.miniview) { |
| 213 section.miniview.style.top = y + 'px'; | 216 section.miniview.style.top = y + 'px'; |
| 214 if (section != expandedSection) { | 217 if (section != expandedSection) { |
| 215 y += section.miniview.offsetHeight; | 218 y += section.miniview.offsetHeight; |
| 216 } | 219 } |
| 217 } | 220 } |
| (...skipping 512 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 730 var p = e.target; | 733 var p = e.target; |
| 731 while (p && p.tagName != 'H2') { | 734 while (p && p.tagName != 'H2') { |
| 732 p = p.parentNode; | 735 p = p.parentNode; |
| 733 } | 736 } |
| 734 | 737 |
| 735 if (!p) { | 738 if (!p) { |
| 736 return; | 739 return; |
| 737 } | 740 } |
| 738 | 741 |
| 739 p = p.parentNode; | 742 p = p.parentNode; |
| 740 if (p.noexpand) { | 743 if (p.hasAttribute('noexpand')) { |
| 741 return; | 744 return; |
| 742 } | 745 } |
| 743 | 746 |
| 744 var section = p.getAttribute('section'); | 747 var section = p.getAttribute('section'); |
| 745 if (section) { | 748 if (section) { |
| 746 if (shownSections & Section[section]) { | 749 if (shownSections & Section[section]) { |
| 747 hideSection(Section[section]); | 750 hideSection(Section[section]); |
| 748 } else { | 751 } else { |
| 749 for (var p in Section) { | 752 for (var p in Section) { |
| 750 if (p == section) | 753 if (p == section) |
| (...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1019 window.setTimeout(function() { | 1022 window.setTimeout(function() { |
| 1020 mostVisited.ensureSmallGridCorrect(); | 1023 mostVisited.ensureSmallGridCorrect(); |
| 1021 document.body.classList.remove('loading'); | 1024 document.body.classList.remove('loading'); |
| 1022 }, 1); | 1025 }, 1); |
| 1023 | 1026 |
| 1024 // Only show the first run notification if first run. | 1027 // Only show the first run notification if first run. |
| 1025 if (firstRun) { | 1028 if (firstRun) { |
| 1026 showFirstRunNotification(); | 1029 showFirstRunNotification(); |
| 1027 } | 1030 } |
| 1028 } | 1031 } |
| OLD | NEW |