| Index: chrome/browser/resources/pdf/elements/viewer-page-selector/viewer-page-selector.js
|
| diff --git a/chrome/browser/resources/pdf/elements/viewer-page-selector/viewer-page-selector.js b/chrome/browser/resources/pdf/elements/viewer-page-selector/viewer-page-selector.js
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..99ee88f69621d16dc5e64e2330b09d0e0fdec9ac
|
| --- /dev/null
|
| +++ b/chrome/browser/resources/pdf/elements/viewer-page-selector/viewer-page-selector.js
|
| @@ -0,0 +1,36 @@
|
| +// Copyright 2015 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +var DIGIT_LENGTH = 0.6;
|
| +
|
| +Polymer('viewer-page-selector', {
|
| + // The current entry in the input field (1-based).
|
| + pageNo: '1',
|
| + // The index of the current page being viewed (0-based).
|
| + index: 0,
|
| + docLength: 1,
|
| + // The submitted input from the user (1-based).
|
| + chosenPageNo: '1',
|
| +
|
| + chosenPageNoChanged: function() {
|
| + var page = parseInt(this.chosenPageNo);
|
| + if (!isNaN(page)) {
|
| + this.fire('changePage', {page: page - 1});
|
| + } else {
|
| + // Repopulate the input.
|
| + this.indexChanged();
|
| + // Change the chosenPageNo so if it is '' again we can repopulate it.
|
| + this.chosenPageNo = this.pageNo;
|
| + }
|
| + },
|
| +
|
| + indexChanged: function() {
|
| + this.pageNo = String(this.index + 1);
|
| + },
|
| +
|
| + docLengthChanged: function() {
|
| + var numDigits = this.docLength.toString().length;
|
| + this.$.pageselector.style.width = (numDigits * DIGIT_LENGTH) + 'em';
|
| + }
|
| +});
|
|
|