Add aelxar js method, fixes for core libs, edit base file

aelxar is like aelx but it uses an array and does not use objects
directly

fixed various possible empty array access issues in various core lib &
edit base files
This commit is contained in:
Clemens Schwaighofer
2020-02-27 15:42:32 +09:00
parent 3e29073664
commit a86eaf0f02
9 changed files with 62 additions and 23 deletions

View File

@@ -121,8 +121,7 @@ function setCenter(id, left, top)
function goToPos(element, offset = 0)
{
try {
if ($('#' + element).length)
{
if ($('#' + element).length) {
$('body,html').animate({
scrollTop: $('#' + element).offset().top - offset
}, 500);
@@ -558,6 +557,21 @@ function aelx(base, ...attach)
return base;
}
/**
* same as aelx, but instead of using objects as parameters
* get an array of objects to attach
* @param {Object} base object to where we attach the elements
* @param {Array} attach array of objects to attach
* @return {Object} "none", technically there is no return needed, global attach
*/
function aelxar(base, attach)
{
for (var i = 0; i < attach.length; i ++) {
base.sub.push(Object.assign({}, attach[i]));
}
return base;
}
/**
* resets the sub elements of the base element given
* @param {Object} base cel created element

View File

@@ -201,8 +201,7 @@ function setCenter(id, left, top)
function goToPos(element, offset = 0)
{
try {
if ($(element))
{
if ($(element)) {
// get the element pos
var pos = $(element).cumulativeOffset();
// if not top element and no offset given, set auto offset for top element
@@ -618,6 +617,21 @@ function aelx(base, ...attach)
return base;
}
/**
* same as aelx, but instead of using objects as parameters
* get an array of objects to attach
* @param {Object} base object to where we attach the elements
* @param {Array} attach array of objects to attach
* @return {Object} "none", technically there is no return needed, global attach
*/
function aelxar(base, attach)
{
attach.each(function(t) {
base.sub.push(Object.assign({}, t));
});
return base;
}
/**
* resets the sub elements of the base element given
* @param {Object} base cel created element