1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-10 08:52:39 +01:00

Allow only one global top menu to be open at a time

Summary: Fixes T3715. Makes "visible" global instead of per-menu, so all the menus share a visible state.

Test Plan: For menus A and B, clicked "A, A", "A, B, A", "A, B, B", "A, B, B, A", etc. Couldn't figure out a way to break it.

Reviewers: btrahan, chad

Reviewed By: chad

CC: aran

Maniphest Tasks: T3715

Differential Revision: https://secure.phabricator.com/D6745
This commit is contained in:
epriestley 2013-08-13 14:57:52 -07:00
parent a530004ac7
commit 3021e1d52d
2 changed files with 75 additions and 60 deletions

View file

@ -1235,7 +1235,7 @@ celerity_register_resource_map(array(
),
'javelin-behavior-aphlict-dropdown' =>
array(
'uri' => '/res/c8def75f/rsrc/js/application/aphlict/behavior-aphlict-dropdown.js',
'uri' => '/res/3ff0c90a/rsrc/js/application/aphlict/behavior-aphlict-dropdown.js',
'type' => 'js',
'requires' =>
array(
@ -2217,7 +2217,7 @@ celerity_register_resource_map(array(
),
'javelin-behavior-pholio-mock-edit' =>
array(
'uri' => '/res/d5f4b705/rsrc/js/application/pholio/behavior-pholio-mock-edit.js',
'uri' => '/res/1fd14497/rsrc/js/application/pholio/behavior-pholio-mock-edit.js',
'type' => 'js',
'requires' =>
array(
@ -3706,7 +3706,7 @@ celerity_register_resource_map(array(
),
'pholio-edit-css' =>
array(
'uri' => '/res/00e3a3a8/rsrc/css/application/pholio/pholio-edit.css',
'uri' => '/res/63f3332d/rsrc/css/application/pholio/pholio-edit.css',
'type' => 'css',
'requires' =>
array(
@ -4222,7 +4222,7 @@ celerity_register_resource_map(array(
'uri' => '/res/pkg/638c9d42/core.pkg.css',
'type' => 'css',
),
'7cc3f99d' =>
'4f81c788' =>
array(
'name' => 'core.pkg.js',
'symbols' =>
@ -4265,7 +4265,7 @@ celerity_register_resource_map(array(
35 => 'phabricator-hovercard',
36 => 'javelin-behavior-phabricator-hovercards',
),
'uri' => '/res/pkg/7cc3f99d/core.pkg.js',
'uri' => '/res/pkg/4f81c788/core.pkg.js',
'type' => 'js',
),
'4ccfeb47' =>
@ -4435,16 +4435,16 @@ celerity_register_resource_map(array(
'diffusion-icons-css' => 'c8ce2d88',
'global-drag-and-drop-css' => '638c9d42',
'inline-comment-summary-css' => 'dd27a69b',
'javelin-aphlict' => '7cc3f99d',
'javelin-aphlict' => '4f81c788',
'javelin-behavior' => '2dbbb7d1',
'javelin-behavior-aphlict-dropdown' => '7cc3f99d',
'javelin-behavior-aphlict-listen' => '7cc3f99d',
'javelin-behavior-aphront-basic-tokenizer' => '7cc3f99d',
'javelin-behavior-aphlict-dropdown' => '4f81c788',
'javelin-behavior-aphlict-listen' => '4f81c788',
'javelin-behavior-aphront-basic-tokenizer' => '4f81c788',
'javelin-behavior-aphront-drag-and-drop-textarea' => '48040be9',
'javelin-behavior-aphront-form-disable-on-submit' => '7cc3f99d',
'javelin-behavior-aphront-form-disable-on-submit' => '4f81c788',
'javelin-behavior-audit-preview' => '96909266',
'javelin-behavior-dark-console' => '4ccfeb47',
'javelin-behavior-device' => '7cc3f99d',
'javelin-behavior-device' => '4f81c788',
'javelin-behavior-differential-accept-with-errors' => '48040be9',
'javelin-behavior-differential-add-reviewers-and-ccs' => '48040be9',
'javelin-behavior-differential-comment-jump' => '48040be9',
@ -4460,33 +4460,33 @@ celerity_register_resource_map(array(
'javelin-behavior-diffusion-commit-graph' => '96909266',
'javelin-behavior-diffusion-pull-lastmodified' => '96909266',
'javelin-behavior-error-log' => '4ccfeb47',
'javelin-behavior-global-drag-and-drop' => '7cc3f99d',
'javelin-behavior-history-install' => '7cc3f99d',
'javelin-behavior-konami' => '7cc3f99d',
'javelin-behavior-lightbox-attachments' => '7cc3f99d',
'javelin-behavior-global-drag-and-drop' => '4f81c788',
'javelin-behavior-history-install' => '4f81c788',
'javelin-behavior-konami' => '4f81c788',
'javelin-behavior-lightbox-attachments' => '4f81c788',
'javelin-behavior-load-blame' => '48040be9',
'javelin-behavior-maniphest-batch-selector' => '98f64f07',
'javelin-behavior-maniphest-subpriority-editor' => '98f64f07',
'javelin-behavior-maniphest-transaction-controls' => '98f64f07',
'javelin-behavior-maniphest-transaction-expand' => '98f64f07',
'javelin-behavior-maniphest-transaction-preview' => '98f64f07',
'javelin-behavior-phabricator-active-nav' => '7cc3f99d',
'javelin-behavior-phabricator-autofocus' => '7cc3f99d',
'javelin-behavior-phabricator-gesture' => '7cc3f99d',
'javelin-behavior-phabricator-hovercards' => '7cc3f99d',
'javelin-behavior-phabricator-keyboard-shortcuts' => '7cc3f99d',
'javelin-behavior-phabricator-nav' => '7cc3f99d',
'javelin-behavior-phabricator-active-nav' => '4f81c788',
'javelin-behavior-phabricator-autofocus' => '4f81c788',
'javelin-behavior-phabricator-gesture' => '4f81c788',
'javelin-behavior-phabricator-hovercards' => '4f81c788',
'javelin-behavior-phabricator-keyboard-shortcuts' => '4f81c788',
'javelin-behavior-phabricator-nav' => '4f81c788',
'javelin-behavior-phabricator-object-selector' => '48040be9',
'javelin-behavior-phabricator-oncopy' => '7cc3f99d',
'javelin-behavior-phabricator-remarkup-assist' => '7cc3f99d',
'javelin-behavior-phabricator-reveal-content' => '7cc3f99d',
'javelin-behavior-phabricator-search-typeahead' => '7cc3f99d',
'javelin-behavior-phabricator-tooltips' => '7cc3f99d',
'javelin-behavior-phabricator-watch-anchor' => '7cc3f99d',
'javelin-behavior-refresh-csrf' => '7cc3f99d',
'javelin-behavior-phabricator-oncopy' => '4f81c788',
'javelin-behavior-phabricator-remarkup-assist' => '4f81c788',
'javelin-behavior-phabricator-reveal-content' => '4f81c788',
'javelin-behavior-phabricator-search-typeahead' => '4f81c788',
'javelin-behavior-phabricator-tooltips' => '4f81c788',
'javelin-behavior-phabricator-watch-anchor' => '4f81c788',
'javelin-behavior-refresh-csrf' => '4f81c788',
'javelin-behavior-repository-crossreference' => '48040be9',
'javelin-behavior-toggle-class' => '7cc3f99d',
'javelin-behavior-workflow' => '7cc3f99d',
'javelin-behavior-toggle-class' => '4f81c788',
'javelin-behavior-workflow' => '4f81c788',
'javelin-dom' => '2dbbb7d1',
'javelin-event' => '2dbbb7d1',
'javelin-history' => '2dbbb7d1',
@ -4511,31 +4511,31 @@ celerity_register_resource_map(array(
'maniphest-transaction-detail-css' => '06bacb9a',
'phabricator-action-list-view-css' => '638c9d42',
'phabricator-application-launch-view-css' => '638c9d42',
'phabricator-busy' => '7cc3f99d',
'phabricator-busy' => '4f81c788',
'phabricator-content-source-view-css' => 'dd27a69b',
'phabricator-core-css' => '638c9d42',
'phabricator-crumbs-view-css' => '638c9d42',
'phabricator-drag-and-drop-file-upload' => '48040be9',
'phabricator-dropdown-menu' => '7cc3f99d',
'phabricator-file-upload' => '7cc3f99d',
'phabricator-dropdown-menu' => '4f81c788',
'phabricator-file-upload' => '4f81c788',
'phabricator-filetree-view-css' => '638c9d42',
'phabricator-flag-css' => '638c9d42',
'phabricator-form-view-css' => '638c9d42',
'phabricator-header-view-css' => '638c9d42',
'phabricator-hovercard' => '7cc3f99d',
'phabricator-hovercard' => '4f81c788',
'phabricator-jump-nav' => '638c9d42',
'phabricator-keyboard-shortcut' => '7cc3f99d',
'phabricator-keyboard-shortcut-manager' => '7cc3f99d',
'phabricator-keyboard-shortcut' => '4f81c788',
'phabricator-keyboard-shortcut-manager' => '4f81c788',
'phabricator-main-menu-view' => '638c9d42',
'phabricator-menu-item' => '7cc3f99d',
'phabricator-menu-item' => '4f81c788',
'phabricator-nav-view-css' => '638c9d42',
'phabricator-notification' => '7cc3f99d',
'phabricator-notification' => '4f81c788',
'phabricator-notification-css' => '638c9d42',
'phabricator-notification-menu-css' => '638c9d42',
'phabricator-object-item-list-view-css' => '638c9d42',
'phabricator-object-selector-css' => 'dd27a69b',
'phabricator-phtize' => '7cc3f99d',
'phabricator-prefab' => '7cc3f99d',
'phabricator-phtize' => '4f81c788',
'phabricator-prefab' => '4f81c788',
'phabricator-project-tag-css' => '06bacb9a',
'phabricator-property-list-view-css' => '638c9d42',
'phabricator-remarkup-css' => '638c9d42',
@ -4543,8 +4543,8 @@ celerity_register_resource_map(array(
'phabricator-side-menu-view-css' => '638c9d42',
'phabricator-standard-page-view' => '638c9d42',
'phabricator-tag-view-css' => '638c9d42',
'phabricator-textareautils' => '7cc3f99d',
'phabricator-tooltip' => '7cc3f99d',
'phabricator-textareautils' => '4f81c788',
'phabricator-tooltip' => '4f81c788',
'phabricator-transaction-view-css' => '638c9d42',
'phabricator-zindex-css' => '638c9d42',
'phui-button-css' => '638c9d42',

View file

@ -8,11 +8,13 @@
* javelin-uri
*/
JX.behavior('aphlict-dropdown', function(config) {
JX.behavior('aphlict-dropdown', function(config, statics) {
// Track the current globally visible menu.
statics.visible = statics.visible || null;
var dropdown = JX.$(config.dropdownID);
var count = JX.$(config.countID);
var bubble = JX.$(config.bubbleID);
var visible = false;
var request = null;
var dirty = true;
@ -28,6 +30,7 @@ JX.behavior('aphlict-dropdown', function(config) {
if (request) { //already fetching
return;
}
request = new JX.Request(config.uri, function(response) {
var display = (response.number > 999) ? "\u221E" : response.number;
@ -55,7 +58,7 @@ JX.behavior('aphlict-dropdown', function(config) {
if (!e.getNode('phabricator-notification-menu')) {
// Click outside the dropdown; hide it.
JX.DOM.hide(dropdown);
visible = false;
statics.visible = null;
return;
}
@ -83,22 +86,34 @@ JX.behavior('aphlict-dropdown', function(config) {
return;
}
if (visible) {
JX.DOM.hide(dropdown);
} else {
if (dirty) {
refresh();
}
var p = JX.$V(bubble);
p.y = null;
p.x -= 6;
p.setPos(dropdown);
JX.DOM.show(dropdown);
}
visible = !visible;
e.kill();
// If a menu is currently open, close it.
if (statics.visible) {
var previously_visible = statics.visible;
JX.DOM.hide(statics.visible);
statics.visible = null;
// If the menu we just closed was the menu attached to the clicked
// icon, we're all done -- clicking the icon for an open menu just
// closes it. Otherwise, we closed some other menu and still need to
// open the one the user just clicked.
if (previously_visible === dropdown) {
return;
}
}
if (dirty) {
refresh();
}
var p = JX.$V(bubble);
p.y = null;
p.x -= 6;
p.setPos(dropdown);
JX.DOM.show(dropdown);
statics.visible = dropdown;
}
);