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

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

Issue 2915773003: PDF Plugin: Add compile targets for a few more files. (Closed)
Patch Set: Addressing comments. Created 3 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 Polymer({ 5 Polymer({
6 is: 'viewer-page-selector', 6 is: 'viewer-page-selector',
7 7
8 properties: { 8 properties: {
9 /** 9 /**
10 * The number of pages the document contains. 10 * The number of pages the document contains.
11 */ 11 */
12 docLength: { 12 docLength: {
13 type: Number, 13 type: Number,
14 value: 1, 14 value: 1,
15 observer: 'docLengthChanged' 15 observer: 'docLengthChanged_'
16 }, 16 },
17 17
18 /** 18 /**
19 * The current page being viewed (1-based). A change to pageNo is mirrored 19 * The current page being viewed (1-based). A change to pageNo is mirrored
20 * immediately to the input field. A change to the input field is not 20 * immediately to the input field. A change to the input field is not
21 * mirrored back until pageNoCommitted() is called and change-page is fired. 21 * mirrored back until pageNoCommitted() is called and change-page is fired.
22 */ 22 */
23 pageNo: { 23 pageNo: {
24 type: Number, 24 type: Number,
25 value: 1 25 value: 1
26 }, 26 },
27 27
28 strings: Object, 28 strings: Object,
29 }, 29 },
30 30
31 pageNoCommitted: function() { 31 pageNoCommitted: function() {
32 var page = parseInt(this.$.input.value); 32 var page = parseInt(this.$.input.value, 10);
33 33
34 if (!isNaN(page) && page <= this.docLength && page > 0) 34 if (!isNaN(page) && page <= this.docLength && page > 0)
35 this.fire('change-page', {page: page - 1}); 35 this.fire('change-page', {page: page - 1});
36 else 36 else
37 this.$.input.value = this.pageNo; 37 this.$.input.value = this.pageNo;
38 this.$.input.blur(); 38 this.$.input.blur();
39 }, 39 },
40 40
41 docLengthChanged: function() { 41 /** @private */
42 docLengthChanged_: function() {
42 var numDigits = this.docLength.toString().length; 43 var numDigits = this.docLength.toString().length;
43 this.$.pageselector.style.width = numDigits + 'ch'; 44 this.$.pageselector.style.width = numDigits + 'ch';
44 // Set both sides of the slash to the same width, so that the layout is 45 // Set both sides of the slash to the same width, so that the layout is
45 // exactly centered. 46 // exactly centered.
46 this.$['pagelength-spacer'].style.width = numDigits + 'ch'; 47 this.$['pagelength-spacer'].style.width = numDigits + 'ch';
47 }, 48 },
48 49
49 select: function() { 50 select: function() {
50 this.$.input.select(); 51 this.$.input.select();
51 }, 52 },
52 53
53 /** 54 /**
54 * @return {boolean} True if the selector input field is currently focused. 55 * @return {boolean} True if the selector input field is currently focused.
55 */ 56 */
56 isActive: function() { 57 isActive: function() {
57 return this.shadowRoot.activeElement == this.$.input; 58 return this.shadowRoot.activeElement == this.$.input;
58 } 59 }
59 }); 60 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698