Skip to content
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

Merged
merged 22 commits into from Mar 26, 2019
Merged
Changes from 3 commits
Commits
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.

Always

Just for now

@@ -0,0 +1,2 @@
INSERT INTO `#__extensions` (`extension_id`, `name`, `type`, `element`, `folder`, `client_id`, `enabled`, `access`, `protected`, `manifest_cache`, `params`, `custom_data`, `system_data`, `checked_out`, `checked_out_time`, `ordering`, `state`) VALUES
This conversation was marked as resolved by brianteeman

This comment has been minimized.

Copy link
@SharkyKZ

SharkyKZ Mar 9, 2019

Contributor

Missing package_id column after extension_id. custom_data and system_data columns do not exist.

(496, 0, 'plg_system_skipto', 'plugin', 'skipto', 'system', 0, 1, 1, 0, '', '{"section_skipto":"2"}', 0, '0000-00-00 00:00:00', 0, 0),
This conversation was marked as resolved by brianteeman

This comment has been minimized.

Copy link
@SharkyKZ

SharkyKZ Mar 10, 2019

Contributor
Suggested change
(496, 0, 'plg_system_skipto', 'plugin', 'skipto', 'system', 0, 1, 1, 0, '', '{"section_skipto":"2"}', 0, '0000-00-00 00:00:00', 0, 0),
(496, 0, 'plg_system_skipto', 'plugin', 'skipto', 'system', 0, 1, 1, 0, '', '{}', 0, '0000-00-00 00:00:00', 0, 0),
@@ -0,0 +1,2 @@
INSERT INTO "#__extensions" ("extension_id", "name", "type", "element", "folder", "client_id", "enabled", "access", "protected", "manifest_cache", "params", "custom_data", "system_data", "checked_out", "checked_out_time", "ordering", "state") VALUES
This conversation was marked as resolved by brianteeman

This comment has been minimized.

Copy link
@SharkyKZ

SharkyKZ Mar 9, 2019

Contributor

Same as above.

This comment has been minimized.

Copy link
@SharkyKZ

SharkyKZ Mar 9, 2019

Contributor

This needs fixing too.

This conversation was marked as resolved by brianteeman

This comment has been minimized.

Copy link
@SharkyKZ

SharkyKZ Mar 10, 2019

Contributor
Suggested change
INSERT INTO "#__extensions" ("extension_id", "name", "type", "element", "folder", "client_id", "enabled", "access", "protected", "manifest_cache", "params", "custom_data", "system_data", "checked_out", "checked_out_time", "ordering", "state") VALUES
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
This conversation was marked as resolved by brianteeman

This comment has been minimized.

Copy link
@SharkyKZ

SharkyKZ Mar 11, 2019

Contributor
Suggested change
INSERT INTO "#__extensions" ("extension_id", "name", "type", "element", "folder", "client_id", "enabled", "access", "protected", "manifest_cache", "params", "custom_data", "system_data", "checked_out", "checked_out_time", "ordering", "state") VALUES
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, '', '{"section_skipto":"2"}', 0, '1970-01-01 00:00:00', 0, 0),
This conversation was marked as resolved by brianteeman

This comment has been minimized.

Copy link
@SharkyKZ

SharkyKZ Mar 10, 2019

