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..9b22421a847172a4465059c3c3450602755f147e |
| --- /dev/null |
| +++ b/chrome/browser/resources/pdf/elements/page-selector/page-selector.js |
| @@ -0,0 +1,44 @@ |
| +// 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', { |
| + // The current entry in the input field. |
| + pageNo: '1', |
| + // The index of the current page being viewed. |
| + index: 0, |
| + docLength: 1, |
| + // The submitted input from the user. |
| + chosenPageNo: '1', |
| + pageLabels: null, |
|
benwells
2015/01/27 02:01:41
Could you add more comment for all of these fields
Alexandre Carlton
2015/01/27 04:04:54
digitLength is used in setting the length of the f
|
| + digitLength: 0.6, |
| + |
| + chosenPageNoChanged: function() { |
| + var page = parseInt(this.chosenPageNo); |
| + if (!isNaN(page)) { |
| + // TODO(alexandrec): This is not correct if pageLabels is set. |
|
benwells
2015/01/27 02:01:41
This TODO confuses me. Is the TODO to handle pageL
Alexandre Carlton
2015/01/27 04:04:54
This is more to do with Print Preview; I've modifi
|
| + 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'; |
| + } |
| +}); |