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

Main PR #18

Open
wants to merge 160 commits into
base: 4.2-dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 154 commits
Commits
Show all changes
160 commits
Select commit Hold shift + click to select a range
b44ece4
Fix form label relation removed title from non active elements
Krshivam25 Jun 8, 2021
8d82ea4
Keboard Shortcuts Plugin Setup
Krshivam25 Jun 14, 2021
1bb1802
Language description
Krshivam25 Jun 15, 2021
d98a6e6
Added Shortcut keys for buttons
Krshivam25 Jun 15, 2021
ecf9491
Added more Keyboard shortcuts
Krshivam25 Jun 16, 2021
a77362b
Optimized code with function
Krshivam25 Jun 17, 2021
c0db25f
Removed Options Shortcuts and Improved Comment
Krshivam25 Jun 17, 2021
847a265
Improved code by adding Joomla.shortcut
Krshivam25 Jun 19, 2021
cd2953e
Updated actionbutton.split
Krshivam25 Jun 19, 2021
0ce4961
Update plugins/system/shortcut/shortcut.php
Krshivam25 Jun 19, 2021
a293b3e
Deleted Index.html
Krshivam25 Jun 20, 2021
1bd0433
Update Shortcut.js
Krshivam25 Jun 20, 2021
fb6c0d9
Delete index.html
Krshivam25 Jun 20, 2021
88d6fd4
Updated file name
Krshivam25 Jun 20, 2021
f072443
Rename shortcut.js to shortcut.es6.js
Krshivam25 Jun 20, 2021
000ee23
Update en-GB.plg_system_shortcut.ini
Krshivam25 Jun 20, 2021
03797b0
Update en-GB.plg_system_shortcut.ini
Krshivam25 Jun 20, 2021
3c51c9d
Update Copyright
HLeithner Jun 20, 2021
30071b0
Update en-GB.plg_system_shortcut.ini
Krshivam25 Jun 20, 2021
95c7fc4
Drone
HLeithner Jun 20, 2021
9b8981f
Update drone key for gsoc21_accessibility
HLeithner Jun 20, 2021
2965133
Update shortcut.es6.js
Krshivam25 Jun 20, 2021
f96bc36
Update Shortcut.php
Krshivam25 Jun 20, 2021
edf6b11
Update shortcut.xml
Krshivam25 Jun 20, 2021
5210736
Update shortcut.php
Krshivam25 Jun 20, 2021
65f0fe7
Added type module
Krshivam25 Jun 21, 2021
386af1c
Fix conflict
Krshivam25 Jun 21, 2021
f0d7e1c
Merge branch '4.1-dev' of https://github.com/joomla-projects/gsoc21_a…
Krshivam25 Jun 21, 2021
f24b581
Fix phpcs error in shortcut.php file
Krshivam25 Jun 22, 2021
b223844
Updated phpcs fixes in shortcut.php
Krshivam25 Jun 22, 2021
96b47e0
updated comments and added @var in shortcut.php
Krshivam25 Jun 22, 2021
8348889
Updated Javascript-cs Fixes in shortcut.es6.js file
Krshivam25 Jun 22, 2021
b699d04
Revert changes in package-lock.json and package.json
Krshivam25 Jun 22, 2021
2c986c0
Merge branch '4.1-dev' of github.com:joomla/joomla-cms into 4.1-dev-a…
bembelimen Jun 22, 2021
692b302
Added $document->addScriptOptions()
Krshivam25 Jun 24, 2021
4b1987c
Fix extra space in shortcut.php
Krshivam25 Jun 24, 2021
e34f5b8
Updated Shortcut.es6.js
Krshivam25 Jun 25, 2021
d764d68
Updated shortcut.php
Krshivam25 Jun 25, 2021
bfe158d
Updated keyboard shortcuts plugin
Krshivam25 Jun 25, 2021
6cb6ef1
Removed Extra Space
Krshivam25 Jun 27, 2021
b98e002
Updated shortcut Functionality with radio buttons
Krshivam25 Jun 28, 2021
e7a5d8a
Merge pull request #9 from joomla-projects/4.1-dev
bembelimen Jul 1, 2021
470dfeb
Merge pull request #10 from joomla-projects/dev
bembelimen Jul 1, 2021
b990af8
Updated Keyboard Shortcuts with keyselect field
Krshivam25 Jul 3, 2021
1417be4
Added: Key combination features in modal
Krshivam25 Jul 4, 2021
9ac232d
Added: Restore Default and Updated Modal Pop-up
Krshivam25 Jul 5, 2021
5f2b7e3
Updated: shortcut.xml according coding standard.
Krshivam25 Jul 6, 2021
0f97b78
Removed: Jimport
Krshivam25 Jul 6, 2021
d3acba5
Removed: Jimport
Krshivam25 Jul 6, 2021
b1b7c82
Removed: Jimport
Krshivam25 Jul 7, 2021
1bbca23
Removed: Input Field and MySql Updated
Krshivam25 Jul 7, 2021
309c093
Fix: Undefined method and Updated: base.sql files
Krshivam25 Jul 9, 2021
aa7948d
Update: Fix codestyle in PHP and drone error fix
Krshivam25 Jul 9, 2021
3271ea9
Removed: Extra Column in Base.sql
Krshivam25 Jul 10, 2021
5d6e72d
Removed: Extra Column in Postgresql
Krshivam25 Jul 10, 2021
2e60e4f
Updated: keyselect.es6.js with array []
Krshivam25 Jul 10, 2021
7d3c64f
Updated: Fix Code Style in shortcut.xml
Krshivam25 Jul 10, 2021
b91e29f
Updated: Keyselect.php
Krshivam25 Jul 10, 2021
dd3aa28
Update: Restore Defaults button removed namespace
Krshivam25 Jul 10, 2021
04b38ef
Update shortcut.php
Krshivam25 Jul 10, 2021
52fa2f7
Updated: keyselect.es6.js modal is vertically centered
Krshivam25 Jul 19, 2021
e064b3b
Merge branch '4.1-dev' of github.com:joomla/joomla-cms into 4.1-dev
bembelimen Jul 19, 2021
474905f
Merge branch 'dev' into gsoc
Krshivam25 Jul 20, 2021
fca4f51
Merge branch '4.1-dev' of github.com:joomla/joomla-cms into 4.1-dev
bembelimen Jul 22, 2021
b622a9d
Fixes: Keyselect and Restoredefault
Krshivam25 Jul 23, 2021
8e1ee53
Added Object.entries in Restoredefaults.js
Krshivam25 Jul 25, 2021
fda263b
Button colour is changed for Restore
Krshivam25 Jul 25, 2021
3299ebb
Updated: restoredefault.js
Krshivam25 Jul 25, 2021
f8c426a
Fix: Keyselect for meta keys
Krshivam25 Jul 25, 2021
6c46439
Update: Cancel Button text color changed
Krshivam25 Jul 29, 2021
472199b
Removed prevent default from modal
Krshivam25 Aug 2, 2021
acf57e5
Removed Empty _DESC
Krshivam25 Aug 2, 2021
d070170
Updated: Restore default added querySelector
Krshivam25 Aug 3, 2021
5a237ea
Removed Label in text string
Krshivam25 Aug 4, 2021
d657db8
Updated: XML version DEPLOY_VERSION
Krshivam25 Aug 4, 2021
6530c88
Updated: MAC Options in restoredefaults
Krshivam25 Aug 5, 2021
5b37825
Merge pull request #14 from joomla-projects/4.1-dev
bembelimen Aug 10, 2021
f13592e
Merge branch '4.1-dev' into gsoc
Krshivam25 Aug 11, 2021
132bc9d
Removed: Whitespace in keyselect
Krshivam25 Aug 11, 2021
a9fa0d8
Removed: PhpCS in restoredefault
Krshivam25 Aug 11, 2021
ec5e675
PHPCS fix in shortcut
Krshivam25 Aug 11, 2021
9e7679c
PHPCS code fix
Krshivam25 Aug 12, 2021
e6c21d5
phpcs fix
Krshivam25 Aug 12, 2021
e5773d4
PHPCS fix
Krshivam25 Aug 12, 2021
63fa7f9
PHPCS fix
Krshivam25 Aug 12, 2021
35e5df7
PHPCS fix
Krshivam25 Aug 12, 2021
20c4609
phpcs fix
Krshivam25 Aug 12, 2021
04f1fb8
PHPCS fix
Krshivam25 Aug 12, 2021
4fec5e1
PHPCS shortcut
Krshivam25 Aug 13, 2021
9f4618b
Merge branch 'gsoc' of https://github.com/Krshivam25/gsoc21_accessibi…
Krshivam25 Aug 13, 2021
52f8b40
ESlint fix in JS file
Krshivam25 Aug 15, 2021
34d0cf2
Removed for of loops in keyselect
Krshivam25 Aug 16, 2021
8b51d96
eslint keyselect
Krshivam25 Aug 16, 2021
1c78a6c
Eslint fix issues in Shortcut.js
Krshivam25 Aug 18, 2021
b87c5c0
Merge if statement in shortcut.js
Krshivam25 Aug 18, 2021
19b521a
Component Shortcuts
Krshivam25 Sep 1, 2021
52cf4b0
Component shortcut
Krshivam25 Sep 1, 2021
1060ee2
Component Shortcut
Krshivam25 Sep 2, 2021
cbb976e
Updated: XML for components
Krshivam25 Sep 5, 2021
78e527b
Updated: shortcut php
Krshivam25 Sep 5, 2021
b6697a2
Updated: keyselect.php & restoredefaults.php
Krshivam25 Sep 5, 2021
19c21fc
Updated: javascript files for restore default
Krshivam25 Sep 5, 2021
da5dccb
Removed extra space
Krshivam25 Sep 22, 2021
9409a82
Removed Login file
Krshivam25 Sep 22, 2021
a884350
Removed login file
Krshivam25 Sep 22, 2021
9b549a1
Revert login tmpl
bembelimen Sep 22, 2021
f26cbd6
Removed the Component Shortcuts and Reset is Fix
Krshivam25 Nov 12, 2021
4324f87
Added package Mousetrap
Krshivam25 Nov 14, 2021
acffa6d
changes revert
Krshivam25 Nov 14, 2021
88fdbb3
Revert changes
Krshivam25 Nov 14, 2021
5670196
Added packages in settings.json
Krshivam25 Nov 15, 2021
0ec44db
Added mousetrap in settings.json
Krshivam25 Nov 16, 2021
2bdaab6
importing mousetrap library
Krshivam25 Nov 19, 2021
ed7f431
Mousetrap library added
Krshivam25 Dec 4, 2021
a1e1e16
Updated PHP files for shortcut
Krshivam25 Dec 4, 2021
dbc106c
Shortcut list appears in alert
Krshivam25 Dec 4, 2021
3d8b905
Updated shortcut in Modal Window with esc key
Krshivam25 Dec 11, 2021
9011e23
Merge pull request #7 from Krshivam25/keyboard-shortcut
bembelimen May 8, 2022
594d288
Merge pull request #8 from Krshivam25/gsoc
bembelimen May 8, 2022
18abf8a
Merge branch 'gsoc' into keyboard-shortcut
bembelimen May 8, 2022
f6e2ca0
Merge pull request #17 from joomla-projects/keyboard-shortcut
bembelimen May 8, 2022
a8977e5
Merge branch '4.2-dev' of github.com:joomla/joomla-cms into gsoc
bembelimen May 8, 2022
395b15e
Merge branch 'gsoc' of github.com:joomla-projects/gsoc21_accessibilit…
bembelimen May 8, 2022
81870e9
First step of moving to hotkeys
bembelimen May 9, 2022
c479805
Merge branch '4.2-dev' of github.com:joomla/joomla-cms into shortcut
bembelimen May 17, 2022
6f957e2
Rename language files
bembelimen May 18, 2022
9ddb327
Merge remote-tracking branch 'Joomla/4.2-dev' into gsoc
bembelimen May 21, 2022
74cf78d
Merge branch '4.2-dev' of github.com:joomla/joomla-cms into shortcut
bembelimen May 25, 2022
3909e21
Merge branch 'gsoc' of github.com:joomla-projects/gsoc21_accessibilit…
bembelimen May 25, 2022
7afd288
Fix keyselect field
bembelimen May 25, 2022
6674e07
Add shortcut function
bembelimen May 26, 2022
f9bf842
Remove eval and add key selector only
bembelimen May 26, 2022
3f530d8
Fix PR comments
fancyFranci Jun 4, 2022
d174a11
Remove unnecessary classes
fancyFranci Jun 4, 2022
9b6e728
Fix text files
fancyFranci Jun 4, 2022
089301c
Set h3 instead of h5 in modal
fancyFranci Jun 4, 2022
4b8be66
Remove readonly attribute from new-key-input
fancyFranci Jun 4, 2022
cc9ca65
Remove readonly and change current-key to text
fancyFranci Jun 4, 2022
1d88bb4
Remove unused stuff
fancyFranci Jun 4, 2022
388d974
Add search
fancyFranci Jun 4, 2022
59a8fa7
Move search button
bembelimen Jun 4, 2022
9180e66
Fix styleguide
bembelimen Jun 4, 2022
d026f0c
Format doc and remove double class
fancyFranci Jun 5, 2022
3ba8c1c
Add info text to key select modal
bembelimen Jun 5, 2022
c67a992
Add default options to shortcut keys
bembelimen Jun 5, 2022
e32e449
Refactor keyselect js and include mac
fancyFranci Jun 6, 2022
0768e59
Merge branch 'gsoc' of github.com:joomla-projects/gsoc21_accessibilit…
fancyFranci Jun 6, 2022
798bd8e
Use "confirm" instead of "save"
fancyFranci Jun 6, 2022
2f63245
Set modifier "j"
fancyFranci Jun 11, 2022
e2193d3
Remove shortcut editing
fancyFranci Jun 11, 2022
466c17c
Mark global hotkeys
fancyFranci Jun 11, 2022
8b2629d
Add overview modal
fancyFranci Jun 12, 2022
72ab7ea
Remove not working editor actions
fancyFranci Jun 12, 2022
f7fbdc8
Set keyboard icon and dl instead of ul
fancyFranci Jun 16, 2022
7a51413
Set correct version
fancyFranci Jun 18, 2022
d518e90
Remove not working editor shortcuts
fancyFranci Jun 18, 2022
d1658eb
Improve overview list
fancyFranci Jun 18, 2022
ac07f6d
Generate overview with options
fancyFranci Jun 18, 2022
dedbdb6
Set plugin description in sys.ini too
fancyFranci Jun 18, 2022
b0d6420
Fix shortcut filter by allowing checkboxes
fancyFranci Jun 18, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions administrator/language/en-GB/plg_system_shortcut.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
; Joomla! Project
; (C) 2022 Open Source Matters, Inc. <https://www.joomla.org>
; 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_SHORTCUT="System - Keyboard Shortcut"
PLG_SYSTEM_SHORTCUT_ACTIONS_FORM_LABEL="Form View Actions"
PLG_SYSTEM_SHORTCUT_ACTIONS_GENERAL_LABEL="General Actions"
PLG_SYSTEM_SHORTCUT_ACTIONS_LIST_LABEL="List View Actions"
PLG_SYSTEM_SHORTCUT_CORE_SHORTCUTS_TAB="Core Shortcuts"
PLG_SYSTEM_SHORTCUT_OVERVIEW_HINT="Press J + X for our keyboard shortcut overview"
PLG_SYSTEM_SHORTCUT_OVERVIEW_TITLE="Available Joomla Shortcuts"
PLG_SYSTEM_SHORTCUT_XML_DESCRIPTION="<p>Enables keyboard shortcuts on the administrator site, which can be provided by other plugins and includes directly the following list of shortcuts:<p><ul><li>Save: J + S</li><li>Cancel: J + Q</li><li>New: J + N</li><li>Save & New: J + N</li><li>Save & Close: J + W</li><li>Search: J + S</li><li>Option: J + O</li><li>Help: J + H</li><li>Overview: J + X</li></ul>"
7 changes: 7 additions & 0 deletions administrator/language/en-GB/plg_system_shortcut.sys.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
; Joomla! Project
; (C) 2022 Open Source Matters, Inc. <https://www.joomla.org>
; 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_SHORTCUT="System - Keyboard Shortcut"
PLG_SYSTEM_SHORTCUT_XML_DESCRIPTION="System - Keyboard Shortcut Plugin"
fancyFranci marked this conversation as resolved.
Show resolved Hide resolved
18 changes: 18 additions & 0 deletions build/build-modules-js/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,24 @@
"dependencies": [],
"licenseFilename": "LICENSE.txt"
},
"hotkeys-js": {
"name": "hotkeys.js",
"licenseFilename": "LICENSE",
"js" : {
"dist/hotkeys.js": "js/hotkeys.js",
"dist/hotkeys.min.js": "js/hotkeys.min.js"
},
"provideAssets": [
{
"name": "hotkeys.js",
"type": "script",
"uri": "hotkeys.min.js",
"attributes": {
"defer": true
}
}
]
},
"jquery": {
"name": "jquery",
"js": {
Expand Down
122 changes: 122 additions & 0 deletions build/media_source/plg_system_shortcut/js/shortcut.es6.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
((document, Joomla) => {
'use strict';

if (!Joomla) {
throw new Error('Joomla API is not properly initialised');
}

/* global hotkeys */
Joomla.addShortcut = (hotkey, callback) => {
hotkeys(hotkey, (event) => {
event.preventDefault();
event.stopPropagation();
event.stopImmediatePropagation();

callback.call();
});
};

Joomla.addClickShortcut = (hotkey, selector) => {
Joomla.addShortcut(hotkey, () => {
const element = document.querySelector(selector);
if (element) {
element.click();
}
});
};

Joomla.addFocusShortcut = (hotkey, selector) => {
Joomla.addShortcut(hotkey, () => {
const element = document.querySelector(selector);
if (element) {
element.focus();
}
});
};

const addOverviewHint = () => {
const iconElement = document.createElement('span');
iconElement.className = 'icon-keyboard fa-keyboard me-2';
iconElement.setAttribute('aria-hidden', true);
const textElement = document.createElement('span');
textElement.innerText = Joomla.Text._('PLG_SYSTEM_SHORTCUT_OVERVIEW_HINT');
const hintElement = document.createElement('p');
hintElement.appendChild(iconElement);
hintElement.appendChild(textElement);
const containerElement = document.createElement('section');
containerElement.className = 'content pt-4';
containerElement.appendChild(hintElement);
document.querySelector('.container-main').appendChild(containerElement);
};

const initOverviewModal = () => {
const modal = `
<div class="modal fade" id="shortcutOverviewModal" tabindex="-1" role="dialog" data-bs-backdrop="static" aria-labelledby="shortcutOverviewModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h3 id="shortcutOverviewModalLabel" class="modal-title">
${Joomla.Text._('PLG_SYSTEM_SHORTCUT_OVERVIEW_TITLE')}
</h3>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body p-3">
<div class="mb-3">
<h4>${Joomla.Text._('PLG_SYSTEM_SHORTCUT_ACTIONS_GENERAL_LABEL')}</h4>
<dl>
<dt>${Joomla.Text._('JHELP')}</dt>
<dd>J + H</dd>
<dt>${Joomla.Text._('JOPTIONS')}</dt>
<dd>J + O</dd>
<dt>${Joomla.Text._('JSEARCH_FILTER')}</dt>
<dd>J + S</dd>
</dl>

<h4>${Joomla.Text._('PLG_SYSTEM_SHORTCUT_ACTIONS_LIST_LABEL')}</h4>
<dl>
<dt>${Joomla.Text._('JTOOLBAR_NEW')}</dt>
<dd>J + N</dd>
<dt>${Joomla.Text._('JCANCEL')}</dt>
<dd>J + Q</dd>
</dl>

<h4>${Joomla.Text._('PLG_SYSTEM_SHORTCUT_ACTIONS_FORM_LABEL')}</h4>
<dl>
<dt>${Joomla.Text._('JAPPLY')}</dt>
<dd>J + A</dd>
<dt>${Joomla.Text._('JTOOLBAR_SAVE')}</dt>
<dd>J + S</dd>
<dt>${Joomla.Text._('JTOOLBAR_SAVE_AND_NEW')}</dt>
<dd>J + N</dd>
<dt>${Joomla.Text._('JTOOLBAR_CLOSE')}</dt>
<dd>J + Q</dd>
</dl>
</div>
</div>
</div>
</div>
</div>
`;

document.body.insertAdjacentHTML('beforeend', modal);

const bootstrapModal = new bootstrap.Modal(document.getElementById('shortcutOverviewModal'), {
keyboard: true,
backdrop: true,
});
hotkeys('J + X', () => bootstrapModal.show());
};

document.addEventListener('DOMContentLoaded', () => {
const options = Joomla.getOptions('plg_system_shortcut.shortcuts');
Object.values(options).forEach((value) => {
if (value.selector.includes('input')) {
Joomla.addFocusShortcut(value.shortcut, value.selector);
} else {
Joomla.addClickShortcut(value.shortcut, value.selector);
}
});
addOverviewHint();
initOverviewModal();
});
})(document, Joomla);
1 change: 1 addition & 0 deletions installation/sql/mysql/base.sql
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,7 @@ INSERT INTO `#__extensions` (`package_id`, `name`, `type`, `element`, `folder`,
(0, 'plg_system_sef', 'plugin', 'sef', 'system', 0, 1, 1, 0, 1, '', '', '', 18, 0),
(0, 'plg_system_sessiongc', 'plugin', 'sessiongc', 'system', 0, 1, 1, 0, 1, '', '', '', 19, 0),
(0, 'plg_system_skipto', 'plugin', 'skipto', 'system', 0, 1, 1, 0, 1, '', '{}', '', 20, 0),
(0, 'plg_system_shortcut', 'plugin', 'shortcut', 'system', 0, 1, 1, 0, 0, '', '{}', '', 0, 0),
(0, 'plg_system_stats', 'plugin', 'stats', 'system', 0, 1, 1, 0, 1, '', '', '', 21, 0),
(0, 'plg_system_tasknotification', 'plugin', 'tasknotification', 'system', 0, 1, 1, 0, 1, '', '', '', 22, 0),
(0, 'plg_system_updatenotification', 'plugin', 'updatenotification', 'system', 0, 1, 1, 0, 1, '', '', '', 23, 0),
Expand Down
1 change: 1 addition & 0 deletions installation/sql/postgresql/base.sql
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,7 @@ INSERT INTO "#__extensions" ("package_id", "name", "type", "element", "folder",
(0, 'plg_system_sef', 'plugin', 'sef', 'system', 0, 1, 1, 0, 1, '', '', '', 18, 0),
(0, 'plg_system_sessiongc', 'plugin', 'sessiongc', 'system', 0, 1, 1, 0, 1, '', '', '', 19, 0),
(0, 'plg_system_skipto', 'plugin', 'skipto', 'system', 0, 1, 1, 0, 1, '', '{}', '', 20, 0),
(0, 'plg_system_shortcut', 'plugin', 'shortcut', 'system', 0, 1, 1, 0, 0, '', '{}', '', 0, 0),
(0, 'plg_system_stats', 'plugin', 'stats', 'system', 0, 1, 1, 0, 1, '', '', '', 21, 0),
(0, 'plg_system_tasknotification', 'plugin', 'tasknotification', 'system', 0, 1, 1, 0, 1, '', '', '', 22, 0),
(0, 'plg_system_updatenotification', 'plugin', 'updatenotification', 'system', 0, 1, 1, 0, 1, '', '', '', 23, 0),
Expand Down
11 changes: 11 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
"diff": "^5.0.0",
"dragula": "^3.7.3",
"focus-visible": "^5.2.0",
"hotkeys-js": "^3.9.3",
"joomla-ui-custom-elements": "^0.2.0",
"jquery": "^3.6.0",
"jquery-migrate": "^3.3.2",
Expand Down
155 changes: 155 additions & 0 deletions plugins/system/shortcut/shortcut.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,155 @@
<?php
/**
* @package Joomla.Plugins
* @subpackage System.shortcut
*
* @copyright (C) 2022 Open Source Matters, Inc. <https://www.joomla.org>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/

defined('_JEXEC') or die;

use Joomla\CMS\Application\AdministratorApplication;
use Joomla\CMS\Event\GenericEvent;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Plugin\CMSPlugin;
use Joomla\CMS\Plugin\PluginHelper;
use Joomla\Event\Event;
use Joomla\Event\SubscriberInterface;

/**
* Shortcut plugin to add accessible keyboard shortcuts to the administrator templates.
*
* @since __DEPLOY_VERSION__
*/
class PlgSystemShortcut extends CMSPlugin implements SubscriberInterface
{
/**
* Application object.
*
* @var AdministratorApplication
*
* @since __DEPLOY_VERSION__
*/
protected $app;

/**
* Load the language file on instantiation.
*
* @var boolean
* @since 3.1
fancyFranci marked this conversation as resolved.
Show resolved Hide resolved
*/
protected $autoloadLanguage = true;

/**
* Returns an array of events this subscriber will listen to.
*
* The array keys are event names and the value can be:
*
* - The method name to call (priority defaults to 0)
* - An array composed of the method name to call and the priority
*
* For instance:
*
* * array('eventName' => 'methodName')
* * array('eventName' => array('methodName', $priority))
*
* @return array
*
* @since __DEPLOY_VERSION__
*/
public static function getSubscribedEvents(): array
{
return [
'onBeforeCompileHead' => 'initialize',
'onLoadShortcuts' => 'addShortcuts'
];
}


/**
* Add the javascript for the shortcuts
*
* @return void
*
* @since __DEPLOY_VERSION__
*/
public function initialize()
{
if (!$this->app->isClient('administrator'))
{
return;
}

PluginHelper::importPlugin('shortcut');

$context = $this->app->input->get('option') . '.' . $this->app->input->get('view');

$shortcuts = [];

$event = new GenericEvent('onLoadShortcuts', [
'context' => $context,
'shortcuts' => $shortcuts
]);

$this->app->getDispatcher()->dispatch('onLoadShortcuts', $event);

$shortcuts = $event->getArgument('shortcuts');

Text::script('JAPPLY');
Text::script('JCANCEL');
Text::script('JHELP');
Text::script('JOPTIONS');
Text::script('JSEARCH_FILTER');
Text::script('JTOOLBAR_CLOSE');
Text::script('JTOOLBAR_NEW');
Text::script('JTOOLBAR_SAVE');
Text::script('JTOOLBAR_SAVE_AND_NEW');
Text::script('PLG_SYSTEM_SHORTCUT_ACTIONS_FORM_LABEL');
Text::script('PLG_SYSTEM_SHORTCUT_ACTIONS_GENERAL_LABEL');
Text::script('PLG_SYSTEM_SHORTCUT_ACTIONS_LIST_LABEL');
Text::script('PLG_SYSTEM_SHORTCUT_OVERVIEW_HINT');
Text::script('PLG_SYSTEM_SHORTCUT_OVERVIEW_TITLE');

$wa = $this->app->getDocument()->getWebAssetManager();
$wa->useScript('bootstrap.modal');
$wa->registerAndUseScript('script', 'plg_system_shortcut/shortcut.min.js', ['dependencies' => ['hotkeys.js']]);

$this->app->getDocument()->addScriptOptions('plg_system_shortcut.shortcuts', $shortcuts);
}

/**
* Add default shortcuts to the document
*
* @param Event $event The event
*
* @return void
*
* @since __DEPLOY_VERSION__
*/
public function addShortcuts(Event $event)
{
$shortcuts = $event->getArgument('shortcuts');

$keys = [
'helpKey' => (object) ['selector' => 'joomla-toolbar-button .button-help', 'shortcut' => 'J + H'],
'newKey' => (object) ['selector' => 'joomla-toolbar-button .button-new', 'shortcut' => 'J + N'],
'applyKey' => (object) ['selector' => 'joomla-toolbar-button .button-apply', 'shortcut' => 'J + S'],
'saveKey' => (object) ['selector' => 'joomla-toolbar-button .button-save', 'shortcut' => 'J + W'],
'saveNewKey' => (object) ['selector' => 'joomla-toolbar-button .button-save-new', 'shortcut' => 'J + N'],
'cancelKey' => (object) ['selector' => 'joomla-toolbar-button .button-cancel', 'shortcut' => 'J + Q'],
'optionKey' => (object) ['selector' => 'joomla-toolbar-button .button-options', 'shortcut' => 'J + O'],
'searchKey' => (object) ['selector' => 'input[placeholder=' . Text::_('JSEARCH_FILTER') . ']', 'shortcut' => 'J + S'],
'editorArticleKey' => (object) ['selector' => 'joomla-editor-option ~ article_modal', 'shortcut' => 'CTRL + ALT + A'],
fancyFranci marked this conversation as resolved.
Show resolved Hide resolved
'editorContactKey' => (object) ['selector' => 'joomla-editor-option ~ contact_modal', 'shortcut' => 'CTRL + ALT + C'],
'editorFieldsKey' => (object) ['selector' => 'joomla-editor-option ~ fields_modal', 'shortcut' => 'CTRL + ALT + F'],
'editorImageKey' => (object) ['selector' => 'joomla-editor-option ~ image_modal', 'shortcut' => 'CTRL + ALT + I'],
'editorMenuKey' => (object) ['selector' => 'joomla-editor-option ~ menu_modal', 'shortcut' => 'CTRL + ALT + M'],
'editorModuleKey' => (object) ['selector' => 'joomla-editor-option ~ module_modal', 'shortcut' => 'CTRL + SHIFT + ALT + M'],
'editorPagebreakKey' => (object) ['selector' => 'joomla-editor-option ~ pagebreak_modal', 'shortcut' => 'CTRL + ALT + P'],
'editorReadmoreKey' => (object) ['selector' => 'joomla-editor-option ~ read_more', 'shortcut' => 'CTRL + ALT + R'],
];

$event->setArgument('shortcuts', $keys);
}
}
Loading