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

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

Issue 1162863002: Material PDF: Fix inconsistent behaviour in page selector, update styling (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix rebase mistake Created 5 years, 6 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 var DIGIT_LENGTH = 0.6; 5 var DIGIT_LENGTH = 0.6;
6 6
7 Polymer({ 7 Polymer({
8 is: 'viewer-page-selector', 8 is: 'viewer-page-selector',
9 9
10 properties: { 10 properties: {
11 /** 11 /**
12 * The index of the current page being viewed (0-based).
13 */
14 index: {
15 type: Number,
16 value: 0,
17 observer: 'indexChanged'
18 },
19
20 /**
21 * The number of pages the document contains. 12 * The number of pages the document contains.
22 */ 13 */
23 docLength: { 14 docLength: {
24 type: Number, 15 type: Number,
25 value: 1, 16 value: 1,
26 observer: 'docLengthChanged' 17 observer: 'docLengthChanged'
27 }, 18 },
28 19
29 /** 20 /**
30 * The current entry in the input field (1-based). 21 * The current page being viewed (1-based).
31 */ 22 */
32 pageNo: { 23 pageNo: {
33 type: String, 24 type: String,
34 value: '1', 25 value: '1'
35 observer: 'pageNoChanged'
36 },
37 },
38
39 pageNoChanged: function() {
40 var page = parseInt(this.pageNo);
41 if (!isNaN(page) && page != this.index + 1) {
42 this.fire('change-page', {page: page - 1});
43 } else {
44 // Repopulate the input.
45 this.indexChanged();
46 } 26 }
47 }, 27 },
48 28
49 indexChanged: function() { 29 pageNoCommitted: function() {
50 this.pageNo = String(this.index + 1); 30 var page = parseInt(this.pageNo);
31 if (!isNaN(page)) {
32 this.fire('change-page', {page: page - 1});
33 }
51 }, 34 },
52 35
53 docLengthChanged: function() { 36 docLengthChanged: function() {
54 var numDigits = this.docLength.toString().length; 37 var numDigits = this.docLength.toString().length;
55 this.$.pageselector.style.width = (numDigits * DIGIT_LENGTH) + 'em'; 38 this.$.pageselector.style.width = (numDigits * DIGIT_LENGTH) + 'em';
56 }, 39 },
57 40
58 select: function() { 41 select: function() {
59 this.$.input.select(); 42 this.$.input.select();
60 } 43 }
61 }); 44 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698