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

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

Issue 861673002: Implement Page Selection in PDF Toolbar (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@pdf-toolbar
Patch Set: Restore viewer-progress-bar in index.html 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/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';
+ }
+});

Powered by Google App Engine
This is Rietveld 408576698