| 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 function getAppsCallback(data) { | 5 function getAppsCallback(data) { |
| 6 logEvent('received apps'); | 6 logEvent('received apps'); |
| 7 var appsSection = $('apps'); | 7 var appsSection = $('apps'); |
| 8 var appsSectionContent = $('apps-maxiview'); | 8 var appsSectionContent = $('apps-maxiview'); |
| 9 var appsMiniview = appsSection.getElementsByClassName('miniview')[0]; | 9 var appsMiniview = appsSection.getElementsByClassName('miniview')[0]; |
| 10 appsSectionContent.textContent = ''; | 10 appsSectionContent.textContent = ''; |
| 11 appsMiniview.textContent = ''; | 11 appsMiniview.textContent = ''; |
| 12 | 12 |
| 13 if (data.apps.length == 0) { | 13 if (data.apps.length == 0) { |
| 14 appsSection.classList.add('disabled'); | 14 appsSection.classList.add('disabled'); |
| 15 setShownSections(Section.THUMB); | 15 setShownSections(Section.THUMB); |
| 16 return; | 16 } else { |
| 17 data.apps.forEach(function(app) { |
| 18 appsSectionContent.appendChild(apps.createElement(app)); |
| 19 }); |
| 20 |
| 21 appsSectionContent.appendChild(apps.createWebStoreElement()); |
| 22 |
| 23 data.apps.slice(0, MAX_MINIVIEW_ITEMS).forEach(function(app) { |
| 24 appsMiniview.appendChild(apps.createMiniviewElement(app)); |
| 25 }); |
| 26 |
| 27 appsSection.classList.remove('disabled'); |
| 17 } | 28 } |
| 18 | 29 |
| 19 data.apps.forEach(function(app) { | 30 apps.loaded = true; |
| 20 appsSectionContent.appendChild(apps.createElement(app)); | 31 maybeDoneLoading(); |
| 21 }); | |
| 22 | 32 |
| 23 appsSectionContent.appendChild(apps.createWebStoreElement()); | 33 if (data.apps.length > 0 && isDoneLoading()) { |
| 24 | 34 updateMiniviewClipping(appsMiniview); |
| 25 data.apps.slice(0, MAX_MINIVIEW_ITEMS).forEach(function(app) { | 35 layoutSections(); |
| 26 appsMiniview.appendChild(apps.createMiniviewElement(app)); | 36 } |
| 27 }); | |
| 28 | |
| 29 appsSection.classList.remove('disabled'); | |
| 30 updateMiniviewClipping(appsMiniview); | |
| 31 layoutSections(); | |
| 32 } | 37 } |
| 33 | 38 |
| 34 var apps = (function() { | 39 var apps = (function() { |
| 35 | 40 |
| 36 function createElement(app) { | 41 function createElement(app) { |
| 37 var div = document.createElement('div'); | 42 var div = document.createElement('div'); |
| 38 div.className = 'app'; | 43 div.className = 'app'; |
| 39 | 44 |
| 40 var a = div.appendChild(document.createElement('a')); | 45 var a = div.appendChild(document.createElement('a')); |
| 41 a.setAttribute('app-id', app['id']); | 46 a.setAttribute('app-id', app['id']); |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 e.canExecute = currentApp && currentApp['options_url']; | 141 e.canExecute = currentApp && currentApp['options_url']; |
| 137 break; | 142 break; |
| 138 case 'apps-launch-command': | 143 case 'apps-launch-command': |
| 139 case 'apps-uninstall-command': | 144 case 'apps-uninstall-command': |
| 140 e.canExecute = true; | 145 e.canExecute = true; |
| 141 break; | 146 break; |
| 142 } | 147 } |
| 143 }); | 148 }); |
| 144 | 149 |
| 145 return { | 150 return { |
| 151 loaded: false, |
| 152 |
| 146 createElement: function(app) { | 153 createElement: function(app) { |
| 147 var div = createElement(app); | 154 var div = createElement(app); |
| 148 var a = div.firstChild; | 155 var a = div.firstChild; |
| 149 | 156 |
| 150 a.onclick = handleClick; | 157 a.onclick = handleClick; |
| 151 a.style.backgroundImage = url(app['icon_big']); | 158 a.style.backgroundImage = url(app['icon_big']); |
| 152 if (hashParams['app-id'] == app['id']) { | 159 if (hashParams['app-id'] == app['id']) { |
| 153 div.setAttribute('new', 'new'); | 160 div.setAttribute('new', 'new'); |
| 154 // Delay changing the attribute a bit to let the page settle down a bit. | 161 // Delay changing the attribute a bit to let the page settle down a bit. |
| 155 setTimeout(function() { | 162 setTimeout(function() { |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 191 | 198 |
| 192 createWebStoreElement: function() { | 199 createWebStoreElement: function() { |
| 193 return createElement({ | 200 return createElement({ |
| 194 'id': 'web-store-entry', | 201 'id': 'web-store-entry', |
| 195 'name': localStrings.getString('web_store_title'), | 202 'name': localStrings.getString('web_store_title'), |
| 196 'launch_url': localStrings.getString('web_store_url') | 203 'launch_url': localStrings.getString('web_store_url') |
| 197 }); | 204 }); |
| 198 } | 205 } |
| 199 }; | 206 }; |
| 200 })(); | 207 })(); |
| OLD | NEW |