-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[4.0] [a11y] Add SkipTo Navigation plugin #24142
Changes from all commits
ede21d8
b9da8b3
1231267
a998bd7
6376480
0268f3f
60c0294
0fce2ea
eb1e656
2d4e1cf
85927b8
c8622f8
dce1d6d
32866f7
637d23f
2f52b52
02f8e45
5574492
0f993b9
38cb29e
44775ee
d1d1054
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
INSERT INTO `#__extensions` (`extension_id`, `package_id`, `name`, `type`, `element`, `folder`, `client_id`, `enabled`, `access`, `protected`, `manifest_cache`, `params`, `checked_out`, `checked_out_time`, `ordering`, `state`) VALUES | ||
(496, 0, 'plg_system_skipto', 'plugin', 'skipto', 'system', 0, 1, 1, 0, '', '{}', 0, '0000-00-00 00:00:00', 0, 0), |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
INSERT INTO "#__extensions" ("extension_id", "package_id", "name", "type", "element", "folder", "client_id", "enabled", "access", "protected", "manifest_cache", "params", "checked_out", "checked_out_time", "ordering", "state") VALUES | ||
(496, 0, 'plg_system_skipto', 'plugin', 'skipto', 'system', 0, 1, 1, 0, '', '{}', 0, '1970-01-01 00:00:00', 0, 0), |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
; Joomla! Project | ||
; Copyright (C) 2005 - 2019 Open Source Matters. All rights reserved. | ||
; License GNU General Public License version 2 or later; see LICENSE.txt, see LICENSE.php | ||
; Note : All ini files need to be saved as UTF-8 | ||
|
||
PLG_SYSTEM_SKIPTO="System - Skip-To Navigation" | ||
PLG_SYSTEM_SKIPTO_CONTENT="Content" | ||
PLG_SYSTEM_SKIPTO_PAGE_OUTLINE="Page Outline" | ||
PLG_SYSTEM_SKIPTO_SECTION="Site Section" | ||
PLG_SYSTEM_SKIPTO_SECTION_ADMIN="Administrator (Backend)" | ||
PLG_SYSTEM_SKIPTO_SECTION_BOTH="Both" | ||
PLG_SYSTEM_SKIPTO_SECTION_SITE="Site (Frontend)" | ||
PLG_SYSTEM_SKIPTO_SKIP_TO="Skip To" | ||
PLG_SYSTEM_SKIPTO_SKIP_TO_AND_PAGE_OUTLINE="Skip To and Page Outline" | ||
PLG_SYSTEM_SKIPTO_SKIP_TO_KEYBOARD="Skip To Keyboard Navigation" | ||
PLG_SYSTEM_SKIPTO_XML_DESCRIPTION="The plugin creates a dropdown menu consisting of the links to the important places on a given web page. This makes it easier for keyboard and screen reader users to quickly jump to the desired location by simply choosing it from the list of options." |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
; Joomla! Project | ||
; Copyright (C) 2005 - 2019 Open Source Matters. All rights reserved. | ||
; License GNU General Public License version 2 or later; see LICENSE.txt, see LICENSE.php | ||
; Note : All ini files need to be saved as UTF-8 | ||
|
||
PLG_SYSTEM_SKIPTO="System - Skip-To Navigation" | ||
PLG_SYSTEM_SKIPTO_XML_DESCRIPTION="The plugin creates a dropdown menu consisting of the links to the important places on a given web page. This makes it easier for keyboard and screen reader users to quickly jump to the desired location by simply choosing it from the list of options." |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
<?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\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 __DEPLOY_VERSION__ | ||
*/ | ||
class PlgSystemSkipto extends CMSPlugin | ||
{ | ||
/** | ||
* If true, language files will be loaded automatically. | ||
* | ||
* @var boolean | ||
* @since 4.0.0 | ||
*/ | ||
protected $autoloadLanguage = true; | ||
|
||
/** | ||
* Application object. | ||
* | ||
* @var JApplicationCms | ||
* @since 4.0.0 | ||
*/ | ||
protected $app; | ||
|
||
/** | ||
* Add the css and javascript for the skipto navigation menu. | ||
* | ||
* @return void | ||
* | ||
* @since __DEPLOY_VERSION__ | ||
*/ | ||
public function onBeforeCompileHead() | ||
{ | ||
$section = (int) $this->params->get('section_skipto', 2); | ||
$current_section = 0; | ||
|
||
try | ||
{ | ||
$app = $this->app; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove this line. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You told me to put it in #24142 (comment) |
||
|
||
if ($this->app->isClient('administrator')) | ||
{ | ||
$current_section = 2; | ||
} | ||
elseif ($this->app->isClient('site')) | ||
{ | ||
$current_section = 1; | ||
} | ||
} | ||
catch (Exception $exc) | ||
{ | ||
$current_section = 0; | ||
} | ||
|
||
if (!($current_section && $section)) | ||
wilsonge marked this conversation as resolved.
Show resolved
Hide resolved
|
||
{ | ||
return; | ||
} | ||
|
||
// TODO remove this line when bug is fixed | ||
$this->loadLanguage(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Personally, I would keep this and remove |
||
|
||
// Get the document object. | ||
$document = $this->app->getDocument(); | ||
|
||
// 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'), | ||
'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(); | ||
});"); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<extension version="4.0" type="plugin" group="system" method="upgrade"> | ||
<name>plg_system_skipto</name> | ||
<author>Joomla! Project</author> | ||
<creationDate>2019-2-27</creationDate> | ||
<copyright>(C) 2005 - 2019 Open Source Matters. All rights reserved.</copyright> | ||
<license>GNU General Public License version 2 or later; see LICENSE.txt</license> | ||
<authorEmail>admin@joomla.org</authorEmail> | ||
<authorUrl>www.joomla.org</authorUrl> | ||
<version>4.0.0</version> | ||
<description>PLG_SYSTEM_SKIPTO_XML_DESCRIPTION</description> | ||
<files> | ||
<filename plugin="skipto">skipto.php</filename> | ||
</files> | ||
<languages> | ||
<language tag="en-GB">language/en-GB/en-GB.plg_system_skipto.ini</language> | ||
<language tag="en-GB">language/en-GB/en-GB.plg_system_skipto.sys.ini</language> | ||
</languages> | ||
<config> | ||
<fields name="params"> | ||
<fieldset name="basic"> | ||
<field | ||
name="section_skipto" | ||
type="list" | ||
label="PLG_SYSTEM_SKIPTO_SECTION" | ||
default="2" | ||
filter="integer" | ||
> | ||
<option value="1">PLG_SYSTEM_SKIPTO_SECTION_SITE</option> | ||
<option value="2">PLG_SYSTEM_SKIPTO_SECTION_ADMIN</option> | ||
<option value="3">PLG_SYSTEM_SKIPTO_SECTION_BOTH</option> | ||
</field> | ||
</fieldset> | ||
</fields> | ||
</config> | ||
</extension> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove this since language is loaded conditionally on line 80.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If anyone has an idea why line 80 is required by the way I'll buy them a beer. Because for the life of me I don't understand why the variable here isn't working properly
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
line 80 should not be necessary, because autloadLanguage does exactly the same only in the constructor...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well there is a bug somewhere
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's definitely a bug somewhere. I just didn't have the time/energy to debug it at 1am (i put about 15 minutes into it and succeeded in being very confused :) - only about half the system plugins language files were actually being loaded)