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({ | 7 Polymer({ |
8 is: 'viewer-page-selector', | 8 is: 'viewer-page-selector', |
9 | 9 |
10 properties: { | 10 properties: { |
(...skipping 19 matching lines...) Expand all Loading... |
30 var page = parseInt(this.pageNo); | 30 var page = parseInt(this.pageNo); |
31 if (!isNaN(page)) { | 31 if (!isNaN(page)) { |
32 this.fire('change-page', {page: page - 1}); | 32 this.fire('change-page', {page: page - 1}); |
33 this.$.input.blur(); | 33 this.$.input.blur(); |
34 } | 34 } |
35 }, | 35 }, |
36 | 36 |
37 docLengthChanged: function() { | 37 docLengthChanged: function() { |
38 var numDigits = this.docLength.toString().length; | 38 var numDigits = this.docLength.toString().length; |
39 this.$.pageselector.style.width = (numDigits * DIGIT_LENGTH) + 'em'; | 39 this.$.pageselector.style.width = (numDigits * DIGIT_LENGTH) + 'em'; |
| 40 // Set both sides of the slash to the same width, so that the layout is |
| 41 // exactly centered. |
| 42 this.$['pagelength-inner'].style.width = |
| 43 this.$.pageselector.getBoundingClientRect().width + 'px'; |
40 }, | 44 }, |
41 | 45 |
42 select: function() { | 46 select: function() { |
43 this.$.input.select(); | 47 this.$.input.select(); |
44 }, | 48 }, |
45 | 49 |
46 /** | 50 /** |
47 * @return {boolean} True if the selector input field is currently focused. | 51 * @return {boolean} True if the selector input field is currently focused. |
48 */ | 52 */ |
49 isActive: function() { | 53 isActive: function() { |
50 return this.shadowRoot.activeElement == this.$.input; | 54 return this.shadowRoot.activeElement == this.$.input; |
51 } | 55 } |
52 }); | 56 }); |
OLD | NEW |