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

Side by Side Diff: chrome/browser/resources/ntp/apps.js

Issue 6354016: Fix layout glitches in NTP. Also, lots of naming cleanup. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: blech 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.js ('k') | chrome/browser/resources/ntp/most_visited.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 var MAX_APPS_PER_ROW = []; 5 var MAX_APPS_PER_ROW = [];
6 MAX_APPS_PER_ROW[LayoutMode.SMALL] = 4; 6 MAX_APPS_PER_ROW[LayoutMode.SMALL] = 4;
7 MAX_APPS_PER_ROW[LayoutMode.NORMAL] = 6; 7 MAX_APPS_PER_ROW[LayoutMode.NORMAL] = 6;
8 8
9 // The URL prefix used in the app link 'ping' attributes. 9 // The URL prefix used in the app link 'ping' attributes.
10 var PING_APP_LAUNCH_PREFIX = 'record-app-launch'; 10 var PING_APP_LAUNCH_PREFIX = 'record-app-launch';
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 addClosedMenuEntryWithLink(apps.menu, apps.createClosedMenuElement(app)); 59 addClosedMenuEntryWithLink(apps.menu, apps.createClosedMenuElement(app));
60 }); 60 });
61 if (data.apps.length < MAX_MINIVIEW_ITEMS) { 61 if (data.apps.length < MAX_MINIVIEW_ITEMS) {
62 webStoreMiniEntry = apps.createWebStoreMiniElement(); 62 webStoreMiniEntry = apps.createWebStoreMiniElement();
63 webStoreEntry.querySelector('a').setAttribute('ping', appsPromoPing); 63 webStoreEntry.querySelector('a').setAttribute('ping', appsPromoPing);
64 appsMiniview.appendChild(webStoreMiniEntry); 64 appsMiniview.appendChild(webStoreMiniEntry);
65 addClosedMenuEntryWithLink(apps.menu, 65 addClosedMenuEntryWithLink(apps.menu,
66 apps.createWebStoreClosedMenuElement()); 66 apps.createWebStoreClosedMenuElement());
67 } 67 }
68 68
69 if (!data.showLauncher || (shownSections & MINIMIZED_APPS)) { 69 if (!data.showLauncher)
70 appsSection.classList.add('disabled'); 70 appsSection.classList.add('disabled');
71 } else { 71 else
72 appsSection.classList.remove('disabled'); 72 appsSection.classList.remove('disabled');
73 } 73
74 addClosedMenuFooter(apps.menu, 'apps', MINIMIZED_APPS, Section.APPS); 74 addClosedMenuFooter(apps.menu, 'apps', MENU_APPS, Section.APPS);
75 75
76 apps.loaded = true; 76 apps.loaded = true;
77 if (apps.showPromo) 77 if (apps.showPromo)
78 document.documentElement.classList.add('apps-promo-visible'); 78 document.documentElement.classList.add('apps-promo-visible');
79 else 79 else
80 document.documentElement.classList.remove('apps-promo-visible'); 80 document.documentElement.classList.remove('apps-promo-visible');
81 81
82 var appsPromoLink = $('apps-promo-link'); 82 var appsPromoLink = $('apps-promo-link');
83 if (appsPromoLink) 83 if (appsPromoLink)
84 appsPromoLink.setAttribute('ping', appsPromoPing); 84 appsPromoLink.setAttribute('ping', appsPromoPing);
(...skipping 29 matching lines...) Expand all
114 a.setAttribute('app-id', app['id']); 114 a.setAttribute('app-id', app['id']);
115 a.setAttribute('launch-type', app['launch_type']); 115 a.setAttribute('launch-type', app['launch_type']);
116 a.xtitle = a.textContent = app['name']; 116 a.xtitle = a.textContent = app['name'];
117 a.href = app['launch_url']; 117 a.href = app['launch_url'];
118 118
119 return div; 119 return div;
120 } 120 }
121 121
122 function launchApp(appId) { 122 function launchApp(appId) {
123 var appsSection = $('apps'); 123 var appsSection = $('apps');
124 var expanded = !appsSection.classList.contains('hidden'); 124 var expanded = !appsSection.classList.contains('collapsed');
125 var element = document.querySelector( 125 var element = document.querySelector(
126 (expanded ? '.maxiview' : '.miniview') + ' a[app-id=' + appId + ']'); 126 (expanded ? '.maxiview' : '.miniview') + ' a[app-id=' + appId + ']');
127 127
128 // TODO(arv): Handle zoom? 128 // TODO(arv): Handle zoom?
129 var rect = element.getBoundingClientRect(); 129 var rect = element.getBoundingClientRect();
130 var cs = getComputedStyle(element); 130 var cs = getComputedStyle(element);
131 var size = cs.backgroundSize.split(/\s+/); // background-size has the 131 var size = cs.backgroundSize.split(/\s+/); // background-size has the
132 // format '123px 456px'. 132 // format '123px 456px'.
133 133
134 var width = parseInt(size[0], 10); 134 var width = parseInt(size[0], 10);
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
357 createWebStoreClosedMenuElement: function() { 357 createWebStoreClosedMenuElement: function() {
358 var a = document.createElement('a'); 358 var a = document.createElement('a');
359 a.textContent = localStrings.getString('web_store_title'); 359 a.textContent = localStrings.getString('web_store_title');
360 a.href = localStrings.getString('web_store_url'); 360 a.href = localStrings.getString('web_store_url');
361 a.style.backgroundImage = url('chrome://theme/IDR_PRODUCT_LOGO_16'); 361 a.style.backgroundImage = url('chrome://theme/IDR_PRODUCT_LOGO_16');
362 a.className = 'item'; 362 a.className = 'item';
363 return a; 363 return a;
364 } 364 }
365 }; 365 };
366 })(); 366 })();
OLDNEW
« no previous file with comments | « chrome/browser/resources/new_new_tab.js ('k') | chrome/browser/resources/ntp/most_visited.css » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698