| 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 Polymer({ | 5 Polymer({ |
| 6 is: 'viewer-page-selector', | 6 is: 'viewer-page-selector', |
| 7 | 7 |
| 8 properties: { | 8 properties: { |
| 9 /** | 9 /** |
| 10 * The number of pages the document contains. | 10 * The number of pages the document contains. |
| 11 */ | 11 */ |
| 12 docLength: { | 12 docLength: { |
| 13 type: Number, | 13 type: Number, |
| 14 value: 1, | 14 value: 1, |
| 15 observer: 'docLengthChanged' | 15 observer: 'docLengthChanged' |
| 16 }, | 16 }, |
| 17 | 17 |
| 18 /** | 18 /** |
| 19 * The current page being viewed (1-based). A change to pageNo is mirrored | 19 * The current page being viewed (1-based). A change to pageNo is mirrored |
| 20 * immediately to the input field. A change to the input field is not | 20 * immediately to the input field. A change to the input field is not |
| 21 * mirrored back until pageNoCommitted() is called and change-page is fired. | 21 * mirrored back until pageNoCommitted() is called and change-page is fired. |
| 22 */ | 22 */ |
| 23 pageNo: { | 23 pageNo: { |
| 24 type: Number, | 24 type: Number, |
| 25 value: 1 | 25 value: 1 |
| 26 } | 26 }, |
| 27 |
| 28 strings: Object, |
| 27 }, | 29 }, |
| 28 | 30 |
| 29 pageNoCommitted: function() { | 31 pageNoCommitted: function() { |
| 30 var page = parseInt(this.$.input.value); | 32 var page = parseInt(this.$.input.value); |
| 31 | 33 |
| 32 if (!isNaN(page) && page <= this.docLength && page > 0) | 34 if (!isNaN(page) && page <= this.docLength && page > 0) |
| 33 this.fire('change-page', {page: page - 1}); | 35 this.fire('change-page', {page: page - 1}); |
| 34 else | 36 else |
| 35 this.$.input.value = this.pageNo; | 37 this.$.input.value = this.pageNo; |
| 36 this.$.input.blur(); | 38 this.$.input.blur(); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 48 this.$.input.select(); | 50 this.$.input.select(); |
| 49 }, | 51 }, |
| 50 | 52 |
| 51 /** | 53 /** |
| 52 * @return {boolean} True if the selector input field is currently focused. | 54 * @return {boolean} True if the selector input field is currently focused. |
| 53 */ | 55 */ |
| 54 isActive: function() { | 56 isActive: function() { |
| 55 return this.shadowRoot.activeElement == this.$.input; | 57 return this.shadowRoot.activeElement == this.$.input; |
| 56 } | 58 } |
| 57 }); | 59 }); |
| OLD | NEW |