OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 /** | 5 /** |
6 * @fileoverview This code supports the popup behaviour of the extension, and | 6 * @fileoverview This code supports the popup behaviour of the extension, and |
7 * demonstrates how to: | 7 * demonstrates how to: |
8 * | 8 * |
9 * 1) Set the zoom for a tab using tabs.setZoom() | 9 * 1) Set the zoom for a tab using tabs.setZoom() |
10 * 2) Read the current zoom of a tab using tabs.getZoom() | 10 * 2) Read the current zoom of a tab using tabs.getZoom() |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 modeRadios[i].checked = true; | 44 modeRadios[i].checked = true; |
45 } | 45 } |
46 | 46 |
47 var scopeRadios = document.getElementsByName('scopeRadio'); | 47 var scopeRadios = document.getElementsByName('scopeRadio'); |
48 for (var i = 0; i < scopeRadios.length; i++) { | 48 for (var i = 0; i < scopeRadios.length; i++) { |
49 if (scopeRadios[i].value == zoomSettings.scope) | 49 if (scopeRadios[i].value == zoomSettings.scope) |
50 scopeRadios[i].checked = true; | 50 scopeRadios[i].checked = true; |
51 } | 51 } |
52 | 52 |
53 var percentDefaultZoom = | 53 var percentDefaultZoom = |
54 parseFloat(zoomSettings.default_zoom_factor) * 100; | 54 parseFloat(zoomSettings.defaultZoomFactor) * 100; |
55 document.getElementById('defaultLabel').textContent = | 55 document.getElementById('defaultLabel').textContent = |
56 'Default: ' + percentDefaultZoom.toFixed(1) + '%'; | 56 'Default: ' + percentDefaultZoom.toFixed(1) + '%'; |
57 }); | 57 }); |
58 | 58 |
59 chrome.tabs.getZoom(tabId, displayZoomLevel); | 59 chrome.tabs.getZoom(tabId, displayZoomLevel); |
60 }); | 60 }); |
61 | 61 |
62 document.getElementById('increaseButton').onclick = doZoomIn; | 62 document.getElementById('increaseButton').onclick = doZoomIn; |
63 document.getElementById('decreaseButton').onclick = doZoomOut; | 63 document.getElementById('decreaseButton').onclick = doZoomOut; |
64 document.getElementById('defaultButton').onclick = doZoomDefault; | 64 document.getElementById('defaultButton').onclick = doZoomDefault; |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
132 if (chrome.runtime.lastError) { | 132 if (chrome.runtime.lastError) { |
133 console.log('[ZoomDemoExtension] doSetMode() error: ' + | 133 console.log('[ZoomDemoExtension] doSetMode() error: ' + |
134 chrome.runtime.lastError.message); | 134 chrome.runtime.lastError.message); |
135 } | 135 } |
136 }); | 136 }); |
137 } | 137 } |
138 | 138 |
139 function doClose() { | 139 function doClose() { |
140 self.close(); | 140 self.close(); |
141 } | 141 } |
OLD | NEW |