mirror of
https://github.com/Karaka-Management/jsOMS.git
synced 2026-01-11 17:58:41 +00:00
fixes #24
This commit is contained in:
parent
8f7b866be9
commit
3e7875c638
|
|
@ -38,7 +38,7 @@
|
|||
jsOMS.Asset.AssetManager.prototype.registerLoadedAssets = function ()
|
||||
{
|
||||
const scripts = document.getElementsByTagName('script'),
|
||||
length = scripts.length;
|
||||
length = !scripts ? 0 : scripts.length;
|
||||
|
||||
for (let i = 0; i < length; i++) {
|
||||
this.assets[jsOMS.hash(scripts[i].src)] = scripts[i].src;
|
||||
|
|
@ -72,7 +72,11 @@
|
|||
fileref.setAttribute('src', path);
|
||||
|
||||
if (typeof fileref !== 'undefined') {
|
||||
document.getElementsByTagName('head')[0].appendChild(fileref);
|
||||
const head = document.getElementsByTagName('head');
|
||||
|
||||
if(head) {
|
||||
head[0].appendChild(fileref);
|
||||
}
|
||||
}
|
||||
|
||||
this.assets[hash] = path;
|
||||
|
|
@ -83,7 +87,11 @@
|
|||
fileref.setAttribute('href', path);
|
||||
|
||||
if (typeof fileref !== 'undefined') {
|
||||
document.getElementsByTagName('head')[0].appendChild(fileref);
|
||||
const head = document.getElementsByTagName('head');
|
||||
|
||||
if(head) {
|
||||
head[0].appendChild(fileref);
|
||||
}
|
||||
}
|
||||
|
||||
this.assets[hash] = path;
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@
|
|||
jsOMS.Autoloader.initPreloaded = function ()
|
||||
{
|
||||
const scripts = document.getElementsByTagName('script'),
|
||||
length = scripts.length;
|
||||
length = !scripts ? 0 : scripts.length;
|
||||
|
||||
for (let i = 0; i < length; i++) {
|
||||
/** global: URL */
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@
|
|||
this.bindElement(id);
|
||||
} else {
|
||||
const elements = document.querySelectorAll('[draggable]'),
|
||||
length = elements.length;
|
||||
length = !elements ? 0 : elements.length;
|
||||
|
||||
for (var i = 0; i < length; i++) {
|
||||
if (typeof elements[i].getAttribute('id') !== 'undefined' && elements[i].getAttribute('id') !== null) {
|
||||
|
|
@ -75,6 +75,10 @@
|
|||
const element = document.getElementById(id);
|
||||
console.log(id);
|
||||
|
||||
if(!element) {
|
||||
return;
|
||||
}
|
||||
|
||||
element.addEventListener('dragstart', function(event) {
|
||||
// todo:
|
||||
console.log('drag start');
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@
|
|||
{
|
||||
/* Handle remote datalist/autocomplete input element */
|
||||
let listId, list;
|
||||
if (typeof (listId = this.getAttribute('list')) !== 'undefined' && (list = document.getElementById(listId)).getAttribute('data-list-src') !== 'undefined') {
|
||||
if (typeof (listId = this.getAttribute('list')) !== 'undefined' && (list = document.getElementById(listId)) && list.getAttribute('data-list-src') !== 'undefined') {
|
||||
self.addRemoteDatalistOptions(this, list);
|
||||
}
|
||||
|
||||
|
|
@ -72,6 +72,10 @@
|
|||
if (typeof (ref = this.getAttribute('data-ref')) !== 'undefined') {
|
||||
let e = document.getElementById(ref);
|
||||
|
||||
if(!e) {
|
||||
return;
|
||||
}
|
||||
|
||||
switch (e.tagName) {
|
||||
case 'ul':
|
||||
break;
|
||||
|
|
@ -85,7 +89,11 @@
|
|||
if (typeof (dataButton = input.getAttribute('data-button')) !== 'undefined') {
|
||||
this.app.inputManager.getKeyboardManager().bind(input, 13, function ()
|
||||
{
|
||||
document.getElementById(dataButton).click();
|
||||
const db = document.getElementById(dataButton);
|
||||
|
||||
if(db) {
|
||||
db.click();
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -80,7 +80,7 @@
|
|||
this.bindForm(id);
|
||||
} else {
|
||||
const forms = document.getElementsByTagName('form'),
|
||||
length = forms.length;
|
||||
length = !forms ? 0 : forms.length;
|
||||
|
||||
for (var i = 0; i < length; i++) {
|
||||
if (typeof forms[i].getAttribute('id') !== 'undefined' && forms[i].getAttribute('id') !== null && typeof this.ignore[forms[i].getAttribute('id')] === 'undefined') {
|
||||
|
|
|
|||
10
UI/Input.js
10
UI/Input.js
|
|
@ -63,6 +63,10 @@
|
|||
if (typeof (ref = this.getAttribute('data-ref')) !== 'undefined') {
|
||||
let e = document.getElementById(ref);
|
||||
|
||||
if(!e) {
|
||||
return;
|
||||
}
|
||||
|
||||
switch (e.tagName) {
|
||||
case 'ul':
|
||||
break;
|
||||
|
|
@ -76,7 +80,11 @@
|
|||
if (typeof (dataButton = input.getAttribute('data-button')) !== 'undefined') {
|
||||
this.app.inputManager.getKeyboardManager().bind(input, 13, function ()
|
||||
{
|
||||
document.getElementById(dataButton).click();
|
||||
const db = document.getElementById(dataButton);
|
||||
|
||||
if(db) {
|
||||
db.click();
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@
|
|||
const self = this,
|
||||
e = document.getElementById(element);
|
||||
|
||||
if (e === null) {
|
||||
if (!e) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -55,6 +55,10 @@
|
|||
const e = document.getElementById(surface),
|
||||
self = this;
|
||||
|
||||
if(!e) {
|
||||
return;
|
||||
}
|
||||
|
||||
e.addEventListener('touchstart', function (event)
|
||||
{
|
||||
const touch = this.changedTouches[0];
|
||||
|
|
|
|||
|
|
@ -37,11 +37,16 @@
|
|||
jsOMS.UI.TabManager.prototype.bind = function (id)
|
||||
{
|
||||
if (typeof id !== 'undefined') {
|
||||
this.bindElement(document.getElementById(id));
|
||||
} else {
|
||||
var tabs = document.querySelectorAll('.tabview');
|
||||
const e = document.getElementById(id);
|
||||
|
||||
for (var i = 0; i < tabs.length; i++) {
|
||||
if(e) {
|
||||
this.bindElement();
|
||||
}
|
||||
} else {
|
||||
var tabs = document.querySelectorAll('.tabview'),
|
||||
length = !tabs ? 0 : tabs.length;
|
||||
|
||||
for (var i = 0; i < length; i++) {
|
||||
this.bindElement(tabs[i]);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -37,11 +37,16 @@
|
|||
jsOMS.UI.TableManager.prototype.bind = function (id)
|
||||
{
|
||||
if (typeof id !== 'undefined') {
|
||||
this.bindElement(document.getElementById(id));
|
||||
} else {
|
||||
const tables = document.querySelectorAll('.tables');
|
||||
const e = document.getElementById(id);
|
||||
|
||||
for (var i = 0; i < tables.length; i++) {
|
||||
if(e) {
|
||||
this.bindElement(e);
|
||||
}
|
||||
} else {
|
||||
const tables = document.querySelectorAll('.tables'),
|
||||
length = !tables ? 0 : tables.length;
|
||||
|
||||
for (var i = 0; i < length; i++) {
|
||||
this.bindElement(tables[i]);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -53,6 +53,10 @@
|
|||
} else {
|
||||
const tag = document.getElementById(id);
|
||||
|
||||
if(!tag) {
|
||||
return;
|
||||
}
|
||||
|
||||
switch (tag.tagName) {
|
||||
case 'form':
|
||||
this.formManager.bind(id);
|
||||
|
|
|
|||
|
|
@ -190,7 +190,13 @@
|
|||
} else if (typeof jsOMS.Uri.UriFactory.uri[match] !== 'undefined') {
|
||||
return jsOMS.Uri.UriFactory.uri[match];
|
||||
} else if (match.indexOf('#') === 0) {
|
||||
return document.getElementById(match.substr(1)).value;
|
||||
const e = document.getElementById(match.substr(1));
|
||||
|
||||
if(e) {
|
||||
return e.value;
|
||||
}
|
||||
|
||||
return '';
|
||||
} else if (match.indexOf('?') === 0) {
|
||||
return jsOMS.Uri.Http.getUriQueryParameter(current.query, match.substr(1));
|
||||
} else if (match.indexOf('/') === 0) {
|
||||
|
|
|
|||
|
|
@ -81,7 +81,13 @@
|
|||
*/
|
||||
jsOMS.Views.FormView.prototype.getSubmit = function ()
|
||||
{
|
||||
return document.getElementById(this.id).querySelectorAll('input[type=submit]');
|
||||
const e = document.getElementById(this.id);
|
||||
|
||||
if(!e) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return e.querySelectorAll('input[type=submit]');
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
@ -133,8 +139,13 @@
|
|||
*/
|
||||
jsOMS.Views.FormView.prototype.getFormElements = function ()
|
||||
{
|
||||
const form = document.getElementById(this.id),
|
||||
selects = form.getElementsByTagName('select'),
|
||||
const form = document.getElementById(this.id)
|
||||
|
||||
if(!form) {
|
||||
return [];
|
||||
}
|
||||
|
||||
const selects = form.getElementsByTagName('select'),
|
||||
textareas = form.getElementsByTagName('textarea'),
|
||||
inputs = form.getElementsByTagName('input'),
|
||||
external = document.querySelectorAll('[form=' + this.id + ']');
|
||||
|
|
@ -235,13 +246,13 @@
|
|||
{
|
||||
let id = e.getAttribute('name');
|
||||
|
||||
if (id === null) {
|
||||
if (!id) {
|
||||
id = e.getAttribute('id');
|
||||
} else {
|
||||
return id;
|
||||
}
|
||||
|
||||
if (id === null) {
|
||||
if (!id) {
|
||||
id = e.getAttribute('type');
|
||||
} else {
|
||||
return id;
|
||||
|
|
@ -273,8 +284,14 @@
|
|||
{
|
||||
this.clean();
|
||||
|
||||
this.method = document.getElementById(this.id).attributes['method'].value;
|
||||
this.action = document.getElementById(this.id).action;
|
||||
const e = document.getElementById(this.id);
|
||||
|
||||
if(!e) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.method = e.attributes['method'].value;
|
||||
this.action = e.action;
|
||||
|
||||
const elements = this.getFormElements(),
|
||||
length = elements.length;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user