Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(700)

Side by Side Diff: chrome/browser/resources/pdf/pdf.js

Issue 169683005: Add shortcuts for zoom, print and saving PDFs. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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 // Simulate a click on the button so that the <a download ...>
179 // attribute is used.
180 $('save-button-link').click();
181 }
182 return;
183 case 80: // p key.
184 if (e.ctrlKey) {
185 print();
186 e.preventDefault();
187 }
188 return;
167 } 189 }
168 }; 190 };
169 } 191 }
170 192
171 load(); 193 load();
172 194
173 })(); 195 })();
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698