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

Unified Diff: chrome/browser/resources/md_history/lazy_load.crisper.js

Issue 2614663011: MD WebUI: Fix incorrect positioning of action menu after window resize (Closed)
Patch Set: forgot vulcanize lol whoops Created 3 years, 11 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/resources/md_history/lazy_load.crisper.js
diff --git a/chrome/browser/resources/md_history/lazy_load.crisper.js b/chrome/browser/resources/md_history/lazy_load.crisper.js
index bfd93f4c20510141e2f95661429f67ea031247f4..88861d34b4d3910d07b68e8615aad1daa7aeeea8 100644
--- a/chrome/browser/resources/md_history/lazy_load.crisper.js
+++ b/chrome/browser/resources/md_history/lazy_load.crisper.js
@@ -10,7 +10,7 @@ cr.define("cr.ui",function(){function FocusGrid(){this.rows=[]}FocusGrid.prototy
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-Polymer({is:"cr-action-menu","extends":"dialog",options_:null,anchorElement_:null,onWindowResize_:null,hostAttributes:{tabindex:0},listeners:{keydown:"onKeyDown_",tap:"onTap_"},attached:function(){this.options_=this.querySelectorAll(".dropdown-item")},detached:function(){this.removeResizeListener_()},removeResizeListener_:function(){window.removeEventListener("resize",this.onWindowResize_)},onTap_:function(e){if(e.target==this){this.close();e.stopPropagation()}},onKeyDown_:function(e){if(e.key=="Tab"||e.key=="Escape"){this.close();e.preventDefault();return}if(e.key!=="ArrowDown"&&e.key!=="ArrowUp")return;var nextOption=this.getNextOption_(e.key=="ArrowDown"?1:-1);if(nextOption)nextOption.focus();e.preventDefault()},getNextOption_:function(step){var counter=0;var nextOption=null;var numOptions=this.options_.length;var focusedIndex=Array.prototype.indexOf.call(this.options_,this.root.activeElement);do{focusedIndex=(numOptions+focusedIndex+step)%numOptions;nextOption=this.options_[focusedIndex];if(nextOption.disabled||nextOption.hidden)nextOption=null;counter++}while(!nextOption&&counter<numOptions);return nextOption},close:function(){this.removeResizeListener_();HTMLDialogElement.prototype.close.call(this);this.anchorElement_.focus();this.anchorElement_=null},showAt:function(anchorElement){this.anchorElement_=anchorElement;this.onWindowResize_=this.onWindowResize_||function(){if(this.open)this.close()}.bind(this);window.addEventListener("resize",this.onWindowResize_);this.showModal();var rect=this.anchorElement_.getBoundingClientRect();if(getComputedStyle(this.anchorElement_).direction=="rtl"){var right=window.innerWidth-rect.left-this.offsetWidth;this.style.right=right+"px"}else{var left=rect.right-this.offsetWidth;this.style.left=left+"px"}var top=rect.top+this.offsetHeight<=window.innerHeight?rect.top:rect.bottom-this.offsetHeight-Math.max(rect.bottom-window.innerHeight,0);this.style.top=top+"px"}});Polymer({is:"paper-icon-button-light","extends":"button",behaviors:[Polymer.PaperRippleBehavior],listeners:{down:"_rippleDown",up:"_rippleUp",focus:"_rippleDown",blur:"_rippleUp"},_rippleDown:function(){this.getRipple().downAction()},_rippleUp:function(){this.getRipple().upAction()},ensureRipple:function(var_args){var lastRipple=this._ripple;Polymer.PaperRippleBehavior.ensureRipple.apply(this,arguments);if(this._ripple&&this._ripple!==lastRipple){this._ripple.center=true;this._ripple.classList.add("circle")}}});
+Polymer({is:"cr-action-menu","extends":"dialog",options_:null,anchorElement_:null,onWindowResize_:null,hostAttributes:{tabindex:0},listeners:{keydown:"onKeyDown_",tap:"onTap_"},attached:function(){this.options_=this.querySelectorAll(".dropdown-item")},detached:function(){this.removeResizeListener_()},removeResizeListener_:function(){window.removeEventListener("resize",this.onWindowResize_)},onTap_:function(e){if(e.target==this){this.close();e.stopPropagation()}},onKeyDown_:function(e){if(e.key=="Tab"||e.key=="Escape"){this.close();e.preventDefault();return}if(e.key!=="ArrowDown"&&e.key!=="ArrowUp")return;var nextOption=this.getNextOption_(e.key=="ArrowDown"?1:-1);if(nextOption)nextOption.focus();e.preventDefault()},getNextOption_:function(step){var counter=0;var nextOption=null;var numOptions=this.options_.length;var focusedIndex=Array.prototype.indexOf.call(this.options_,this.root.activeElement);do{focusedIndex=(numOptions+focusedIndex+step)%numOptions;nextOption=this.options_[focusedIndex];if(nextOption.disabled||nextOption.hidden)nextOption=null;counter++}while(!nextOption&&counter<numOptions);return nextOption},close:function(){this.removeResizeListener_();HTMLDialogElement.prototype.close.call(this);this.anchorElement_.focus();this.anchorElement_=null},showAt:function(anchorElement){this.anchorElement_=anchorElement;this.onWindowResize_=this.onWindowResize_||function(){if(this.open)this.close()}.bind(this);window.addEventListener("resize",this.onWindowResize_);this.style.left="";this.style.right="";this.style.top="";this.showModal();var rect=this.anchorElement_.getBoundingClientRect();if(getComputedStyle(this.anchorElement_).direction=="rtl"){var right=window.innerWidth-rect.left-this.offsetWidth;this.style.right=right+"px"}else{var left=rect.right-this.offsetWidth;this.style.left=left+"px"}var top=rect.top+this.offsetHeight<=window.innerHeight?rect.top:rect.bottom-this.offsetHeight-Math.max(rect.bottom-window.innerHeight,0);this.style.top=top+"px"}});Polymer({is:"paper-icon-button-light","extends":"button",behaviors:[Polymer.PaperRippleBehavior],listeners:{down:"_rippleDown",up:"_rippleUp",focus:"_rippleDown",blur:"_rippleUp"},_rippleDown:function(){this.getRipple().downAction()},_rippleUp:function(){this.getRipple().upAction()},ensureRipple:function(var_args){var lastRipple=this._ripple;Polymer.PaperRippleBehavior.ensureRipple.apply(this,arguments);if(this._ripple&&this._ripple!==lastRipple){this._ripple.center=true;this._ripple.classList.add("circle")}}});
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

Powered by Google App Engine
This is Rietveld 408576698