Chromium Code Reviews| Index: chrome/browser/resources/pdf/elements/pdf-page-indicator/pdf-page-indicator.js |
| diff --git a/chrome/browser/resources/pdf/elements/pdf-page-indicator/pdf-page-indicator.js b/chrome/browser/resources/pdf/elements/pdf-page-indicator/pdf-page-indicator.js |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..f5fd6c1924f3fca0e2e6a4a4de20a6691909a39b |
| --- /dev/null |
| +++ b/chrome/browser/resources/pdf/elements/pdf-page-indicator/pdf-page-indicator.js |
| @@ -0,0 +1,40 @@ |
| +// 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('pdf-page-indicator', { |
| + pageNo: '1', |
|
Sam McNally
2015/01/21 04:03:37
Can you add comments for these fields. In particul
Alexandre Carlton
2015/01/21 05:20:35
Done.
|
| + index: 0, |
| + docLength: 1, |
| + chosenPageNo: '1', |
| + pageLabels: null, |
|
Sam McNally
2015/01/21 04:03:37
Is this used?
Alexandre Carlton
2015/01/21 05:20:35
Yes, for Print Preview.
|
| + digitLength: 0.6, |
| + |
| + chosenPageNoChanged: function() { |
| + if (this.chosenPageNo !== '') { |
| + var page = parseInt(this.chosenPageNo) - 1; |
|
Sam McNally
2015/01/21 04:03:37
What happens if it isn't a number?
Alexandre Carlton
2015/01/21 05:20:35
Done.
|
| + this.fire('changePage', {page: page}); |
| + } 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'; |
| + } |
| +}); |