| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 var DIGIT_LENGTH = 0.6; | 5 var DIGIT_LENGTH = 0.6; |
| 6 | 6 |
| 7 Polymer('viewer-page-selector', { | 7 Polymer('viewer-page-selector', { |
| 8 // The current entry in the input field (1-based). | 8 /** |
| 9 * @type {string} |
| 10 * The current entry in the input field (1-based). |
| 11 */ |
| 9 pageNo: '1', | 12 pageNo: '1', |
| 10 // The index of the current page being viewed (0-based). | 13 |
| 14 /** |
| 15 * @type {number} |
| 16 * The index of the current page being viewed (0-based). |
| 17 */ |
| 11 index: 0, | 18 index: 0, |
| 19 |
| 20 /** |
| 21 * @type {number} |
| 22 * The number of pages the document contains. |
| 23 */ |
| 12 docLength: 1, | 24 docLength: 1, |
| 13 // The submitted input from the user (1-based). | 25 |
| 26 /** |
| 27 * @type {string} |
| 28 * The submitted input from the user (1-based). |
| 29 */ |
| 14 chosenPageNo: '1', | 30 chosenPageNo: '1', |
| 15 | 31 |
| 16 chosenPageNoChanged: function() { | 32 chosenPageNoChanged: function() { |
| 17 var page = parseInt(this.chosenPageNo); | 33 var page = parseInt(this.chosenPageNo); |
| 18 if (!isNaN(page)) { | 34 if (!isNaN(page)) { |
| 19 this.fire('changePage', {page: page - 1}); | 35 this.fire('change-page', {page: page - 1}); |
| 20 } else { | 36 } else { |
| 21 // Repopulate the input. | 37 // Repopulate the input. |
| 22 this.indexChanged(); | 38 this.indexChanged(); |
| 23 // Change the chosenPageNo so if it is '' again we can repopulate it. | 39 // Change the chosenPageNo so if it is '' again we can repopulate it. |
| 24 this.chosenPageNo = this.pageNo; | 40 this.chosenPageNo = this.pageNo; |
| 25 } | 41 } |
| 26 }, | 42 }, |
| 27 | 43 |
| 28 indexChanged: function() { | 44 indexChanged: function() { |
| 29 this.pageNo = String(this.index + 1); | 45 this.pageNo = String(this.index + 1); |
| 30 }, | 46 }, |
| 31 | 47 |
| 32 docLengthChanged: function() { | 48 docLengthChanged: function() { |
| 33 var numDigits = this.docLength.toString().length; | 49 var numDigits = this.docLength.toString().length; |
| 34 this.$.pageselector.style.width = (numDigits * DIGIT_LENGTH) + 'em'; | 50 this.$.pageselector.style.width = (numDigits * DIGIT_LENGTH) + 'em'; |
| 35 }, | 51 }, |
| 36 | 52 |
| 37 select: function() { | 53 select: function() { |
| 38 this.$.input.select(); | 54 this.$.input.select(); |
| 39 } | 55 } |
| 40 }); | 56 }); |
| OLD | NEW |