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