mirror of
https://github.com/Karaka-Management/jsOMS.git
synced 2026-02-16 17:28:41 +00:00
parse all href elements and allow form data in uri
This commit is contained in:
parent
35ebe853f2
commit
c517b37e0e
|
|
@ -54,14 +54,26 @@ export class GeneralUI
|
||||||
*/
|
*/
|
||||||
bindHref (e)
|
bindHref (e)
|
||||||
{
|
{
|
||||||
e = e !== null ? e.querySelectorAll('[data-href]') : document.querySelectorAll('[data-href]');
|
e = e !== null ? e.querySelectorAll('[data-href], [href]') : document.querySelectorAll('[data-href], [href]');
|
||||||
const length = e.length;
|
const length = e.length;
|
||||||
|
|
||||||
for (let i = 0; i < length; ++i) {
|
for (let i = 0; i < length; ++i) {
|
||||||
|
if (e[i].getAttribute('data-action') !== null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
e[i].addEventListener('click', function(event) {
|
e[i].addEventListener('click', function(event) {
|
||||||
jsOMS.preventAll(event);
|
jsOMS.preventAll(event);
|
||||||
history.pushState(null, null, window.location);
|
history.pushState(null, null, window.location);
|
||||||
window.location = UriFactory.build(this.getAttribute('data-href'));
|
|
||||||
|
let uri = this.getAttribute('data-href');
|
||||||
|
uri = uri === null ? this.getAttribute('href') : uri;
|
||||||
|
|
||||||
|
if (this.getAttribute('target') === '_blank' || this.getAttribute(['data-target']) === '_blank') {
|
||||||
|
window.open(UriFactory.build(uri), '_blank');
|
||||||
|
} else {
|
||||||
|
window.location = UriFactory.build(uri);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
import { Http } from './Http.js';
|
import { Http } from './Http.js';
|
||||||
|
import { FormView } from './../Views//FormView.js';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Uri factory.
|
* Uri factory.
|
||||||
|
|
@ -190,7 +191,18 @@ export class UriFactory
|
||||||
const e = document.getElementById(match.substr(1));
|
const e = document.getElementById(match.substr(1));
|
||||||
|
|
||||||
if (e) {
|
if (e) {
|
||||||
return e.value;
|
if (e.tagName.toLowerCase() !== 'form') {
|
||||||
|
return e.value;
|
||||||
|
}
|
||||||
|
|
||||||
|
let value = '';
|
||||||
|
const form = (new FormView(e.id)).getData();
|
||||||
|
|
||||||
|
for (let pair of form.entries()) {
|
||||||
|
value += '&' + pair[0] + '=' + pair[1];
|
||||||
|
}
|
||||||
|
|
||||||
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
return '';
|
return '';
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
import { Input } from '../UI/Component/Input.js';
|
import { Input } from '/jsOMS/UI/Component/Input.js';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Form view.
|
* Form view.
|
||||||
|
|
@ -312,24 +312,38 @@ export class FormView
|
||||||
specialLength = specialExt.length;
|
specialLength = specialExt.length;
|
||||||
|
|
||||||
for (let i = 0; i < inputLength; ++i) {
|
for (let i = 0; i < inputLength; ++i) {
|
||||||
if ((inputs[i].type === 'checkbox' || inputs[i].type === 'radio') && !inputs[i].checked) {
|
if (inputs[i] === undefined
|
||||||
|
|| (typeof inputs[i] !== 'undefined'
|
||||||
|
&& (inputs[i].type === 'checkbox' || inputs[i].type === 'radio')
|
||||||
|
&& !inputs[i].checked)
|
||||||
|
) {
|
||||||
delete inputs[i];
|
delete inputs[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (let i = 0; i < externalLength; ++i) {
|
for (let i = 0; i < externalLength; ++i) {
|
||||||
if (form.contains(external[i])) {
|
if (external[i] === undefined
|
||||||
|
|| (typeof external[i] !== 'undefined'
|
||||||
|
&& form.contains(external[i]))
|
||||||
|
) {
|
||||||
delete external[i];
|
delete external[i];
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((external[i].type === 'checkbox' || external[i].type === 'radio') && !external[i].checked) {
|
if ( external[i] === undefined
|
||||||
|
|| (typeof external[i] !== 'undefined'
|
||||||
|
&& (external[i].type === 'checkbox' || external[i].type === 'radio')
|
||||||
|
&& !external[i].checked)
|
||||||
|
) {
|
||||||
delete external[i];
|
delete external[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (let i = 0; i < specialLength; ++i) {
|
for (let i = 0; i < specialLength; ++i) {
|
||||||
if (form.contains(specialExt[i])) {
|
if (specialExt[i] === undefined
|
||||||
|
|| (typeof specialExt[i] !== 'undefined'
|
||||||
|
&& form.contains(specialExt[i]))
|
||||||
|
) {
|
||||||
delete specialExt[i];
|
delete specialExt[i];
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user