Skip to content

Commit e8cebb7

Browse files
author
epriestley
committed
Add support for aural-only and visual-only elements
Summary: Ref T4843. This adds support to `javelin_tag()` for an `aural` attribute. When specified, `true` values mean "this content is aural-only", while `false` values mean "this content is not aural". - I've attempted to find the best modern approaches for marking this content, but the `aural` attribute should let us change the mechanism later. - Make the "beta" markers on application navigation visual only (see T4843). This information is of very low importance, the application navigation is accessed frequently, and the information is available on the application list. - Partially convert the main navigation. This is mostly to test things, since I want to get more concrete feedback about approaches here. - Add a `?__aural__=1` attribute, which renders the page with aural-only elements visible and visual-only elements colored. Test Plan: {F146476} Reviewers: btrahan, scp, chad Reviewed By: chad Subscribers: aklapper, qgil, epriestley Maniphest Tasks: T4843 Differential Revision: https://secure.phabricator.com/D8830
1 parent 3fde020 commit e8cebb7

File tree

15 files changed

+171
-20
lines changed

15 files changed

+171
-20
lines changed

resources/celerity/map.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
return array(
88
'names' =>
99
array(
10-
'core.pkg.css' => 'b7ba02ba',
10+
'core.pkg.css' => 'cc50ddf5',
1111
'core.pkg.js' => '417722ff',
1212
'darkconsole.pkg.js' => 'ca8671ce',
1313
'differential.pkg.css' => '8a064eb7',
@@ -105,10 +105,10 @@
105105
'rsrc/css/application/subscriptions/subscribers-list.css' => '5bb30c78',
106106
'rsrc/css/application/tokens/tokens.css' => '5f7bca25',
107107
'rsrc/css/application/uiexample/example.css' => '528b19de',
108-
'rsrc/css/core/core.css' => 'da26ddb2',
108+
'rsrc/css/core/core.css' => '7dff07c3',
109109
'rsrc/css/core/remarkup.css' => '98a7627b',
110110
'rsrc/css/core/syntax.css' => '3c18c1cb',
111-
'rsrc/css/core/z-index.css' => '0d89d53c',
111+
'rsrc/css/core/z-index.css' => '7e4989ed',
112112
'rsrc/css/diviner/diviner-shared.css' => '38813222',
113113
'rsrc/css/font/font-awesome.css' => '62bc244d',
114114
'rsrc/css/font/font-glyphicons-halflings.css' => 'c4c1c6b6',
@@ -686,7 +686,7 @@
686686
'phabricator-busy' => '6453c869',
687687
'phabricator-chatlog-css' => '852140ff',
688688
'phabricator-content-source-view-css' => '4b8b05d4',
689-
'phabricator-core-css' => 'da26ddb2',
689+
'phabricator-core-css' => '7dff07c3',
690690
'phabricator-countdown-css' => '86b7b0a0',
691691
'phabricator-crumbs-view-css' => '0222cbe0',
692692
'phabricator-drag-and-drop-file-upload' => 'ae6abfba',
@@ -735,7 +735,7 @@
735735
'phabricator-uiexample-reactor-select' => '189e4fe3',
736736
'phabricator-uiexample-reactor-sendclass' => 'bf97561d',
737737
'phabricator-uiexample-reactor-sendproperties' => '551add57',
738-
'phabricator-zindex-css' => '0d89d53c',
738+
'phabricator-zindex-css' => '7e4989ed',
739739
'phame-css' => '19ecc703',
740740
'pholio-css' => '2fa97dbe',
741741
'pholio-edit-css' => 'b9e59b6d',

src/applications/auth/application/PhabricatorApplicationAuth.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ public function buildMainMenuItems(
4040
->setWorkflow(true)
4141
->setHref('/logout/')
4242
->setSelected(($controller instanceof PhabricatorLogoutController))
43+
->setAural(pht('Log Out'))
4344
->setOrder(900);
4445
$items[] = $item;
4546
} else {
@@ -53,6 +54,7 @@ public function buildMainMenuItems(
5354
// TODO: Login icon?
5455
->setIcon('power')
5556
->setHref('/auth/start/')
57+
->setAural(pht('Log In'))
5658
->setOrder(900);
5759
$items[] = $item;
5860
}

src/applications/help/application/PhabricatorApplicationHelp.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,13 @@ public function buildMainMenuItems(
3131
}
3232

3333
if ($application && $application->getHelpURI()) {
34+
$help_name = pht('%s Help', $application->getName());
35+
3436
$item = id(new PHUIListItemView())
35-
->setName(pht('%s Help', $application->getName()))
37+
->setName($help_name)
3638
->addClass('core-menu-item')
3739
->setIcon('info-sm')
40+
->setAural($help_name)
3841
->setOrder(200)
3942
->setHref($application->getHelpURI());
4043
$items[] = $item;

src/applications/home/application/PhabricatorApplicationHome.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ public function buildMainMenuItems(
6060
->setHref('/home/create/')
6161
->addSigil('quick-create-menu')
6262
->setID($create_id)
63+
->setAural(pht('Quick Create'))
6364
->setOrder(300);
6465
$items[] = $item;
6566
}

src/applications/home/controller/PhabricatorHomeController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ public function buildNav() {
167167
}
168168
}
169169

170-
$nav->addFilter(
170+
$nav->addFilter(
171171
'',
172172
pht('Customize Applications...'),
173173
'/settings/panel/home/');

src/applications/meta/view/PhabricatorApplicationLaunchView.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,10 @@ public function render() {
3939
$application->getName());
4040

4141
if ($application->isBeta()) {
42-
$content[] = phutil_tag(
42+
$content[] = javelin_tag(
4343
'span',
4444
array(
45+
'aural' => false,
4546
'class' => 'phabricator-application-beta',
4647
),
4748
"\xCE\xB2");

src/applications/people/application/PhabricatorApplicationPeople.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ public function buildMainMenuItems(
120120
->setName($user->getUsername())
121121
->setHref('/p/'.$user->getUsername().'/')
122122
->addClass('core-menu-item')
123+
->setAural(pht('Profile'))
123124
->setOrder(100);
124125

125126
$classes = array(

src/applications/settings/application/PhabricatorApplicationSettings.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ public function buildMainMenuItems(
4646
->addClass('core-menu-item')
4747
->setSelected($selected)
4848
->setHref('/settings/')
49+
->setAural(pht('Settings'))
4950
->setOrder(400);
5051
$items[] = $item;
5152
}

src/infrastructure/javelin/markup.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,20 @@ function javelin_tag(
3636
}
3737
}
3838

39+
if (isset($attributes['aural'])) {
40+
if ($attributes['aural']) {
41+
$class = idx($attributes, 'class', '');
42+
$class = rtrim('aural-only '.$class);
43+
$attributes['class'] = $class;
44+
} else {
45+
$class = idx($attributes, 'class', '');
46+
$class = rtrim('visual-only '.$class);
47+
$attributes['class'] = $class;
48+
$attributes['aria-hidden'] = 'true';
49+
}
50+
unset($attributes['aural']);
51+
}
52+
3953
return phutil_tag($tag, $attributes, $content);
4054
}
4155

src/view/form/control/PhabricatorRemarkupControl.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,13 +133,22 @@ protected function renderInput() {
133133
$target = '_blank';
134134
}
135135

136+
$content = null;
137+
136138
$tip = idx($spec, 'tip');
137139
if ($tip) {
138140
$meta['tip'] = $tip;
141+
$content = phutil_tag(
142+
'span',
143+
array(
144+
'class' => 'aural-only',
145+
),
146+
$tip);
139147
}
140148

141149
require_celerity_resource('sprite-icons-css');
142150

151+
143152
$buttons[] = javelin_tag(
144153
'a',
145154
array(
@@ -156,7 +165,7 @@ protected function renderInput() {
156165
array(
157166
'class' => 'remarkup-assist sprite-icons remarkup-assist-'.$action,
158167
),
159-
''));
168+
$content));
160169
}
161170

162171
$buttons = phutil_tag(

src/view/page/PhabricatorStandardPageView.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -430,6 +430,10 @@ protected function getBodyClasses() {
430430
$classes[] = 'printable';
431431
}
432432

433+
if ($this->getRequest()->getStr('__aural__')) {
434+
$classes[] = 'audible';
435+
}
436+
433437
return implode(' ', $classes);
434438
}
435439

src/view/page/menu/PhabricatorMainMenuView.php

Lines changed: 63 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,10 @@ public function render() {
3434
$alerts = array();
3535
$search_button = '';
3636
$app_button = '';
37+
$aural = null;
3738

3839
if ($user->isLoggedIn() && $user->isUserActivated()) {
39-
list($menu, $dropdowns) = $this->renderNotificationMenu();
40+
list($menu, $dropdowns, $aural) = $this->renderNotificationMenu();
4041
$alerts[] = $menu;
4142
$menus = array_merge($menus, $dropdowns);
4243
$app_button = $this->renderApplicationMenuButton($header_id);
@@ -51,14 +52,24 @@ public function render() {
5152
$search_menu = $this->renderPhabricatorSearchMenu();
5253

5354
if ($alerts) {
54-
$alerts = phutil_tag(
55+
$alerts = javelin_tag(
5556
'div',
5657
array(
5758
'class' => 'phabricator-main-menu-alerts',
59+
'aural' => false,
5860
),
5961
$alerts);
6062
}
6163

64+
if ($aural) {
65+
$aural = javelin_tag(
66+
'span',
67+
array(
68+
'aural' => true,
69+
),
70+
phutil_implode_html(' ', $aural));
71+
}
72+
6273
$application_menu = $this->renderApplicationMenu();
6374
$classes = array();
6475
$classes[] = 'phabricator-main-menu';
@@ -76,6 +87,7 @@ public function render() {
7687
$search_button,
7788
$this->renderPhabricatorLogo(),
7889
$alerts,
90+
$aural,
7991
$application_menu,
8092
$search_menu,
8193
$menus,
@@ -236,12 +248,20 @@ private function renderPhabricatorLogo() {
236248
'class' => 'phabricator-main-menu-logo',
237249
'href' => '/',
238250
),
239-
phutil_tag(
240-
'span',
241-
array(
242-
'class' => 'sprite-menu menu-logo-image '.$class,
243-
),
244-
''));
251+
array(
252+
javelin_tag(
253+
'span',
254+
array(
255+
'aural' => true,
256+
),
257+
pht('Home')),
258+
phutil_tag(
259+
'span',
260+
array(
261+
'class' => 'sprite-menu menu-logo-image '.$class,
262+
),
263+
''),
264+
));
245265
}
246266

247267
private function renderNotificationMenu() {
@@ -256,6 +276,8 @@ private function renderNotificationMenu() {
256276
'alert-notifications',
257277
);
258278

279+
$aural = array();
280+
259281
$message_tag = '';
260282
$message_notification_dropdown = '';
261283
$conpherence = 'PhabricatorApplicationConpherence';
@@ -270,6 +292,20 @@ private function renderNotificationMenu() {
270292
->withParticipationStatus($unread_status)
271293
->execute();
272294
$message_count_number = idx($unread, $user->getPHID(), 0);
295+
296+
if ($message_count_number) {
297+
$aural[] = phutil_tag(
298+
'a',
299+
array(
300+
'href' => '/conpherence/',
301+
),
302+
pht(
303+
'%s unread messages.',
304+
new PhutilNumber($message_count_number)));
305+
} else {
306+
$aural[] = pht('No messages.');
307+
}
308+
273309
if ($message_count_number > 999) {
274310
$message_count_number = "\xE2\x88\x9E";
275311
}
@@ -333,6 +369,19 @@ private function renderNotificationMenu() {
333369
$count_number = id(new PhabricatorFeedStoryNotification())
334370
->countUnread($user);
335371

372+
if ($count_number) {
373+
$aural[] = phutil_tag(
374+
'a',
375+
array(
376+
'href' => '/notification/',
377+
),
378+
pht(
379+
'%s unread notifications.',
380+
new PhutilNumber($count_number)));
381+
} else {
382+
$aural[] = pht('No notifications.');
383+
}
384+
336385
if ($count_number > 999) {
337386
$count_number = "\xE2\x88\x9E";
338387
}
@@ -397,8 +446,12 @@ private function renderNotificationMenu() {
397446
}
398447

399448
return array(
400-
hsprintf('%s%s', $bubble_tag, $message_tag),
401-
$dropdowns
449+
array(
450+
$bubble_tag,
451+
$message_tag,
452+
),
453+
$dropdowns,
454+
$aural,
402455
);
403456
}
404457

src/view/phui/PHUIListItemView.php

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,16 @@ final class PHUIListItemView extends AphrontTagView {
2525
private $renderNameAsTooltip;
2626
private $statusColor;
2727
private $order;
28+
private $aural;
29+
30+
public function setAural($aural) {
31+
$this->aural = $aural;
32+
return $this;
33+
}
34+
35+
public function getAural() {
36+
return $this->aural;
37+
}
2838

2939
public function setOrder($order) {
3040
$this->order = $order;
@@ -170,10 +180,21 @@ protected function getTagContent() {
170180
$external = " \xE2\x86\x97";
171181
}
172182

183+
// If this element has an aural representation, make any name visual
184+
// only. This is primarily dealing with the links in the main menu like
185+
// "Profile" and "Logout". If we don't hide the name, the mobile
186+
// version of these elements will have two redundant names.
187+
188+
$classes = array();
189+
$classes[] = 'phui-list-item-name';
190+
if ($this->aural !== null) {
191+
$classes[] = 'visual-only';
192+
}
193+
173194
$name = phutil_tag(
174195
'span',
175196
array(
176-
'class' => 'phui-list-item-name',
197+
'class' => implode(' ', $classes),
177198
),
178199
array(
179200
$this->name,
@@ -182,6 +203,16 @@ protected function getTagContent() {
182203
}
183204
}
184205

206+
$aural = null;
207+
if ($this->aural !== null) {
208+
$aural = phutil_tag(
209+
'span',
210+
array(
211+
'class' => 'aural-only',
212+
),
213+
$this->aural);
214+
}
215+
185216
if ($this->icon) {
186217
$icon_name = $this->icon;
187218
if ($this->getDisabled()) {
@@ -210,6 +241,7 @@ protected function getTagContent() {
210241
'sigil' => $sigil,
211242
),
212243
array(
244+
$aural,
213245
$icon,
214246
$this->renderChildren(),
215247
$name,

0 commit comments

Comments
 (0)