- md5
- 21c19d90e7f749613f140de8a2bf57a4
- sha1
- 43ab6d05c226335ea342e4ade768ca08b7913532
- sha256
- de7b7400f66c201f4883a6f0d7116c47c1eb8d2494ebf4087ae8cd8f1a10aa05
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
<?php
/**
* @package Joomla.Plugin
* @subpackage System.skipto
*
* @copyright Copyright (C) 2005 - 2020 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\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'),
]
]
]
);
/** @var Joomla\CMS\WebAsset\WebAssetManager $wa */
$wa = $document->getWebAssetManager();
$wa->useStyle('skipto')
->useScript('skipto.dropmenu')
->useScript('skipto')
->addInlineScript(
'document.addEventListener(\'DOMContentLoaded\', function() {'
. 'window.SkipToConfig = Joomla.getOptions(\'skipto-settings\');'
. 'window.skipToMenuInit();});',
[],
['type' => 'module'],
['skipto']
);
}
}
The same content is in 5 releases, Joomla 4.0.0-beta to 4.0.0-beta5. See them all, or every version of this file.