Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1406)

Unified Diff: chrome/browser/resources/pdf/elements/pdf-page-indicator/pdf-page-indicator.js

Issue 861673002: Implement Page Selection in PDF Toolbar (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@pdf-toolbar
Patch Set: Shift CSS into polymer element Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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';
+ }
+});

Powered by Google App Engine
This is Rietveld 408576698