-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathGStime.min.js
More file actions
3 lines (3 loc) · 13 KB
/
Copy pathGStime.min.js
File metadata and controls
3 lines (3 loc) · 13 KB
1
2
3
/* GStime.js v2.0.1 | GLOBUS.studio | MIT License */
!function(t,e){"use strict";if("function"==typeof define&&define.amd)define([],e);else if("object"==typeof module&&module.exports)module.exports=e();else{const n=e();t.GStime=n.GStime,t.$=n.$}}("undefined"!=typeof self?self:"undefined"!=typeof globalThis?globalThis:this,function(){"use strict";const t="undefined"!=typeof document,e=/^\s*<([a-z][\w-]*)[\s\S]*>/i,n=t?new WeakMap:null,o=t?new WeakMap:null;function i(n){if(!(this instanceof i))return new i(n);if(this.elements=[],t&&null!=n)if("string"==typeof n)if(e.test(n))this.elements=this.createHTML(n);else try{this.elements=Array.from(document.querySelectorAll(n))}catch(t){this.elements=[]}else n instanceof Element||"undefined"!=typeof Document&&n instanceof Document||"undefined"!=typeof Window&&n instanceof Window?this.elements=[n]:n instanceof NodeList||Array.isArray(n)||n instanceof HTMLCollection?this.elements=Array.from(n).filter(Boolean):"function"==typeof n&&i.ready(n)}i.prototype.createHTML=function(t){const e=document.createElement("template");return e.innerHTML=String(t).trim(),Array.from(e.content.children)},i.prototype.each=function(t){return this.elements.forEach((e,n)=>t.call(e,n,e)),this},i.prototype.on=function(t,e,o){return"function"==typeof e&&(o=e,e=null),"function"!=typeof o?this:this.each(function(){const i=this;let r;r=e?function(t){let n=t.target;for(;n&&n!==i;){if(1===n.nodeType&&n.matches(e)){const e=new Proxy(t,{get(t,e){if("currentTarget"===e)return n;if("delegateTarget"===e)return i;const o=t[e];return"function"==typeof o?o.bind(t):o}});return void o.call(n,e)}n=n.parentNode}}:function(t){o.call(i,t)},i.addEventListener(t,r,!1),function(t,e){let o=n.get(t);o||(o=new Map,n.set(t,o));let i=o.get(e);return i||(i=[],o.set(e,i)),i}(i,t).push({user:o,listener:r,selector:e||null})})},i.prototype.off=function(t,e){return this.each(function(){const o=this,i=n.get(o);if(!i)return;const r=i.get(t);if(r){for(let n=r.length-1;n>=0;n--)e&&r[n].user!==e||(o.removeEventListener(t,r[n].listener,!1),r.splice(n,1));0===r.length&&i.delete(t)}})},i.prototype.val=function(t){return void 0===t?this.elements[0]?this.elements[0].value:void 0:this.each(function(){this.value=t})},i.prototype.append=function(t){return this.each(function(){this.insertAdjacentHTML("beforeend",t)})},i.prototype.prepend=function(t){return this.each(function(){this.insertAdjacentHTML("afterbegin",t)})},i.prototype.html=function(t){return void 0===t?this.elements[0]?this.elements[0].innerHTML:void 0:this.each(function(){this.innerHTML=t})},i.prototype.css=function(t,e){return"string"==typeof t&&void 0===e?this.elements[0]?getComputedStyle(this.elements[0])[t]:void 0:this.each(function(){"object"==typeof t?Object.assign(this.style,t):this.style[t]=e})},i.prototype.hide=function(){return this.each(function(){if(1===this.nodeType){const t=this.style.display;"none"!==t&&o.set(this,t),this.style.display="none"}})},i.prototype.show=function(){return this.each(function(){if(1===this.nodeType){const t=o.get(this);this.style.display=t||"",o.delete(this)}})},i.prototype.toggle=function(){return this.each(function(){"none"===getComputedStyle(this).display?new i(this).show():new i(this).hide()})},i.prototype.clone=function(){return new i(this.elements.map(t=>t.cloneNode(!0)))};const r=new Set(["opacity","zIndex","fontWeight","lineHeight","order","flexGrow","flexShrink","zoom"]);function s(t,e){if(r.has(t))return"";if("string"==typeof e){const t=e.match(/[a-z%]+$/i);if(t)return t[0]}return"px"}let a;function c(t){return new i(t)}return i.prototype.animate=function(t,e,n){e=Math.max(0,Number(e)||0);const o=performance.now(),i={};for(const e in t)i[e]=s(e,t[e]);const r=this.elements.map(e=>Object.fromEntries(Object.keys(t).map(t=>[t,parseFloat(getComputedStyle(e)[t])||0])));if(0===e)return this.elements.forEach(e=>{for(const n in t)e.style[n]=parseFloat(t[n])+i[n]}),"function"==typeof n&&n(),this;const a=s=>{const c=s-o,l=Math.min(c/e,1);this.elements.forEach((e,n)=>{for(const o in t){const s=r[n][o],a=s+(parseFloat(t[o])-s)*l;e.style[o]=a+i[o]}}),l<1?requestAnimationFrame(a):"function"==typeof n&&n()};return requestAnimationFrame(a),this},i.prototype.fadeOut=function(t,e){return this.animate({opacity:0},t,()=>{this.hide(),"function"==typeof e&&e()})},i.prototype.fadeIn=function(t,e){return this.each(function(){"none"===getComputedStyle(this).display&&(this.style.display=""),this.style.opacity="0"}),this.animate({opacity:1},t,e)},i.prototype.hasClass=function(t){return!!this.elements[0]&&this.elements[0].classList.contains(t)},i.prototype.addClass=function(t){return this.each(function(){this.classList.add(t)})},i.prototype.removeClass=function(t){return this.each(function(){this.classList.remove(t)})},i.prototype.toggleClass=function(t){return this.each(function(){this.classList.toggle(t)})},i.prototype.attr=function(t,e){return void 0===e?this.elements[0]?this.elements[0].getAttribute(t):void 0:this.each(function(){this.setAttribute(t,e)})},i.prototype.removeAttr=function(t){return this.each(function(){this.removeAttribute(t)})},i.prototype.width=function(t){return void 0===t?this.elements[0]?this.elements[0].offsetWidth:void 0:this.css("width","number"==typeof t?`${t}px`:t)},i.prototype.height=function(t){return void 0===t?this.elements[0]?this.elements[0].offsetHeight:void 0:this.css("height","number"==typeof t?`${t}px`:t)},i.prototype.offset=function(){if(!this.elements[0])return;const t=this.elements[0].getBoundingClientRect();return{top:t.top+window.pageYOffset,left:t.left+window.pageXOffset}},i.prototype.position=function(){return this.elements[0]?{top:this.elements[0].offsetTop,left:this.elements[0].offsetLeft}:void 0},i.get=function(t,e,n){return i.ajax({url:t,method:"GET",data:e,...n})},i.post=function(t,e,n){return i.ajax({url:t,method:"POST",data:e,...n})},i.put=function(t,e,n){return i.ajax({url:t,method:"PUT",data:e,...n})},i.delete=function(t,e,n){return i.ajax({url:t,method:"DELETE",data:e,...n})},i.ajax=function(t){return new Promise((e,n)=>{if(!t||void 0===t.url)return void n(new Error("A URL is required for the ajax request"));const o=Object.assign({method:"GET",headers:{},timeout:0,credentials:"same-origin",mode:"cors"},t);if(o.beforeSend&&!1===o.beforeSend())return void n(new Error("Request aborted by beforeSend callback"));let i=o.url;const r={method:String(o.method).toUpperCase(),headers:Object.assign({},o.headers),credentials:o.credentials,mode:o.mode};if(o.cache&&(r.cache=o.cache),o.redirect&&(r.redirect=o.redirect),o.referrer&&(r.referrer=o.referrer),o.integrity&&(r.integrity=o.integrity),null!=o.data)if("GET"===r.method||"HEAD"===r.method){const t=new URLSearchParams(o.data).toString();i+=(i.indexOf("?")>=0?"&":"?")+t}else if(o.data instanceof FormData||o.data instanceof Blob||o.data instanceof ArrayBuffer||"string"==typeof o.data)r.body=o.data;else if("object"==typeof o.data){const t=r.headers["Content-Type"]||r.headers["content-type"];if(t&&/application\/x-www-form-urlencoded/i.test(t))r.body=new URLSearchParams(o.data).toString();else if(t&&/multipart\/form-data/i.test(t)){const t=new FormData;for(const e in o.data)t.append(e,o.data[e]);r.body=t,delete r.headers["Content-Type"],delete r.headers["content-type"]}else t||(r.headers["Content-Type"]="application/json"),r.body=JSON.stringify(o.data)}else r.body=String(o.data);let s;const a="undefined"!=typeof AbortController?new AbortController:null;a&&(r.signal=a.signal),o.timeout>0&&a&&(s=setTimeout(()=>a.abort(),o.timeout)),fetch(i,r).then(t=>{if(!t.ok)throw new Error(`HTTP error! status: ${t.status}`);const e=t.headers.get("content-type")||"";return e.includes("application/json")?t.json():e.includes("xml")?t.text().then(t=>(new DOMParser).parseFromString(t,"text/xml")):e.startsWith("text/")||e.includes("javascript")?t.text():t.blob()}).then(t=>{"function"==typeof o.success&&o.success(t),e(t)}).catch(t=>{const e=t&&"AbortError"===t.name?new Error(`Request timeout after ${o.timeout}ms`):t;"function"==typeof o.error&&o.error(e),n(e)}).finally(()=>{s&&clearTimeout(s),"function"==typeof o.complete&&o.complete()})})},i.prototype.after=function(t){return this.each(function(){this.insertAdjacentHTML("afterend",t)})},i.prototype.before=function(t){return this.each(function(){this.insertAdjacentHTML("beforebegin",t)})},i.prototype.remove=function(){return this.each(function(){this.parentNode&&this.parentNode.removeChild(this)})},i.prototype.parent=function(){return new i(this.elements.map(t=>t.parentNode).filter(Boolean))},i.prototype.children=function(){return new i(this.elements.flatMap(t=>Array.from(t.children)))},i.prototype.siblings=function(){return new i(this.elements.flatMap(t=>t.parentNode?Array.from(t.parentNode.children).filter(e=>e!==t):[]))},i.prototype.find=function(t){return new i(this.elements.flatMap(e=>Array.from(e.querySelectorAll(t))))},i.prototype.closest=function(t){return new i(this.elements.map(e=>e.closest(t)).filter(Boolean))},i.each=function(t,e){if(Array.isArray(t))t.forEach((t,n)=>e.call(t,n,t));else for(let n in t)t.hasOwnProperty(n)&&e.call(t[n],n,t[n]);return t},i.map=function(t,e){if(Array.isArray(t))return t.map(e);{const n={};for(let o in t)t.hasOwnProperty(o)&&(n[o]=e.call(t[o],o,t[o]));return n}},i.ready=function(e){t&&("loading"!==document.readyState?e():document.addEventListener("DOMContentLoaded",e))},i.prototype.slideUp=function(t,e){return this.each(function(){const n=this,o=n.offsetHeight,i={overflow:n.style.overflow,height:n.style.height,paddingTop:n.style.paddingTop,paddingBottom:n.style.paddingBottom,marginTop:n.style.marginTop,marginBottom:n.style.marginBottom};n.style.overflow="hidden",n.style.height=`${o}px`,requestAnimationFrame(()=>{n.style.height="0px",n.style.paddingTop="0px",n.style.paddingBottom="0px",n.style.marginTop="0px",n.style.marginBottom="0px",n.style.transition=`height ${t}ms, padding ${t}ms, margin ${t}ms`;let o=!1;const r=function(){if(!o){o=!0,n.style.display="none";for(const t in i)n.style[t]=i[t];n.style.transition="",n.removeEventListener("transitionend",s),"function"==typeof e&&e.call(n)}},s=function(t){t.target===n&&"height"===t.propertyName&&r()};n.addEventListener("transitionend",s),setTimeout(r,t+50)})})},i.prototype.slideDown=function(t,e){return this.each(function(){const n=this,o="none"===getComputedStyle(n).display,i=n.style.display&&"none"!==n.style.display?n.style.display:"";n.style.overflow="hidden",o&&(n.style.display=""),"none"===getComputedStyle(n).display&&(n.style.display="block"),n.style.height="0px",n.style.paddingTop="0px",n.style.paddingBottom="0px",n.style.marginTop="0px",n.style.marginBottom="0px";const r=n.scrollHeight;requestAnimationFrame(()=>{n.style.transition=`height ${t}ms, padding ${t}ms, margin ${t}ms`,n.style.height=`${r}px`,n.style.paddingTop="",n.style.paddingBottom="",n.style.marginTop="",n.style.marginBottom="";let s=!1;const a=function(){s||(s=!0,n.style.height="",n.style.overflow="",n.style.transition="",o&&i&&(n.style.display=i),n.removeEventListener("transitionend",c),"function"==typeof e&&e.call(n))},c=function(t){t.target===n&&"height"===t.propertyName&&a()};n.addEventListener("transitionend",c),setTimeout(a,t+50)})})},i.prototype.slideToggle=function(t,e){return this.each(function(){const n=this;"none"===window.getComputedStyle(n).display?new i(n).slideDown(t,e):new i(n).slideUp(t,e)})},i.prototype.colorAnimate=function(t,e,n){function o(t){if(!t||"transparent"===t)return[0,0,0,0];if("string"==typeof t&&t.startsWith("rgb")){const e=t.match(/[\d.]+/g);if(!e)return[0,0,0,1];const n=e.map(Number);return 3===n.length&&n.push(1),n}if("string"==typeof t&&t.startsWith("#")){if(4===t.length)return[parseInt(t[1]+t[1],16),parseInt(t[2]+t[2],16),parseInt(t[3]+t[3],16),1];if(5===t.length)return[parseInt(t[1]+t[1],16),parseInt(t[2]+t[2],16),parseInt(t[3]+t[3],16),parseInt(t[4]+t[4],16)/255];if(7===t.length)return[parseInt(t.substring(1,3),16),parseInt(t.substring(3,5),16),parseInt(t.substring(5,7),16),1];if(9===t.length)return[parseInt(t.substring(1,3),16),parseInt(t.substring(3,5),16),parseInt(t.substring(5,7),16),parseInt(t.substring(7,9),16)/255]}if("undefined"!=typeof document&&"string"==typeof t){const e=document.createElement("div");e.style.color=t,e.style.display="none",document.body.appendChild(e);const n=getComputedStyle(e).color;if(document.body.removeChild(e),n&&n.startsWith("rgb")){const t=n.match(/[\d.]+/g);if(t){const e=t.map(Number);return 3===e.length&&e.push(1),e}}}return[0,0,0,1]}function i(t,e,n){return t.map((t,o)=>{const i=t+((null!=e[o]?e[o]:t)-t)*n;return 3===o?i:Math.round(i)})}e=Math.max(0,Number(e)||0);const r=performance.now(),s={};this.elements.forEach(e=>{const n=getComputedStyle(e);for(const i in t)s[i]||(s[i]=new WeakMap),s[i].set(e,o(n[i]))});const a={};for(const e in t)a[e]=o(t[e]);const c=o=>{const l=o-r,f=0===e?1:Math.min(l/e,1);this.elements.forEach(e=>{for(const n in t){const t=i(s[n].get(e),a[n],f);e.style[n]=`rgba(${t[0]}, ${t[1]}, ${t[2]}, ${t[3]})`}}),f<1?requestAnimationFrame(c):"function"==typeof n&&n()};return requestAnimationFrame(c),this},i.noConflict=function(){return"undefined"!=typeof window&&window.$===c&&(window.$=a),c},c.fn=i.prototype,Object.keys(i).forEach(t=>{c[t]=i[t]}),"undefined"!=typeof window&&(a=window.$),{GStime:i,$:c}});
//# sourceMappingURL=GStime.min.js.map