| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 PromiseResolver() { | 4 function PromiseResolver() { |
| 5 this.resolve_; | 5 this.resolve_; |
| 6 this.reject_; | 6 this.reject_; |
| 7 this.promise_ = new Promise(function(resolve, reject) { | 7 this.promise_ = new Promise(function(resolve, reject) { |
| 8 this.resolve_ = resolve; | 8 this.resolve_ = resolve; |
| 9 this.reject_ = reject; | 9 this.reject_ = reject; |
| 10 }.bind(this)); | 10 }.bind(this)); |
| (...skipping 6308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6319 var node = config.node; | 6319 var node = config.node; |
| 6320 this._effect = new KeyframeEffect(node, [ { | 6320 this._effect = new KeyframeEffect(node, [ { |
| 6321 opacity: '1' | 6321 opacity: '1' |
| 6322 }, { | 6322 }, { |
| 6323 opacity: '0' | 6323 opacity: '0' |
| 6324 } ], this.timingFromConfig(config)); | 6324 } ], this.timingFromConfig(config)); |
| 6325 return this._effect; | 6325 return this._effect; |
| 6326 } | 6326 } |
| 6327 }); | 6327 }); |
| 6328 | 6328 |
| 6329 (function() { |
| 6330 Polymer({ |
| 6331 is: 'paper-listbox', |
| 6332 behaviors: [ Polymer.IronMenuBehavior ], |
| 6333 hostAttributes: { |
| 6334 role: 'listbox' |
| 6335 } |
| 6336 }); |
| 6337 })(); |
| 6338 |
| 6329 Polymer({ | 6339 Polymer({ |
| 6330 is: 'paper-menu-grow-height-animation', | 6340 is: 'paper-menu-grow-height-animation', |
| 6331 behaviors: [ Polymer.NeonAnimationBehavior ], | 6341 behaviors: [ Polymer.NeonAnimationBehavior ], |
| 6332 configure: function(config) { | 6342 configure: function(config) { |
| 6333 var node = config.node; | 6343 var node = config.node; |
| 6334 var rect = node.getBoundingClientRect(); | 6344 var rect = node.getBoundingClientRect(); |
| 6335 var height = rect.height; | 6345 var height = rect.height; |
| 6336 this._effect = new KeyframeEffect(node, [ { | 6346 this._effect = new KeyframeEffect(node, [ { |
| 6337 height: height / 2 + 'px' | 6347 height: height / 2 + 'px' |
| 6338 }, { | 6348 }, { |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6394 } | 6404 } |
| 6395 }); | 6405 }); |
| 6396 | 6406 |
| 6397 // Copyright 2016 The Chromium Authors. All rights reserved. | 6407 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 6398 // Use of this source code is governed by a BSD-style license that can be | 6408 // Use of this source code is governed by a BSD-style license that can be |
| 6399 // found in the LICENSE file. | 6409 // found in the LICENSE file. |
| 6400 var SLIDE_CUBIC_BEZIER = 'cubic-bezier(0.3, 0.95, 0.5, 1)'; | 6410 var SLIDE_CUBIC_BEZIER = 'cubic-bezier(0.3, 0.95, 0.5, 1)'; |
| 6401 | 6411 |
| 6402 Polymer({ | 6412 Polymer({ |
| 6403 is: 'cr-shared-menu', | 6413 is: 'cr-shared-menu', |
| 6404 behaviors: [ Polymer.IronA11yKeysBehavior ], | |
| 6405 properties: { | 6414 properties: { |
| 6406 menuOpen: { | 6415 menuOpen: { |
| 6407 type: Boolean, | 6416 type: Boolean, |
| 6408 observer: 'menuOpenChanged_', | 6417 observer: 'menuOpenChanged_', |
| 6409 value: false, | 6418 value: false, |
| 6410 notify: true | 6419 notify: true |
| 6411 }, | 6420 }, |
| 6412 itemData: { | 6421 itemData: { |
| 6413 type: Object, | 6422 type: Object, |
| 6414 value: null | 6423 value: null |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6450 value: function() { | 6459 value: function() { |
| 6451 return [ { | 6460 return [ { |
| 6452 name: 'fade-out-animation', | 6461 name: 'fade-out-animation', |
| 6453 timing: { | 6462 timing: { |
| 6454 duration: 150 | 6463 duration: 150 |
| 6455 } | 6464 } |
| 6456 } ]; | 6465 } ]; |
| 6457 } | 6466 } |
| 6458 } | 6467 } |
| 6459 }, | 6468 }, |
| 6460 keyBindings: { | |
| 6461 tab: 'onTabPressed_' | |
| 6462 }, | |
| 6463 listeners: { | 6469 listeners: { |
| 6464 'dropdown.iron-overlay-canceled': 'onOverlayCanceled_' | 6470 'dropdown.iron-overlay-canceled': 'onOverlayCanceled_' |
| 6465 }, | 6471 }, |
| 6466 lastAnchor_: null, | 6472 lastAnchor_: null, |
| 6467 firstFocus_: null, | |
| 6468 lastFocus_: null, | |
| 6469 attached: function() { | 6473 attached: function() { |
| 6470 window.addEventListener('resize', this.closeMenu.bind(this)); | 6474 window.addEventListener('resize', this.closeMenu.bind(this)); |
| 6475 this.$.menu.addEventListener('keydown', this.onCaptureKeyDown_.bind(this), t
rue); |
| 6471 }, | 6476 }, |
| 6472 closeMenu: function() { | 6477 closeMenu: function() { |
| 6473 if (this.root.activeElement == null) { | 6478 if (this.root.activeElement == null) { |
| 6474 this.$.dropdown.restoreFocusOnClose = false; | 6479 this.$.dropdown.restoreFocusOnClose = false; |
| 6475 } | 6480 } |
| 6476 this.menuOpen = false; | 6481 this.menuOpen = false; |
| 6477 }, | 6482 }, |
| 6478 openMenu: function(anchor, itemData) { | 6483 openMenu: function(anchor, opt_itemData) { |
| 6479 if (this.lastAnchor_ == anchor && this.menuOpen) return; | 6484 if (this.lastAnchor_ == anchor && this.menuOpen) return; |
| 6480 if (this.menuOpen) this.closeMenu(); | 6485 if (this.menuOpen) this.closeMenu(); |
| 6481 this.itemData = itemData; | 6486 this.itemData = opt_itemData || null; |
| 6482 this.lastAnchor_ = anchor; | 6487 this.lastAnchor_ = anchor; |
| 6483 this.$.dropdown.restoreFocusOnClose = true; | 6488 this.$.dropdown.restoreFocusOnClose = true; |
| 6484 var focusableChildren = Polymer.dom(this).querySelectorAll('[tabindex]:not([
disabled]):not([hidden]),' + 'button:not([disabled]):not([hidden])'); | 6489 this.$.menu.selected = -1; |
| 6485 if (focusableChildren.length > 0) { | |
| 6486 this.$.dropdown.focusTarget = focusableChildren[0]; | |
| 6487 this.firstFocus_ = focusableChildren[0]; | |
| 6488 this.lastFocus_ = focusableChildren[focusableChildren.length - 1]; | |
| 6489 } | |
| 6490 this.$.dropdown.positionTarget = anchor; | 6490 this.$.dropdown.positionTarget = anchor; |
| 6491 this.menuOpen = true; | 6491 this.menuOpen = true; |
| 6492 }, | 6492 }, |
| 6493 toggleMenu: function(anchor, itemData) { | 6493 toggleMenu: function(anchor, opt_itemData) { |
| 6494 if (anchor == this.lastAnchor_ && this.menuOpen) this.closeMenu(); else this
.openMenu(anchor, itemData); | 6494 if (anchor == this.lastAnchor_ && this.menuOpen) this.closeMenu(); else this
.openMenu(anchor, opt_itemData); |
| 6495 }, | 6495 }, |
| 6496 onTabPressed_: function(e) { | 6496 onCaptureKeyDown_: function(e) { |
| 6497 if (!this.firstFocus_ || !this.lastFocus_) return; | 6497 if (Polymer.IronA11yKeysBehavior.keyboardEventMatchesKeys(e, 'tab')) { |
| 6498 var toFocus; | 6498 this.$.dropdown.restoreFocusOnClose = false; |
| 6499 var keyEvent = e.detail.keyboardEvent; | 6499 this.lastAnchor_.focus(); |
| 6500 if (keyEvent.shiftKey && keyEvent.target == this.firstFocus_) toFocus = this
.lastFocus_; else if (!keyEvent.shiftKey && keyEvent.target == this.lastFocus_)
toFocus = this.firstFocus_; | 6500 this.closeMenu(); |
| 6501 if (!toFocus) return; | 6501 } |
| 6502 e.preventDefault(); | |
| 6503 toFocus.focus(); | |
| 6504 }, | 6502 }, |
| 6505 menuOpenChanged_: function() { | 6503 menuOpenChanged_: function() { |
| 6506 if (!this.menuOpen) { | 6504 if (!this.menuOpen) { |
| 6507 this.itemData = null; | 6505 this.itemData = null; |
| 6508 this.lastAnchor_ = null; | 6506 this.lastAnchor_ = null; |
| 6509 } | 6507 } |
| 6510 }, | 6508 }, |
| 6511 onOverlayCanceled_: function(e) { | 6509 onOverlayCanceled_: function(e) { |
| 6512 if (e.detail.type == 'tap') this.$.dropdown.restoreFocusOnClose = false; | 6510 if (e.detail.type == 'tap') this.$.dropdown.restoreFocusOnClose = false; |
| 6513 } | 6511 } |
| (...skipping 2426 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8940 | 8938 |
| 8941 case HistoryRange.MONTH: | 8939 case HistoryRange.MONTH: |
| 8942 histogramValue = HistoryPageViewHistogram.GROUPED_MONTH; | 8940 histogramValue = HistoryPageViewHistogram.GROUPED_MONTH; |
| 8943 break; | 8941 break; |
| 8944 } | 8942 } |
| 8945 break; | 8943 break; |
| 8946 } | 8944 } |
| 8947 md_history.BrowserService.getInstance().recordHistogram('History.HistoryPage
View', histogramValue, HistoryPageViewHistogram.END); | 8945 md_history.BrowserService.getInstance().recordHistogram('History.HistoryPage
View', histogramValue, HistoryPageViewHistogram.END); |
| 8948 } | 8946 } |
| 8949 }); | 8947 }); |
| OLD | NEW |