Streamline a few pieces of JavaScript code

The main goal here is to reduce complexity. For example, the method to
remove a parameter from the current URL is never used with another
parameter. The complexity is not needed.

This is inspired by the changes I have seen in Icaf086f.

Change-Id: If22c25e84f50ac380320cd581690835ddb70f01d
This commit is contained in:
Thiemo Kreuz
2020-01-19 17:00:40 +01:00
committed by jenkins-bot
parent 459d55c5d3
commit a5ae7cb556
2 changed files with 20 additions and 20 deletions

View File

@@ -24,8 +24,7 @@
'use strict';
var ULSDialog = function ( options ) {
var noop = function () { },
$dialog = options.container,
var $dialog = options.container,
hasOverlay = options.hasOverlay,
$overlay,
// Source: https://github.com/ghosh/Micromodal/blob/master/lib/src/index.js#L4
@@ -42,8 +41,8 @@
'[contenteditable]',
'[tabindex]:not([tabindex^="-"])'
],
afterClose = options.afterClose || noop,
afterOpen = options.afterOpen || noop;
afterOpen = options.afterOpen,
afterClose = options.afterClose;
function getFocusableNodes() {
return $dialog.find( FOCUSABLE_NODES.join( ', ' ) );
@@ -159,14 +158,18 @@
addEvents();
showOverlay();
focusFirstNodeOrOverlay();
afterOpen();
if ( afterOpen ) {
afterOpen();
}
}
function close() {
$dialog.hide();
removeEvents();
hideOverlay();
afterClose();
if ( afterClose ) {
afterClose();
}
}
function elem() {