Chromium Code Reviews| Index: chrome/browser/resources/pdf/elements/page-selector/page-selector.js |
| diff --git a/chrome/browser/resources/pdf/elements/page-selector/page-selector.js b/chrome/browser/resources/pdf/elements/page-selector/page-selector.js |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..0e50b70b7aa06d89631adf01a0c1d1fbf793eede |
| --- /dev/null |
| +++ b/chrome/browser/resources/pdf/elements/page-selector/page-selector.js |
| @@ -0,0 +1,41 @@ |
| +// 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. |
| + |
| +Polymer('page-selector', { |
| + pageNo: '1', // The current entry in the input field. |
|
raymes
2015/01/22 22:31:55
nit: double space before "//"
Alexandre Carlton
2015/01/22 22:50:29
I've placed the comments on their own lines.
|
| + index: 0, // The index of the current page being viewed. |
| + docLength: 1, |
| + chosenPageNo: '1', // The submitted input from the user. |
| + pageLabels: null, |
| + digitLength: 0.6, |
| + |
| + chosenPageNoChanged: function() { |
| + if (this.chosenPageNo !== '') { |
| + 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; |
| + } |
| + }, |
| + |
| + pageLabelsChanged: function() { |
| + this.indexChanged(); |
| + }, |
| + |
| + indexChanged: function() { |
| + if (this.pageLabels) |
| + this.pageNo = this.pageLabels[this.index]; |
| + else |
| + this.pageNo = String(this.index + 1); |
| + }, |
| + |
| + docLengthChanged: function() { |
| + var numDigits = this.docLength.toString().length; |
| + this.$.pageselector.style.width = (numDigits * this.digitLength) + 'em'; |
| + } |
| +}); |