-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtiny-query.min.js
More file actions
1 lines (1 loc) · 4.87 KB
/
tiny-query.min.js
File metadata and controls
1 lines (1 loc) · 4.87 KB
1
(function(a,b){function c(f){if(this.items=[],this.applyAll=g=>{this.items.forEach(h=>{g(h)})},this.addClass=g=>{let h=g.trim().split(" ");return this.applyAll(j=>{j.classList.add(h)}),this},this.removeClass=g=>{let h=g.trim().split(" ");return this.applyAll(j=>{j.classList.remove(h)}),this},this.toggleClass=g=>{let h=g.trim().split(" ");return this.applyAll(j=>{j.classList.toggle(h)}),this},this.show=()=>{return this.applyAll(g=>{g.style.display="",g.style.opacity=1}),this},this.hide=()=>{return this.applyAll(g=>{g.style.display="none"}),this},this.toggle=()=>{return this.applyAll(g=>{"none"==g.style.display?(g.style.display="",g.style.opacity=1):g.style.display="none"}),this},this.fadeToggle=()=>{return this.applyAll(g=>{0==g.style.opacity?(g.style.transition="opacity 400ms",g.style.display="",g.style.opacity=1):(g.style.transition="opacity 400ms",g.style.opacity=0)}),this},this.fadeIn=()=>{return this.applyAll(g=>{g.style.transition="opacity 400ms","none"==g.style.display&&(g.style.opacity=0,g.style.display=""),g.style.opacity=1}),this},this.fadeOut=()=>{return this.applyAll(g=>{g.style.transition="opacity 400ms",g.style.opacity=0}),this},this.before=g=>{return this.applyAll(h=>{h.insertAdjacentHTML("beforebegin",g)}),this},this.after=g=>{return this.applyAll(h=>{h.insertAdjacentHTML("afterend",g)}),this},this.append=g=>{return this.applyAll(h=>{h.appendChild(g)}),this},this.prepend=g=>{return this.applyAll(h=>{h.insertBefore(g,parent.firstChild)}),this},this.html=g=>{return"string"==typeof g?(this.applyAll(h=>{h.innerHTML=g}),this):this.items[0].innerHTML},this.outerHtml=g=>{return"string"==typeof g?(this.applyAll(h=>{h.outerHTML=g}),this):this.items[0].outerHTML},this.text=g=>{return"string"==typeof g?(this.applyAll(h=>{h.textContent=g}),this):this.items[0].textContent},this.remove=()=>{return this.applyAll(g=>{g.parentNode.removeChild(g)}),this},this.hasClass=g=>{return this.items[0].classList.contains(g)},this.is=g=>{return"string"==typeof g?(this.items[0].matches||this.items[0].matchesSelector||this.items[0].msMatchesSelector||this.items[0].mozMatchesSelector||this.items[0].webkitMatchesSelector||this.items[0].oMatchesSelector).call(this.items[0],g):this.items[0]===g},this.next=()=>{return this.items[0].nextElementSibling},this.prev=()=>{return this.items[0].previousElementSibling},this.on=(g,h)=>{return this.applyAll(j=>{j.addEventListener(g,h)}),this},this.off=(g,h)=>{return this.applyAll(j=>{j.removeEventListener(g,h)}),this},this.ready=g=>{let h=b;return(h.attachEvent?"complete"===h.readyState:"loading"!==h.readyState)?g():b.addEventListener("DOMContentLoaded",g),!0},this.attr=(g,h)=>{return h?(this.applyAll(j=>{j.setAttribute(g,h)}),this):this.items[0].getAttribute(g)},this.parent=()=>{return this.items[0].parentNode},this.children=()=>{let g=[];return this.applyAll(h=>{for(var j of h.children)g.push(j)}),this.items=g,this.return()},this.clone=()=>{return this.items[0].cloneNode(!0)},this.contains=(g,h)=>{return g!==h&&g.contains(h)},this.css=g=>{return g?getComputedStyle(this.items[0])[g]:getComputedStyle(this.items[0])},this.classes=()=>{return this.items[0].classList.toString()},this.eq=g=>{return this.items=[this.items[g]],this},this.each=(g,h)=>{return g.forEach(h)},this.extend=g=>{g=g||{};for(var h=1;h<arguments.length;h++)if(arguments[h])for(var j in arguments[h])arguments[h].hasOwnProperty(j)&&(g[j]=arguments[h][j]);return g},this.siblings=()=>{return Array.prototype.filter.call(this.items[0].parentNode.children,function(g){return g!==this.items[0]})},this.getScript=g=>{return b.body.insertAdjacentHTML("afterend",`<script src="${g}"></script>`)},this.getStylesheet=g=>{b.body.insertAdjacentHTML("afterend",`<link rel="stylesheet" href="${g}">`)},this.position=()=>{return{left:this.items[0].offsetLeft,top:this.items[0].offsetTop}},this.offset=()=>{var g=this.items[0].getBoundingClientRect();return{top:g.top+b.body.scrollTop,left:g.left+b.body.scrollLeft}},this.width=()=>{return this.items[0].offsetWidth},this.height=()=>{return this.items[0].offsetHeight},this.find=g=>{let h=[];return this.applyAll(j=>{for(var l of j.querySelectorAll(g))h.push(l)}),this.items=h,this.return()},this.param=g=>{return Object.keys(g).map(h=>encodeURIComponent(h)+"="+encodeURIComponent(g[h])).join("&")},this.first=()=>{return this.items=[this.items[0]],this},this.val=g=>{return g?(this.applyAll(h=>{h.value=g}),this):this.items[0].value},a.reqwest&&(this.ajax=a.reqwest),"string"==typeof f){let g=b.querySelectorAll(f);g.length||0===g.length||(g=[g]),this.items=g}else"object"==typeof f&&(this.items=[f]);return this.return=()=>{return Object.keys(this).forEach(g=>{"items"!==g&&"return"!==g&&(this.items.__proto__[g]=this[g])}),f&&"string"==typeof f?this.items:this},this.return()}if(!a||!b)return!1;const e=f=>{return new c(f)};Object.keys(c()).forEach(f=>{"items"!==f&&"return"!==f&&(e.__proto__[f]=c()[f])}),a.reqwest&&(e.__proto__.ajax=c().ajax),a.$=e})("undefined"==typeof window?this:window,document);