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, 10); | 25 var page = parseInt(this.$.input.value, 10); |
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 14 matching lines...) Expand all Loading... |
51 this.$.input.select(); | 44 this.$.input.select(); |
52 }, | 45 }, |
53 | 46 |
54 /** | 47 /** |
55 * @return {boolean} True if the selector input field is currently focused. | 48 * @return {boolean} True if the selector input field is currently focused. |
56 */ | 49 */ |
57 isActive: function() { | 50 isActive: function() { |
58 return this.shadowRoot.activeElement == this.$.input; | 51 return this.shadowRoot.activeElement == this.$.input; |
59 } | 52 } |
60 }); | 53 }); |
OLD | NEW |