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 'use strict'; | 5 'use strict'; |
6 | 6 |
7 <include src="../../../../ui/webui/resources/js/util.js"> | 7 <include src="../../../../ui/webui/resources/js/util.js"> |
8 <include src="open_pdf_params_parser.js"> | 8 <include src="open_pdf_params_parser.js"> |
9 <include src="pdf_scripting_api.js"> | 9 <include src="pdf_scripting_api.js"> |
10 <include src="viewport.js"> | 10 <include src="viewport.js"> |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
175 var pageUpHandler = function() { | 175 var pageUpHandler = function() { |
176 // Go to the previous page if we are fit-to-page. | 176 // Go to the previous page if we are fit-to-page. |
177 if (this.viewport_.fittingType == Viewport.FittingType.FIT_TO_PAGE) { | 177 if (this.viewport_.fittingType == Viewport.FittingType.FIT_TO_PAGE) { |
178 this.viewport_.goToPage(this.viewport_.getMostVisiblePage() - 1); | 178 this.viewport_.goToPage(this.viewport_.getMostVisiblePage() - 1); |
179 // Since we do the movement of the page. | 179 // Since we do the movement of the page. |
180 e.preventDefault(); | 180 e.preventDefault(); |
181 } else if (fromScriptingAPI) { | 181 } else if (fromScriptingAPI) { |
182 position.y -= this.viewport.size.height; | 182 position.y -= this.viewport.size.height; |
183 this.viewport.position = position; | 183 this.viewport.position = position; |
184 } | 184 } |
185 }; | 185 }.bind(this); |
186 var pageDownHandler = function() { | 186 var pageDownHandler = function() { |
187 // Go to the next page if we are fit-to-page. | 187 // Go to the next page if we are fit-to-page. |
188 if (this.viewport_.fittingType == Viewport.FittingType.FIT_TO_PAGE) { | 188 if (this.viewport_.fittingType == Viewport.FittingType.FIT_TO_PAGE) { |
189 this.viewport_.goToPage(this.viewport_.getMostVisiblePage() + 1); | 189 this.viewport_.goToPage(this.viewport_.getMostVisiblePage() + 1); |
190 // Since we do the movement of the page. | 190 // Since we do the movement of the page. |
191 e.preventDefault(); | 191 e.preventDefault(); |
192 } else if (fromScriptingAPI) { | 192 } else if (fromScriptingAPI) { |
193 position.y += this.viewport.size.height; | 193 position.y += this.viewport.size.height; |
194 this.viewport.position = position; | 194 this.viewport.position = position; |
195 } | 195 } |
196 }; | 196 }.bind(this); |
197 | 197 |
198 switch (e.keyCode) { | 198 switch (e.keyCode) { |
199 case 32: // Space key. | 199 case 32: // Space key. |
200 if (e.shiftKey) | 200 if (e.shiftKey) |
201 pageUpHandler(); | 201 pageUpHandler(); |
202 else | 202 else |
203 pageDownHandler(); | 203 pageDownHandler(); |
204 return; | 204 return; |
205 case 33: // Page up key. | 205 case 33: // Page up key. |
206 pageUpHandler(); | 206 pageUpHandler(); |
(...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
568 | 568 |
569 /** | 569 /** |
570 * @type {Viewport} the viewport of the PDF viewer. | 570 * @type {Viewport} the viewport of the PDF viewer. |
571 */ | 571 */ |
572 get viewport() { | 572 get viewport() { |
573 return this.viewport_; | 573 return this.viewport_; |
574 } | 574 } |
575 }; | 575 }; |
576 | 576 |
577 var viewer = new PDFViewer(); | 577 var viewer = new PDFViewer(); |
OLD | NEW |