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.
5 var DIGIT_LENGTH = 0.6;
7 Polymer('viewer-page-selector', {
10 * The current entry in the input field (1-based).
16 * The index of the current page being viewed (0-based).
22 * The number of pages the document contains.
28 * The submitted input from the user (1-based).
32 chosenPageNoChanged: function() {
33 var page = parseInt(this.chosenPageNo);
35 this.fire('change-page', {page: page - 1});
37 // Repopulate the input.
39 // Change the chosenPageNo so if it is '' again we can repopulate it.
40 this.chosenPageNo = this.pageNo;
44 indexChanged: function() {
45 this.pageNo = String(this.index + 1);
48 docLengthChanged: function() {
49 var numDigits = this.docLength.toString().length;
50 this.$.pageselector.style.width = (numDigits * DIGIT_LENGTH) + 'em';
54 this.$.input.select();