| 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('recieved apps'); | 6 logEvent('recieved apps'); |
| 7 var appsSection = $('apps-section'); | 7 var appsSection = $('apps-section'); |
| 8 var debugSection = $('debug'); | 8 var debugSection = $('debug'); |
| 9 appsSection.textContent = ''; | 9 appsSection.textContent = ''; |
| 10 | 10 |
| 11 data.apps.forEach(function(app) { | 11 data.apps.forEach(function(app) { |
| 12 appsSection.appendChild(apps.createElement(app)); | 12 appsSection.appendChild(apps.createElement(app)); |
| 13 }); | 13 }); |
| 14 | 14 |
| 15 | |
| 16 // TODO(aa): Figure out what to do with the debug mode when we turn apps on | 15 // TODO(aa): Figure out what to do with the debug mode when we turn apps on |
| 17 // for everyone. | 16 // for everyone. |
| 18 if (appsSection.hasChildNodes()) { | 17 if (appsSection.hasChildNodes()) { |
| 19 appsSection.classList.remove('disabled'); | 18 appsSection.classList.remove('disabled'); |
| 20 if (data.showDebugLink) { | 19 if (data.showDebugLink) { |
| 21 debugSection.classList.remove('disabled'); | 20 debugSection.classList.remove('disabled'); |
| 22 } | 21 } |
| 22 |
| 23 appsSection.appendChild(apps.createWebStoreElement()); |
| 23 } else { | 24 } else { |
| 24 appsSection.classList.add('disabled'); | 25 appsSection.classList.add('disabled'); |
| 25 debugSection.classList.add('disabled'); | 26 debugSection.classList.add('disabled'); |
| 26 } | 27 } |
| 27 } | 28 } |
| 28 | 29 |
| 29 var apps = { | 30 var apps = { |
| 30 /** | 31 /** |
| 31 * @this {!HTMLAnchorElement} | 32 * @this {!HTMLAnchorElement} |
| 32 */ | 33 */ |
| (...skipping 18 matching lines...) Expand all Loading... |
| 51 // We are using background-position-x 50%. | 52 // We are using background-position-x 50%. |
| 52 var left = rect.left + ((rect.width - width) >> 1); // Integer divide by 2. | 53 var left = rect.left + ((rect.width - width) >> 1); // Integer divide by 2. |
| 53 var top = rect.top + parseInt(cs.backgroundPositionY, 10); | 54 var top = rect.top + parseInt(cs.backgroundPositionY, 10); |
| 54 | 55 |
| 55 chrome.send('launchApp', [this.id, launchType, | 56 chrome.send('launchApp', [this.id, launchType, |
| 56 String(left), String(top), | 57 String(left), String(top), |
| 57 String(width), String(height)]); | 58 String(width), String(height)]); |
| 58 return false; | 59 return false; |
| 59 }, | 60 }, |
| 60 | 61 |
| 61 createElement: function(app) { | 62 createElement_: function(app) { |
| 62 var div = document.createElement('div'); | 63 var div = document.createElement('div'); |
| 63 div.className = 'app'; | 64 div.className = 'app'; |
| 64 | 65 |
| 65 var front = div.appendChild(document.createElement('div')); | 66 var front = div.appendChild(document.createElement('div')); |
| 66 front.className = 'front'; | 67 front.className = 'front'; |
| 67 | 68 |
| 68 var a = front.appendChild(document.createElement('a')); | 69 var a = front.appendChild(document.createElement('a')); |
| 69 a.id = app['id']; | 70 a.id = app['id']; |
| 70 a.xtitle = a.textContent = app['name']; | 71 a.xtitle = a.textContent = app['name']; |
| 71 a.href = app['launch_url']; | 72 a.href = app['launch_url']; |
| 72 | 73 |
| 74 return div; |
| 75 }, |
| 76 |
| 77 createElement: function(app) { |
| 78 var div = this.createElement_(app); |
| 79 var front = div.firstChild; |
| 80 var a = front.firstChild; |
| 81 |
| 73 a.onclick = apps.handleClick_; | 82 a.onclick = apps.handleClick_; |
| 74 a.style.backgroundImage = url(app['icon']); | 83 a.style.backgroundImage = url(app['icon']); |
| 75 if (hashParams['app-id'] == app['id']) { | 84 if (hashParams['app-id'] == app['id']) { |
| 76 div.setAttribute('new', 'new'); | 85 div.setAttribute('new', 'new'); |
| 77 // Delay changing the attribute a bit to let the page settle down a bit. | 86 // Delay changing the attribute a bit to let the page settle down a bit. |
| 78 setTimeout(function() { | 87 setTimeout(function() { |
| 79 div.setAttribute('new', 'installed'); | 88 div.setAttribute('new', 'installed'); |
| 80 }, 500); | 89 }, 500); |
| 81 } | 90 } |
| 82 | 91 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 105 }; | 114 }; |
| 106 | 115 |
| 107 var closeButton = back.appendChild(document.createElement('button')); | 116 var closeButton = back.appendChild(document.createElement('button')); |
| 108 closeButton.title = localStrings.getString('close'); | 117 closeButton.title = localStrings.getString('close'); |
| 109 closeButton.className = 'flip'; | 118 closeButton.className = 'flip'; |
| 110 closeButton.onclick = settingsButton.onclick = function() { | 119 closeButton.onclick = settingsButton.onclick = function() { |
| 111 div.classList.toggle('config'); | 120 div.classList.toggle('config'); |
| 112 }; | 121 }; |
| 113 | 122 |
| 114 return div; | 123 return div; |
| 124 }, |
| 125 |
| 126 createWebStoreElement: function() { |
| 127 return this.createElement_({ |
| 128 'id': 'web-store-entry', |
| 129 'name': localStrings.getString('web_store_title'), |
| 130 'launch_url': localStrings.getString('web_store_url') |
| 131 }); |
| 115 } | 132 } |
| 116 }; | 133 }; |
| OLD | NEW |