Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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() { | 5 (function() { |
| 6 | 6 |
| 7 <include src="../../../../ui/webui/resources/js/util.js"></include> | 7 <include src="../../../../ui/webui/resources/js/util.js"></include> |
| 8 <include src="viewport.js"></include> | 8 <include src="viewport.js"></include> |
| 9 | 9 |
| 10 // The plugin element is sized to fill the entire window and is set to be fixed | 10 // The plugin element is sized to fill the entire window and is set to be fixed |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 124 viewport.fitToWidth.bind(viewport)); | 124 viewport.fitToWidth.bind(viewport)); |
| 125 $('fit-to-page-button').addEventListener('click', | 125 $('fit-to-page-button').addEventListener('click', |
| 126 viewport.fitToPage.bind(viewport)); | 126 viewport.fitToPage.bind(viewport)); |
| 127 $('zoom-in-button').addEventListener('click', | 127 $('zoom-in-button').addEventListener('click', |
| 128 viewport.zoomIn.bind(viewport)); | 128 viewport.zoomIn.bind(viewport)); |
| 129 $('zoom-out-button').addEventListener('click', | 129 $('zoom-out-button').addEventListener('click', |
| 130 viewport.zoomOut.bind(viewport)); | 130 viewport.zoomOut.bind(viewport)); |
| 131 $('save-button-link').href = streamDetails.originalURL; | 131 $('save-button-link').href = streamDetails.originalURL; |
| 132 $('print-button').addEventListener('click', print); | 132 $('print-button').addEventListener('click', print); |
| 133 | 133 |
| 134 | |
| 135 // Setup keyboard event listeners. | 134 // Setup keyboard event listeners. |
| 136 document.onkeydown = function(e) { | 135 document.onkeydown = function(e) { |
| 137 switch (e.keyCode) { | 136 switch (e.keyCode) { |
| 138 case 37: // Left arrow key. | 137 case 37: // Left arrow key. |
| 139 // Go to the previous page if there are no horizontal scrollbars. | 138 // Go to the previous page if there are no horizontal scrollbars. |
| 140 if (!viewport.documentHasScrollbars().x) { | 139 if (!viewport.documentHasScrollbars().x) { |
| 141 viewport.goToPage(viewport.getMostVisiblePage() - 1); | 140 viewport.goToPage(viewport.getMostVisiblePage() - 1); |
| 142 // Since we do the movement of the page | 141 // Since we do the movement of the page |
| 143 e.preventDefault(); | 142 e.preventDefault(); |
| 144 } | 143 } |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 157 e.preventDefault(); | 156 e.preventDefault(); |
| 158 } | 157 } |
| 159 return; | 158 return; |
| 160 case 34: // Page down key. | 159 case 34: // Page down key. |
| 161 // Go to the next page if we are fit-to-page. | 160 // Go to the next page if we are fit-to-page. |
| 162 if (isFitToPageEnabled()) { | 161 if (isFitToPageEnabled()) { |
| 163 viewport.goToPage(viewport.getMostVisiblePage() + 1); | 162 viewport.goToPage(viewport.getMostVisiblePage() + 1); |
| 164 e.preventDefault(); | 163 e.preventDefault(); |
| 165 } | 164 } |
| 166 return; | 165 return; |
| 166 case 187: // +/= key. | |
| 167 case 107: // Numpad + key. | |
| 168 if (e.ctrlKey) | |
| 169 viewport.zoomIn(); | |
| 170 return; | |
| 171 case 189: // -/_ key. | |
| 172 case 109: // Numpad - key. | |
| 173 if (e.ctrlKey) | |
| 174 viewport.zoomOut(); | |
| 175 return; | |
| 176 case 83: // s key. | |
| 177 if (e.ctrlKey) { | |
| 178 // Dispatch an event simulating a click so that the <a download ...> | |
| 179 // attribute is used. | |
| 180 var click = document.createEvent('MouseEvents'); | |
|
arv (Not doing code reviews)
2014/02/19 02:15:56
var click = new MouseEvent('click', {
bubbles: t
raymes
2014/02/19 03:29:38
Yep, it works!
| |
| 181 click.initEvent('click', true, true); | |
| 182 $('save-button-link').dispatchEvent(click); | |
| 183 e.preventDefault(); | |
| 184 } | |
| 185 return; | |
| 186 case 80: // p key. | |
| 187 if (e.ctrlKey) { | |
| 188 print(); | |
| 189 e.preventDefault(); | |
| 190 } | |
| 191 return; | |
| 167 } | 192 } |
| 168 }; | 193 }; |
| 169 } | 194 } |
| 170 | 195 |
| 171 load(); | 196 load(); |
| 172 | 197 |
| 173 })(); | 198 })(); |
| OLD | NEW |