Elim cr-checkbox
[chromium-blink-merge.git] / chrome / browser / resources / pdf / elements / viewer-page-selector / viewer-page-selector.js
blobe731adf64527e2cf7baff5ee7eb86c65a1db7879
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
3 // found in the LICENSE file.
5 Polymer({
6 is: 'viewer-page-selector',
8 properties: {
9 /**
10 * The number of pages the document contains.
12 docLength: {
13 type: Number,
14 value: 1,
15 observer: 'docLengthChanged'
18 /**
19 * The current page being viewed (1-based).
21 pageNo: {
22 type: String,
23 value: '1'
27 pageNoCommitted: function() {
28 var page = parseInt(this.pageNo);
29 if (!isNaN(page)) {
30 this.fire('change-page', {page: page - 1});
31 this.$.input.blur();
35 docLengthChanged: function() {
36 var numDigits = this.docLength.toString().length;
37 this.$.pageselector.style.width = numDigits + 'ch';
38 // Set both sides of the slash to the same width, so that the layout is
39 // exactly centered.
40 this.$['pagelength-spacer'].style.width = numDigits + 'ch';
43 select: function() {
44 this.$.input.select();
47 /**
48 * @return {boolean} True if the selector input field is currently focused.
50 isActive: function() {
51 return this.shadowRoot.activeElement == this.$.input;
53 });