Add ENABLE_MEDIA_ROUTER define to builds other than Android and iOS.
[chromium-blink-merge.git] / chrome / browser / resources / pdf / elements / viewer-pdf-toolbar / viewer-pdf-toolbar.js
blob11208da06fae6695ba33697039ce1bf5d74745ac
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 /**
6 * @type {Object}
7 * core-meta object used to determine type of transition used.
8 */
9 var meta = document.createElement('core-meta');
10 meta.type = 'transition';
12 /**
13 * @type {Object}
14 * Sets up, starts and destroys the transition used.
15 * This has no state and therefore is OK to make global.
17 var transition;
19 Polymer('viewer-pdf-toolbar', {
20 /**
21 * @type {string}
22 * The title of the PDF document.
24 docTitle: '',
26 /**
27 * @type {number}
28 * The current index of the page being viewed (0-based).
30 pageIndex: 0,
32 /**
33 * @type {number}
34 * The current loading progress of the PDF document (0 - 100).
36 loadProgress: 0,
38 /**
39 * @type {boolean}
40 * Whether the document has bookmarks.
42 hasBookmarks: false,
44 /**
45 * @type {number}
46 * The number of pages in the PDF document.
48 docLength: 1,
50 ready: function() {
51 // We cannot initialise transition before ensuring that core-meta has been
52 // imported.
53 if (transition === undefined)
54 transition = meta.byId('core-transition-top');
55 transition.setup(this.$.animatable);
57 /**
58 * @type {Object}
59 * Used in core-transition to determine whether the animatable is open.
61 this.state_ = { opened: false };
62 this.show();
65 loadProgressChanged: function() {
66 if (this.loadProgress >= 100) {
67 this.$.title.classList.toggle('invisible', false);
68 this.$.pageselector.classList.toggle('invisible', false);
69 this.$.buttons.classList.toggle('invisible', false);
73 hide: function() {
74 if (this.state_.opened)
75 this.toggleVisibility();
78 show: function() {
79 if (!this.state_.opened)
80 this.toggleVisibility();
83 toggleVisibility: function() {
84 this.state_.opened = !this.state_.opened;
85 transition.go(this.$.animatable, this.state_);
88 selectPageNumber: function() {
89 this.$.pageselector.select();
92 rotateRight: function() {
93 this.fire('rotate-right');
96 toggleBookmarks: function() {
97 this.fire('toggle-bookmarks');
100 save: function() {
101 this.fire('save');
104 print: function() {
105 this.fire('print');
108 })();