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'); | 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 = ''; |
(...skipping 16 matching lines...) Expand all Loading... |
27 | 27 |
28 appsSection.classList.remove('disabled'); | 28 appsSection.classList.remove('disabled'); |
29 layoutSections(); | 29 layoutSections(); |
30 } | 30 } |
31 | 31 |
32 var apps = { | 32 var apps = { |
33 /** | 33 /** |
34 * @this {!HTMLAnchorElement} | 34 * @this {!HTMLAnchorElement} |
35 */ | 35 */ |
36 handleClick_: function() { | 36 handleClick_: function() { |
37 var launchType = ''; | |
38 var inputElements = document.querySelectorAll( | |
39 '#apps-launch-control input'); | |
40 for (var i = 0, input; input = inputElements[i]; i++) { | |
41 if (input.checked) { | |
42 launchType = input.value; | |
43 break; | |
44 } | |
45 } | |
46 | |
47 // TODO(arv): Handle zoom? | 37 // TODO(arv): Handle zoom? |
48 var rect = this.getBoundingClientRect(); | 38 var rect = this.getBoundingClientRect(); |
49 var cs = getComputedStyle(this); | 39 var cs = getComputedStyle(this); |
50 var size = cs.backgroundSize.split(/\s+/); // background-size has the | 40 var size = cs.backgroundSize.split(/\s+/); // background-size has the |
51 // format '123px 456px'. | 41 // format '123px 456px'. |
52 var width = parseInt(size[0], 10); | 42 var width = parseInt(size[0], 10); |
53 var height = parseInt(size[1], 10); | 43 var height = parseInt(size[1], 10); |
54 // We are using background-position-x 50%. | 44 // We are using background-position-x 50%. |
55 var left = rect.left + ((rect.width - width) >> 1); // Integer divide by 2. | 45 var left = rect.left + ((rect.width - width) >> 1); // Integer divide by 2. |
56 var top = rect.top + parseInt(cs.backgroundPositionY, 10); | 46 var top = rect.top + parseInt(cs.backgroundPositionY, 10); |
57 | 47 |
58 chrome.send('launchApp', [this.getAttribute("app_id"), launchType, | 48 chrome.send('launchApp', [this.getAttribute("app_id"), |
59 String(left), String(top), | 49 String(left), String(top), |
60 String(width), String(height)]); | 50 String(width), String(height)]); |
61 return false; | 51 return false; |
62 }, | 52 }, |
63 | 53 |
64 createElement_: function(app) { | 54 createElement_: function(app) { |
65 var div = document.createElement('div'); | 55 var div = document.createElement('div'); |
66 div.className = 'app'; | 56 div.className = 'app'; |
67 | 57 |
68 var front = div.appendChild(document.createElement('div')); | 58 var front = div.appendChild(document.createElement('div')); |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
140 }, | 130 }, |
141 | 131 |
142 createWebStoreElement: function() { | 132 createWebStoreElement: function() { |
143 return this.createElement_({ | 133 return this.createElement_({ |
144 'id': 'web-store-entry', | 134 'id': 'web-store-entry', |
145 'name': localStrings.getString('web_store_title'), | 135 'name': localStrings.getString('web_store_title'), |
146 'launch_url': localStrings.getString('web_store_url') | 136 'launch_url': localStrings.getString('web_store_url') |
147 }); | 137 }); |
148 } | 138 } |
149 }; | 139 }; |
OLD | NEW |