Verified Commit 82dbf5a2 authored by Marco Kellershoff's avatar Marco Kellershoff 🤸
Browse files

Update builds

parent 42b349e1
......@@ -1976,7 +1976,7 @@ gorilla.attr = function (el, key, value) {
returnvalue = el;
if (value) {
el.setAttribute(key, value);
} else if ((typeof key === "undefined" ? "undefined" : _typeof(key)) === "object") {
} else if ((typeof key === "undefined" ? "undefined" : _typeof(key)) === "object" && !key.length) {
gorilla.each(key, function (v, k) {
el.setAttribute(k, v);
});
......@@ -2065,6 +2065,28 @@ gorilla.css = function (el, def) {
}
return returnvalue;
};
gorilla.data = function (el, key, value) {
"use strict";
var returnvalue = void 0;
returnvalue = el;
if (value) {
if ((typeof value === "undefined" ? "undefined" : _typeof(value)) === "object") {
value = JSON.stringify(value);
}
el.setAttribute("data-" + key, value);
} else if ((typeof key === "undefined" ? "undefined" : _typeof(key)) === "object" && !key.length) {
gorilla.each(key, function (v, k) {
if ((typeof v === "undefined" ? "undefined" : _typeof(v)) === "object") {
v = JSON.stringify(v);
}
el.setAttribute("data-" + k, v);
});
} else {
returnvalue = el.getAttribute("data-" + key);
}
return returnvalue;
};
gorilla.DOMReady = function (cb) {
"use strict";
......@@ -2106,6 +2128,9 @@ gorilla.find = function (sel, ref) {
el.find = function (sel1) {
return gorilla.find(sel1, this);
};
el.data = function (k, v) {
return gorilla.data(this, k, v);
};
el.on = function (eventName, cb) {
return gorilla.on(this, eventName, cb);
};
......@@ -2317,47 +2342,45 @@ gorilla.remove = function (el) {
el.parentNode.removeChild(el);
};
gorilla.serialize = function (arr, opts) {
gorilla.serialize = function (list, opts) {
"use strict";
opts = opts || {};
if (arr.tagName && arr.tagName === "FORM") {
var array = [],
items = arr.elements;
if (list.tagName && list.tagName === "FORM") {
var datalist = {},
items = list.elements;
gorilla.each(items, function (el) {
if (el.name && el.name !== "") {
array.push([el.name, el.value]);
datalist[el.name] = el.value;
}
});
return gorilla.serialize(array);
return gorilla.serialize(datalist);
}
var data = [];
var delimiter = opts.delimiter || "&";
var q = opts.q || false;
gorilla.each(arr, function (v) {
switch (_typeof(v[1])) {
gorilla.each(list, function (v, k) {
switch (typeof v === "undefined" ? "undefined" : _typeof(v)) {
case "boolean":
case "string":
case "number":
if (opts.parentName) {
data.push(opts.parentName + "[" + v[0] + "]=" + encodeURIComponent(v[1]));
data.push(opts.parentName + "[" + k + "]=" + encodeURIComponent(v));
} else {
data.push(v[0] + "=" + encodeURIComponent(v[1]));
data.push(k + "=" + encodeURIComponent(v));
}
break;
case "object":
if (v[1].length) {
if (opts.parentName) {
v[0] = opts.parentName + "[" + v[0] + "]";
}
data.push(gorilla.serialize(v[1], {
delimiter: opts.delimiter,
parentName: v[0]
}));
if (opts.parentName) {
k = opts.parentName + "[" + k + "]";
}
data.push(gorilla.serialize(v, {
delimiter: opts.delimiter,
parentName: k
}));
break;
default:
break;
......
This diff is collapsed.
......@@ -102,7 +102,7 @@ gorilla.attr = function(el, key, value) {
returnvalue = el;
if (value) {
el.setAttribute(key, value);
} else if (typeof key === "object") {
} else if (typeof key === "object" && !key.length) {
gorilla.each(key, (v, k) => {
el.setAttribute(k, v);
});
......@@ -194,6 +194,27 @@ gorilla.css = function(el, def) {
}
return returnvalue;
};
gorilla.data = function(el, key, value) {
"use strict";
let returnvalue;
returnvalue = el;
if (value) {
if (typeof value === "object") {
value = JSON.stringify(value);
}
el.setAttribute("data-" + key, value);
} else if (typeof key === "object" && !key.length) {
gorilla.each(key, (v, k) => {
if (typeof v === "object") {
v = JSON.stringify(v);
}
el.setAttribute("data-" + k, v);
});
} else {
returnvalue = el.getAttribute("data-" + key);
}
return returnvalue;
};
gorilla.DOMReady = function(cb) {
"use strict";
if (document.readyState === "complete") {
......@@ -229,6 +250,9 @@ gorilla.find = function(sel, ref) {
el.find = function(sel1) {
return gorilla.find(sel1, this);
};
el.data = function(k, v) {
return gorilla.data(this, k, v);
};
el.on = function(eventName, cb) {
return gorilla.on(this, eventName, cb);
};
......@@ -436,57 +460,48 @@ gorilla.remove = function(el) {
"use strict";
el.parentNode.removeChild(el);
};
gorilla.serialize = (arr, opts) => {
gorilla.serialize = (list, opts) => {
"use strict";
opts = opts || {};
if (arr.tagName && arr.tagName === "FORM") {
let array = [],
items = arr.elements;
if (list.tagName && list.tagName === "FORM") {
let datalist = {},
items = list.elements;
gorilla.each(items, (el) => {
if (el.name && el.name !== "") {
array.push([el.name, el.value]);
datalist[el.name] = el.value;
}
});
return gorilla.serialize(array);
return gorilla.serialize(datalist);
}
let data = [];
let delimiter = opts.delimiter || "&";
let q = opts.q || false;
gorilla.each(arr, (v) => {
switch (typeof v[1]) {
gorilla.each(list, (v, k) => {
switch (typeof v) {
case "boolean":
case "string":
case "number":
if (opts.parentName) {
data.push(opts.parentName +
"[" +
v[0] +
k +
"]=" +
encodeURIComponent(v[1]));
encodeURIComponent(v));
} else {
data.push(v[0] +
"=" +
encodeURIComponent(v[1]));
data.push(k + "=" + encodeURIComponent(v));
}
break;
case "object":
if (v[1].length) {
if (opts.parentName) {
v[0] =
opts.parentName +
"[" +
v[0] +
"]";
}
data.push(gorilla.serialize(v[1], {
delimiter:
opts.delimiter,
parentName: v[0]
}));
if (opts.parentName) {
k = opts.parentName + "[" + k + "]";
}
data.push(gorilla.serialize(v, {
delimiter: opts.delimiter,
parentName: k
}));
break;
default:
break;
......
let gorilla={};gorilla.after=function(a,b){"use strict";return a.parentNode.insertBefore(b,a.nextElementSibling),a},gorilla.ajax=function(a){"use strict";return new Promise((b,c)=>{let d,e;a=a||{},a.method=a.method||"GET",a.method=a.method.toUpperCase(),a.cb=a.cb||function(){},a.params=a.params||{},a.requestContentType=a.requestContentType||"application/x-www-form-urlencoded",d=function(){return Math.floor(Date.now()/1e3)};const f=a=>{let b,c;for(c in b=[],a)Reflect.has(a,c)&&b.push({key:c,value:a[c]});return b},g=function(a){let b,c;for(c in b=[],a)Reflect.has(a,c)&&b.push(encodeURIComponent(c)+"="+encodeURIComponent(a[c]));return b}(a.params);if(e=new XMLHttpRequest,"GET"===a.method&&g.length&&(a.url=a.url+"?"+g.join("&")),"GET"===a.method&&!1===a.cache&&(-1===a.url.indexOf("?")?a.url=a.url+"?_nocache="+d():a.url=a.url+"&_nocache="+d()),e.open(a.method,a.url),e.setRequestHeader("Content-type",a.requestContentType),a.headers){const b=f(a.headers);b.forEach(a=>{e.setRequestHeader(a.key,a.value)})}"GET"===a.method?e.send(null):g.length?e.send(g.join("&")):e.send(null),e.onreadystatechange=function(){4===e.readyState&&(200===e.status?b(e.responseText):c(e))}})},gorilla.append=function(a,b){"use strict";return b.length?b.forEach(function(b){a.appendChild(b)}):a.appendChild(b),a},gorilla.attr=function(a,b,c){"use strict";let d;return d=a,c?a.setAttribute(b,c):"object"==typeof b?gorilla.each(b,(b,c)=>{a.setAttribute(c,b)}):d=a.getAttribute(b),d},gorilla.before=function(a,b){"use strict";return a.parentNode.insertBefore(b,a),a},gorilla.compareJSON=function(a,b){"use strict";const c=function(c,a,b){if("object"==typeof c[b]){if(!d(c[b],a[b]))return!1;}else if(c[b]!==a[b])return!1},d=function(d,a){for(let b in d)if(Reflect.has(b,d))return!!Reflect.has(b,a)&&c(d,a,b);return!0};return d(a,b)&&d(b,a)},gorilla.create=function(a,b){"use strict";let c;return c=b?document.createElement(a,b):document.createElement(a),gorilla.find(c).get(0)},gorilla.css=function(a,b){"use strict";let c,d="",e=a;switch(typeof b){case"string":c=window.getComputedStyle(a),e=c.getPropertyValue(b);break;case"object":Reflect.has(b,"length")?(c=window.getComputedStyle(a),e={},gorilla.each(b,a=>{e[a]=c.getPropertyValue(a)})):(gorilla.each(b,(a,b)=>{d=d+b+":"+a+";"}),a.setAttribute("style",d));break;case"undefined":c=window.getComputedStyle(a),e={},gorilla.each(c,a=>{e[a]=c.getPropertyValue(a)});break;default:}return e},gorilla.DOMReady=function(a){"use strict";return"complete"===document.readyState?window.setTimeout(a,1):void document.addEventListener("DOMContentLoaded",function(){a()})},gorilla.each=function(a,b){"use strict";if(a.length){let c=0,d=a.length;for(;c<d;c++)b(a[c],c)}else for(let c in a)Reflect.has(a,c)&&b(a[c],c);return a},gorilla.find=function(a,b){"use strict";let c,d,e,f;c=[];let g=function(a){a.find=function(a){return gorilla.find(a,this)},a.on=function(a,b){return gorilla.on(this,a,b)},a.attr=function(a,b){return gorilla.attr(this,a,b)},a.html=function(a){return gorilla.html(this,a)},a.prepend=function(a){return gorilla.prepend(this,a)},a.append=function(a){return gorilla.append(this,a)},a.after=function(a){return gorilla.after(this,a)},a.before=function(a){return gorilla.before(this,a)},a.parent=function(){return gorilla.parent(this)},a.next=function(){return gorilla.next(this)},a.prev=function(){return gorilla.prev(this)},a.nodes=function(){return gorilla.nodes(this)},a.remove=function(){return gorilla.remove(this)},a.css=function(a){return gorilla.css(this,a)},a.offset=function(){return gorilla.offset(this)},c.push(a)};if(a){for(d="object"==typeof a?a.length?a:[a]:b?b.querySelectorAll(a):document.querySelectorAll(a),e=0,f=d.length;e<f;e++)g(d[e]);c.each=function(a){return gorilla.each(this,a)},c.get=function(a){return this[a]}}return c},gorilla.getFileContents=function(a,b){"use strict";if(a){let c=new FileReader;c.readAsText(a,"UTF-8"),c.onload=function(c){b(!1,c.target.result,a)},c.onerror=function(){b("Error reading file",null,a)}}else b("file ref not found",null,null)},gorilla.getUnixtime=function(){"use strict";return parseInt(Math.floor(Date.now()/1e3),10)},gorilla.getURLParams=function(a){"use strict";let b={},c=document.createElement("a");c.setAttribute("href",a);let d=c.search;return 0===d.length?b:(0===d.indexOf("?")&&(d=d.substring(1)),d.split("&").forEach(function(a){let c=a.split("=");b[c[0].toString()]=c[1]}),b)},gorilla.html=function(a,b){"use strict";let c;switch(c=a,typeof b){case"string":case"boolean":case"number":a.innerHTML=b;break;case"undefined":c=a.innerHTML;break;default:c=!1;}return c},gorilla.loadCSS=function(a){"use strict";return new Promise((b,c)=>{let d=gorilla.create("link").attr("rel","stylesheet").attr("href",a);return d.on("error",function(a){c(a)}),d.on("load",function(){b(this)}),gorilla.find("script").get(0).prepend(d)})},gorilla.loadJS=function(a){"use strict";return new Promise((b,c)=>{let d=gorilla.create("script").attr("type","text/javascript").attr("async","true").attr("src",a);return d.on("error",function(a){c(a)}),d.on("load",function(){b(this)}),gorilla.find("script").get(0).prepend(d)})},gorilla.next=function(a){"use strict";return gorilla.find(a.nextElementSibling).get(0)},gorilla.nodes=function(a){"use strict";let b,c,d,e,f;for(c=[],f=a.children,(d=0,e=f.length);d<e;d++)b=f[d],c.push(gorilla.find(b).get(0));return c},gorilla.offset=function(a){"use strict";const b=a.getBoundingClientRect();return{top:b.top,left:b.left}},gorilla.on=function(a,b,c){"use strict";return a.addEventListener(b,c,!1),a},gorilla.parent=function(a){"use strict";return gorilla.find(a.parentNode).get(0)},gorilla.plugins={},gorilla.prepend=function(a,b){"use strict";return a.parentNode.insertBefore(b,a),a},gorilla.prev=function(a){"use strict";return gorilla.find(a.previousElementSibling).get(0)},gorilla.remove=function(a){"use strict";a.parentNode.removeChild(a)},gorilla.serialize=(a,b)=>{"use strict";if(b=b||{},a.tagName&&"FORM"===a.tagName){let b=[],c=a.elements;return gorilla.each(c,a=>{a.name&&""!==a.name&&b.push([a.name,a.value])}),gorilla.serialize(b)}let c=[],d=b.delimiter||"&",e=b.q||!1;return gorilla.each(a,a=>{switch(typeof a[1]){case"boolean":case"string":case"number":b.parentName?c.push(b.parentName+"["+a[0]+"]="+encodeURIComponent(a[1])):c.push(a[0]+"="+encodeURIComponent(a[1]));break;case"object":a[1].length&&(b.parentName&&(a[0]=b.parentName+"["+a[0]+"]"),c.push(gorilla.serialize(a[1],{delimiter:b.delimiter,parentName:a[0]})));break;default:}}),(!0===e?"?":"")+c.join(d)},gorilla.stringFormat=(()=>function(a,...b){return b.forEach(b=>{a=a.replace(/%[^ ]*/,b)}),a})(),gorilla.version="1.0.0";
\ No newline at end of file
let gorilla={};gorilla.after=function(a,b){"use strict";return a.parentNode.insertBefore(b,a.nextElementSibling),a},gorilla.ajax=function(a){"use strict";return new Promise((b,c)=>{let d,e;a=a||{},a.method=a.method||"GET",a.method=a.method.toUpperCase(),a.cb=a.cb||function(){},a.params=a.params||{},a.requestContentType=a.requestContentType||"application/x-www-form-urlencoded",d=function(){return Math.floor(Date.now()/1e3)};const f=a=>{let b,c;for(c in b=[],a)Reflect.has(a,c)&&b.push({key:c,value:a[c]});return b},g=function(a){let b,c;for(c in b=[],a)Reflect.has(a,c)&&b.push(encodeURIComponent(c)+"="+encodeURIComponent(a[c]));return b}(a.params);if(e=new XMLHttpRequest,"GET"===a.method&&g.length&&(a.url=a.url+"?"+g.join("&")),"GET"===a.method&&!1===a.cache&&(-1===a.url.indexOf("?")?a.url=a.url+"?_nocache="+d():a.url=a.url+"&_nocache="+d()),e.open(a.method,a.url),e.setRequestHeader("Content-type",a.requestContentType),a.headers){const b=f(a.headers);b.forEach(a=>{e.setRequestHeader(a.key,a.value)})}"GET"===a.method?e.send(null):g.length?e.send(g.join("&")):e.send(null),e.onreadystatechange=function(){4===e.readyState&&(200===e.status?b(e.responseText):c(e))}})},gorilla.append=function(a,b){"use strict";return b.length?b.forEach(function(b){a.appendChild(b)}):a.appendChild(b),a},gorilla.attr=function(a,b,c){"use strict";let d;return d=a,c?a.setAttribute(b,c):"object"!=typeof b||b.length?d=a.getAttribute(b):gorilla.each(b,(b,c)=>{a.setAttribute(c,b)}),d},gorilla.before=function(a,b){"use strict";return a.parentNode.insertBefore(b,a),a},gorilla.compareJSON=function(a,b){"use strict";const c=function(c,a,b){if("object"==typeof c[b]){if(!d(c[b],a[b]))return!1;}else if(c[b]!==a[b])return!1},d=function(d,a){for(let b in d)if(Reflect.has(b,d))return!!Reflect.has(b,a)&&c(d,a,b);return!0};return d(a,b)&&d(b,a)},gorilla.create=function(a,b){"use strict";let c;return c=b?document.createElement(a,b):document.createElement(a),gorilla.find(c).get(0)},gorilla.css=function(a,b){"use strict";let c,d="",e=a;switch(typeof b){case"string":c=window.getComputedStyle(a),e=c.getPropertyValue(b);break;case"object":Reflect.has(b,"length")?(c=window.getComputedStyle(a),e={},gorilla.each(b,a=>{e[a]=c.getPropertyValue(a)})):(gorilla.each(b,(a,b)=>{d=d+b+":"+a+";"}),a.setAttribute("style",d));break;case"undefined":c=window.getComputedStyle(a),e={},gorilla.each(c,a=>{e[a]=c.getPropertyValue(a)});break;default:}return e},gorilla.data=function(a,b,c){"use strict";let d;return d=a,c?("object"==typeof c&&(c=JSON.stringify(c)),a.setAttribute("data-"+b,c)):"object"!=typeof b||b.length?d=a.getAttribute("data-"+b):gorilla.each(b,(b,c)=>{"object"==typeof b&&(b=JSON.stringify(b)),a.setAttribute("data-"+c,b)}),d},gorilla.DOMReady=function(a){"use strict";return"complete"===document.readyState?window.setTimeout(a,1):void document.addEventListener("DOMContentLoaded",function(){a()})},gorilla.each=function(a,b){"use strict";if(a.length){let c=0,d=a.length;for(;c<d;c++)b(a[c],c)}else for(let c in a)Reflect.has(a,c)&&b(a[c],c);return a},gorilla.find=function(a,b){"use strict";let c,d,e,f;c=[];let g=function(a){a.find=function(a){return gorilla.find(a,this)},a.data=function(a,b){return gorilla.data(this,a,b)},a.on=function(a,b){return gorilla.on(this,a,b)},a.attr=function(a,b){return gorilla.attr(this,a,b)},a.html=function(a){return gorilla.html(this,a)},a.prepend=function(a){return gorilla.prepend(this,a)},a.append=function(a){return gorilla.append(this,a)},a.after=function(a){return gorilla.after(this,a)},a.before=function(a){return gorilla.before(this,a)},a.parent=function(){return gorilla.parent(this)},a.next=function(){return gorilla.next(this)},a.prev=function(){return gorilla.prev(this)},a.nodes=function(){return gorilla.nodes(this)},a.remove=function(){return gorilla.remove(this)},a.css=function(a){return gorilla.css(this,a)},a.offset=function(){return gorilla.offset(this)},c.push(a)};if(a){for(d="object"==typeof a?a.length?a:[a]:b?b.querySelectorAll(a):document.querySelectorAll(a),e=0,f=d.length;e<f;e++)g(d[e]);c.each=function(a){return gorilla.each(this,a)},c.get=function(a){return this[a]}}return c},gorilla.getFileContents=function(a,b){"use strict";if(a){let c=new FileReader;c.readAsText(a,"UTF-8"),c.onload=function(c){b(!1,c.target.result,a)},c.onerror=function(){b("Error reading file",null,a)}}else b("file ref not found",null,null)},gorilla.getUnixtime=function(){"use strict";return parseInt(Math.floor(Date.now()/1e3),10)},gorilla.getURLParams=function(a){"use strict";let b={},c=document.createElement("a");c.setAttribute("href",a);let d=c.search;return 0===d.length?b:(0===d.indexOf("?")&&(d=d.substring(1)),d.split("&").forEach(function(a){let c=a.split("=");b[c[0].toString()]=c[1]}),b)},gorilla.html=function(a,b){"use strict";let c;switch(c=a,typeof b){case"string":case"boolean":case"number":a.innerHTML=b;break;case"undefined":c=a.innerHTML;break;default:c=!1;}return c},gorilla.loadCSS=function(a){"use strict";return new Promise((b,c)=>{let d=gorilla.create("link").attr("rel","stylesheet").attr("href",a);return d.on("error",function(a){c(a)}),d.on("load",function(){b(this)}),gorilla.find("script").get(0).prepend(d)})},gorilla.loadJS=function(a){"use strict";return new Promise((b,c)=>{let d=gorilla.create("script").attr("type","text/javascript").attr("async","true").attr("src",a);return d.on("error",function(a){c(a)}),d.on("load",function(){b(this)}),gorilla.find("script").get(0).prepend(d)})},gorilla.next=function(a){"use strict";return gorilla.find(a.nextElementSibling).get(0)},gorilla.nodes=function(a){"use strict";let b,c,d,e,f;for(c=[],f=a.children,(d=0,e=f.length);d<e;d++)b=f[d],c.push(gorilla.find(b).get(0));return c},gorilla.offset=function(a){"use strict";const b=a.getBoundingClientRect();return{top:b.top,left:b.left}},gorilla.on=function(a,b,c){"use strict";return a.addEventListener(b,c,!1),a},gorilla.parent=function(a){"use strict";return gorilla.find(a.parentNode).get(0)},gorilla.plugins={},gorilla.prepend=function(a,b){"use strict";return a.parentNode.insertBefore(b,a),a},gorilla.prev=function(a){"use strict";return gorilla.find(a.previousElementSibling).get(0)},gorilla.remove=function(a){"use strict";a.parentNode.removeChild(a)},gorilla.serialize=(a,b)=>{"use strict";if(b=b||{},a.tagName&&"FORM"===a.tagName){let b={},c=a.elements;return gorilla.each(c,a=>{a.name&&""!==a.name&&(b[a.name]=a.value)}),gorilla.serialize(b)}let c=[],d=b.delimiter||"&",e=b.q||!1;return gorilla.each(a,(a,d)=>{switch(typeof a){case"boolean":case"string":case"number":b.parentName?c.push(b.parentName+"["+d+"]="+encodeURIComponent(a)):c.push(d+"="+encodeURIComponent(a));break;case"object":b.parentName&&(d=b.parentName+"["+d+"]"),c.push(gorilla.serialize(a,{delimiter:b.delimiter,parentName:d}));break;default:}}),(!0===e?"?":"")+c.join(d)},gorilla.stringFormat=(()=>function(a,...b){return b.forEach(b=>{a=a.replace(/%[^ ]*/,b)}),a})(),gorilla.version="1.0.0";
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment