more sr friendly

This commit is contained in:
2018-07-28 12:01:12 +02:00
parent 72011feea9
commit 59e6649a1d
23 changed files with 432 additions and 250 deletions
+31
View File
@@ -27,6 +27,37 @@ class AppServiceProvider extends ServiceProvider
if (!$u) abort(404);
return $u;
});
\Blade::directive('tooltip', function($arg) {
$arge = e($arg);
return 'aria-label="' . $arge . '" title="' . $arge . '"';
});
\Blade::directive('sr', function($arg) {
$sr = str_replace('~', ' ', e($arg));
return '<span class="sr-only">'.$sr.'</span>';
});
\Blade::directive('icon', function($arg) {
// arg: classes... , alt text
// tildes in alt text may be used to add nbsp to sr-only, they are removed from the tooltip.
// giving no alt text makes it sr-hidden, with no tooltip
$parts = explode(',', $arg, 2);
if (count($parts) == 2) {
list($classes, $title) = $parts;
$classes = trim($classes);
$title = trim($title);
$sr = str_replace('~', '&nbsp;', e($title));
$tit = str_replace('~', '', e(trim($title, ' \r\n\t:,')));
return '<span class="sr-only">' . $sr . '</span>' .
'<i class="' . e($classes) . '" title="' . $tit . '" aria-hidden=true></i>';
} else {
return '<i class="' . e(trim($arg)) . '" aria-hidden=true></i>';
}
});
}
/**