|
|
@ -4,24 +4,6 @@ |
|
|
|
* @copyright by its creator Christian Martin |
|
|
|
*/ |
|
|
|
|
|
|
|
/** |
|
|
|
* Iterates over the keys of attrs, |
|
|
|
* extracts the corresponding value |
|
|
|
* and applies the callback (cb) on it in the order (key, value, targetContainer) |
|
|
|
* @extends StyleAndScriptStoringComponent |
|
|
|
* @param {map<string,any>} attrs |
|
|
|
* @param {Object} intoContainer |
|
|
|
* @param {Function<string, any, Object>} cb |
|
|
|
* @returns {Object} the filled container |
|
|
|
*/ |
|
|
|
function fillAttrsInContainerByCb(attrs, intoContainer, cb) { |
|
|
|
let keys = Object.keys(attrs); |
|
|
|
for (let i = 0; i < keys.length; i++) { |
|
|
|
cb(keys[i], attrs[keys[i]], intoContainer); |
|
|
|
} |
|
|
|
return intoContainer; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* |
|
|
|
*/ |
|
|
@ -78,49 +60,78 @@ class ObjectAccessObject { |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* (De-) hides the given element. |
|
|
|
* On ensureHidden=true it will be hidden regardless of the current state. |
|
|
|
* |
|
|
|
* @param {HTMLElement} element |
|
|
|
* @param {boolean} ensureHidden |
|
|
|
* @returns {boolean} |
|
|
|
* @type {Map<string, Function>} |
|
|
|
*/ |
|
|
|
function toggleElementVisibility(element, ensureHidden = false) { |
|
|
|
element.classList.toggle("compel-mech-hidden"); |
|
|
|
const helperFun = { |
|
|
|
/** |
|
|
|
* Iterates over the keys of attrs, |
|
|
|
* extracts the corresponding value |
|
|
|
* and applies the callback (cb) on it in the order (key, value, targetContainer) |
|
|
|
* @extends StyleAndScriptStoringComponent |
|
|
|
* @param {map<string,any>} attrs |
|
|
|
* @param {Object} intoContainer |
|
|
|
* @param {Function<string, any, Object>} cb |
|
|
|
* @returns {Object} the filled container |
|
|
|
*/ |
|
|
|
fillAttrsInContainerByCb: function (attrs, intoContainer, cb) { |
|
|
|
let keys = Object.keys(attrs); |
|
|
|
for (let i = 0; i < keys.length; i++) { |
|
|
|
cb(keys[i], attrs[keys[i]], intoContainer); |
|
|
|
} |
|
|
|
return intoContainer; |
|
|
|
}, |
|
|
|
|
|
|
|
let isNowHidden = false; |
|
|
|
/** |
|
|
|
* |
|
|
|
* @param {string} selector |
|
|
|
* @returns {boolean} [ensureHidden=false] for true element is now hidden and false it is not hidden. |
|
|
|
*/ |
|
|
|
toggleSelectorElementVisibility: function (selector, ensureHidden = false) { |
|
|
|
/** |
|
|
|
* @type {HTMLElement} |
|
|
|
*/ |
|
|
|
let el = document.querySelector(selector); |
|
|
|
let name = el.getAttribute("data-autocompel"); |
|
|
|
|
|
|
|
if (element.hasAttribute("hidden")) { |
|
|
|
element.removeAttribute("hidden"); |
|
|
|
element.style["display"] = "flex"; |
|
|
|
isNowHidden = false; |
|
|
|
} else { |
|
|
|
element.setAttribute("hidden", "hidden"); |
|
|
|
element.style.removeProperty("display"); |
|
|
|
isNowHidden = true; |
|
|
|
} |
|
|
|
console.log("De-/hiding", name, selector); |
|
|
|
|
|
|
|
if (ensureHidden && !isNowHidden) { |
|
|
|
return toggleSelectorElementVisibility(selector) |
|
|
|
} else { |
|
|
|
return isNowHidden; |
|
|
|
} |
|
|
|
} |
|
|
|
return helperFun.toggleElementVisibility(el, ensureHidden); |
|
|
|
}, |
|
|
|
|
|
|
|
/** |
|
|
|
* |
|
|
|
* @param {string} selector |
|
|
|
* @returns {boolean} for true element is now hidden and false it is not hidden. |
|
|
|
*/ |
|
|
|
function toggleSelectorElementVisibility(selector, ensureHidden = false) { |
|
|
|
/** |
|
|
|
* @type {HTMLElement} |
|
|
|
* (De-) hides the given element. |
|
|
|
* On ensureHidden=true it will be hidden regardless of the current state. |
|
|
|
* |
|
|
|
* @param {HTMLElement} element |
|
|
|
* @param {boolean} ensureHidden |
|
|
|
* @returns {boolean} |
|
|
|
*/ |
|
|
|
let el = document.querySelector(selector); |
|
|
|
let name = el.getAttribute("data-autocompel"); |
|
|
|
toggleElementVisibility: function (element, ensureHidden = false) { |
|
|
|
element.classList.toggle("compel-mech-hidden"); |
|
|
|
|
|
|
|
console.log("De-/hiding", name, selector); |
|
|
|
let isNowHidden = false; |
|
|
|
|
|
|
|
return toggleElementVisibility(el, ensureHidden); |
|
|
|
} |
|
|
|
if (element.hasAttribute("hidden")) { |
|
|
|
element.removeAttribute("hidden"); |
|
|
|
element.style["display"] = "flex"; |
|
|
|
isNowHidden = false; |
|
|
|
} else { |
|
|
|
element.setAttribute("hidden", "hidden"); |
|
|
|
element.style.removeProperty("display"); |
|
|
|
isNowHidden = true; |
|
|
|
} |
|
|
|
|
|
|
|
if (ensureHidden && !isNowHidden) { |
|
|
|
return helperFun.toggleSelectorElementVisibility(selector) |
|
|
|
} else { |
|
|
|
return isNowHidden; |
|
|
|
} |
|
|
|
}, |
|
|
|
|
|
|
|
/** |
|
|
|
* @type {Map<string, Function>} |
|
|
|
*/ |
|
|
|
extensions: {} |
|
|
|
} |