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; |
| (...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 188 winEl.sessionTag = win.sessionTag; | 188 winEl.sessionTag = win.sessionTag; |
| 189 winEl.winNum = i; | 189 winEl.winNum = i; |
| 190 winEl.addEventListener('click', maybeOpenForeignWindow); | 190 winEl.addEventListener('click', maybeOpenForeignWindow); |
| 191 winEl.addEventListener('keydown', | 191 winEl.addEventListener('keydown', |
| 192 handleIfEnterKey(maybeOpenForeignWindow)); | 192 handleIfEnterKey(maybeOpenForeignWindow)); |
| 193 winSpan.appendChild(winEl); | 193 winSpan.appendChild(winEl); |
| 194 | 194 |
| 195 // Sort tabs by MRU order | 195 // Sort tabs by MRU order |
| 196 win.tabs.sort(function(a, b) { | 196 win.tabs.sort(function(a, b) { |
| 197 return a.timestamp < b.timestamp; | 197 return a.timestamp < b.timestamp; |
| 198 }) | 198 }); |
| 199 | 199 |
| 200 // Create individual tab information. | 200 // Create individual tab information. |
| 201 win.tabs.forEach(function(data) { | 201 win.tabs.forEach(function(data) { |
| 202 var tabEl = document.createElement('a'); | 202 var tabEl = document.createElement('a'); |
| 203 tabEl.className = 'item link tab'; | 203 tabEl.className = 'item link tab'; |
| 204 tabEl.href = data.timestamp; | 204 tabEl.href = data.timestamp; |
| 205 tabEl.style.backgroundImage = url('chrome://favicon/' + data.url); | 205 tabEl.style.backgroundImage = url('chrome://favicon/' + data.url); |
| 206 tabEl.dir = data.direction; | 206 tabEl.dir = data.direction; |
| 207 tabEl.textContent = data.title; | 207 tabEl.textContent = data.title; |
| 208 tabEl.sessionTag = win.sessionTag; | 208 tabEl.sessionTag = win.sessionTag; |
| 209 tabEl.winNum = i; | 209 tabEl.winNum = i; |
| 210 tabEl.sessionId = data.sessionId; | 210 tabEl.sessionId = data.sessionId; |
| 211 tabEl.addEventListener('click', maybeOpenForeignTab); | 211 tabEl.addEventListener('click', maybeOpenForeignTab); |
| 212 tabEl.addEventListener('keydown', | 212 tabEl.addEventListener('keydown', |
| 213 handleIfEnterKey(maybeOpenForeignTab)); | 213 handleIfEnterKey(maybeOpenForeignTab)); |
| 214 | 214 |
| 215 winSpan.appendChild(tabEl); | 215 winSpan.appendChild(tabEl); |
| 216 }) | 216 }); |
| 217 | 217 |
| 218 // Append the window. | 218 // Append the window. |
| 219 stack.appendChild(winSpan); | 219 stack.appendChild(winSpan); |
| 220 }); | 220 }); |
| 221 return stack; | 221 return stack; |
| 222 } | 222 } |
| 223 | 223 |
| 224 var recentItems = []; | 224 var recentItems = []; |
| 225 | 225 |
| 226 function recentlyClosedTabs(data) { | 226 function recentlyClosedTabs(data) { |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 310 return; | 310 return; |
| 311 } | 311 } |
| 312 | 312 |
| 313 var oldLayoutMode = layoutMode; | 313 var oldLayoutMode = layoutMode; |
| 314 var b = useSmallGrid(); | 314 var b = useSmallGrid(); |
| 315 layoutMode = b ? LayoutMode.SMALL : LayoutMode.NORMAL; | 315 layoutMode = b ? LayoutMode.SMALL : LayoutMode.NORMAL; |
| 316 | 316 |
| 317 if (layoutMode != oldLayoutMode){ | 317 if (layoutMode != oldLayoutMode){ |
| 318 mostVisited.useSmallGrid = b; | 318 mostVisited.useSmallGrid = b; |
| 319 mostVisited.layout(); | 319 mostVisited.layout(); |
| 320 apps.invalidate(); | |
| 321 apps.layout(); | |
| 320 renderRecentlyClosed(); | 322 renderRecentlyClosed(); |
| 321 renderForeignSessions(); | 323 renderForeignSessions(); |
| 322 updateAllMiniviewClippings(); | 324 updateAllMiniviewClippings(); |
| 323 } | 325 } |
| 324 | 326 |
| 325 layoutSections(); | 327 layoutSections(); |
| 326 } | 328 } |
| 327 | 329 |
| 328 // Stores some information about each section necessary to layout. A new | 330 // Stores some information about each section necessary to layout. A new |
| 329 // instance is constructed for each section on each layout. | 331 // instance is constructed for each section on each layout. |
| (...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 607 // The miniview is hidden immediately (no need to set this async). | 609 // The miniview is hidden immediately (no need to set this async). |
| 608 miniview.classList.remove('opaque'); | 610 miniview.classList.remove('opaque'); |
| 609 } | 611 } |
| 610 } | 612 } |
| 611 | 613 |
| 612 switch (section) { | 614 switch (section) { |
| 613 case Section.THUMB: | 615 case Section.THUMB: |
| 614 mostVisited.visible = true; | 616 mostVisited.visible = true; |
| 615 mostVisited.layout(); | 617 mostVisited.layout(); |
| 616 break; | 618 break; |
| 619 case Section.APPS: | |
| 620 apps.visible = true; | |
|
Aaron Boodman
2011/01/22 23:42:57
The visible flag here (and in mostVisited ftm) see
jstritar
2011/01/24 01:00:42
I think we could use the classes to determine visi
| |
| 621 apps.layout(true); | |
| 617 } | 622 } |
| 618 } | 623 } |
| 619 } | 624 } |
| 620 | 625 |
| 621 // Show this section and hide all other sections - at most one section can | 626 // Show this section and hide all other sections - at most one section can |
| 622 // be open at one time. | 627 // be open at one time. |
| 623 function showOnlySection(section) { | 628 function showOnlySection(section) { |
| 624 for (var p in Section) { | 629 for (var p in Section) { |
| 625 if (p == section) | 630 if (p == section) |
| 626 showSection(Section[p]); | 631 showSection(Section[p]); |
| 627 else | 632 else |
| 628 hideSection(Section[p]); | 633 hideSection(Section[p]); |
| 629 } | 634 } |
| 630 } | 635 } |
| 631 | 636 |
| 632 function hideSection(section) { | 637 function hideSection(section) { |
| 633 if (section & shownSections) { | 638 if (section & shownSections) { |
| 634 shownSections &= ~section; | 639 shownSections &= ~section; |
| 635 | 640 |
| 636 switch (section) { | 641 switch (section) { |
| 637 case Section.THUMB: | 642 case Section.THUMB: |
| 638 mostVisited.visible = false; | 643 mostVisited.visible = false; |
| 639 mostVisited.layout(); | 644 mostVisited.layout(); |
| 640 break; | 645 break; |
| 646 case Section.APPS: | |
| 647 apps.visible = false; | |
| 648 apps.layout(); | |
| 649 break; | |
| 641 } | 650 } |
| 642 | 651 |
| 643 var el = getSectionElement(section); | 652 var el = getSectionElement(section); |
| 644 if (el) { | 653 if (el) { |
| 645 el.classList.add('hidden'); | 654 el.classList.add('hidden'); |
| 646 | 655 |
| 647 var maxiview = getSectionMaxiview(el); | 656 var maxiview = getSectionMaxiview(el); |
| 648 if (maxiview) { | 657 if (maxiview) { |
| 649 maxiview.classList.add(isDoneLoading() ? 'hiding' : 'hidden'); | 658 maxiview.classList.add(isDoneLoading() ? 'hiding' : 'hidden'); |
| 650 maxiview.classList.remove('opaque'); | 659 maxiview.classList.remove('opaque'); |
| (...skipping 731 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 |