weery
Version:
Small library for DOM manipulating.
1 lines • 4.75 kB
JavaScript
module.exports=function(t){var n={};function e(r){if(n[r])return n[r].exports;var i=n[r]={i:r,l:!1,exports:{}};return t[r].call(i.exports,i,i.exports,e),i.l=!0,i.exports}return e.m=t,e.c=n,e.d=function(t,n,r){e.o(t,n)||Object.defineProperty(t,n,{enumerable:!0,get:r})},e.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},e.t=function(t,n){if(1&n&&(t=e(t)),8&n)return t;if(4&n&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(e.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&n&&"string"!=typeof t)for(var i in t)e.d(r,i,function(n){return t[n]}.bind(null,i));return r},e.n=function(t){var n=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(n,"a",n),n},e.o=function(t,n){return Object.prototype.hasOwnProperty.call(t,n)},e.p="",e(e.s=7)}([function(t,n){t.exports=function(t,n,e){var r=e||!1,i=Array.prototype.slice.call(t);if(!r)for(var o=0;o<n.length;o++)delete n[o];n.length=i.length,i.forEach(function(t,e){n[e]=t})}},function(t,n){t.exports=function(t,n){for(var e in t)Object.prototype.hasOwnProperty.call(t,e)&&(n[e]=t[e]);return n}},function(t,n){t.exports={on:function(t,n){return this.each(function(e){e.addEventListener(t,n)})},ready:function(t){document.addEventListener("DOMContentLoaded",t)},resize:function(t){this.on("resize",t)},scroll:function(t){this.on("scroll",t)}}},function(t,n,e){var r=e(1),i=e(0);t.exports={each:function(t){Array.prototype.forEach.call(this,t)},find:function(t){var n=[];return"string"==typeof t&&this.each(function(e){var r=e.querySelectorAll(t),i=Array.prototype.slice.call(r);n=n.concat(i)}),i(n,this),this},css:function(t,n){var e;return n?(this.each(function(e){e.style[t]=n}),e=this):"string"==typeof t?e=this[0]?this[0].style[t]:void 0:(this.each(function(n){r(t,n.style)}),e=this),e},text:function(t){if(!t){var n="";return this.each(function(t){n+=t.textContent}),n}return this.each(function(n){n.textContent=t}),this},html:function(t){return!t&&this[0]?this[0].innerHTML:(this.each(function(n){n.innerHTML=t}),this)},next:function(){var t=[];return this.each(function(n){var e=n.nextElementSibling;e&&t.push(e)}),i(t,this),this},prev:function(){var t=[];return this.each(function(n){var e=n.previousElementSibling;e&&t.push(e)}),i(t,this),this},outerHeight:function(t){if(this[0]){var n=this[0];if(n instanceof Window)return n.innerHeight;var e=n.offsetHeight;if(t){var r=getComputedStyle(n);e+=parseInt(r.marginTop)+parseInt(r.marginBottom)}return e}},outerWidth:function(t){if(this[0]){var n=this[0];if(n instanceof Window)return n.innerWidth;var e=n.offsetWidth;if(t){var r=getComputedStyle(n);e+=parseInt(r.marginLeft)+parseInt(r.marginRight)}return e}},remove:function(){return this.each(function(t){t.parentNode.removeChild(t)}),this},offset:function(){if(this[0]){var t=this[0].getBoundingClientRect();return{top:t.top,left:t.left}}},position:function(){if(this[0]){var t=this[0];return{top:t.offsetTop,left:t.offsetLeft}}},append:function(t){var n=this.parseHTML;return this.each(function(e){var r=n(t);e.appendChild(r)}),this},prepend:function(t){var n=this.parseHTML;return this.each(function(e){var r=n(t);e.insertBefore(r,e.firstChild)}),this},scrollTop:function(t){var n=this[0];if(!t){if(!n)return;return n instanceof Window?n.pageYOffset:n.scrollTop}var e=n instanceof Window?n.pageXOffset:n.scrollLeft;return n.scrollTo(e,t),this}}},function(t,n){t.exports={parseHTML:function(t){var n=document.implementation.createHTMLDocument();return n.body.innerHTML=t,n.body.children[0]}}},function(t,n){t.exports={addClass:function(t){return this.each(function(n){t.split(" ").forEach(function(t){n.classList.add(t)})}),this},removeClass:function(t){return this.each(function(n){t.split(" ").forEach(function(t){n.classList.remove(t)})}),this},toggleClass:function(t){return this.each(function(n){t.split(" ").forEach(function(t){n.classList.toggle(t)})}),this},hasClass:function(t){var n=!1;return this.each(function(e){t.split(" ").forEach(function(t){e.classList.contains(t)&&(n=!0)})}),n}}},function(t,n){t.exports={attr:function(t,n){if(this[0])return n?(this.each(function(e){e.setAttribute(t,n)}),this):this[0].getAttribute(t)||void 0},removeAttr:function(t){return this.each(function(n){n.removeAttribute(t)}),this}}},function(t,n,e){var r=e(6),i=e(5),o=e(4),s=e(3),u=e(2),c=e(1),f=e(0);function a(t){if("string"==typeof t){var n=document.querySelectorAll(t);f(n,this)}else this[0]=t,this.length=1;return this}function h(t){return new a(t)}c(r,a.prototype),c(i,a.prototype),c(o,a.prototype),c(s,a.prototype),c(u,a.prototype),c(a.prototype,h),t.exports=h,window&&(window.$=window.W=h)}]);