Action box update with change from keyInObject to objectKeyExists
All checks were successful
JavaScriptUtilsVitest / ci-tests (push) Successful in 18s
All checks were successful
JavaScriptUtilsVitest / ci-tests (push) Successful in 18s
This commit is contained in:
@@ -5,7 +5,7 @@ Creator: Clemens Schwaighofer
|
||||
*/
|
||||
|
||||
export { ActionBox };
|
||||
import { keyInObject, getObjectCount } from './JavaScriptHelpers.mjs';
|
||||
import { objectKeyExists, getObjectCount } from './JavaScriptHelpers.mjs';
|
||||
import { exists } from './DomHelpers.mjs';
|
||||
import { setCenter, getWindowSize } from './ResizingAndMove.mjs';
|
||||
|
||||
@@ -155,7 +155,7 @@ class ActionBox {
|
||||
}
|
||||
// adjust zIndex so its above all other and set action box zindex +1
|
||||
$('#overlayBox').show();
|
||||
if (!keyInObject(target_id, this.zIndex.boxes)) {
|
||||
if (!objectKeyExists(this.zIndex.boxes, target_id)) {
|
||||
this.zIndex.boxes[target_id] = this.zIndex.max;
|
||||
// increase by ten
|
||||
this.zIndex.max += 10;
|
||||
@@ -197,7 +197,7 @@ class ActionBox {
|
||||
}
|
||||
// clear storage object
|
||||
if (
|
||||
keyInObject(target_id, this.action_box_storage) && clean === true
|
||||
objectKeyExists(this.action_box_storage, target_id) && clean === true
|
||||
) {
|
||||
this.action_box_storage[target_id] = {};
|
||||
}
|
||||
@@ -249,18 +249,18 @@ class ActionBox {
|
||||
settings = {},
|
||||
show_close = true
|
||||
) {
|
||||
if (!keyInObject(target_id, this.action_box_storage)) {
|
||||
if (!objectKeyExists(this.action_box_storage, target_id)) {
|
||||
this.action_box_storage[target_id] = {};
|
||||
}
|
||||
// settings can have the following
|
||||
// : header_css:[]
|
||||
// : action_box_css:[]
|
||||
let header_css = [];
|
||||
if (keyInObject('header_css', settings)) {
|
||||
if (objectKeyExists(settings, 'header_css')) {
|
||||
header_css = settings.header_css;
|
||||
}
|
||||
let action_box_css = [];
|
||||
if (keyInObject('action_box_css', settings)) {
|
||||
if (objectKeyExists(settings, 'action_box_css')) {
|
||||
action_box_css = settings.action_box_css;
|
||||
}
|
||||
let elements = [];
|
||||
@@ -288,7 +288,7 @@ class ActionBox {
|
||||
// if we have header content, add that here
|
||||
if (getObjectCount(headers) > 0) {
|
||||
// if the element has an entry called "raw_string" then this does not need to be converted
|
||||
if (keyInObject('raw_string', headers)) {
|
||||
if (objectKeyExists(headers, 'raw_string')) {
|
||||
elements.push(headers.raw_string);
|
||||
} else {
|
||||
elements.push(this.hec.phfo(headers));
|
||||
@@ -297,7 +297,7 @@ class ActionBox {
|
||||
// main content part (this should NOT be empty), if empty, add empty _content block
|
||||
if (getObjectCount(contents) > 0) {
|
||||
// if the element has an entry called "raw_string" then this does not need to be converted
|
||||
if (keyInObject('raw_string', contents)) {
|
||||
if (objectKeyExists(contents, 'raw_string')) {
|
||||
elements.push(contents.raw_string);
|
||||
} else {
|
||||
elements.push(this.hec.phfo(contents));
|
||||
|
||||
@@ -5,7 +5,8 @@ Creator: Clemens Schwaighofer
|
||||
*/
|
||||
|
||||
export {
|
||||
errorCatch, isFunction, executeFunctionByName,
|
||||
errorCatch, isFunction,
|
||||
executeFunctionByName, runFunction, runFunctionArgsArray,
|
||||
isObject, getObjectCount,
|
||||
keyInObject, objectKeyExists,
|
||||
getKeyByValue, valueInObject, objectValueExists,
|
||||
@@ -77,6 +78,35 @@ function executeFunctionByName(functionName, context /*, args */)
|
||||
return context[func].apply(context, args);
|
||||
}
|
||||
|
||||
/**
|
||||
* call a function by string
|
||||
* call runFunctionArgArray
|
||||
* @param {string} name Function name to call
|
||||
* @param {Array} arguments all next function arguments are passed on as argument to the function
|
||||
* @returns void
|
||||
*/
|
||||
function runFunction(name)
|
||||
{
|
||||
var args = Array.prototype.slice.call(arguments, 1);
|
||||
runFunctionArgsArray(name, args);
|
||||
}
|
||||
|
||||
/**
|
||||
* call a function with a string, argumens as array
|
||||
* @param {string} name Function name to call
|
||||
* @param {array} args function arguments as arry
|
||||
* @returns void
|
||||
*/
|
||||
function runFunctionArgsArray(name, args)
|
||||
{
|
||||
var fn = window[name];
|
||||
if(typeof fn !== 'function') {
|
||||
return;
|
||||
}
|
||||
|
||||
fn.apply(window, args);
|
||||
}
|
||||
|
||||
/**
|
||||
* checks if a variable is an object
|
||||
* @param {any} val possible object
|
||||
|
||||
Reference in New Issue
Block a user