- md5
- 32dcb887e7079a862312a6a5f86ae345
- sha1
- 39fce3e793db7fb460cee296a116ac6f822bbbd7
- sha256
- 956b08894166e3f4bf84514c9e4dd79a95f57d53bbbfabda8a18f60cd2b41c5b
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
<?php
/**
* @package Joomla.Plugin
* @subpackage System.skipto
*
* @copyright Copyright (C) 2005 - 2019 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
use Joomla\CMS\Application\CMSApplicationInterface;
use Joomla\CMS\HTML\HTMLHelper;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Plugin\CMSPlugin;
/**
* Skipto plugin to add accessible keyboard navigation to the site and administrator templates.
*
* @since 4.0.0
*/
class PlgSystemSkipto extends CMSPlugin
{
/**
* Application object.
*
* @var CMSApplicationInterface
* @since 4.0.0
*/
protected $app;
/**
* Add the CSS and JavaScript for the skipto navigation menu.
*
* @return void
*
* @since 4.0.0
*/
public function onAfterDispatch()
{
$section = $this->params->get('section', 'administrator');
if ($section !== 'both' && $this->app->isClient($section) !== true)
{
return;
}
// Get the document object.
$document = $this->app->getDocument();
if ($document->getType() !== 'html')
{
return;
}
// Load language file.
$this->loadLanguage();
// Add strings for translations in JavaScript.
$document->addScriptOptions(
'skipto-settings',
[
'settings' => [
'skipTo' => [
'buttonDivRole' => 'navigation',
'buttonDivLabel' => Text::_('PLG_SYSTEM_SKIPTO_SKIP_TO_KEYBOARD'),
'buttonLabel' => Text::_('PLG_SYSTEM_SKIPTO_SKIP_TO'),
'buttonDivTitle' => '',
'menuLabel' => Text::_('PLG_SYSTEM_SKIPTO_SKIP_TO_AND_PAGE_OUTLINE'),
'landmarksLabel' => Text::_('PLG_SYSTEM_SKIPTO_SKIP_TO'),
'headingsLabel' => Text::_('PLG_SYSTEM_SKIPTO_PAGE_OUTLINE'),
// The following string begins with a space
'contentLabel' => ' ' . Text::_('PLG_SYSTEM_SKIPTO_CONTENT'),
]
]
]
);
HTMLHelper::_('script', 'vendor/skipto/dropMenu.js', ['version' => 'auto', 'relative' => true], ['defer' => true]);
HTMLHelper::_('script', 'vendor/skipto/skipTo.js', ['version' => 'auto', 'relative' => true], ['defer' => true]);
HTMLHelper::_('stylesheet', 'vendor/skipto/SkipTo.css', ['version' => 'auto', 'relative' => true]);
$document->addScriptDeclaration("document.addEventListener('DOMContentLoaded', function() {
window.SkipToConfig = Joomla.getOptions('skipto-settings');
window.skipToMenuInit();
});"
);
}
}
The same content is in 2 releases, Joomla 4.0.0-alpha11 to 4.0.0-alpha12. See them all, or every version of this file.