1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-27 01:02:42 +01:00

Fix show/hide applications on homepage

Summary:
Fixes T2482. After D4792, menus have more formal structure, but previously we were just shoving some `<div>` into the middle of the thing. This no longer works correctly, since we end up with `<div class="nice-formal-div"><div></div>`.

Just put IDs on all the items we're going to show/hide instead so we don't have to render any half-tags.

Test Plan: Home page show/hide works again.

Reviewers: btrahan, chad

Reviewed By: btrahan

CC: aran

Maniphest Tasks: T2482

Differential Revision: https://secure.phabricator.com/D4810
This commit is contained in:
epriestley 2013-02-05 07:43:58 -08:00
parent e4a0c17079
commit 742ee44960
3 changed files with 90 additions and 86 deletions

View file

@ -1292,7 +1292,7 @@ celerity_register_resource_map(array(
), ),
'javelin-behavior-differential-keyboard-navigation' => 'javelin-behavior-differential-keyboard-navigation' =>
array( array(
'uri' => '/res/89e93cc9/rsrc/js/application/differential/behavior-keyboard-nav.js', 'uri' => '/res/a7798465/rsrc/js/application/differential/behavior-keyboard-nav.js',
'type' => 'js', 'type' => 'js',
'requires' => 'requires' =>
array( array(
@ -1664,21 +1664,9 @@ celerity_register_resource_map(array(
), ),
'disk' => '/rsrc/js/application/core/behavior-autofocus.js', 'disk' => '/rsrc/js/application/core/behavior-autofocus.js',
), ),
'javelin-behavior-phabricator-file-tree' =>
array(
'uri' => '/res/e9c96597/rsrc/js/application/core/behavior-file-tree.js',
'type' => 'js',
'requires' =>
array(
0 => 'javelin-behavior',
1 => 'phabricator-keyboard-shortcut',
2 => 'javelin-stratcom',
),
'disk' => '/rsrc/js/application/core/behavior-file-tree.js',
),
'javelin-behavior-phabricator-home-reveal-tiles' => 'javelin-behavior-phabricator-home-reveal-tiles' =>
array( array(
'uri' => '/res/7230ca0c/rsrc/js/application/core/behavior-home-reveal-tiles.js', 'uri' => '/res/b3c5cea9/rsrc/js/application/core/behavior-home-reveal-tiles.js',
'type' => 'js', 'type' => 'js',
'requires' => 'requires' =>
array( array(
@ -1716,7 +1704,7 @@ celerity_register_resource_map(array(
), ),
'javelin-behavior-phabricator-nav' => 'javelin-behavior-phabricator-nav' =>
array( array(
'uri' => '/res/222b9329/rsrc/js/application/core/behavior-phabricator-nav.js', 'uri' => '/res/cec31f3f/rsrc/js/application/core/behavior-phabricator-nav.js',
'type' => 'js', 'type' => 'js',
'requires' => 'requires' =>
array( array(
@ -3443,7 +3431,7 @@ celerity_register_resource_map(array(
'uri' => '/res/pkg/7d347135/core.pkg.css', 'uri' => '/res/pkg/7d347135/core.pkg.css',
'type' => 'css', 'type' => 'css',
), ),
'22373a47' => 'd2e59a7e' =>
array( array(
'name' => 'core.pkg.js', 'name' => 'core.pkg.js',
'symbols' => 'symbols' =>
@ -3482,7 +3470,7 @@ celerity_register_resource_map(array(
31 => 'javelin-behavior-global-drag-and-drop', 31 => 'javelin-behavior-global-drag-and-drop',
32 => 'javelin-behavior-phabricator-home-reveal-tiles', 32 => 'javelin-behavior-phabricator-home-reveal-tiles',
), ),
'uri' => '/res/pkg/22373a47/core.pkg.js', 'uri' => '/res/pkg/d2e59a7e/core.pkg.js',
'type' => 'js', 'type' => 'js',
), ),
'8edbada5' => '8edbada5' =>
@ -3520,7 +3508,7 @@ celerity_register_resource_map(array(
'uri' => '/res/pkg/ec01d039/differential.pkg.css', 'uri' => '/res/pkg/ec01d039/differential.pkg.css',
'type' => 'css', 'type' => 'css',
), ),
'95d0d865' => '1b2c991b' =>
array( array(
'name' => 'differential.pkg.js', 'name' => 'differential.pkg.js',
'symbols' => 'symbols' =>
@ -3545,7 +3533,7 @@ celerity_register_resource_map(array(
17 => 'javelin-behavior-differential-toggle-files', 17 => 'javelin-behavior-differential-toggle-files',
18 => 'javelin-behavior-differential-user-select', 18 => 'javelin-behavior-differential-user-select',
), ),
'uri' => '/res/pkg/95d0d865/differential.pkg.js', 'uri' => '/res/pkg/1b2c991b/differential.pkg.js',
'type' => 'js', 'type' => 'js',
), ),
'c8ce2d88' => 'c8ce2d88' =>
@ -3645,7 +3633,7 @@ celerity_register_resource_map(array(
'aphront-typeahead-control-css' => '7d347135', 'aphront-typeahead-control-css' => '7d347135',
'differential-changeset-view-css' => 'ec01d039', 'differential-changeset-view-css' => 'ec01d039',
'differential-core-view-css' => 'ec01d039', 'differential-core-view-css' => 'ec01d039',
'differential-inline-comment-editor' => '95d0d865', 'differential-inline-comment-editor' => '1b2c991b',
'differential-local-commits-view-css' => 'ec01d039', 'differential-local-commits-view-css' => 'ec01d039',
'differential-results-table-css' => 'ec01d039', 'differential-results-table-css' => 'ec01d039',
'differential-revision-add-comment-css' => 'ec01d039', 'differential-revision-add-comment-css' => 'ec01d039',
@ -3658,56 +3646,56 @@ celerity_register_resource_map(array(
'diffusion-icons-css' => 'c8ce2d88', 'diffusion-icons-css' => 'c8ce2d88',
'global-drag-and-drop-css' => '7d347135', 'global-drag-and-drop-css' => '7d347135',
'inline-comment-summary-css' => 'ec01d039', 'inline-comment-summary-css' => 'ec01d039',
'javelin-aphlict' => '22373a47', 'javelin-aphlict' => 'd2e59a7e',
'javelin-behavior' => '88225b70', 'javelin-behavior' => '88225b70',
'javelin-behavior-aphlict-dropdown' => '22373a47', 'javelin-behavior-aphlict-dropdown' => 'd2e59a7e',
'javelin-behavior-aphlict-listen' => '22373a47', 'javelin-behavior-aphlict-listen' => 'd2e59a7e',
'javelin-behavior-aphront-basic-tokenizer' => '22373a47', 'javelin-behavior-aphront-basic-tokenizer' => 'd2e59a7e',
'javelin-behavior-aphront-drag-and-drop' => '95d0d865', 'javelin-behavior-aphront-drag-and-drop' => '1b2c991b',
'javelin-behavior-aphront-drag-and-drop-textarea' => '95d0d865', 'javelin-behavior-aphront-drag-and-drop-textarea' => '1b2c991b',
'javelin-behavior-aphront-form-disable-on-submit' => '22373a47', 'javelin-behavior-aphront-form-disable-on-submit' => 'd2e59a7e',
'javelin-behavior-audit-preview' => 'f96657b8', 'javelin-behavior-audit-preview' => 'f96657b8',
'javelin-behavior-dark-console' => '8edbada5', 'javelin-behavior-dark-console' => '8edbada5',
'javelin-behavior-dark-console-ajax' => '8edbada5', 'javelin-behavior-dark-console-ajax' => '8edbada5',
'javelin-behavior-device' => '22373a47', 'javelin-behavior-device' => 'd2e59a7e',
'javelin-behavior-differential-accept-with-errors' => '95d0d865', 'javelin-behavior-differential-accept-with-errors' => '1b2c991b',
'javelin-behavior-differential-add-reviewers-and-ccs' => '95d0d865', 'javelin-behavior-differential-add-reviewers-and-ccs' => '1b2c991b',
'javelin-behavior-differential-comment-jump' => '95d0d865', 'javelin-behavior-differential-comment-jump' => '1b2c991b',
'javelin-behavior-differential-diff-radios' => '95d0d865', 'javelin-behavior-differential-diff-radios' => '1b2c991b',
'javelin-behavior-differential-dropdown-menus' => '95d0d865', 'javelin-behavior-differential-dropdown-menus' => '1b2c991b',
'javelin-behavior-differential-edit-inline-comments' => '95d0d865', 'javelin-behavior-differential-edit-inline-comments' => '1b2c991b',
'javelin-behavior-differential-feedback-preview' => '95d0d865', 'javelin-behavior-differential-feedback-preview' => '1b2c991b',
'javelin-behavior-differential-keyboard-navigation' => '95d0d865', 'javelin-behavior-differential-keyboard-navigation' => '1b2c991b',
'javelin-behavior-differential-populate' => '95d0d865', 'javelin-behavior-differential-populate' => '1b2c991b',
'javelin-behavior-differential-show-more' => '95d0d865', 'javelin-behavior-differential-show-more' => '1b2c991b',
'javelin-behavior-differential-toggle-files' => '95d0d865', 'javelin-behavior-differential-toggle-files' => '1b2c991b',
'javelin-behavior-differential-user-select' => '95d0d865', 'javelin-behavior-differential-user-select' => '1b2c991b',
'javelin-behavior-diffusion-commit-graph' => 'f96657b8', 'javelin-behavior-diffusion-commit-graph' => 'f96657b8',
'javelin-behavior-diffusion-pull-lastmodified' => 'f96657b8', 'javelin-behavior-diffusion-pull-lastmodified' => 'f96657b8',
'javelin-behavior-error-log' => '8edbada5', 'javelin-behavior-error-log' => '8edbada5',
'javelin-behavior-global-drag-and-drop' => '22373a47', 'javelin-behavior-global-drag-and-drop' => 'd2e59a7e',
'javelin-behavior-konami' => '22373a47', 'javelin-behavior-konami' => 'd2e59a7e',
'javelin-behavior-lightbox-attachments' => '22373a47', 'javelin-behavior-lightbox-attachments' => 'd2e59a7e',
'javelin-behavior-maniphest-batch-selector' => '7707de41', 'javelin-behavior-maniphest-batch-selector' => '7707de41',
'javelin-behavior-maniphest-subpriority-editor' => '7707de41', 'javelin-behavior-maniphest-subpriority-editor' => '7707de41',
'javelin-behavior-maniphest-transaction-controls' => '7707de41', 'javelin-behavior-maniphest-transaction-controls' => '7707de41',
'javelin-behavior-maniphest-transaction-expand' => '7707de41', 'javelin-behavior-maniphest-transaction-expand' => '7707de41',
'javelin-behavior-maniphest-transaction-preview' => '7707de41', 'javelin-behavior-maniphest-transaction-preview' => '7707de41',
'javelin-behavior-phabricator-active-nav' => '22373a47', 'javelin-behavior-phabricator-active-nav' => 'd2e59a7e',
'javelin-behavior-phabricator-autofocus' => '22373a47', 'javelin-behavior-phabricator-autofocus' => 'd2e59a7e',
'javelin-behavior-phabricator-home-reveal-tiles' => '22373a47', 'javelin-behavior-phabricator-home-reveal-tiles' => 'd2e59a7e',
'javelin-behavior-phabricator-keyboard-shortcuts' => '22373a47', 'javelin-behavior-phabricator-keyboard-shortcuts' => 'd2e59a7e',
'javelin-behavior-phabricator-nav' => '22373a47', 'javelin-behavior-phabricator-nav' => 'd2e59a7e',
'javelin-behavior-phabricator-object-selector' => '95d0d865', 'javelin-behavior-phabricator-object-selector' => '1b2c991b',
'javelin-behavior-phabricator-oncopy' => '22373a47', 'javelin-behavior-phabricator-oncopy' => 'd2e59a7e',
'javelin-behavior-phabricator-remarkup-assist' => '22373a47', 'javelin-behavior-phabricator-remarkup-assist' => 'd2e59a7e',
'javelin-behavior-phabricator-search-typeahead' => '22373a47', 'javelin-behavior-phabricator-search-typeahead' => 'd2e59a7e',
'javelin-behavior-phabricator-tooltips' => '22373a47', 'javelin-behavior-phabricator-tooltips' => 'd2e59a7e',
'javelin-behavior-phabricator-watch-anchor' => '22373a47', 'javelin-behavior-phabricator-watch-anchor' => 'd2e59a7e',
'javelin-behavior-refresh-csrf' => '22373a47', 'javelin-behavior-refresh-csrf' => 'd2e59a7e',
'javelin-behavior-repository-crossreference' => '95d0d865', 'javelin-behavior-repository-crossreference' => '1b2c991b',
'javelin-behavior-toggle-class' => '22373a47', 'javelin-behavior-toggle-class' => 'd2e59a7e',
'javelin-behavior-workflow' => '22373a47', 'javelin-behavior-workflow' => 'd2e59a7e',
'javelin-dom' => '88225b70', 'javelin-dom' => '88225b70',
'javelin-event' => '88225b70', 'javelin-event' => '88225b70',
'javelin-install' => '88225b70', 'javelin-install' => '88225b70',
@ -3729,39 +3717,39 @@ celerity_register_resource_map(array(
'lightbox-attachment-css' => '7d347135', 'lightbox-attachment-css' => '7d347135',
'maniphest-task-summary-css' => 'e30a3fa8', 'maniphest-task-summary-css' => 'e30a3fa8',
'maniphest-transaction-detail-css' => 'e30a3fa8', 'maniphest-transaction-detail-css' => 'e30a3fa8',
'phabricator-busy' => '22373a47', 'phabricator-busy' => 'd2e59a7e',
'phabricator-content-source-view-css' => 'ec01d039', 'phabricator-content-source-view-css' => 'ec01d039',
'phabricator-core-buttons-css' => '7d347135', 'phabricator-core-buttons-css' => '7d347135',
'phabricator-core-css' => '7d347135', 'phabricator-core-css' => '7d347135',
'phabricator-crumbs-view-css' => '7d347135', 'phabricator-crumbs-view-css' => '7d347135',
'phabricator-directory-css' => '7d347135', 'phabricator-directory-css' => '7d347135',
'phabricator-drag-and-drop-file-upload' => '95d0d865', 'phabricator-drag-and-drop-file-upload' => '1b2c991b',
'phabricator-dropdown-menu' => '22373a47', 'phabricator-dropdown-menu' => 'd2e59a7e',
'phabricator-file-upload' => '22373a47', 'phabricator-file-upload' => 'd2e59a7e',
'phabricator-filetree-view-css' => '7d347135', 'phabricator-filetree-view-css' => '7d347135',
'phabricator-flag-css' => '7d347135', 'phabricator-flag-css' => '7d347135',
'phabricator-form-view-css' => '7d347135', 'phabricator-form-view-css' => '7d347135',
'phabricator-header-view-css' => '7d347135', 'phabricator-header-view-css' => '7d347135',
'phabricator-jump-nav' => '7d347135', 'phabricator-jump-nav' => '7d347135',
'phabricator-keyboard-shortcut' => '22373a47', 'phabricator-keyboard-shortcut' => 'd2e59a7e',
'phabricator-keyboard-shortcut-manager' => '22373a47', 'phabricator-keyboard-shortcut-manager' => 'd2e59a7e',
'phabricator-main-menu-view' => '7d347135', 'phabricator-main-menu-view' => '7d347135',
'phabricator-menu-item' => '22373a47', 'phabricator-menu-item' => 'd2e59a7e',
'phabricator-nav-view-css' => '7d347135', 'phabricator-nav-view-css' => '7d347135',
'phabricator-notification' => '22373a47', 'phabricator-notification' => 'd2e59a7e',
'phabricator-notification-css' => '7d347135', 'phabricator-notification-css' => '7d347135',
'phabricator-notification-menu-css' => '7d347135', 'phabricator-notification-menu-css' => '7d347135',
'phabricator-object-item-list-view-css' => '7d347135', 'phabricator-object-item-list-view-css' => '7d347135',
'phabricator-object-selector-css' => 'ec01d039', 'phabricator-object-selector-css' => 'ec01d039',
'phabricator-paste-file-upload' => '22373a47', 'phabricator-paste-file-upload' => 'd2e59a7e',
'phabricator-prefab' => '22373a47', 'phabricator-prefab' => 'd2e59a7e',
'phabricator-project-tag-css' => 'e30a3fa8', 'phabricator-project-tag-css' => 'e30a3fa8',
'phabricator-remarkup-css' => '7d347135', 'phabricator-remarkup-css' => '7d347135',
'phabricator-shaped-request' => '95d0d865', 'phabricator-shaped-request' => '1b2c991b',
'phabricator-side-menu-view-css' => '7d347135', 'phabricator-side-menu-view-css' => '7d347135',
'phabricator-standard-page-view' => '7d347135', 'phabricator-standard-page-view' => '7d347135',
'phabricator-textareautils' => '22373a47', 'phabricator-textareautils' => 'd2e59a7e',
'phabricator-tooltip' => '22373a47', 'phabricator-tooltip' => 'd2e59a7e',
'phabricator-transaction-view-css' => '7d347135', 'phabricator-transaction-view-css' => '7d347135',
'phabricator-zindex-css' => '7d347135', 'phabricator-zindex-css' => '7d347135',
'sprite-apps-large-css' => '7d347135', 'sprite-apps-large-css' => '7d347135',

View file

@ -79,7 +79,7 @@ abstract class PhabricatorDirectoryController extends PhabricatorController {
$is_hide = ($tile_display == PhabricatorApplication::TILE_HIDE); $is_hide = ($tile_display == PhabricatorApplication::TILE_HIDE);
if ($is_hide) { if ($is_hide) {
$show_item_id = celerity_generate_unique_node_id(); $show_item_id = celerity_generate_unique_node_id();
$show_tiles_id = celerity_generate_unique_node_id(); $hide_item_id = celerity_generate_unique_node_id();
$show_item = id(new PhabricatorMenuItemView()) $show_item = id(new PhabricatorMenuItemView())
->setName(pht('Show More Applications')) ->setName(pht('Show More Applications'))
@ -90,18 +90,12 @@ abstract class PhabricatorDirectoryController extends PhabricatorController {
$hide_item = id(new PhabricatorMenuItemView()) $hide_item = id(new PhabricatorMenuItemView())
->setName(pht('Show Fewer Applications')) ->setName(pht('Show Fewer Applications'))
->setHref('#') ->setHref('#')
->setStyle('display: none')
->setID($hide_item_id)
->addSigil('home-hide-applications'); ->addSigil('home-hide-applications');
$nav->addMenuItem($show_item); $nav->addMenuItem($show_item);
$nav->addCustomBlock( $tile_ids = array($hide_item_id);
'<div '.
'id="'.phutil_escape_html($show_tiles_id).'"'.
'style="display: none;">');
Javelin::initBehavior('phabricator-home-reveal-tiles', array(
'tilesID' => $show_tiles_id,
'showID' => $show_item_id,
));
} }
foreach ($tile_group as $group => $application_list) { foreach ($tile_group as $group => $application_list) {
@ -124,21 +118,39 @@ abstract class PhabricatorDirectoryController extends PhabricatorController {
while (count($tiles) % 3) { while (count($tiles) % 3) {
$tiles[] = id(new PhabricatorApplicationLaunchView()); $tiles[] = id(new PhabricatorApplicationLaunchView());
} }
$nav->addLabel($groups[$group]); $label = id(new PhabricatorMenuItemView())
->setType(PhabricatorMenuItemView::TYPE_LABEL)
->setName($groups[$group]);
if ($is_hide) {
$label->setStyle('display: none');
$label_id = celerity_generate_unique_node_id();
$label->setID($label_id);
$tile_ids[] = $label_id;
}
$nav->addMenuItem($label);
} }
$group_id = celerity_generate_unique_node_id();
$tile_ids[] = $group_id;
$nav->addCustomBlock( $nav->addCustomBlock(
phutil_render_tag( phutil_render_tag(
'div', 'div',
array( array(
'class' => 'application-tile-group', 'class' => 'application-tile-group',
'id' => $group_id,
'style' => ($is_hide ? 'display: none' : null),
), ),
id(new AphrontNullView())->appendChild($tiles)->render())); id(new AphrontNullView())->appendChild($tiles)->render()));
} }
$is_hide = ($tile_display == PhabricatorApplication::TILE_HIDE);
if ($is_hide) { if ($is_hide) {
Javelin::initBehavior('phabricator-home-reveal-tiles', array(
'tileIDs' => $tile_ids,
'showID' => $show_item_id,
));
$nav->addMenuItem($hide_item); $nav->addMenuItem($hide_item);
$nav->addCustomBlock('</div>');
} }
} }

View file

@ -13,7 +13,9 @@ JX.behavior('phabricator-home-reveal-tiles', function(config) {
function(e) { function(e) {
e.kill(); e.kill();
JX.DOM.show(JX.$(config.tilesID)); for (var ii = 0; ii < config.tileIDs.length; ii++) {
JX.DOM.show(JX.$(config.tileIDs[ii]));
}
JX.DOM.hide(JX.$(config.showID)); JX.DOM.hide(JX.$(config.showID));
}); });
@ -23,7 +25,9 @@ JX.behavior('phabricator-home-reveal-tiles', function(config) {
function(e) { function(e) {
e.kill(); e.kill();
JX.DOM.hide(JX.$(config.tilesID)); for (var ii = 0; ii < config.tileIDs.length; ii++) {
JX.DOM.hide(JX.$(config.tileIDs[ii]));
}
JX.DOM.show(JX.$(config.showID)); JX.DOM.show(JX.$(config.showID));
}); });
}); });