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
3 // found in the LICENSE file.
6 is: 'viewer-page-selector',
10 * The number of pages the document contains.
15 observer: 'docLengthChanged'
19 * The current page being viewed (1-based).
27 pageNoCommitted: function() {
28 var page = parseInt(this.pageNo);
30 this.fire('change-page', {page: page - 1});
35 docLengthChanged: function() {
36 var numDigits = this.docLength.toString().length;
37 this.$.pageselector.style.width = numDigits + 'ch';
38 // Set both sides of the slash to the same width, so that the layout is
40 this.$['pagelength-spacer'].style.width = numDigits + 'ch';
44 this.$.input.select();
48 * @return {boolean} True if the selector input field is currently focused.
50 isActive: function() {
51 return this.shadowRoot.activeElement == this.$.input;