From 7aa4a6e345e3b58181ab6c0a166e8d1645a58490 Mon Sep 17 00:00:00 2001 From: Bob Trahan Date: Wed, 22 May 2013 16:08:23 -0700 Subject: [PATCH] Randomsauce - make the align-rightness of PhabricatorDropdownMenu configurable Summary: using this for the Conpherence drop down menu and it should be left aligned. This makes that work. Test Plan: using it in conpherence and it aligns how I want it. also still aligns right in other existing usage spot - differential Reviewers: epriestley Reviewed By: epriestley CC: chad, aran, Korvin Differential Revision: https://secure.phabricator.com/D6002 --- webroot/rsrc/js/core/DropdownMenu.js | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/webroot/rsrc/js/core/DropdownMenu.js b/webroot/rsrc/js/core/DropdownMenu.js index f22380c379..112989daef 100644 --- a/webroot/rsrc/js/core/DropdownMenu.js +++ b/webroot/rsrc/js/core/DropdownMenu.js @@ -45,6 +45,13 @@ JX.install('PhabricatorDropdownMenu', { _menu : null, _open : false, _items : null, + _alignRight : true, + + // By default, the dropdown will have its right edge aligned with the + // right edge of _node. Making this false does left edge alignment + toggleAlignDropdownRight : function (bool) { + this._alignRight = bool; + }, open : function() { if (this._open) { @@ -127,10 +134,15 @@ JX.install('PhabricatorDropdownMenu', { var m = JX.Vector.getDim(this._menu); - JX.$V(this._node) - .add(JX.Vector.getDim(this._node)) - .add(JX.$V(-m.x, 0)) - .setPos(this._menu); + var v = JX.$V(this._node); + var d = JX.Vector.getDim(this._node); + if (this._alignRight) { + v = v.add(d) + .add(JX.$V(-m.x, 0)); + } else { + v = v.add(0, d.y); + } + v.setPos(this._menu); JX.DOM.alterClass(this._node, 'dropdown-open', true); },