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

Unified Diff: chrome/browser/resources/pdf/elements/page-selector/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: Implement Raymes' suggestions 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/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';
+ }
+});

Powered by Google App Engine
This is Rietveld 408576698