1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-29 00:40:57 +01:00

Use ActionList-based dropdowns in Conpherence

Summary:
See D8966, D8973. Replace PhabricatorDropdownMenu with PHUIXDropdownMenu.

These new menus look weird on mobile because all action lists pick up a bunch of weird styles on mobile and we're now reusing the CSS.

Test Plan:
{F150425}

{F150426}

Reviewers: btrahan, chad

Reviewed By: btrahan

Subscribers: epriestley

Differential Revision: https://secure.phabricator.com/D8974
This commit is contained in:
epriestley 2014-05-05 10:56:38 -07:00
parent 56aa508f43
commit 7584d10b49
5 changed files with 52 additions and 29 deletions

View file

@ -81,11 +81,13 @@ final class ConpherenceLayoutView extends AphrontView {
'widgetRegistry' => array( 'widgetRegistry' => array(
'conpherence-message-pane' => array( 'conpherence-message-pane' => array(
'name' => pht('Thread'), 'name' => pht('Thread'),
'icon' => 'comment',
'deviceOnly' => true, 'deviceOnly' => true,
'hasCreate' => false 'hasCreate' => false
), ),
'widgets-people' => array( 'widgets-people' => array(
'name' => pht('Participants'), 'name' => pht('Participants'),
'icon' => 'user',
'deviceOnly' => false, 'deviceOnly' => false,
'hasCreate' => true, 'hasCreate' => true,
'createData' => array( 'createData' => array(
@ -96,11 +98,13 @@ final class ConpherenceLayoutView extends AphrontView {
), ),
'widgets-files' => array( 'widgets-files' => array(
'name' => pht('Files'), 'name' => pht('Files'),
'icon' => 'file',
'deviceOnly' => false, 'deviceOnly' => false,
'hasCreate' => false 'hasCreate' => false
), ),
'widgets-calendar' => array( 'widgets-calendar' => array(
'name' => pht('Calendar'), 'name' => pht('Calendar'),
'icon' => 'calendar',
'deviceOnly' => false, 'deviceOnly' => false,
'hasCreate' => true, 'hasCreate' => true,
'createData' => array( 'createData' => array(
@ -111,6 +115,7 @@ final class ConpherenceLayoutView extends AphrontView {
), ),
'widgets-settings' => array( 'widgets-settings' => array(
'name' => pht('Settings'), 'name' => pht('Settings'),
'icon' => 'wrench',
'deviceOnly' => false, 'deviceOnly' => false,
'hasCreate' => false 'hasCreate' => false
), ),

View file

@ -62,11 +62,6 @@
display: none; display: none;
} }
.dropdown-menu-frame {
width: 200px !important;
margin-top: 4px;
}
.conpherence-widget-pane .widgets-body { .conpherence-widget-pane .widgets-body {
position: fixed; position: fixed;
overflow-y: auto; overflow-y: auto;

View file

@ -11,6 +11,12 @@
display: none; display: none;
} }
.device .phuix-dropdown-menu .phabricator-action-list-view {
/* When an action list view appears inside a dropdown menu, don't hide it
by default. */
display: block;
}
.device .phabricator-action-list-view.phabricator-action-list-toggle { .device .phabricator-action-list-view.phabricator-action-list-toggle {
display: block; display: block;
} }

View file

@ -6,8 +6,9 @@
* javelin-util * javelin-util
* phabricator-notification * phabricator-notification
* javelin-behavior-device * javelin-behavior-device
* phabricator-dropdown-menu * phuix-dropdown-menu
* phabricator-menu-item * phuix-action-list-view
* phuix-action-view
* @provides javelin-behavior-conpherence-widget-pane * @provides javelin-behavior-conpherence-widget-pane
*/ */
@ -37,7 +38,7 @@ JX.behavior('conpherence-widget-pane', function(config) {
return; return;
} }
JX.DOM.show(device_header); JX.DOM.show(device_header);
var device_menu = new JX.PhabricatorDropdownMenu(device_header); var device_menu = new JX.PHUIXDropdownMenu(device_header);
data.deviceMenu = true; data.deviceMenu = true;
_buildWidgetSelector(device_menu, data); _buildWidgetSelector(device_menu, data);
}; };
@ -51,8 +52,12 @@ JX.behavior('conpherence-widget-pane', function(config) {
var root = JX.DOM.find(document, 'div', 'conpherence-layout'); var root = JX.DOM.find(document, 'div', 'conpherence-layout');
var widget_pane = JX.DOM.find(root, 'div', 'conpherence-widget-pane'); var widget_pane = JX.DOM.find(root, 'div', 'conpherence-widget-pane');
var widget_header = JX.DOM.find(widget_pane, 'a', 'widgets-selector'); var widget_header = JX.DOM.find(widget_pane, 'a', 'widgets-selector');
var menu = new JX.PhabricatorDropdownMenu(widget_header);
menu.toggleAlignDropdownRight(false); var menu = new JX.PHUIXDropdownMenu(widget_header);
menu
.setAlign('left')
.setOffsetY(4);
data.deviceMenu = false; data.deviceMenu = false;
_buildWidgetSelector(menu, data); _buildWidgetSelector(menu, data);
}; };
@ -64,32 +69,40 @@ JX.behavior('conpherence-widget-pane', function(config) {
*/ */
var _buildWidgetSelector = function (menu, data) { var _buildWidgetSelector = function (menu, data) {
_loadedWidgetsID = data.threadID; _loadedWidgetsID = data.threadID;
var list = new JX.PHUIXActionListView();
var map = {};
var widgets = config.widgetRegistry; var widgets = config.widgetRegistry;
for (var widget in widgets) { for (var widget in widgets) {
var widget_data = widgets[widget]; var widget_data = widgets[widget];
if (widget_data.deviceOnly && data.deviceMenu === false) { if (widget_data.deviceOnly && data.deviceMenu === false) {
continue; continue;
} }
menu.addItem(new JX.PhabricatorMenuItem(
widget_data.name, var item = new JX.PHUIXActionView()
JX.bind(null, toggleWidget, { widget : widget }), .setIcon(widget_data.icon || 'none')
'#' .setName(widget_data.name)
).setDisabled(widget == data.widget)); .setHandler(
JX.bind(null, function(widget, e) {
toggleWidget({widget: widget});
e.prevent();
menu.close();
}, widget));
map[widget_data.name] = item;
list.addItem(item);
} }
menu.listen( menu
'open', .setWidth(200)
JX.bind(menu, function () { .setContent(list.getNode());
for (var ii = 0; ii < this._items.length; ii++) {
var item = this._items[ii]; menu.listen('open', function() {
var name = item.getName(); for (var k in map) {
if (name == _selectedWidgetName) { map[k].setDisabled((k == _selectedWidgetName));
item.setDisabled(true); }
} else { });
item.setDisabled(false);
}
}
}));
}; };
/** /**

View file

@ -44,7 +44,9 @@ JX.install('PHUIXDropdownMenu', {
properties: { properties: {
width: null, width: null,
align: 'right' align: 'right',
offsetX: 0,
offsetY: 0
}, },
members: { members: {
@ -171,6 +173,8 @@ JX.install('PHUIXDropdownMenu', {
break; break;
} }
v = v.add(this.getOffsetX(), this.getOffsetY());
v.setPos(this._menu); v.setPos(this._menu);
} }
} }