Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3)

Side by Side Diff: chrome/browser/resources/new_new_tab.js

Issue 6297013: [NTP] Allow reordering of apps via drag and drop. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: nit Created 9 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/resources/new_new_tab.html ('k') | chrome/browser/resources/ntp/apps.css » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 winEl.sessionTag = win.sessionTag; 180 winEl.sessionTag = win.sessionTag;
181 winEl.winNum = i; 181 winEl.winNum = i;
182 winEl.addEventListener('click', maybeOpenForeignWindow); 182 winEl.addEventListener('click', maybeOpenForeignWindow);
183 winEl.addEventListener('keydown', 183 winEl.addEventListener('keydown',
184 handleIfEnterKey(maybeOpenForeignWindow)); 184 handleIfEnterKey(maybeOpenForeignWindow));
185 winSpan.appendChild(winEl); 185 winSpan.appendChild(winEl);
186 186
187 // Sort tabs by MRU order 187 // Sort tabs by MRU order
188 win.tabs.sort(function(a, b) { 188 win.tabs.sort(function(a, b) {
189 return a.timestamp < b.timestamp; 189 return a.timestamp < b.timestamp;
190 }) 190 });
191 191
192 // Create individual tab information. 192 // Create individual tab information.
193 win.tabs.forEach(function(data) { 193 win.tabs.forEach(function(data) {
194 var tabEl = document.createElement('a'); 194 var tabEl = document.createElement('a');
195 tabEl.className = 'item link tab'; 195 tabEl.className = 'item link tab';
196 tabEl.href = data.timestamp; 196 tabEl.href = data.timestamp;
197 tabEl.style.backgroundImage = url('chrome://favicon/' + data.url); 197 tabEl.style.backgroundImage = url('chrome://favicon/' + data.url);
198 tabEl.dir = data.direction; 198 tabEl.dir = data.direction;
199 tabEl.textContent = data.title; 199 tabEl.textContent = data.title;
200 tabEl.sessionTag = win.sessionTag; 200 tabEl.sessionTag = win.sessionTag;
201 tabEl.winNum = i; 201 tabEl.winNum = i;
202 tabEl.sessionId = data.sessionId; 202 tabEl.sessionId = data.sessionId;
203 tabEl.addEventListener('click', maybeOpenForeignTab); 203 tabEl.addEventListener('click', maybeOpenForeignTab);
204 tabEl.addEventListener('keydown', 204 tabEl.addEventListener('keydown',
205 handleIfEnterKey(maybeOpenForeignTab)); 205 handleIfEnterKey(maybeOpenForeignTab));
206 206
207 winSpan.appendChild(tabEl); 207 winSpan.appendChild(tabEl);
208 }) 208 });
209 209
210 // Append the window. 210 // Append the window.
211 stack.appendChild(winSpan); 211 stack.appendChild(winSpan);
212 }); 212 });
213 return stack; 213 return stack;
214 } 214 }
215 215
216 var recentItems = []; 216 var recentItems = [];
217 217
218 function recentlyClosedTabs(data) { 218 function recentlyClosedTabs(data) {
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
302 return; 302 return;
303 } 303 }
304 304
305 var oldLayoutMode = layoutMode; 305 var oldLayoutMode = layoutMode;
306 var b = useSmallGrid(); 306 var b = useSmallGrid();
307 layoutMode = b ? LayoutMode.SMALL : LayoutMode.NORMAL; 307 layoutMode = b ? LayoutMode.SMALL : LayoutMode.NORMAL;
308 308
309 if (layoutMode != oldLayoutMode){ 309 if (layoutMode != oldLayoutMode){
310 mostVisited.useSmallGrid = b; 310 mostVisited.useSmallGrid = b;
311 mostVisited.layout(); 311 mostVisited.layout();
312 apps.layout({force:true});
312 renderRecentlyClosed(); 313 renderRecentlyClosed();
313 renderForeignSessions(); 314 renderForeignSessions();
314 updateAllMiniviewClippings(); 315 updateAllMiniviewClippings();
315 } 316 }
316 317
317 layoutSections(); 318 layoutSections();
318 } 319 }
319 320
320 // Stores some information about each section necessary to layout. A new 321 // Stores some information about each section necessary to layout. A new
321 // instance is constructed for each section on each layout. 322 // instance is constructed for each section on each layout.
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after
619 // The miniview is hidden immediately (no need to set this async). 620 // The miniview is hidden immediately (no need to set this async).
620 miniview.classList.remove('opaque'); 621 miniview.classList.remove('opaque');
621 } 622 }
622 } 623 }
623 624
624 switch (section) { 625 switch (section) {
625 case Section.THUMB: 626 case Section.THUMB:
626 mostVisited.visible = true; 627 mostVisited.visible = true;
627 mostVisited.layout(); 628 mostVisited.layout();
628 break; 629 break;
630 case Section.APPS:
631 apps.visible = true;
632 apps.layout({disableAnimations:true});
633 break;
629 } 634 }
630 } 635 }
631 } 636 }
632 637
633 // Show this section and hide all other sections - at most one section can 638 // Show this section and hide all other sections - at most one section can
634 // be open at one time. 639 // be open at one time.
635 function showOnlySection(section) { 640 function showOnlySection(section) {
636 for (var p in Section) { 641 for (var p in Section) {
637 if (p == section) 642 if (p == section)
638 showSection(Section[p]); 643 showSection(Section[p]);
639 else 644 else
640 hideSection(Section[p]); 645 hideSection(Section[p]);
641 } 646 }
642 } 647 }
643 648
644 function hideSection(section) { 649 function hideSection(section) {
645 if (section & shownSections) { 650 if (section & shownSections) {
646 shownSections &= ~section; 651 shownSections &= ~section;
647 652
648 switch (section) { 653 switch (section) {
649 case Section.THUMB: 654 case Section.THUMB:
650 mostVisited.visible = false; 655 mostVisited.visible = false;
651 mostVisited.layout(); 656 mostVisited.layout();
652 break; 657 break;
658 case Section.APPS:
659 apps.visible = false;
660 apps.layout();
661 break;
653 } 662 }
654 663
655 var el = getSectionElement(section); 664 var el = getSectionElement(section);
656 if (el) { 665 if (el) {
657 el.classList.add('collapsed'); 666 el.classList.add('collapsed');
658 667
659 var maxiview = getSectionMaxiview(el); 668 var maxiview = getSectionMaxiview(el);
660 if (maxiview) { 669 if (maxiview) {
661 maxiview.classList.add(isDoneLoading() ? 'collapsing' : 'collapsed'); 670 maxiview.classList.add(isDoneLoading() ? 'collapsing' : 'collapsed');
662 maxiview.classList.remove('opaque'); 671 maxiview.classList.remove('opaque');
(...skipping 728 matching lines...) Expand 10 before | Expand all | Expand 10 after
1391 var promoLink = document.querySelector('#apps-promo-text1 a'); 1400 var promoLink = document.querySelector('#apps-promo-text1 a');
1392 promoLink.id = 'apps-promo-link'; 1401 promoLink.id = 'apps-promo-link';
1393 promoLink.href = localStrings.getString('web_store_url'); 1402 promoLink.href = localStrings.getString('web_store_url');
1394 1403
1395 $('apps-promo-hide').addEventListener('click', function() { 1404 $('apps-promo-hide').addEventListener('click', function() {
1396 chrome.send('hideAppsPromo', []); 1405 chrome.send('hideAppsPromo', []);
1397 document.documentElement.classList.remove('apps-promo-visible'); 1406 document.documentElement.classList.remove('apps-promo-visible');
1398 layoutSections(); 1407 layoutSections();
1399 }); 1408 });
1400 }); 1409 });
OLDNEW
« no previous file with comments | « chrome/browser/resources/new_new_tab.html ('k') | chrome/browser/resources/ntp/apps.css » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698