more sr friendly
This commit is contained in:
@@ -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('~', ' ', 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>';
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user