Contributor
Suggested change
(496, 0, 'plg_system_skipto', 'plugin', 'skipto', 'system', 0, 1, 1, 0, '', '{"section_skipto":"2"}', 0, '1970-01-01 00:00:00', 0, 0),
(496, 0, 'plg_system_skipto', 'plugin', 'skipto', 'system', 0, 1, 1, 0, '', '{}', 0, '1970-01-01 00:00:00', 0, 0),
@@ -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."
@@ -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."
@@ -372,6 +372,17 @@
"dist/metismenujs.min.js": "js/metismenujs.min.js",
"dist/metismenujs.min.js.map": "js/metismenujs.min.js.map"
}
},
"skipto": {
"name": "skipto",
"licenseFilename": "LICENSE.md",
"js": {
"src/js/skipTo.js": "js/skipTo.js",
"src/js/dropMenu.js": "js/dropMenu.js"
},
"css": {
"src/css/SkipTo.css": "css/SkipTo.css"
}
}
},
"errorPages": {
@@ -678,6 +678,7 @@ INSERT INTO `#__extensions` (`extension_id`, `package_id`, `name`, `type`, `elem
(493, 0, 'plg_extension_finder', 'plugin', 'finder', 'extension', 0, 1, 1, 0, '', '', 0, '0000-00-00 00:00:00', 0, 0),
(494, 0, 'plg_api-authentication_basic', 'plugin', 'basic', 'api-authentication', 0, 1, 1, 0, '', '{}', 0, '0000-00-00 00:00:00', 0, 0),
(495, 0, 'plg_webservices_content', 'plugin', 'content', 'webservices', 0, 1, 1, 0, '', '{}', 0, '0000-00-00 00:00:00', 0, 0),
(496, 0, 'plg_system_skipto', 'plugin', 'skipto', 'system', 0, 1, 1, 0, '', '{"section_skipto":"2"}', 0, '0000-00-00 00:00:00', 0, 0),
This conversation was marked as resolved by brianteeman

This comment has been minimized.

Copy link
@SharkyKZ

SharkyKZ Mar 10, 2019

Contributor
Suggested change
(496, 0, 'plg_system_skipto', 'plugin', 'skipto', 'system', 0, 1, 1, 0, '', '{"section_skipto":"2"}', 0, '0000-00-00 00:00:00', 0, 0),
(496, 0, 'plg_system_skipto', 'plugin', 'skipto', 'system', 0, 1, 1, 0, '', '{}', 0, '0000-00-00 00:00:00', 0, 0),
(509, 0, 'atum', 'template', 'atum', '', 1, 1, 1, 0, '', '', 0, '0000-00-00 00:00:00', 0, 0),
(510, 0, 'cassiopeia', 'template', 'cassiopeia', '', 0, 1, 1, 0, '', '{"logoFile":"","fluidContainer":"0","sidebarLeftWidth":"3","sidebarRightWidth":"3"}', 0, '0000-00-00 00:00:00', 0, 0),
(600, 802, 'English (en-GB)', 'language', 'en-GB', '', 0, 1, 1, 1, '', '', 0, '0000-00-00 00:00:00', 0, 0),
@@ -687,6 +687,7 @@ INSERT INTO "#__extensions" ("extension_id", "package_id", "name", "type", "elem
(493, 0, 'plg_extension_finder', 'plugin', 'finder', 'extension', 0, 1, 1, 0, '', '', 0, '1970-01-01 00:00:00', 0, 0),
(494, 0, 'plg_api-authentication_basic', 'plugin', 'basic', 'api-authentication', 0, 1, 1, 0, '', '{}', 0, '1970-01-01 00:00:00', 0, 0),
(495, 0, 'plg_webservices_content', 'plugin', 'content', 'webservices', 0, 1, 1, 0, '', '{}', 0, '1970-01-01 00:00:00', 0, 0),
(496, 0, 'plg_system_skipto', 'plugin', 'skipto', 'system', 0, 1, 1, 0, '', '{"section_skipto":"2"}', 0, 'q970-01-01 00:00:00', 0, 0),
This conversation was marked as resolved by brianteeman

This comment has been minimized.

Copy link
@SharkyKZ

SharkyKZ Mar 9, 2019

Contributor
Suggested change
(496, 0, 'plg_system_skipto', 'plugin', 'skipto', 'system', 0, 1, 1, 0, '', '{"section_skipto":"2"}', 0, 'q970-01-01 00:00:00', 0, 0),
(496, 0, 'plg_system_skipto', 'plugin', 'skipto', 'system', 0, 1, 1, 0, '', '{"section_skipto":"2"}', 0, '1970-01-01 00:00:00', 0, 0),
(600, 802, 'English (en-GB)', 'language', 'en-GB', '', 0, 1, 1, 1, '', '', 0, '1970-01-01 00:00:00', 0, 0),
(601, 802, 'English (en-GB)', 'language', 'en-GB', '', 1, 1, 1, 1, '', '', 0, '1970-01-01 00:00:00', 0, 0),
(700, 0, 'files_joomla', 'file', 'joomla', '', 0, 1, 1, 1, '', '', 0, '1970-01-01 00:00:00', 0, 0),
@@ -42,6 +42,7 @@
"metismenujs": "^1.0.3",
"popper.js": "^1.14.3",
"punycode": "1.4.1",
"skipto": "^2.0.3",
"tinymce": "4.8.3"
},
"devDependencies": {
@@ -0,0 +1,106 @@
<?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\Factory;
This conversation was marked as resolved by brianteeman

This comment has been minimized.

Copy link
@SharkyKZ

SharkyKZ Mar 11, 2019

Contributor

Remove this. It's not needed once other changes are implemented.

use Joomla\CMS\HTML\HTMLHelper;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Plugin\CMSPlugin;
/**
* Skipto plugin to add accessible keyboard navigation to the administrator template.
*
* @since __DEPLOY_VERSION__
*/
class PlgSystemSkipto extends CMSPlugin
{
/**
* If true, language files will be loaded automatically.
*
* @var boolean
* @since 4.0.0
*/
protected $autoloadLanguage = true;

This comment has been minimized.

Copy link
@SharkyKZ

SharkyKZ Mar 11, 2019

Contributor

Remove this since language is loaded conditionally on line 80.

This comment has been minimized.

Copy link
@wilsonge

wilsonge Mar 15, 2019

Contributor

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

This comment has been minimized.

Copy link
@HLeithner

HLeithner Mar 15, 2019

Member

line 80 should not be necessary, because autloadLanguage does exactly the same only in the constructor...

This comment has been minimized.

Copy link
@brianteeman

brianteeman Mar 15, 2019

Author Contributor

Well there is a bug somewhere

This comment has been minimized.

Copy link
@wilsonge

wilsonge Mar 15, 2019

Contributor

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)

/**
* 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;
// Get the document object.
$document = Factory::getDocument();
This conversation was marked as resolved by brianteeman

This comment has been minimized.

Copy link
@SharkyKZ

SharkyKZ Mar 11, 2019

Contributor
Suggested change
$document = Factory::getDocument();
$document = $this->app->getDocument();

Also move this to its first use so it goes after the early return on line 75.

try
{
$app = Factory::getApplication();
This conversation was marked as resolved by brianteeman

This comment has been minimized.

Copy link
@SharkyKZ

SharkyKZ Mar 11, 2019

Contributor

Remove this. Use $this->app.

if ($app->isClient('administrator'))
This conversation was marked as resolved by brianteeman

This comment has been minimized.

Copy link
@SharkyKZ

SharkyKZ Mar 11, 2019

Contributor
Suggested change
if ($app->isClient('administrator'))
if ($this->app->isClient('administrator'))
{
$current_section = 2;
}
elseif ($app->isClient('site'))
This conversation was marked as resolved by brianteeman

This comment has been minimized.

Copy link
@SharkyKZ

SharkyKZ Mar 11, 2019

Contributor
Suggested change
elseif ($app->isClient('site'))
elseif ($this->app->isClient('site'))
{
$current_section = 1;
}
}
catch (Exception $exc)
{
$current_section = 0;
}
if (!($current_section & $section))

This comment has been minimized.

Copy link
@Quy

Quy Mar 9, 2019

Contributor
Suggested change
if (!($current_section & $section))
if (!($current_section && $section))

This comment has been minimized.

Copy link
@brianteeman

brianteeman Mar 9, 2019

Author Contributor

This code is a direct copy paste from the yubikey plugin

This comment has been minimized.

Copy link
@wilsonge

wilsonge Mar 15, 2019

Contributor

Pretty sure we don't mean to do this http://www.php.net/manual/en/language.operators.bitwise.php - even if it does work. I'd change yubikey to match what @Quy is suggesting

This comment has been minimized.

Copy link
@SharkyKZ

SharkyKZ Mar 15, 2019

Contributor

It does work. The suggestion above does not.

{
return false;
This conversation was marked as resolved by brianteeman

This comment has been minimized.

Copy link
@SharkyKZ

SharkyKZ Mar 11, 2019

Contributor
Suggested change
return false;
return;
}
{
This conversation was marked as resolved by brianteeman

This comment has been minimized.

Copy link
@SharkyKZ

SharkyKZ Mar 11, 2019

Contributor

Remove bracket here and on line 104.

// Add strings for translations in Javascript.
$this->loadLanguage();
Factory::getDocument()->addScriptOptions(
This conversation was marked as resolved by brianteeman

This comment has been minimized.

Copy link
@SharkyKZ

SharkyKZ Mar 11, 2019

Contributor
Suggested change
Factory::getDocument()->addScriptOptions(
$document->addScriptOptions(
'skipto-settings',
[
'settings' => [
'skipTo' => [
'buttonLabel' => Text::_('PLG_SYSTEM_SKIPTO_SKIP_TO'),
'buttonDivTitle' => Text::_('PLG_SYSTEM_SKIPTO_SKIP_TO_KEYBOARD'),
'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();
});");
}
}
}
@@ -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>
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.