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

Side by Side Diff: third_party/polymer/v1_0/components-chromium/paper-menu-button/paper-menu-button-extracted.js

Issue 2158913007: Roll Polymer from 1.5.0 -> 1.6.0 to pick up native CSS custom props (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: merge Created 4 years, 4 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 (function() { 1 (function() {
2 'use strict'; 2 'use strict';
3 3
4 var config = {
5 ANIMATION_CUBIC_BEZIER: 'cubic-bezier(.3,.95,.5,1)',
6 MAX_ANIMATION_TIME_MS: 400
7 };
8
4 var PaperMenuButton = Polymer({ 9 var PaperMenuButton = Polymer({
5 is: 'paper-menu-button', 10 is: 'paper-menu-button',
6 11
7 /** 12 /**
8 * Fired when the dropdown opens. 13 * Fired when the dropdown opens.
9 * 14 *
10 * @event paper-dropdown-open 15 * @event paper-dropdown-open
11 */ 16 */
12 17
13 /** 18 /**
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 * The orientation against which to align the menu dropdown 51 * The orientation against which to align the menu dropdown
47 * vertically relative to the dropdown trigger. 52 * vertically relative to the dropdown trigger.
48 */ 53 */
49 verticalAlign: { 54 verticalAlign: {
50 type: String, 55 type: String,
51 value: 'top', 56 value: 'top',
52 reflectToAttribute: true 57 reflectToAttribute: true
53 }, 58 },
54 59
55 /** 60 /**
61 * If true, the `horizontalAlign` and `verticalAlign` properties will
62 * be considered preferences instead of strict requirements when
63 * positioning the dropdown and may be changed if doing so reduces
64 * the area of the dropdown falling outside of `fitInto`.
65 */
66 dynamicAlign: {
67 type: Boolean
68 },
69
70 /**
56 * A pixel value that will be added to the position calculated for the 71 * A pixel value that will be added to the position calculated for the
57 * given `horizontalAlign`. Use a negative value to offset to the 72 * given `horizontalAlign`. Use a negative value to offset to the
58 * left, or a positive value to offset to the right. 73 * left, or a positive value to offset to the right.
59 */ 74 */
60 horizontalOffset: { 75 horizontalOffset: {
61 type: Number, 76 type: Number,
62 value: 0, 77 value: 0,
63 notify: true 78 notify: true
64 }, 79 },
65 80
66 /** 81 /**
67 * A pixel value that will be added to the position calculated for the 82 * A pixel value that will be added to the position calculated for the
68 * given `verticalAlign`. Use a negative value to offset towards the 83 * given `verticalAlign`. Use a negative value to offset towards the
69 * top, or a positive value to offset towards the bottom. 84 * top, or a positive value to offset towards the bottom.
70 */ 85 */
71 verticalOffset: { 86 verticalOffset: {
72 type: Number, 87 type: Number,
73 value: 0, 88 value: 0,
74 notify: true 89 notify: true
75 }, 90 },
76 91
77 /** 92 /**
93 * If true, the dropdown will be positioned so that it doesn't overlap
94 * the button.
95 */
96 noOverlap: {
97 type: Boolean
98 },
99
100 /**
78 * Set to true to disable animations when opening and closing the 101 * Set to true to disable animations when opening and closing the
79 * dropdown. 102 * dropdown.
80 */ 103 */
81 noAnimations: { 104 noAnimations: {
82 type: Boolean, 105 type: Boolean,
83 value: false 106 value: false
84 }, 107 },
85 108
86 /** 109 /**
87 * Set to true to disable automatically closing the dropdown after 110 * Set to true to disable automatically closing the dropdown after
88 * a selection has been made. 111 * a selection has been made.
89 */ 112 */
90 ignoreSelect: { 113 ignoreSelect: {
91 type: Boolean, 114 type: Boolean,
92 value: false 115 value: false
93 }, 116 },
94 117
95 /** 118 /**
119 * Set to true to enable automatically closing the dropdown after an
120 * item has been activated, even if the selection did not change.
121 */
122 closeOnActivate: {
123 type: Boolean,
124 value: false
125 },
126
127 /**
96 * An animation config. If provided, this will be used to animate the 128 * An animation config. If provided, this will be used to animate the
97 * opening of the dropdown. 129 * opening of the dropdown.
98 */ 130 */
99 openAnimationConfig: { 131 openAnimationConfig: {
100 type: Object, 132 type: Object,
101 value: function() { 133 value: function() {
102 return [{ 134 return [{
103 name: 'fade-in-animation', 135 name: 'fade-in-animation',
104 timing: { 136 timing: {
105 delay: 100, 137 delay: 100,
106 duration: 200 138 duration: 200
107 } 139 }
108 }, { 140 }, {
109 name: 'paper-menu-grow-width-animation', 141 name: 'paper-menu-grow-width-animation',
110 timing: { 142 timing: {
111 delay: 100, 143 delay: 100,
112 duration: 150, 144 duration: 150,
113 easing: PaperMenuButton.ANIMATION_CUBIC_BEZIER 145 easing: config.ANIMATION_CUBIC_BEZIER
114 } 146 }
115 }, { 147 }, {
116 name: 'paper-menu-grow-height-animation', 148 name: 'paper-menu-grow-height-animation',
117 timing: { 149 timing: {
118 delay: 100, 150 delay: 100,
119 duration: 275, 151 duration: 275,
120 easing: PaperMenuButton.ANIMATION_CUBIC_BEZIER 152 easing: config.ANIMATION_CUBIC_BEZIER
121 } 153 }
122 }]; 154 }];
123 } 155 }
124 }, 156 },
125 157
126 /** 158 /**
127 * An animation config. If provided, this will be used to animate the 159 * An animation config. If provided, this will be used to animate the
128 * closing of the dropdown. 160 * closing of the dropdown.
129 */ 161 */
130 closeAnimationConfig: { 162 closeAnimationConfig: {
131 type: Object, 163 type: Object,
132 value: function() { 164 value: function() {
133 return [{ 165 return [{
134 name: 'fade-out-animation', 166 name: 'fade-out-animation',
135 timing: { 167 timing: {
136 duration: 150 168 duration: 150
137 } 169 }
138 }, { 170 }, {
139 name: 'paper-menu-shrink-width-animation', 171 name: 'paper-menu-shrink-width-animation',
140 timing: { 172 timing: {
141 delay: 100, 173 delay: 100,
142 duration: 50, 174 duration: 50,
143 easing: PaperMenuButton.ANIMATION_CUBIC_BEZIER 175 easing: config.ANIMATION_CUBIC_BEZIER
144 } 176 }
145 }, { 177 }, {
146 name: 'paper-menu-shrink-height-animation', 178 name: 'paper-menu-shrink-height-animation',
147 timing: { 179 timing: {
148 duration: 200, 180 duration: 200,
149 easing: 'ease-in' 181 easing: 'ease-in'
150 } 182 }
151 }]; 183 }];
152 } 184 }
153 }, 185 },
186
187 /**
188 * By default, the dropdown will constrain scrolling on the page
189 * to itself when opened.
190 * Set to true in order to prevent scroll from being constrained
191 * to the dropdown when it opens.
192 */
193 allowOutsideScroll: {
194 type: Boolean,
195 value: false
196 },
154 197
155 /** 198 /**
156 * This is the element intended to be bound as the focus target 199 * This is the element intended to be bound as the focus target
157 * for the `iron-dropdown` contained by `paper-menu-button`. 200 * for the `iron-dropdown` contained by `paper-menu-button`.
158 */ 201 */
159 _dropdownContent: { 202 _dropdownContent: {
160 type: Object 203 type: Object
161 } 204 }
162 }, 205 },
163 206
164 hostAttributes: { 207 hostAttributes: {
165 role: 'group', 208 role: 'group',
166 'aria-haspopup': 'true' 209 'aria-haspopup': 'true'
167 }, 210 },
168 211
169 listeners: { 212 listeners: {
213 'iron-activate': '_onIronActivate',
170 'iron-select': '_onIronSelect' 214 'iron-select': '_onIronSelect'
171 }, 215 },
172 216
173 /** 217 /**
174 * The content element that is contained by the menu button, if any. 218 * The content element that is contained by the menu button, if any.
175 */ 219 */
176 get contentElement() { 220 get contentElement() {
177 return Polymer.dom(this.$.content).getDistributedNodes()[0]; 221 return Polymer.dom(this.$.content).getDistributedNodes()[0];
178 }, 222 },
179 223
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
214 * @param {CustomEvent} event A CustomEvent instance with type 258 * @param {CustomEvent} event A CustomEvent instance with type
215 * set to `"iron-select"`. 259 * set to `"iron-select"`.
216 */ 260 */
217 _onIronSelect: function(event) { 261 _onIronSelect: function(event) {
218 if (!this.ignoreSelect) { 262 if (!this.ignoreSelect) {
219 this.close(); 263 this.close();
220 } 264 }
221 }, 265 },
222 266
223 /** 267 /**
268 * Closes the dropdown when an `iron-activate` event is received if
269 * `closeOnActivate` is true.
270 *
271 * @param {CustomEvent} event A CustomEvent of type 'iron-activate'.
272 */
273 _onIronActivate: function(event) {
274 if (this.closeOnActivate) {
275 this.close();
276 }
277 },
278
279 /**
224 * When the dropdown opens, the `paper-menu-button` fires `paper-open`. 280 * When the dropdown opens, the `paper-menu-button` fires `paper-open`.
225 * When the dropdown closes, the `paper-menu-button` fires `paper-close` . 281 * When the dropdown closes, the `paper-menu-button` fires `paper-close` .
226 * 282 *
227 * @param {boolean} opened True if the dropdown is opened, otherwise fal se. 283 * @param {boolean} opened True if the dropdown is opened, otherwise fal se.
228 * @param {boolean} oldOpened The previous value of `opened`. 284 * @param {boolean} oldOpened The previous value of `opened`.
229 */ 285 */
230 _openedChanged: function(opened, oldOpened) { 286 _openedChanged: function(opened, oldOpened) {
231 if (opened) { 287 if (opened) {
232 // TODO(cdata): Update this when we can measure changes in distribut ed 288 // TODO(cdata): Update this when we can measure changes in distribut ed
233 // children in an idiomatic way. 289 // children in an idiomatic way.
(...skipping 25 matching lines...) Expand all
259 var target = Polymer.dom(uiEvent).rootTarget; 315 var target = Polymer.dom(uiEvent).rootTarget;
260 var trigger = this.$.trigger; 316 var trigger = this.$.trigger;
261 var path = Polymer.dom(uiEvent).path; 317 var path = Polymer.dom(uiEvent).path;
262 318
263 if (path.indexOf(trigger) > -1) { 319 if (path.indexOf(trigger) > -1) {
264 event.preventDefault(); 320 event.preventDefault();
265 } 321 }
266 } 322 }
267 }); 323 });
268 324
269 PaperMenuButton.ANIMATION_CUBIC_BEZIER = 'cubic-bezier(.3,.95,.5,1)'; 325 Object.keys(config).forEach(function (key) {
270 PaperMenuButton.MAX_ANIMATION_TIME_MS = 400; 326 PaperMenuButton[key] = config[key];
327 });
271 328
272 Polymer.PaperMenuButton = PaperMenuButton; 329 Polymer.PaperMenuButton = PaperMenuButton;
273 })(); 330 })();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698