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

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

Issue 2939273002: DO NOT SUBMIT: what chrome/browser/resources/ could eventually look like with clang-format (Closed)
Patch Set: 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 (function() { 4 (function() {
5 Polymer({ 5 Polymer({
6 is: 'viewer-pdf-toolbar', 6 is: 'viewer-pdf-toolbar',
7 7
8 behaviors: [ 8 behaviors: [Polymer.NeonAnimationRunnerBehavior],
9 Polymer.NeonAnimationRunnerBehavior
10 ],
11 9
12 properties: { 10 properties: {
13 /** 11 /**
14 * The current loading progress of the PDF document (0 - 100). 12 * The current loading progress of the PDF document (0 - 100).
15 */ 13 */
16 loadProgress: { 14 loadProgress: {type: Number, observer: 'loadProgressChanged'},
17 type: Number,
18 observer: 'loadProgressChanged'
19 },
20 15
21 /** 16 /**
22 * The title of the PDF document. 17 * The title of the PDF document.
23 */ 18 */
24 docTitle: String, 19 docTitle: String,
25 20
26 /** 21 /**
27 * The number of the page being viewed (1-based). 22 * The number of the page being viewed (1-based).
28 */ 23 */
29 pageNo: Number, 24 pageNo: Number,
30 25
31 /** 26 /**
32 * Tree of PDF bookmarks (or null if the document has no bookmarks). 27 * Tree of PDF bookmarks (or null if the document has no bookmarks).
33 */ 28 */
34 bookmarks: { 29 bookmarks: {type: Object, value: null},
35 type: Object,
36 value: null
37 },
38 30
39 /** 31 /**
40 * The number of pages in the PDF document. 32 * The number of pages in the PDF document.
41 */ 33 */
42 docLength: Number, 34 docLength: Number,
43 35
44 /** 36 /**
45 * Whether the toolbar is opened and visible. 37 * Whether the toolbar is opened and visible.
46 */ 38 */
47 opened: { 39 opened: {type: Boolean, value: true},
48 type: Boolean,
49 value: true
50 },
51 40
52 strings: Object, 41 strings: Object,
53 42
54 animationConfig: { 43 animationConfig: {
55 value: function() { 44 value: function() {
56 return { 45 return {
57 'entry': { 46 'entry': {
58 name: 'transform-animation', 47 name: 'transform-animation',
59 node: this, 48 node: this,
60 transformFrom: 'translateY(-100%)', 49 transformFrom: 'translateY(-100%)',
61 transformTo: 'translateY(0%)', 50 transformTo: 'translateY(0%)',
62 timing: { 51 timing: {easing: 'cubic-bezier(0, 0, 0.2, 1)', duration: 250}
63 easing: 'cubic-bezier(0, 0, 0.2, 1)', 52 },
64 duration: 250 53 'exit': {
65 } 54 name: 'slide-up-animation',
66 }, 55 node: this,
67 'exit': { 56 timing: {easing: 'cubic-bezier(0.4, 0, 1, 1)', duration: 250}
68 name: 'slide-up-animation', 57 }
69 node: this, 58 };
70 timing: {
71 easing: 'cubic-bezier(0.4, 0, 1, 1)',
72 duration: 250
73 }
74 }
75 };
76 }
77 } 59 }
78 }, 60 }
61 },
79 62
80 listeners: { 63 listeners: {'neon-animation-finish': '_onAnimationFinished'},
81 'neon-animation-finish': '_onAnimationFinished'
82 },
83 64
84 _onAnimationFinished: function() { 65 _onAnimationFinished: function() {
85 this.style.transform = this.opened ? 'none' : 'translateY(-100%)'; 66 this.style.transform = this.opened ? 'none' : 'translateY(-100%)';
86 }, 67 },
87 68
88 loadProgressChanged: function() { 69 loadProgressChanged: function() {
89 if (this.loadProgress >= 100) { 70 if (this.loadProgress >= 100) {
90 this.$.pageselector.classList.toggle('invisible', false); 71 this.$.pageselector.classList.toggle('invisible', false);
91 this.$.buttons.classList.toggle('invisible', false); 72 this.$.buttons.classList.toggle('invisible', false);
92 this.$.progress.style.opacity = 0; 73 this.$.progress.style.opacity = 0;
93 } 74 }
94 }, 75 },
95 76
96 hide: function() { 77 hide: function() {
97 if (this.opened) 78 if (this.opened)
98 this.toggleVisibility(); 79 this.toggleVisibility();
99 }, 80 },
100 81
101 show: function() { 82 show: function() {
102 if (!this.opened) { 83 if (!this.opened) {
103 this.toggleVisibility(); 84 this.toggleVisibility();
104 } 85 }
105 }, 86 },
106 87
107 toggleVisibility: function() { 88 toggleVisibility: function() {
108 this.opened = !this.opened; 89 this.opened = !this.opened;
109 this.cancelAnimation(); 90 this.cancelAnimation();
110 this.playAnimation(this.opened ? 'entry' : 'exit'); 91 this.playAnimation(this.opened ? 'entry' : 'exit');
111 }, 92 },
112 93
113 selectPageNumber: function() { 94 selectPageNumber: function() {
114 this.$.pageselector.select(); 95 this.$.pageselector.select();
115 }, 96 },
116 97
117 shouldKeepOpen: function() { 98 shouldKeepOpen: function() {
118 return this.$.bookmarks.dropdownOpen || this.loadProgress < 100 || 99 return this.$.bookmarks.dropdownOpen || this.loadProgress < 100 ||
119 this.$.pageselector.isActive(); 100 this.$.pageselector.isActive();
120 }, 101 },
121 102
122 hideDropdowns: function() { 103 hideDropdowns: function() {
123 if (this.$.bookmarks.dropdownOpen) { 104 if (this.$.bookmarks.dropdownOpen) {
124 this.$.bookmarks.toggleDropdown(); 105 this.$.bookmarks.toggleDropdown();
125 return true; 106 return true;
126 } 107 }
127 return false; 108 return false;
128 }, 109 },
129 110
130 setDropdownLowerBound: function(lowerBound) { 111 setDropdownLowerBound: function(lowerBound) {
131 this.$.bookmarks.lowerBound = lowerBound; 112 this.$.bookmarks.lowerBound = lowerBound;
132 }, 113 },
133 114
134 rotateRight: function() { 115 rotateRight: function() {
135 this.fire('rotate-right'); 116 this.fire('rotate-right');
136 }, 117 },
137 118
138 download: function() { 119 download: function() {
139 this.fire('save'); 120 this.fire('save');
140 }, 121 },
141 122
142 print: function() { 123 print: function() {
143 this.fire('print'); 124 this.fire('print');
144 } 125 }
145 }); 126 });
146 })(); 127 })();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698