Skip to content

Commit

Permalink
Merge branch '4.2-dev' into patch-5
Browse files Browse the repository at this point in the history
  • Loading branch information
Quy committed Jun 23, 2022
2 parents 6d0afcf + b12020a commit 9d09186
Show file tree
Hide file tree
Showing 51 changed files with 551 additions and 99 deletions.
@@ -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);
@@ -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);
4 changes: 2 additions & 2 deletions administrator/components/com_joomlaupdate/extract.php
Expand Up @@ -1946,7 +1946,7 @@ function getConfiguration(): ?array
* Sets the PHP timeout to 3600 seconds
*
* @return void
* @since __DEPLOY_VERSION__
* @since 4.2.0
*/
function setLongTimeout()
{
Expand All @@ -1962,7 +1962,7 @@ function setLongTimeout()
* Sets the memory limit to 1GiB
*
* @return void
* @since __DEPLOY_VERSION__
* @since 4.2.0
*/
function setHugeMemoryLimit()
{
Expand Down
Expand Up @@ -588,7 +588,7 @@ public function fetchExtensionCompatibility()
* Called by the Joomla Update JavaScript (PreUpdateChecker.checkNextChunk).
*
* @return void
* @since __DEPLOY_VERSION__
* @since 4.2.0
*
*/
public function batchextensioncompatibility()
Expand Down
Expand Up @@ -119,15 +119,15 @@ class HtmlView extends BaseHtmlView
* Should I disable the confirmation checkbox for pre-update extension version checks?
*
* @var boolean
* @since __DEPLOY_VERSION__
* @since 4.2.0
*/
protected $noVersionCheck = false;

/**
* Should I disable the confirmation checkbox for taking a backup before updating?
*
* @var boolean
* @since __DEPLOY_VERSION__
* @since 4.2.0
*/
protected $noBackupCheck = false;

Expand Down
Expand Up @@ -55,7 +55,7 @@ class HtmlView extends BaseHtmlView
* Should I disable the confirmation checkbox for taking a backup before updating?
*
* @var boolean
* @since __DEPLOY_VERSION__
* @since 4.2.0
*/
protected $noBackupCheck = false;

Expand Down
Expand Up @@ -174,7 +174,7 @@ protected function getListQuery()
*
* @return void
*
* @since __DEPLOY_VERSION__
* @since 4.2.0
*/
public function purge(int $userId): void
{
Expand Down
Expand Up @@ -79,7 +79,7 @@ public function unpublish()
*
* @return void
*
* @since __DEPLOY_VERSION__
* @since 4.2.0
*/
public function republish()
{
Expand All @@ -105,7 +105,7 @@ public function republish()
*
* @return void
*
* @since __DEPLOY_VERSION__
* @since 4.2.0
*/
public function archive()
{
Expand Down
Expand Up @@ -127,7 +127,7 @@ public function unpublishMessage($id)
*
* @return void
*
* @since __DEPLOY_VERSION__
* @since 4.2.0
*/
public function archiveMessage($id)
{
Expand All @@ -152,7 +152,7 @@ public function archiveMessage($id)
*
* @return void
*
* @since __DEPLOY_VERSION__
* @since 4.2.0
*/
public function republishMessage($id)
{
Expand Down
Expand Up @@ -743,7 +743,7 @@ public function getHelp()
*
* @return stdClass
*
* @since __DEPLOY_VERSION__
* @since 4.2.0
*/
public function getAdminTemplate(int $styleId): stdClass
{
Expand Down Expand Up @@ -789,7 +789,7 @@ public function getAdminTemplate(int $styleId): stdClass
*
* @return array
*
* @since __DEPLOY_VERSION__
* @since 4.2.0
*/
public function getSiteTemplates(): array
{
Expand Down
12 changes: 12 additions & 0 deletions administrator/language/en-GB/plg_system_shortcut.ini
@@ -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>"
7 changes: 7 additions & 0 deletions administrator/language/en-GB/plg_system_shortcut.sys.ini
@@ -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>"
2 changes: 1 addition & 1 deletion administrator/manifests/files/joomla.xml
Expand Up @@ -6,7 +6,7 @@
<authorUrl>www.joomla.org</authorUrl>
<copyright>(C) 2019 Open Source Matters, Inc.</copyright>
<license>GNU General Public License version 2 or later; see LICENSE.txt</license>
<version>4.2.0-beta2-dev</version>
<version>4.2.0-dev</version>
<creationDate>2022-06</creationDate>
<description>FILES_JOOMLA_XML_DESCRIPTION</description>

Expand Down
18 changes: 18 additions & 0 deletions build/build-modules-js/settings.json
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
168 changes: 168 additions & 0 deletions build/media_source/plg_system_shortcut/js/shortcut.es6.js
@@ -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);
6 changes: 3 additions & 3 deletions build/media_source/system/js/core.es6.js
Expand Up @@ -573,7 +573,7 @@ window.Joomla.Modal = window.Joomla.Modal || {
*
* @type {Array}
*
* @since __DEPLOY_VERSION__
* @since 4.2.0
*/
const requestQueue = [];

Expand All @@ -582,7 +582,7 @@ window.Joomla.Modal = window.Joomla.Modal || {
*
* @type {boolean}
*
* @since __DEPLOY_VERSION__
* @since 4.2.0
*/
let performingQueuedRequest = false;

Expand Down Expand Up @@ -624,7 +624,7 @@ window.Joomla.Modal = window.Joomla.Modal || {
/**
* Processes queued Request objects.
*
* @since __DEPLOY_VERSION__
* @since 4.2.0
*/
const processQueuedRequests = () => {
if (performingQueuedRequest || requestQueue.length === 0) {
Expand Down
4 changes: 2 additions & 2 deletions components/com_tags/src/Helper/RouteHelper.php
Expand Up @@ -105,7 +105,7 @@ public static function getTagRoute($id)
*
* @return string URL link to pass to the router
*
* @since __DEPLOY_VERSION__
* @since 4.2.0
* @throws Exception
*/
public static function getComponentTagRoute(string $id, string $language = '*'): string
Expand Down Expand Up @@ -167,7 +167,7 @@ public static function getTagsRoute()
*
* @return string URL link to pass to the router
*
* @since __DEPLOY_VERSION__
* @since 4.2.0
* @throws Exception
*/
public static function getComponentTagsRoute(string $language = '*'): string
Expand Down

0 comments on commit 9d09186

Please sign in to comment.