Elim cr-checkbox
[chromium-blink-merge.git] / chrome / browser / resources / pdf / elements / viewer-pdf-toolbar / viewer-pdf-toolbar.js
blob45cc87c5aba85da0a24cb2ef939cdf5bb243ef86
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.
4 (function() {
5 Polymer({
6 is: 'viewer-pdf-toolbar',
8 behaviors: [
9 Polymer.NeonAnimationRunnerBehavior
12 properties: {
13 /**
14 * The current loading progress of the PDF document (0 - 100).
16 loadProgress: {
17 type: Number,
18 observer: 'loadProgressChanged'
21 /**
22 * The title of the PDF document.
24 docTitle: String,
26 /**
27 * The number of the page being viewed (1-based).
29 pageNo: Number,
31 /**
32 * Tree of PDF bookmarks (or null if the document has no bookmarks).
34 bookmarks: {
35 type: Object,
36 value: null
39 /**
40 * The number of pages in the PDF document.
42 docLength: Number,
44 /**
45 * Whether the toolbar is opened and visible.
47 opened: {
48 type: Boolean,
49 value: true
52 animationConfig: {
53 value: function() {
54 return {
55 'entry': {
56 name: 'slide-down-animation',
57 node: this,
58 timing: {
59 easing: 'cubic-bezier(0, 0, 0.2, 1)',
60 duration: 250
63 'exit': {
64 name: 'slide-up-animation',
65 node: this,
66 timing: {
67 easing: 'cubic-bezier(0.4, 0, 1, 1)',
68 duration: 250
76 listeners: {
77 'neon-animation-finish': '_onAnimationFinished'
80 _onAnimationFinished: function() {
81 this.style.transform = this.opened ? 'none' : 'translateY(-100%)';
84 loadProgressChanged: function() {
85 if (this.loadProgress >= 100) {
86 this.$.title.classList.toggle('invisible', false);
87 this.$.pageselector.classList.toggle('invisible', false);
88 this.$.buttons.classList.toggle('invisible', false);
92 hide: function() {
93 if (this.opened)
94 this.toggleVisibility();
97 show: function() {
98 if (!this.opened) {
99 this.toggleVisibility();
103 toggleVisibility: function() {
104 this.opened = !this.opened;
105 this.cancelAnimation();
106 this.playAnimation(this.opened ? 'entry' : 'exit');
109 selectPageNumber: function() {
110 this.$.pageselector.select();
113 shouldKeepOpen: function() {
114 return this.$.bookmarks.dropdownOpen || this.loadProgress < 100 ||
115 this.$.pageselector.isActive();
118 hideDropdowns: function() {
119 if (this.$.bookmarks.dropdownOpen) {
120 this.$.bookmarks.toggleDropdown();
121 return true;
123 return false;
126 setDropdownLowerBound: function(lowerBound) {
127 this.$.bookmarks.lowerBound = lowerBound;
130 rotateLeft: function() {
131 this.fire('rotate-left');
134 rotateRight: function() {
135 this.fire('rotate-right');
138 save: function() {
139 this.fire('save');
142 print: function() {
143 this.fire('print');
146 })();