From f563301e296200c63159679debb3aa1584ff9a2a Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Sun, 4 Feb 2024 20:34:13 +0000 Subject: [PATCH] update --- Model/Action/Dom/AddDOM.js | 25 +++++++++++++++++++++++++ Model/Action/Dom/GetDOM.js | 30 ++++++++++++++++++++++++++++++ Model/Action/Dom/RemoveDOM.js | 30 ++++++++++++++++++++++++++++++ Model/Message/Dom.js | 0 Model/Message/DomAction.js | 28 ---------------------------- Model/Message/DomActionType.js | 19 ------------------- UI/Component/Form.js | 6 ------ UI/GeneralUI.js | 22 ++-------------------- UI/Input/Voice/ReadManager.js | 3 ++- UI/Input/Voice/VoiceManager.js | 3 ++- UI/RemoteData.js | 2 -- Uri/UriFactory.js | 6 ------ 12 files changed, 91 insertions(+), 83 deletions(-) create mode 100644 Model/Action/Dom/AddDOM.js create mode 100644 Model/Action/Dom/GetDOM.js create mode 100644 Model/Action/Dom/RemoveDOM.js delete mode 100755 Model/Message/Dom.js delete mode 100755 Model/Message/DomAction.js delete mode 100755 Model/Message/DomActionType.js diff --git a/Model/Action/Dom/AddDOM.js b/Model/Action/Dom/AddDOM.js new file mode 100644 index 0000000..418057f --- /dev/null +++ b/Model/Action/Dom/AddDOM.js @@ -0,0 +1,25 @@ +/** + * Add dom + * + * @param {Object} action Action data + * @param {function} callback Callback + * @param {string} id Action element + * + * @since 1.0.0 + */ +export function domAddElement (action, callback, id) +{ + 'use strict'; + + const e = action.base === 'self' + ? (action.selector === '' || typeof action.selector === 'undefined' + ? document.getElementById(id) + : document.getElementById(id).querySelector(action.selector)) + : document.querySelector(action.selector); + + for (const i in action.data) { + e.appendChild.removeChild(i); + } + + callback(); +}; diff --git a/Model/Action/Dom/GetDOM.js b/Model/Action/Dom/GetDOM.js new file mode 100644 index 0000000..51a0675 --- /dev/null +++ b/Model/Action/Dom/GetDOM.js @@ -0,0 +1,30 @@ +/** + * Get dom + * + * @param {Object} action Action data + * @param {function} callback Callback + * @param {string} id Action element + * + * @since 1.0.0 + */ +export function domGetElement (action, callback, id) +{ + 'use strict'; + + const e = action.base === 'self' + ? (action.selector === '' || typeof action.selector === 'undefined' + ? [document.getElementById(id)] + : document.getElementById(id).querySelectorAll(action.selector)) + : document.querySelectorAll(action.selector); + + const elements = []; + for (const i in e) { + if (i.tagName === 'template') { + elements.push(i.content.cloneNode(true)); + } else { + elements.push(i.cloneNode(true)); + } + } + + callback(elements); +}; diff --git a/Model/Action/Dom/RemoveDOM.js b/Model/Action/Dom/RemoveDOM.js new file mode 100644 index 0000000..5c851ac --- /dev/null +++ b/Model/Action/Dom/RemoveDOM.js @@ -0,0 +1,30 @@ +/** + * Remove dom + * + * @param {Object} action Action data + * @param {function} callback Callback + * @param {string} id Action element + * + * @since 1.0.0 + */ +export function domRemoveElement (action, callback, id) +{ + 'use strict'; + + const e = action.base === 'self' + ? (action.selector === '' || typeof action.selector === 'undefined' + ? [document.getElementById(id)] + : document.getElementById(id).querySelectorAll(action.selector)) + : document.querySelectorAll(action.selector); + + for (const i in e) { + /** global: HTMLElement */ + if (!Object.prototype.hasOwnProperty.call(e, i) || !(e[i] instanceof HTMLElement)) { + continue; + } + + e.parentElement.removeChild(e); + } + + callback(); +}; diff --git a/Model/Message/Dom.js b/Model/Message/Dom.js deleted file mode 100755 index e69de29..0000000 diff --git a/Model/Message/DomAction.js b/Model/Message/DomAction.js deleted file mode 100755 index 1a262e8..0000000 --- a/Model/Message/DomAction.js +++ /dev/null @@ -1,28 +0,0 @@ -import { jsOMS } from '../../Utils/oLib.js'; -/** - * Perform DOM action. - * - * @param {{delay:number},{type:number}} data DOM action data - * - * @since 1.0.0 - */ -export function domAction (data) -{ - /** global: jsOMS */ - setTimeout(function () - { - switch (data.type) { - case jsOMS.EnumDomActionType.SHOW: - break; - case jsOMS.EnumDomActionType.HIDE: - break; - } - }, parseInt(data.delay)); -}; - -/** - * Show/Hide - * identifier: #element or .elements or query - * anim: someclass - * delay: 0 - */ diff --git a/Model/Message/DomActionType.js b/Model/Message/DomActionType.js deleted file mode 100755 index 5437f41..0000000 --- a/Model/Message/DomActionType.js +++ /dev/null @@ -1,19 +0,0 @@ -/** - * DOM action type. - * - * @copyright Dennis Eichhorn - * @license OMS License 2.0 - * @version 1.0.0 - * @since 1.0.0 - */ -export const EnumDomActionType = Object.freeze({ - CREATE_BEFORE: 0, - CREATE_AFTER: 1, - DELETE: 2, - REPLACE: 3, - MODIFY: 4, - SHOW: 5, - HIDE: 6, - ACTIVATE: 7, - DEACTIVATE: 8 -}); diff --git a/UI/Component/Form.js b/UI/Component/Form.js index 7ee17e3..5d05bbd 100755 --- a/UI/Component/Form.js +++ b/UI/Component/Form.js @@ -1302,12 +1302,6 @@ export class Form for (const e in remoteUrls) { const request = new Request(e); request.setResultCallback(200, function (xhr) { - /** - * @todo Karaka/jsOMS#84 - * Remote data responses need to be parsed - * The data coming from the backend/api usually is not directly usable in the frontend. - * For that purpose some kind of value path should be defined to handle json responses in order to get only the data that is needed. - */ const remoteUrlsLength = remoteUrls[e].length; for (let k = 0; k < remoteUrlsLength; ++k) { const path = remoteUrls[e][k].path; diff --git a/UI/GeneralUI.js b/UI/GeneralUI.js index a07b656..e42958f 100755 --- a/UI/GeneralUI.js +++ b/UI/GeneralUI.js @@ -71,22 +71,10 @@ export class GeneralUI const length = e.length; for (let i = 0; i < length; ++i) { - /* - @todo bad solution, probably needs to be more navigation specific - const link = UriFactory.buildAbsolute( - e[i].getAttribute('href') !== null ? e[i].getAttribute('href') : e[i].getAttribute('data-href') - ); - - if (jsOMS.rtrim(link, '/') !== window.location.origin && window.location.href.startsWith(link)) { - jsOMS.addClass(e[i], 'active'); - } - */ - if (e[i].getAttribute('data-action') !== null) { continue; } - // @todo implement middle mouse click e[i].addEventListener('click', function (event) { if ((event.target.parentElement !== this && event.target.parentElement.getElementsByTagName('input').length > 0) @@ -111,15 +99,9 @@ export class GeneralUI ) { window.open(UriFactory.build(uri), '_blank'); } else if (this.getAttribute('data-redirect') !== null) { - window.location.href = UriFactory.build(uri.indexOf('://') > 0 - ? uri - : jsOMS.rtrim(window.omsApp.request.getRootPath(), '/') + '/' + jsOMS.ltrim(uri, '/')); + window.location.href = UriFactory.build(uri); } else if (uri !== null) { - // window.location = UriFactory.build(uri); - // @todo : consider to implement the line above again. why was it removed? - window.location.href = UriFactory.build(uri.indexOf('://') > 0 - ? uri - : jsOMS.rtrim(window.omsApp.request.getRootPath(), '/') + '/' + jsOMS.ltrim(uri, '/')); + window.location = UriFactory.build(uri); /* @todo Commented out until ObserverMutation is implemented diff --git a/UI/Input/Voice/ReadManager.js b/UI/Input/Voice/ReadManager.js index a0cf6f1..020a872 100755 --- a/UI/Input/Voice/ReadManager.js +++ b/UI/Input/Voice/ReadManager.js @@ -107,7 +107,8 @@ export class ReadManager /** * @todo SpeechRecognition polyfill - * Remove the speech recognition wrapper once it is obsolete and supported by the major browsers. + * Remove the speech recognition wrapper once it is obsolete and supported by the major browsers. + * https://github.com/Karaka-Management/jsOMS/issues/108 */ /* eslint-disable */ /** global: webkitSpeechRecognition */ diff --git a/UI/Input/Voice/VoiceManager.js b/UI/Input/Voice/VoiceManager.js index 64f5086..c96b2da 100755 --- a/UI/Input/Voice/VoiceManager.js +++ b/UI/Input/Voice/VoiceManager.js @@ -166,7 +166,8 @@ export class VoiceManager /** * @todo SpeechRecognition polyfill - * Remove the speech recognition wrapper once it is obsolete and supported by the major browsers. + * Remove the speech recognition wrapper once it is obsolete and supported by the major browsers. + * https://github.com/Karaka-Management/jsOMS/issues/108 */ /* eslint-disable */ /** global: webkitSpeechRecognition */ diff --git a/UI/RemoteData.js b/UI/RemoteData.js index 9c52288..d3f3549 100755 --- a/UI/RemoteData.js +++ b/UI/RemoteData.js @@ -145,8 +145,6 @@ export class RemoteData : Array.prototype.slice.call(dataOriginElement.querySelectorAll('[data-tpl-text]')) ); - // @todo don't just overwrite data, check if data is different - // insert values into element (populate values) RemoteData.setRemoteData('text', texts, data[i]); diff --git a/Uri/UriFactory.js b/Uri/UriFactory.js index 8daf364..5b4766d 100755 --- a/Uri/UriFactory.js +++ b/Uri/UriFactory.js @@ -9,12 +9,6 @@ import { FormView } from './../Views/FormView.js'; * @license OMS License 2.0 * @version 1.0.0 * @since 1.0.0 - * - * @todo Karaka/phpOMS#239 - * Optional parameters - * Sometimes we need to define a list of optional parameters that will be filled if they exist and only if they exist. - * E.g. `u=` for unit `filter=` for filtering etc. - * Otherwise the url on some pages keeps getting longer and longer because parameters get appended. */ export class UriFactory {