mirror of
https://github.com/Karaka-Management/jsOMS.git
synced 2026-01-11 17:58:41 +00:00
update
This commit is contained in:
parent
1cfa17935b
commit
f563301e29
25
Model/Action/Dom/AddDOM.js
Normal file
25
Model/Action/Dom/AddDOM.js
Normal file
|
|
@ -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();
|
||||||
|
};
|
||||||
30
Model/Action/Dom/GetDOM.js
Normal file
30
Model/Action/Dom/GetDOM.js
Normal file
|
|
@ -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);
|
||||||
|
};
|
||||||
30
Model/Action/Dom/RemoveDOM.js
Normal file
30
Model/Action/Dom/RemoveDOM.js
Normal file
|
|
@ -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();
|
||||||
|
};
|
||||||
|
|
@ -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
|
|
||||||
*/
|
|
||||||
|
|
@ -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
|
|
||||||
});
|
|
||||||
|
|
@ -1302,12 +1302,6 @@ export class Form
|
||||||
for (const e in remoteUrls) {
|
for (const e in remoteUrls) {
|
||||||
const request = new Request(e);
|
const request = new Request(e);
|
||||||
request.setResultCallback(200, function (xhr) {
|
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;
|
const remoteUrlsLength = remoteUrls[e].length;
|
||||||
for (let k = 0; k < remoteUrlsLength; ++k) {
|
for (let k = 0; k < remoteUrlsLength; ++k) {
|
||||||
const path = remoteUrls[e][k].path;
|
const path = remoteUrls[e][k].path;
|
||||||
|
|
|
||||||
|
|
@ -71,22 +71,10 @@ export class GeneralUI
|
||||||
const length = e.length;
|
const length = e.length;
|
||||||
|
|
||||||
for (let i = 0; i < length; ++i) {
|
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) {
|
if (e[i].getAttribute('data-action') !== null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// @todo implement middle mouse click
|
|
||||||
e[i].addEventListener('click', function (event) {
|
e[i].addEventListener('click', function (event) {
|
||||||
if ((event.target.parentElement !== this
|
if ((event.target.parentElement !== this
|
||||||
&& event.target.parentElement.getElementsByTagName('input').length > 0)
|
&& event.target.parentElement.getElementsByTagName('input').length > 0)
|
||||||
|
|
@ -111,15 +99,9 @@ export class GeneralUI
|
||||||
) {
|
) {
|
||||||
window.open(UriFactory.build(uri), '_blank');
|
window.open(UriFactory.build(uri), '_blank');
|
||||||
} else if (this.getAttribute('data-redirect') !== null) {
|
} else if (this.getAttribute('data-redirect') !== null) {
|
||||||
window.location.href = UriFactory.build(uri.indexOf('://') > 0
|
window.location.href = UriFactory.build(uri);
|
||||||
? uri
|
|
||||||
: jsOMS.rtrim(window.omsApp.request.getRootPath(), '/') + '/' + jsOMS.ltrim(uri, '/'));
|
|
||||||
} else if (uri !== null) {
|
} else if (uri !== null) {
|
||||||
// window.location = UriFactory.build(uri);
|
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, '/'));
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@todo Commented out until ObserverMutation is implemented
|
@todo Commented out until ObserverMutation is implemented
|
||||||
|
|
|
||||||
|
|
@ -107,7 +107,8 @@ export class ReadManager
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @todo SpeechRecognition polyfill
|
* @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 */
|
/* eslint-disable */
|
||||||
/** global: webkitSpeechRecognition */
|
/** global: webkitSpeechRecognition */
|
||||||
|
|
|
||||||
|
|
@ -166,7 +166,8 @@ export class VoiceManager
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @todo SpeechRecognition polyfill
|
* @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 */
|
/* eslint-disable */
|
||||||
/** global: webkitSpeechRecognition */
|
/** global: webkitSpeechRecognition */
|
||||||
|
|
|
||||||
|
|
@ -145,8 +145,6 @@ export class RemoteData
|
||||||
: Array.prototype.slice.call(dataOriginElement.querySelectorAll('[data-tpl-text]'))
|
: 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)
|
// insert values into element (populate values)
|
||||||
RemoteData.setRemoteData('text', texts, data[i]);
|
RemoteData.setRemoteData('text', texts, data[i]);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -9,12 +9,6 @@ import { FormView } from './../Views/FormView.js';
|
||||||
* @license OMS License 2.0
|
* @license OMS License 2.0
|
||||||
* @version 1.0.0
|
* @version 1.0.0
|
||||||
* @since 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
|
export class UriFactory
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user