Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
51 changed files
with
551 additions
and
99 deletions.
There are no files selected for viewing
3 changes: 3 additions & 0 deletions
3
administrator/components/com_admin/sql/updates/mysql/4.2.0-2022-06-19.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
-- See https://github.com/joomla/joomla-cms/pull/38092 | ||
INSERT INTO `#__extensions` (`package_id`, `name`, `type`, `element`, `folder`, `client_id`, `enabled`, `access`, `protected`, `locked`, `manifest_cache`, `params`, `custom_data`, `ordering`, `state`) VALUES | ||
(0, 'plg_system_shortcut', 'plugin', 'shortcut', 'system', 0, 1, 1, 0, 1, '', '', '', 0, 0); |
3 changes: 3 additions & 0 deletions
3
administrator/components/com_admin/sql/updates/postgresql/4.2.0-2022-06-19.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
-- See https://github.com/joomla/joomla-cms/pull/38092 | ||
INSERT INTO "#__extensions" ("package_id", "name", "type", "element", "folder", "client_id", "enabled", "access", "protected", "locked", "manifest_cache", "params", "custom_data", "ordering", "state") VALUES | ||
(0, 'plg_system_shortcut', 'plugin', 'shortcut', 'system', 0, 1, 1, 0, 1, '', '', '', 0, 0); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
; Joomla! Project | ||
; (C) 2022 Open Source Matters, Inc. <https://www.joomla.org> | ||
; License GNU General Public License version 2 or later; see LICENSE.txt | ||
; Note : All ini files need to be saved as UTF-8 | ||
|
||
PLG_SYSTEM_SHORTCUT="System - Keyboard Shortcuts" | ||
PLG_SYSTEM_SHORTCUT_OVERVIEW_DESC="Press <kbd>J</kbd> to access the shortcut mode followed by the shortcut." | ||
PLG_SYSTEM_SHORTCUT_OVERVIEW_HINT="<span class=\"icon-keyboard fa-keyboard me-2\" aria-hidden=\"true\"></span> <kbd>J</kbd> + <kbd>X</kbd> <small>Keyboard Shortcuts</small>" | ||
PLG_SYSTEM_SHORTCUT_OVERVIEW_TITLE="Joomla Keyboard Shortcuts" | ||
PLG_SYSTEM_SHORTCUT_TIMEOUT_DESC="Maximum time that a shortcut can be pressed after pressing <kbd>J</kbd>." | ||
PLG_SYSTEM_SHORTCUT_TIMEOUT_LABEL="Timeout (in milliseconds)" | ||
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 class=\"list-unstyled\"><li><kbd>J</kbd> <kbd>A</kbd> Save</li><li><kbd>J</kbd> <kbd>S</kbd> Save & Close</li><li><kbd>J</kbd> <kbd>Q</kbd> Cancel</li><li><kbd>J</kbd> <kbd>N</kbd> New</li><li><kbd>J</kbd> <kbd>F</kbd> Search</li><li><kbd>J</kbd> <kbd>O</kbd> Options</li><li><kbd>J</kbd> <kbd>H</kbd> Help</li><li><kbd>J</kbd> <kbd>X</kbd> Overview</li><li><kbd>J</kbd> <kbd>D</kbd> Home Dashboard</li></ul>" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
; Note : All ini files need to be saved as UTF-8 | ||
|
||
PLG_SYSTEM_SHORTCUT="System - Keyboard 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 class=\"list-unstyled\"><li><kbd>J</kbd> <kbd>A</kbd> Save</li><li><kbd>J</kbd> <kbd>S</kbd> Save & Close</li><li><kbd>J</kbd> <kbd>Q</kbd> Cancel</li><li><kbd>J</kbd> <kbd>N</kbd> New</li><li><kbd>J</kbd> <kbd>F</kbd> Search</li><li><kbd>J</kbd> <kbd>O</kbd> Options</li><li><kbd>J</kbd> <kbd>H</kbd> Help</li><li><kbd>J</kbd> <kbd>X</kbd> Overview</li><li><kbd>J</kbd> <kbd>D</kbd> Home Dashboard</li></ul>" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
168 changes: 168 additions & 0 deletions
168
build/media_source/plg_system_shortcut/js/shortcut.es6.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,168 @@ | ||
((document, Joomla) => { | ||
'use strict'; | ||
|
||
if (!Joomla) { | ||
throw new Error('Joomla API is not properly initialised'); | ||
} | ||
|
||
/* global hotkeys */ | ||
Joomla.addShortcut = (hotkey, callback) => { | ||
hotkeys(hotkey, 'joomla', (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(); | ||
} | ||
}); | ||
}; | ||
|
||
Joomla.addLinkShortcut = (hotkey, selector) => { | ||
Joomla.addShortcut(hotkey, () => { | ||
window.location.href = selector; | ||
}); | ||
}; | ||
|
||
const setShortcutFilter = () => { | ||
hotkeys.filter = (event) => { | ||
const target = event.target || event.srcElement; | ||
const { tagName } = target; | ||
|
||
// Checkboxes should not block a shortcut event | ||
if (target.type === 'checkbox') { | ||
return true; | ||
} | ||
// Default hotkeys filter behavior | ||
return !(target.isContentEditable || tagName === 'INPUT' || tagName === 'SELECT' || tagName === 'TEXTAREA'); | ||
}; | ||
}; | ||
|
||
const startupShortcuts = () => { | ||
hotkeys('J', (event) => { | ||
// If we're already in the scope, it's a normal shortkey | ||
if (hotkeys.getScope() === 'joomla') { | ||
return; | ||
} | ||
|
||
event.preventDefault(); | ||
event.stopPropagation(); | ||
event.stopImmediatePropagation(); | ||
|
||
hotkeys.setScope('joomla'); | ||
|
||
// Leave the scope after x milliseconds | ||
setTimeout(() => { | ||
hotkeys.setScope(false); | ||
}, Joomla.getOptions('plg_system_shortcut.timeout', 2000)); | ||
}); | ||
}; | ||
|
||
const addOverviewHint = () => { | ||
const mainContainer = document.querySelector('.com_cpanel .container-main'); | ||
if (mainContainer) { | ||
const containerElement = document.createElement('section'); | ||
containerElement.className = 'content pt-4'; | ||
containerElement.insertAdjacentHTML('beforeend', Joomla.Text._('PLG_SYSTEM_SHORTCUT_OVERVIEW_HINT')); | ||
mainContainer.appendChild(containerElement); | ||
} | ||
}; | ||
|
||
const initOverviewModal = (options) => { | ||
const dlItems = new Map(); | ||
Object.values(options).forEach((value) => { | ||
if (!value.shortcut || !value.title) { | ||
return; | ||
} | ||
let titles = []; | ||
if (dlItems.has(value.shortcut)) { | ||
titles = dlItems.get(value.shortcut); | ||
titles.push(value.title); | ||
} else { | ||
titles = [value.title]; | ||
} | ||
dlItems.set(value.shortcut, titles); | ||
}); | ||
|
||
let dl = '<dl>'; | ||
dlItems.forEach((titles, shortcut) => { | ||
dl += '<dt><kbd>J</kbd>'; | ||
shortcut.split('+').forEach((key) => { | ||
dl += ` <kbd>${key.trim()}</kbd>`; | ||
}); | ||
dl += '</dt>'; | ||
titles.forEach((title) => { | ||
dl += `<dd>${title}</dd>`; | ||
}); | ||
}); | ||
dl += '</dl>'; | ||
|
||
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="${Joomla.Text._('JCLOSE')}"></button> | ||
</div> | ||
<div class="modal-body p-3"> | ||
<p>${Joomla.Text._('PLG_SYSTEM_SHORTCUT_OVERVIEW_DESC')}</p> | ||
<div class="mb-3"> | ||
${dl} | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
`; | ||
|
||
document.body.insertAdjacentHTML('beforeend', modal); | ||
|
||
const bootstrapModal = new bootstrap.Modal(document.getElementById('shortcutOverviewModal'), { | ||
keyboard: true, | ||
backdrop: true, | ||
}); | ||
hotkeys('X', 'joomla', () => bootstrapModal.show()); | ||
}; | ||
|
||
document.addEventListener('DOMContentLoaded', () => { | ||
const options = Joomla.getOptions('plg_system_shortcut.shortcuts'); | ||
Object.values(options).forEach((value) => { | ||
if (!value.shortcut || !value.selector) { | ||
return; | ||
} | ||
if (value.selector.startsWith('/') || value.selector.startsWith('http://') || value.selector.startsWith('www.')) { | ||
Joomla.addLinkShortcut(value.shortcut, value.selector); | ||
} else if (value.selector.includes('input')) { | ||
Joomla.addFocusShortcut(value.shortcut, value.selector); | ||
} else { | ||
Joomla.addClickShortcut(value.shortcut, value.selector); | ||
} | ||
}); | ||
// Show hint and overview on logged in backend only (not login page) | ||
if (document.querySelector('nav')) { | ||
initOverviewModal(options); | ||
addOverviewHint(); | ||
} | ||
setShortcutFilter(); | ||
startupShortcuts(); | ||
}); | ||
})(document, Joomla); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.