mirror of
https://github.com/Karaka-Management/jsOMS.git
synced 2026-01-11 01:48:40 +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)
|
||||
{
|
||||
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;
|
||||
|
||||
for (let i = 0; i < length; ++i) {
|
||||
if (e[i].getAttribute('data-action') !== null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
e[i].addEventListener('click', function(event) {
|
||||
jsOMS.preventAll(event);
|
||||
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 { FormView } from './../Views//FormView.js';
|
||||
|
||||
/**
|
||||
* Uri factory.
|
||||
|
|
@ -190,7 +191,18 @@ export class UriFactory
|
|||
const e = document.getElementById(match.substr(1));
|
||||
|
||||
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 '';
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { Input } from '../UI/Component/Input.js';
|
||||
import { Input } from '/jsOMS/UI/Component/Input.js';
|
||||
|
||||
/**
|
||||
* Form view.
|
||||
|
|
@ -312,24 +312,38 @@ export class FormView
|
|||
specialLength = specialExt.length;
|
||||
|
||||
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];
|
||||
}
|
||||
}
|
||||
|
||||
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];
|
||||
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];
|
||||
}
|
||||
}
|
||||
|
||||
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];
|
||||
continue;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user