diff --git a/dist/domini-core.js b/dist/domini-core.js index da0968e..a73a58a 100644 --- a/dist/domini-core.js +++ b/dist/domini-core.js @@ -1 +1 @@ -(()=>{"use strict";var t={d:(e,n)=>{for(var i in n)t.o(n,i)&&!t.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:n[i]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e)},e={};if(t.d(e,{default:()=>o}),void 0===window.DoMini){var n=function(t,e){return void 0!==arguments[2]?this.constructor.call(this,t,e):1!=arguments.length||"function"!=typeof arguments[0]?new n(t,e,!0):void("complete"===document.readyState||"loaded"===document.readyState||"interactive"===document.readyState?arguments[0].apply(this,[n]):window.addEventListener("DOMContentLoaded",(()=>{arguments[0].apply(this,[n])})))};n.prototype=n.fn={constructor:function(t,e){if(this.length=0,void 0!==e){if(e instanceof n)return e.find(t);if(e instanceof Element||"string"==typeof e)return n(e).find(t)}else if("string"==typeof t&&""!=t)this.push(...this._(t));else{if(t instanceof n)return t;t instanceof Element&&this.push(t)}return this},_:function(t){return"<"===t.charAt(0)?n._fn.createElementsFromHTML(t):[...document.querySelectorAll(t)]},push:Array.prototype.push,pop:Array.prototype.pop,sort:Array.prototype.sort,splice:Array.prototype.splice},n.prototype[Symbol.iterator]=Array.prototype[Symbol.iterator],n._fn={}}else n=window.DoMini;const i=n;i.fn.get=function(t){return void 0===t?Array.from(this):this[t]},i.fn.extend=function(){for(let t=1;t0&&this.forEach((function(t){t.classList.add.apply(t.classList,e)})),this},i.fn.removeClass=function(t){if(void 0!==t){let e=t;"string"==typeof t&&(e=t.split(" ")),e=e.filter((function(t){return""!==t.trim()})),e.length>0&&this.forEach((function(t){t.classList.remove.apply(t.classList,e)}))}else this.forEach((function(t){t.classList.length>0&&t.classList.remove.apply(t.classList,t.classList)}));return this},i.fn.isVisible=function(){let t,e=this.get(0),n=!0;for(;null!==e;){if(t=window.getComputedStyle(e),"none"==t.display||"hidden"==t.visibility||0==t.opacity){n=!1;break}e=e.parentElement}return n},i.fn.val=function(t){let e;if(1==arguments.length){for(const e of this)if("select-multiple"==e.type){t="string"==typeof t?t.split(","):t;for(let n,i=0,o=e.options.length;i0?t?parseInt(this.css("height"))+parseInt(this.css("marginTop"))+parseInt(this.css("marginBottom")):parseInt(this.css("height")):0},i.fn.noPaddingWidth=function(t){return t=t||!1,this.length>0?t?parseInt(this.css("width"))+parseInt(this.css("marginLeft"))+parseInt(this.css("marginRight")):parseInt(this.css("width")):0},i.fn.innerWidth=function(){let t=this.get(0);if(null!=t){let e=window.getComputedStyle(t);return this.outerWidth()-parseFloat(e.borderLeftWidth)-parseFloat(e.borderRightWidth)}return 0},i.fn.innerHeight=function(){let t=this.get(0);if(null!=t){let e=window.getComputedStyle(t);return this.outerHeight()-parseFloat(e.borderTopWidth)-parseFloat(e.borderBottomtWidth)}return 0},i.fn.width=function(){return this.outerWidth()},i.fn.height=function(){return this.outerHeight()},i.fn.on=function(){let t=arguments,e=function(t,e){let n;if("mouseenter"==e.type||"mouseleave"==e.type||"mouseover"==e.type){let o=document.elementFromPoint(e.clientX,e.clientY);if(!o.matches(t[1]))for(;(o=o.parentElement)&&!o.matches(t[1]););null!=o&&(n=i(o))}else n=i(e.target).closest(t[1]);if(null!=n&&n.closest(this).length>0){let i=[];if(i.push(e),void 0!==t[4])for(let e=4;e0)if(void 0===t){let t;for(;t=n._domini_events.pop();)n.removeEventListener(t.type,t.func,t.args);n._domini_events=[]}else t.split(" ").forEach((function(t){let i,o=[];for(;i=n._domini_events.pop();)i.type!=t||void 0!==e&&i.trigger!=e?o.push(i):n.removeEventListener(t,i.func,i.args);n._domini_events=o}))})),this},i.fn.offForced=function(){let t=this;return this.forEach((function(e,n){let i=e.cloneNode(!0);e.parentNode.replaceChild(i,e),t[n]=i})),this},i.fn.trigger=function(t,e,n,o){return n=n||!1,o=o||!1,this.forEach((function(r){let s=!1;if(o&&"undefined"!=typeof jQuery&&void 0!==jQuery._data&&void 0!==jQuery._data(r,"events")&&void 0!==jQuery._data(r,"events")[t]&&(jQuery(r).trigger(t,e),s=!0),!s&&n){let n=new Event(t);n.detail=e,r.dispatchEvent(n)}if(void 0!==r._domini_events)r._domini_events.forEach((function(n){if(n.type==t){let i=new Event(t);n.trigger.apply(r,[i].concat(e))}}));else{let n=!1,o=r;for(;o=o.parentElement,null!=o&&(void 0!==o._domini_events&&o._domini_events.forEach((function(s){if(void 0!==s.selector){let f=i(o).find(s.selector);if(f.length>0&&f.get().indexOf(r)>=0&&s.type==t){let i=new Event(t);s.trigger.apply(r,[i].concat(e)),n=!0}}})),!n););}})),this},i.fn.clear=function(){for(const t of this)delete t._domini_events;return this},i.fn.clone=function(){let t=[];for(const e of this)t.push(e.cloneNode(!0));return i().add(t)},i.fn.detach=function(t){let e=this,n=[];void 0!==t&&(e=this.find(t));for(const t of e)null!=t.parentElement&&n.push(t.parentElement.removeChild(t));return i().add(n)},i.fn.remove=function(t){return this.detach(t).off().clear()},i.fn.prepend=function(t){if((t=i._fn.ElementArrayFromAny(t)).length>0)for(const e of this)for(const n of t)e.insertBefore(n,e.children[0]);return this},i.fn.append=function(t){if((t=i._fn.ElementArrayFromAny(t)).length>0)for(const e of this)for(const n of t)e.appendChild(n);return this},i.fn.is=function(t){let e=!1;for(const n of this)if(n.matches(t)){e=!0;break}return e},i.fn.parent=function(t){let e=[];for(const n of this){let i=n.parentElement;"string"==typeof t&&(null==i||i.matches(t)||(i=null)),e.push(i)}return i().add(e)},i.fn.copy=function(t,e){let n,i,o;if("object"!=typeof t||null===t)return n=t,n;for(i in n=new t.constructor,t)t.hasOwnProperty(i)&&(o=typeof t[i],e&&"object"===o&&null!==t[i]?n[i]=this.copy(t[i]):n[i]=t[i]);return n},i.fn.first=function(){return i(this[0])},i.fn.last=function(){return i(this[this.length-1])},i.fn.prev=function(t){let e=[];for(const n of this){let i;if("string"==typeof t)for(i=n.previousElementSibling;null!=i;){if(i.matches(t)){e.push(i);break}i=i.previousElementSibling}else e.push(n.previousElementSibling)}return i(null).add(e)},i.fn.next=function(t){let e=[];for(const n of this){let i;if("string"==typeof t)for(i=n.nextElementSibling;null!=i;){if(i.matches(t)){e.includes(i)||e.push(i);break}i=i.nextElementSibling}else e.push(n.nextElementSibling)}return i(null).add(e)},i.fn.closest=function(t){let e=[];for(let n of this)if("string"==typeof t&&""!==t){for(;(n=n.parentElement)&&!n.matches(t););e.includes(n)||e.push(n)}else{if((t=t instanceof i?t.get(0):t)instanceof Element)for(;(n=n.parentElement)&&n!==t;);else n=null;e.includes(n)||e.push(n)}return i().add(e)},i.fn.add=function(t){let e=i._fn.ElementArrayFromAny(t);for(const t of e)Array.from(this).includes(t)||this.push(t);return this},i.fn.find=function(t){const e=new i;if("string"==typeof t){let n=[];this.get().forEach((function(e){n=n.concat(Array.from(e.querySelectorAll(t)))})),n.length>0&&e.add(n)}return e},i._fn.bodyTransform=function(){let t=0,e=0;if("undefined"!=typeof WebKitCSSMatrix){let n=window.getComputedStyle(document.body);if(void 0!==n.transform){let i=new WebKitCSSMatrix(n.transform);"undefined"!=i.m41&&(t=i.m41),"undefined"!=i.m42&&(e=i.m42)}}return{x:t,y:e}},i._fn.bodyTransformY=function(){return this.bodyTransform().y},i._fn.bodyTransformX=function(){return this.bodyTransform().x},i._fn.hasFixedParent=function(t){if(0!=i._fn.bodyTransformY())return!1;do{if("fixed"==window.getComputedStyle(t).position)return!0}while(t=t.parentElement);return!1},i._fn.hasEventListener=function(t,e,n){if(void 0===t._domini_events)return!1;for(let i=0;it instanceof Element))}return t},i._fn.absolutePosition=function(t){if(!t.getClientRects().length)return{top:0,left:0};let e=t.getBoundingClientRect(),n=t.ownerDocument.defaultView;return{top:e.top+n.pageYOffset,left:e.left+n.pageXOffset}},i._fn.plugin=function(t,e){i.fn[t]=function(n){return void 0!==n&&e[n]?e[n].apply(this,Array.prototype.slice.call(arguments,1)):this.forEach((function(i){i["domini_"+t]=Object.create(e).init(n,i)}))}},document.dispatchEvent(new Event("domini-dom-core-loaded"));const o=i;window.DoMini=e.default})(); \ No newline at end of file +(()=>{"use strict";var t={d:(e,n)=>{for(var i in n)t.o(n,i)&&!t.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:n[i]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e)},e={};if(t.d(e,{default:()=>o}),void 0===window.DoMini){var n=function(t,e){return void 0!==arguments[2]?this.constructor.call(this,t,e):1!=arguments.length||"function"!=typeof arguments[0]?new n(t,e,!0):void("complete"===document.readyState||"loaded"===document.readyState||"interactive"===document.readyState?arguments[0].apply(this,[n]):window.addEventListener("DOMContentLoaded",(()=>{arguments[0].apply(this,[n])})))};n.prototype=n.fn={constructor:function(t,e){if(this.length=0,void 0!==e){if(e instanceof n)return e.find(t);if(this.isValidNode(e)||"string"==typeof e)return n(e).find(t)}else if("string"==typeof t&&""!=t)this.push(...this._(t));else{if(t instanceof n)return t;this.isValidNode(t)&&this.push(t)}return this},_:function(t){return"<"===t.charAt(0)?n._fn.createElementsFromHTML(t):[...document.querySelectorAll(t)]},isValidNode:t=>t instanceof Element||t instanceof Document||t instanceof Window,push:Array.prototype.push,pop:Array.prototype.pop,sort:Array.prototype.sort,splice:Array.prototype.splice},n.prototype[Symbol.iterator]=Array.prototype[Symbol.iterator],n._fn={}}else n=window.DoMini;const i=n;i.fn.get=function(t){return void 0===t?Array.from(this):this[t]},i.fn.extend=function(){for(let t=1;t0&&this.forEach((function(t){t.classList.add.apply(t.classList,e)})),this},i.fn.removeClass=function(t){if(void 0!==t){let e=t;"string"==typeof t&&(e=t.split(" ")),e=e.filter((function(t){return""!==t.trim()})),e.length>0&&this.forEach((function(t){t.classList.remove.apply(t.classList,e)}))}else this.forEach((function(t){t.classList.length>0&&t.classList.remove.apply(t.classList,t.classList)}));return this},i.fn.isVisible=function(){let t,e=this.get(0),n=!0;for(;null!==e;){if(t=window.getComputedStyle(e),"none"==t.display||"hidden"==t.visibility||0==t.opacity){n=!1;break}e=e.parentElement}return n},i.fn.val=function(t){let e;if(1==arguments.length){for(const e of this)if("select-multiple"==e.type){t="string"==typeof t?t.split(","):t;for(let n,i=0,o=e.options.length;i0?t?parseInt(this.css("height"))+parseInt(this.css("marginTop"))+parseInt(this.css("marginBottom")):parseInt(this.css("height")):0},i.fn.noPaddingWidth=function(t){return t=t||!1,this.length>0?t?parseInt(this.css("width"))+parseInt(this.css("marginLeft"))+parseInt(this.css("marginRight")):parseInt(this.css("width")):0},i.fn.innerWidth=function(){let t=this.get(0);if(null!=t){let e=window.getComputedStyle(t);return this.outerWidth()-parseFloat(e.borderLeftWidth)-parseFloat(e.borderRightWidth)}return 0},i.fn.innerHeight=function(){let t=this.get(0);if(null!=t){let e=window.getComputedStyle(t);return this.outerHeight()-parseFloat(e.borderTopWidth)-parseFloat(e.borderBottomtWidth)}return 0},i.fn.width=function(){return this.outerWidth()},i.fn.height=function(){return this.outerHeight()},i.fn.on=function(){let t=arguments,e=function(t,e){let n;if("mouseenter"==e.type||"mouseleave"==e.type||"mouseover"==e.type){let o=document.elementFromPoint(e.clientX,e.clientY);if(!o.matches(t[1]))for(;(o=o.parentElement)&&!o.matches(t[1]););null!=o&&(n=i(o))}else n=i(e.target).closest(t[1]);if(null!=n&&n.closest(this).length>0){let i=[];if(i.push(e),void 0!==t[4])for(let e=4;e0)if(void 0===t){let t;for(;t=n._domini_events.pop();)n.removeEventListener(t.type,t.func,t.args);n._domini_events=[]}else t.split(" ").forEach((function(t){let i,o=[];for(;i=n._domini_events.pop();)i.type!=t||void 0!==e&&i.trigger!=e?o.push(i):n.removeEventListener(t,i.func,i.args);n._domini_events=o}))})),this},i.fn.offForced=function(){let t=this;return this.forEach((function(e,n){let i=e.cloneNode(!0);e.parentNode.replaceChild(i,e),t[n]=i})),this},i.fn.trigger=function(t,e,n,o){return n=n||!1,o=o||!1,this.forEach((function(r){let s=!1;if(o&&"undefined"!=typeof jQuery&&void 0!==jQuery._data&&void 0!==jQuery._data(r,"events")&&void 0!==jQuery._data(r,"events")[t]&&(jQuery(r).trigger(t,e),s=!0),!s&&n){let n=new Event(t);n.detail=e,r.dispatchEvent(n)}if(void 0!==r._domini_events)r._domini_events.forEach((function(n){if(n.type==t){let i=new Event(t);n.trigger.apply(r,[i].concat(e))}}));else{let n=!1,o=r;for(;o=o.parentElement,null!=o&&(void 0!==o._domini_events&&o._domini_events.forEach((function(s){if(void 0!==s.selector){let f=i(o).find(s.selector);if(f.length>0&&f.get().indexOf(r)>=0&&s.type==t){let i=new Event(t);s.trigger.apply(r,[i].concat(e)),n=!0}}})),!n););}})),this},i.fn.clear=function(){for(const t of this)delete t._domini_events;return this},i.fn.clone=function(){let t=[];for(const e of this)t.push(e.cloneNode(!0));return i().add(t)},i.fn.detach=function(t){let e=this,n=[];void 0!==t&&(e=this.find(t));for(const t of e)null!=t.parentElement&&n.push(t.parentElement.removeChild(t));return i().add(n)},i.fn.remove=function(t){return this.detach(t).off().clear()},i.fn.prepend=function(t){if((t=i._fn.ElementArrayFromAny(t)).length>0)for(const e of this)for(const n of t)e.insertBefore(n,e.children[0]);return this},i.fn.append=function(t){if((t=i._fn.ElementArrayFromAny(t)).length>0)for(const e of this)for(const n of t)e.appendChild(n);return this},i.fn.is=function(t){let e=!1;for(const n of this)if(n.matches(t)){e=!0;break}return e},i.fn.parent=function(t){let e=[];for(const n of this){let i=n.parentElement;"string"==typeof t&&(null==i||i.matches(t)||(i=null)),e.push(i)}return i().add(e)},i.fn.copy=function(t,e){let n,i,o;if("object"!=typeof t||null===t)return n=t,n;for(i in n=new t.constructor,t)t.hasOwnProperty(i)&&(o=typeof t[i],e&&"object"===o&&null!==t[i]?n[i]=this.copy(t[i]):n[i]=t[i]);return n},i.fn.first=function(){return i(this[0])},i.fn.last=function(){return i(this[this.length-1])},i.fn.prev=function(t){let e=[];for(const n of this){let i;if("string"==typeof t)for(i=n.previousElementSibling;null!=i;){if(i.matches(t)){e.push(i);break}i=i.previousElementSibling}else e.push(n.previousElementSibling)}return i(null).add(e)},i.fn.next=function(t){let e=[];for(const n of this){let i;if("string"==typeof t)for(i=n.nextElementSibling;null!=i;){if(i.matches(t)){e.includes(i)||e.push(i);break}i=i.nextElementSibling}else e.push(n.nextElementSibling)}return i(null).add(e)},i.fn.closest=function(t){let e=[];for(let n of this)if("string"==typeof t&&""!==t){for(;(n=n.parentElement)&&!n.matches(t););e.includes(n)||e.push(n)}else{if((t=t instanceof i?t.get(0):t)instanceof Element)for(;(n=n.parentElement)&&n!==t;);else n=null;e.includes(n)||e.push(n)}return i().add(e)},i.fn.add=function(t){let e=i._fn.ElementArrayFromAny(t);for(const t of e)Array.from(this).includes(t)||this.push(t);return this},i.fn.find=function(t){const e=new i;if("string"==typeof t){let n=[];this.get().forEach((function(e){const i=e.querySelectorAll?.(t)??[];n=n.concat(Array.from(i))})),n.length>0&&e.add(n)}return e},i._fn.bodyTransform=function(){let t=0,e=0;if("undefined"!=typeof WebKitCSSMatrix){let n=window.getComputedStyle(document.body);if(void 0!==n.transform){let i=new WebKitCSSMatrix(n.transform);"undefined"!=i.m41&&(t=i.m41),"undefined"!=i.m42&&(e=i.m42)}}return{x:t,y:e}},i._fn.bodyTransformY=function(){return this.bodyTransform().y},i._fn.bodyTransformX=function(){return this.bodyTransform().x},i._fn.hasFixedParent=function(t){if(0!=i._fn.bodyTransformY())return!1;do{if("fixed"==window.getComputedStyle(t).position)return!0}while(t=t.parentElement);return!1},i._fn.hasEventListener=function(t,e,n){if(void 0===t._domini_events)return!1;for(let i=0;it instanceof Element))}return t},i._fn.absolutePosition=function(t){if(!t.getClientRects().length)return{top:0,left:0};let e=t.getBoundingClientRect(),n=t.ownerDocument.defaultView;return{top:e.top+n.pageYOffset,left:e.left+n.pageXOffset}},i._fn.plugin=function(t,e){i.fn[t]=function(n){return void 0!==n&&e[n]?e[n].apply(this,Array.prototype.slice.call(arguments,1)):this.forEach((function(i){i["domini_"+t]=Object.create(e).init(n,i)}))}},document.dispatchEvent(new Event("domini-dom-core-loaded"));const o=i;window.DoMini=e.default})(); \ No newline at end of file diff --git a/dist/domini.js b/dist/domini.js index e9c82c9..6d8164f 100644 --- a/dist/domini.js +++ b/dist/domini.js @@ -1 +1 @@ -!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("DoMini",[],t):"object"==typeof exports?exports.DoMini=t():e.DoMini=t()}(window,(()=>(()=>{"use strict";var e={d:(t,n)=>{for(var i in n)e.o(n,i)&&!e.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:n[i]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t)},t={};if(e.d(t,{default:()=>r}),void 0===window.DoMini){var n=function(e,t){return void 0!==arguments[2]?this.constructor.call(this,e,t):1!=arguments.length||"function"!=typeof arguments[0]?new n(e,t,!0):void("complete"===document.readyState||"loaded"===document.readyState||"interactive"===document.readyState?arguments[0].apply(this,[n]):window.addEventListener("DOMContentLoaded",(()=>{arguments[0].apply(this,[n])})))};n.prototype=n.fn={constructor:function(e,t){if(this.length=0,void 0!==t){if(t instanceof n)return t.find(e);if(t instanceof Element||"string"==typeof t)return n(t).find(e)}else if("string"==typeof e&&""!=e)this.push(...this._(e));else{if(e instanceof n)return e;e instanceof Element&&this.push(e)}return this},_:function(e){return"<"===e.charAt(0)?n._fn.createElementsFromHTML(e):[...document.querySelectorAll(e)]},push:Array.prototype.push,pop:Array.prototype.pop,sort:Array.prototype.sort,splice:Array.prototype.splice},n.prototype[Symbol.iterator]=Array.prototype[Symbol.iterator],n._fn={}}else n=window.DoMini;const i=n;i.fn.get=function(e){return void 0===e?Array.from(this):this[e]},i.fn.extend=function(){for(let e=1;e0&&this.forEach((function(e){e.classList.add.apply(e.classList,t)})),this},i.fn.removeClass=function(e){if(void 0!==e){let t=e;"string"==typeof e&&(t=e.split(" ")),t=t.filter((function(e){return""!==e.trim()})),t.length>0&&this.forEach((function(e){e.classList.remove.apply(e.classList,t)}))}else this.forEach((function(e){e.classList.length>0&&e.classList.remove.apply(e.classList,e.classList)}));return this},i.fn.isVisible=function(){let e,t=this.get(0),n=!0;for(;null!==t;){if(e=window.getComputedStyle(t),"none"==e.display||"hidden"==e.visibility||0==e.opacity){n=!1;break}t=t.parentElement}return n},i.fn.val=function(e){let t;if(1==arguments.length){for(const t of this)if("select-multiple"==t.type){e="string"==typeof e?e.split(","):e;for(let n,i=0,o=t.options.length;i0?e?parseInt(this.css("height"))+parseInt(this.css("marginTop"))+parseInt(this.css("marginBottom")):parseInt(this.css("height")):0},i.fn.noPaddingWidth=function(e){return e=e||!1,this.length>0?e?parseInt(this.css("width"))+parseInt(this.css("marginLeft"))+parseInt(this.css("marginRight")):parseInt(this.css("width")):0},i.fn.innerWidth=function(){let e=this.get(0);if(null!=e){let t=window.getComputedStyle(e);return this.outerWidth()-parseFloat(t.borderLeftWidth)-parseFloat(t.borderRightWidth)}return 0},i.fn.innerHeight=function(){let e=this.get(0);if(null!=e){let t=window.getComputedStyle(e);return this.outerHeight()-parseFloat(t.borderTopWidth)-parseFloat(t.borderBottomtWidth)}return 0},i.fn.width=function(){return this.outerWidth()},i.fn.height=function(){return this.outerHeight()},i.fn.on=function(){let e=arguments,t=function(e,t){let n;if("mouseenter"==t.type||"mouseleave"==t.type||"mouseover"==t.type){let o=document.elementFromPoint(t.clientX,t.clientY);if(!o.matches(e[1]))for(;(o=o.parentElement)&&!o.matches(e[1]););null!=o&&(n=i(o))}else n=i(t.target).closest(e[1]);if(null!=n&&n.closest(this).length>0){let i=[];if(i.push(t),void 0!==e[4])for(let t=4;t0)if(void 0===e){let e;for(;e=n._domini_events.pop();)n.removeEventListener(e.type,e.func,e.args);n._domini_events=[]}else e.split(" ").forEach((function(e){let i,o=[];for(;i=n._domini_events.pop();)i.type!=e||void 0!==t&&i.trigger!=t?o.push(i):n.removeEventListener(e,i.func,i.args);n._domini_events=o}))})),this},i.fn.offForced=function(){let e=this;return this.forEach((function(t,n){let i=t.cloneNode(!0);t.parentNode.replaceChild(i,t),e[n]=i})),this},i.fn.trigger=function(e,t,n,o){return n=n||!1,o=o||!1,this.forEach((function(r){let s=!1;if(o&&"undefined"!=typeof jQuery&&void 0!==jQuery._data&&void 0!==jQuery._data(r,"events")&&void 0!==jQuery._data(r,"events")[e]&&(jQuery(r).trigger(e,t),s=!0),!s&&n){let n=new Event(e);n.detail=t,r.dispatchEvent(n)}if(void 0!==r._domini_events)r._domini_events.forEach((function(n){if(n.type==e){let i=new Event(e);n.trigger.apply(r,[i].concat(t))}}));else{let n=!1,o=r;for(;o=o.parentElement,null!=o&&(void 0!==o._domini_events&&o._domini_events.forEach((function(s){if(void 0!==s.selector){let l=i(o).find(s.selector);if(l.length>0&&l.get().indexOf(r)>=0&&s.type==e){let i=new Event(e);s.trigger.apply(r,[i].concat(t)),n=!0}}})),!n););}})),this},i.fn.clear=function(){for(const e of this)delete e._domini_events;return this},i.fn.clone=function(){let e=[];for(const t of this)e.push(t.cloneNode(!0));return i().add(e)},i.fn.detach=function(e){let t=this,n=[];void 0!==e&&(t=this.find(e));for(const e of t)null!=e.parentElement&&n.push(e.parentElement.removeChild(e));return i().add(n)},i.fn.remove=function(e){return this.detach(e).off().clear()},i.fn.prepend=function(e){if((e=i._fn.ElementArrayFromAny(e)).length>0)for(const t of this)for(const n of e)t.insertBefore(n,t.children[0]);return this},i.fn.append=function(e){if((e=i._fn.ElementArrayFromAny(e)).length>0)for(const t of this)for(const n of e)t.appendChild(n);return this},i.fn.is=function(e){let t=!1;for(const n of this)if(n.matches(e)){t=!0;break}return t},i.fn.parent=function(e){let t=[];for(const n of this){let i=n.parentElement;"string"==typeof e&&(null==i||i.matches(e)||(i=null)),t.push(i)}return i().add(t)},i.fn.copy=function(e,t){let n,i,o;if("object"!=typeof e||null===e)return n=e,n;for(i in n=new e.constructor,e)e.hasOwnProperty(i)&&(o=typeof e[i],t&&"object"===o&&null!==e[i]?n[i]=this.copy(e[i]):n[i]=e[i]);return n},i.fn.first=function(){return i(this[0])},i.fn.last=function(){return i(this[this.length-1])},i.fn.prev=function(e){let t=[];for(const n of this){let i;if("string"==typeof e)for(i=n.previousElementSibling;null!=i;){if(i.matches(e)){t.push(i);break}i=i.previousElementSibling}else t.push(n.previousElementSibling)}return i(null).add(t)},i.fn.next=function(e){let t=[];for(const n of this){let i;if("string"==typeof e)for(i=n.nextElementSibling;null!=i;){if(i.matches(e)){t.includes(i)||t.push(i);break}i=i.nextElementSibling}else t.push(n.nextElementSibling)}return i(null).add(t)},i.fn.closest=function(e){let t=[];for(let n of this)if("string"==typeof e&&""!==e){for(;(n=n.parentElement)&&!n.matches(e););t.includes(n)||t.push(n)}else{if((e=e instanceof i?e.get(0):e)instanceof Element)for(;(n=n.parentElement)&&n!==e;);else n=null;t.includes(n)||t.push(n)}return i().add(t)},i.fn.add=function(e){let t=i._fn.ElementArrayFromAny(e);for(const e of t)Array.from(this).includes(e)||this.push(e);return this},i.fn.find=function(e){const t=new i;if("string"==typeof e){let n=[];this.get().forEach((function(t){n=n.concat(Array.from(t.querySelectorAll(e)))})),n.length>0&&t.add(n)}return t},i._fn.bodyTransform=function(){let e=0,t=0;if("undefined"!=typeof WebKitCSSMatrix){let n=window.getComputedStyle(document.body);if(void 0!==n.transform){let i=new WebKitCSSMatrix(n.transform);"undefined"!=i.m41&&(e=i.m41),"undefined"!=i.m42&&(t=i.m42)}}return{x:e,y:t}},i._fn.bodyTransformY=function(){return this.bodyTransform().y},i._fn.bodyTransformX=function(){return this.bodyTransform().x},i._fn.hasFixedParent=function(e){if(0!=i._fn.bodyTransformY())return!1;do{if("fixed"==window.getComputedStyle(e).position)return!0}while(e=e.parentElement);return!1},i._fn.hasEventListener=function(e,t,n){if(void 0===e._domini_events)return!1;for(let i=0;ie instanceof Element))}return e},i._fn.absolutePosition=function(e){if(!e.getClientRects().length)return{top:0,left:0};let t=e.getBoundingClientRect(),n=e.ownerDocument.defaultView;return{top:t.top+n.pageYOffset,left:t.left+n.pageXOffset}},i._fn.plugin=function(e,t){i.fn[e]=function(n){return void 0!==n&&t[n]?t[n].apply(this,Array.prototype.slice.call(arguments,1)):this.forEach((function(i){i["domini_"+e]=Object.create(t).init(n,i)}))}},document.dispatchEvent(new Event("domini-dom-core-loaded"));const o=i;i.fn.animate=function(e,t,n){t=t||200,n=n||"easeInOutQuad";for(const o of this){let r,s,l,f,a,c=0,u=60,h={},d={};if(l=this.prop("_domini_animations"),l=null==l?[]:l,!1===e)l.forEach((function(e){clearInterval(e)}));else{function p(){c++,c>r?clearInterval(f):(s=a(c/r),Object.keys(d).forEach((function(e){e.indexOf("scroll")>-1?o[e]=h[e]+d[e]*s:o.style[e]=h[e]+d[e]*s+"px"})))}a=i.fn.animate.easing[n]??i.fn.animate.easing.easeInOutQuad,Object.keys(e).forEach((function(t){t.indexOf("scroll")>-1?(h[t]=o[t],d[t]=e[t]-h[t]):(h[t]=parseInt(window.getComputedStyle(o)[t]),d[t]=e[t]-h[t])})),r=t/1e3*u,f=setInterval(p,1e3/u),l.push(f),this.prop("_domini_animations",l)}}return this},i.fn.animate.easing={linear:function(e){return e},easeInOutQuad:function(e){return e<.5?2*e*e:1-Math.pow(-2*e+2,2)/2},easeOutQuad:function(e){return 1-(1-e)*(1-e)}},i.fn.unhighlight=function(e){let t={className:"highlight",element:"span"};return i.fn.extend(t,e),this.find(t.element+"."+t.className).forEach((function(){let e=this.parentNode;e.replaceChild(this.firstChild,this),e.normalize()}))},i.fn.highlight=function(e,t){this.defaults={className:"highlight",element:"span",caseSensitive:!1,wordsOnly:!1,excludeParents:".excludeFromHighlight"};const n=i,o={...this.defaults,...t};if(e.constructor===String&&(e=[e]),(e=e.filter((function(e){return""!=e}))).forEach((function(e,t,n){n[t]=e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&").normalize("NFD").replace(/[\u0300-\u036f]/g,"")})),0==e.length)return this;let r=o.caseSensitive?"":"i",s="("+e.join("|")+")";o.wordsOnly&&(s="(?:,|^|\\s)"+s+"(?:,|$|\\s)");let l=new RegExp(s,r);function f(e,t,i,o,r){if(r=""==r?n.fn.highlight.defaults:r,3===e.nodeType){if(!n(e.parentNode).is(r)){let n=e.data.normalize("NFD").replace(/[\u0300-\u036f]/g,"").match(t);if(n){let t,r=document.createElement(i||"span");r.className=o||"highlight",t=/\.|,|\s/.test(n[0].charAt(0))?n.index+1:n.index;let s=e.splitText(t);s.splitText(n[1].length);let l=s.cloneNode(!0);return r.appendChild(l),s.parentNode.replaceChild(r,s),1}}}else if(1===e.nodeType&&e.childNodes&&!/(script|style)/i.test(e.tagName)&&!n(e).closest(r).length>0&&(e.tagName!==i.toUpperCase()||e.className!==o))for(let n=0;n=0;t-=1)if(""!==e.elements[t].name)switch(e.elements[t].nodeName){case"INPUT":switch(e.elements[t].type){case"checkbox":case"radio":e.elements[t].checked&&i.push(e.elements[t].name+"="+encodeURIComponent(e.elements[t].value));break;case"file":break;default:i.push(e.elements[t].name+"="+encodeURIComponent(e.elements[t].value))}break;case"TEXTAREA":i.push(e.elements[t].name+"="+encodeURIComponent(e.elements[t].value));break;case"SELECT":switch(e.elements[t].type){case"select-one":i.push(e.elements[t].name+"="+encodeURIComponent(e.elements[t].value));break;case"select-multiple":for(n=e.elements[t].options.length-1;n>=0;n-=1)e.elements[t].options[n].selected&&i.push(e.elements[t].name+"="+encodeURIComponent(e.elements[t].options[n].value))}break;case"BUTTON":switch(e.elements[t].type){case"reset":case"submit":case"button":i.push(e.elements[t].name+"="+encodeURIComponent(e.elements[t].value))}}return i.join("&")},i.fn.serializeObject=function(e,t){let n,o=[];for(n in e)if(e.hasOwnProperty(n)){let r=t?t+"["+n+"]":n,s=e[n];o.push(null!==s&&"object"==typeof s?i.fn.serializeObject(s,r):encodeURIComponent(r)+"="+encodeURIComponent(s))}return o.join("&")},i.fn.inViewPort=function(e,t){let n,i,o=this.get(0);if(null==o)return!1;e=void 0===e?0:e,t=void 0===t?window:"string"==typeof t?document.querySelector(t):t;let r=o.getBoundingClientRect(),s=r.top,l=r.bottom,f=r.left,a=r.right,c=!1;if(null==t&&(t=window),t===window)n=window.innerWidth||0,i=window.innerHeight||0;else{n=t.clientWidth,i=t.clientHeight;let e=t.getBoundingClientRect();s-=e.top,l-=e.top,f-=e.left,a-=e.left}return e=~~Math.round(parseFloat(e)),a<=0||f>=n||(c=e>0?s>=e&&l0&&s<=i-e)|(s<=0&&l>e)),c},i.fn.ajax=function(e){if("cors"==(e=this.extend({url:"",method:"GET",cors:"cors",data:{},success:null,fail:null,accept:"text/html",contentType:"application/x-www-form-urlencoded; charset=UTF-8"},e)).cors){let t=new XMLHttpRequest;return t.onreadystatechange=function(){null!=e.success&&4==this.readyState&&this.status>=200&&this.status<400&&e.success(this.responseText),null!=e.fail&&4==this.readyState&&this.status>=400&&e.fail(this)},t.open(e.method.toUpperCase(),e.url,!0),t.setRequestHeader("Content-type",e.contentType),t.setRequestHeader("Accept",e.accept),t.send(this.serializeObject(e.data)),t}{let t="ajax_cb_"+"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(e){let t=16*Math.random()|0;return("x"==e?t:3&t|8).toString(16)})).replaceAll("-","");i.fn[t]=function(){e.success.apply(this,arguments),delete i.fn[e.data.fn]},e.data.callback="DoMini.fn."+t,e.data.fn=t;let n=document.createElement("script");n.type="text/javascript",n.src=e.url+"?"+this.serializeObject(e.data),n.onload=function(){this.remove()},document.body.appendChild(n)}};const r=o;return t.default})())); \ No newline at end of file +!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("DoMini",[],t):"object"==typeof exports?exports.DoMini=t():e.DoMini=t()}(window,(()=>(()=>{"use strict";var e={d:(t,n)=>{for(var i in n)e.o(n,i)&&!e.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:n[i]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t)},t={};if(e.d(t,{default:()=>r}),void 0===window.DoMini){var n=function(e,t){return void 0!==arguments[2]?this.constructor.call(this,e,t):1!=arguments.length||"function"!=typeof arguments[0]?new n(e,t,!0):void("complete"===document.readyState||"loaded"===document.readyState||"interactive"===document.readyState?arguments[0].apply(this,[n]):window.addEventListener("DOMContentLoaded",(()=>{arguments[0].apply(this,[n])})))};n.prototype=n.fn={constructor:function(e,t){if(this.length=0,void 0!==t){if(t instanceof n)return t.find(e);if(this.isValidNode(t)||"string"==typeof t)return n(t).find(e)}else if("string"==typeof e&&""!=e)this.push(...this._(e));else{if(e instanceof n)return e;this.isValidNode(e)&&this.push(e)}return this},_:function(e){return"<"===e.charAt(0)?n._fn.createElementsFromHTML(e):[...document.querySelectorAll(e)]},isValidNode:e=>e instanceof Element||e instanceof Document||e instanceof Window,push:Array.prototype.push,pop:Array.prototype.pop,sort:Array.prototype.sort,splice:Array.prototype.splice},n.prototype[Symbol.iterator]=Array.prototype[Symbol.iterator],n._fn={}}else n=window.DoMini;const i=n;i.fn.get=function(e){return void 0===e?Array.from(this):this[e]},i.fn.extend=function(){for(let e=1;e0&&this.forEach((function(e){e.classList.add.apply(e.classList,t)})),this},i.fn.removeClass=function(e){if(void 0!==e){let t=e;"string"==typeof e&&(t=e.split(" ")),t=t.filter((function(e){return""!==e.trim()})),t.length>0&&this.forEach((function(e){e.classList.remove.apply(e.classList,t)}))}else this.forEach((function(e){e.classList.length>0&&e.classList.remove.apply(e.classList,e.classList)}));return this},i.fn.isVisible=function(){let e,t=this.get(0),n=!0;for(;null!==t;){if(e=window.getComputedStyle(t),"none"==e.display||"hidden"==e.visibility||0==e.opacity){n=!1;break}t=t.parentElement}return n},i.fn.val=function(e){let t;if(1==arguments.length){for(const t of this)if("select-multiple"==t.type){e="string"==typeof e?e.split(","):e;for(let n,i=0,o=t.options.length;i0?e?parseInt(this.css("height"))+parseInt(this.css("marginTop"))+parseInt(this.css("marginBottom")):parseInt(this.css("height")):0},i.fn.noPaddingWidth=function(e){return e=e||!1,this.length>0?e?parseInt(this.css("width"))+parseInt(this.css("marginLeft"))+parseInt(this.css("marginRight")):parseInt(this.css("width")):0},i.fn.innerWidth=function(){let e=this.get(0);if(null!=e){let t=window.getComputedStyle(e);return this.outerWidth()-parseFloat(t.borderLeftWidth)-parseFloat(t.borderRightWidth)}return 0},i.fn.innerHeight=function(){let e=this.get(0);if(null!=e){let t=window.getComputedStyle(e);return this.outerHeight()-parseFloat(t.borderTopWidth)-parseFloat(t.borderBottomtWidth)}return 0},i.fn.width=function(){return this.outerWidth()},i.fn.height=function(){return this.outerHeight()},i.fn.on=function(){let e=arguments,t=function(e,t){let n;if("mouseenter"==t.type||"mouseleave"==t.type||"mouseover"==t.type){let o=document.elementFromPoint(t.clientX,t.clientY);if(!o.matches(e[1]))for(;(o=o.parentElement)&&!o.matches(e[1]););null!=o&&(n=i(o))}else n=i(t.target).closest(e[1]);if(null!=n&&n.closest(this).length>0){let i=[];if(i.push(t),void 0!==e[4])for(let t=4;t0)if(void 0===e){let e;for(;e=n._domini_events.pop();)n.removeEventListener(e.type,e.func,e.args);n._domini_events=[]}else e.split(" ").forEach((function(e){let i,o=[];for(;i=n._domini_events.pop();)i.type!=e||void 0!==t&&i.trigger!=t?o.push(i):n.removeEventListener(e,i.func,i.args);n._domini_events=o}))})),this},i.fn.offForced=function(){let e=this;return this.forEach((function(t,n){let i=t.cloneNode(!0);t.parentNode.replaceChild(i,t),e[n]=i})),this},i.fn.trigger=function(e,t,n,o){return n=n||!1,o=o||!1,this.forEach((function(r){let s=!1;if(o&&"undefined"!=typeof jQuery&&void 0!==jQuery._data&&void 0!==jQuery._data(r,"events")&&void 0!==jQuery._data(r,"events")[e]&&(jQuery(r).trigger(e,t),s=!0),!s&&n){let n=new Event(e);n.detail=t,r.dispatchEvent(n)}if(void 0!==r._domini_events)r._domini_events.forEach((function(n){if(n.type==e){let i=new Event(e);n.trigger.apply(r,[i].concat(t))}}));else{let n=!1,o=r;for(;o=o.parentElement,null!=o&&(void 0!==o._domini_events&&o._domini_events.forEach((function(s){if(void 0!==s.selector){let l=i(o).find(s.selector);if(l.length>0&&l.get().indexOf(r)>=0&&s.type==e){let i=new Event(e);s.trigger.apply(r,[i].concat(t)),n=!0}}})),!n););}})),this},i.fn.clear=function(){for(const e of this)delete e._domini_events;return this},i.fn.clone=function(){let e=[];for(const t of this)e.push(t.cloneNode(!0));return i().add(e)},i.fn.detach=function(e){let t=this,n=[];void 0!==e&&(t=this.find(e));for(const e of t)null!=e.parentElement&&n.push(e.parentElement.removeChild(e));return i().add(n)},i.fn.remove=function(e){return this.detach(e).off().clear()},i.fn.prepend=function(e){if((e=i._fn.ElementArrayFromAny(e)).length>0)for(const t of this)for(const n of e)t.insertBefore(n,t.children[0]);return this},i.fn.append=function(e){if((e=i._fn.ElementArrayFromAny(e)).length>0)for(const t of this)for(const n of e)t.appendChild(n);return this},i.fn.is=function(e){let t=!1;for(const n of this)if(n.matches(e)){t=!0;break}return t},i.fn.parent=function(e){let t=[];for(const n of this){let i=n.parentElement;"string"==typeof e&&(null==i||i.matches(e)||(i=null)),t.push(i)}return i().add(t)},i.fn.copy=function(e,t){let n,i,o;if("object"!=typeof e||null===e)return n=e,n;for(i in n=new e.constructor,e)e.hasOwnProperty(i)&&(o=typeof e[i],t&&"object"===o&&null!==e[i]?n[i]=this.copy(e[i]):n[i]=e[i]);return n},i.fn.first=function(){return i(this[0])},i.fn.last=function(){return i(this[this.length-1])},i.fn.prev=function(e){let t=[];for(const n of this){let i;if("string"==typeof e)for(i=n.previousElementSibling;null!=i;){if(i.matches(e)){t.push(i);break}i=i.previousElementSibling}else t.push(n.previousElementSibling)}return i(null).add(t)},i.fn.next=function(e){let t=[];for(const n of this){let i;if("string"==typeof e)for(i=n.nextElementSibling;null!=i;){if(i.matches(e)){t.includes(i)||t.push(i);break}i=i.nextElementSibling}else t.push(n.nextElementSibling)}return i(null).add(t)},i.fn.closest=function(e){let t=[];for(let n of this)if("string"==typeof e&&""!==e){for(;(n=n.parentElement)&&!n.matches(e););t.includes(n)||t.push(n)}else{if((e=e instanceof i?e.get(0):e)instanceof Element)for(;(n=n.parentElement)&&n!==e;);else n=null;t.includes(n)||t.push(n)}return i().add(t)},i.fn.add=function(e){let t=i._fn.ElementArrayFromAny(e);for(const e of t)Array.from(this).includes(e)||this.push(e);return this},i.fn.find=function(e){const t=new i;if("string"==typeof e){let n=[];this.get().forEach((function(t){const i=t.querySelectorAll?.(e)??[];n=n.concat(Array.from(i))})),n.length>0&&t.add(n)}return t},i._fn.bodyTransform=function(){let e=0,t=0;if("undefined"!=typeof WebKitCSSMatrix){let n=window.getComputedStyle(document.body);if(void 0!==n.transform){let i=new WebKitCSSMatrix(n.transform);"undefined"!=i.m41&&(e=i.m41),"undefined"!=i.m42&&(t=i.m42)}}return{x:e,y:t}},i._fn.bodyTransformY=function(){return this.bodyTransform().y},i._fn.bodyTransformX=function(){return this.bodyTransform().x},i._fn.hasFixedParent=function(e){if(0!=i._fn.bodyTransformY())return!1;do{if("fixed"==window.getComputedStyle(e).position)return!0}while(e=e.parentElement);return!1},i._fn.hasEventListener=function(e,t,n){if(void 0===e._domini_events)return!1;for(let i=0;ie instanceof Element))}return e},i._fn.absolutePosition=function(e){if(!e.getClientRects().length)return{top:0,left:0};let t=e.getBoundingClientRect(),n=e.ownerDocument.defaultView;return{top:t.top+n.pageYOffset,left:t.left+n.pageXOffset}},i._fn.plugin=function(e,t){i.fn[e]=function(n){return void 0!==n&&t[n]?t[n].apply(this,Array.prototype.slice.call(arguments,1)):this.forEach((function(i){i["domini_"+e]=Object.create(t).init(n,i)}))}},document.dispatchEvent(new Event("domini-dom-core-loaded"));const o=i;i.fn.animate=function(e,t,n){t=t||200,n=n||"easeInOutQuad";for(const o of this){let r,s,l,f,a,c=0,u=60,h={},d={};if(l=this.prop("_domini_animations"),l=null==l?[]:l,!1===e)l.forEach((function(e){clearInterval(e)}));else{function p(){c++,c>r?clearInterval(f):(s=a(c/r),Object.keys(d).forEach((function(e){e.indexOf("scroll")>-1?o[e]=h[e]+d[e]*s:o.style[e]=h[e]+d[e]*s+"px"})))}a=i.fn.animate.easing[n]??i.fn.animate.easing.easeInOutQuad,Object.keys(e).forEach((function(t){t.indexOf("scroll")>-1?(h[t]=o[t],d[t]=e[t]-h[t]):(h[t]=parseInt(window.getComputedStyle(o)[t]),d[t]=e[t]-h[t])})),r=t/1e3*u,f=setInterval(p,1e3/u),l.push(f),this.prop("_domini_animations",l)}}return this},i.fn.animate.easing={linear:function(e){return e},easeInOutQuad:function(e){return e<.5?2*e*e:1-Math.pow(-2*e+2,2)/2},easeOutQuad:function(e){return 1-(1-e)*(1-e)}},i.fn.unhighlight=function(e){let t={className:"highlight",element:"span"};return i.fn.extend(t,e),this.find(t.element+"."+t.className).forEach((function(){let e=this.parentNode;e.replaceChild(this.firstChild,this),e.normalize()}))},i.fn.highlight=function(e,t){this.defaults={className:"highlight",element:"span",caseSensitive:!1,wordsOnly:!1,excludeParents:".excludeFromHighlight"};const n=i,o={...this.defaults,...t};if(e.constructor===String&&(e=[e]),(e=e.filter((function(e){return""!=e}))).forEach((function(e,t,n){n[t]=e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&").normalize("NFD").replace(/[\u0300-\u036f]/g,"")})),0==e.length)return this;let r=o.caseSensitive?"":"i",s="("+e.join("|")+")";o.wordsOnly&&(s="(?:,|^|\\s)"+s+"(?:,|$|\\s)");let l=new RegExp(s,r);function f(e,t,i,o,r){if(r=""==r?n.fn.highlight.defaults:r,3===e.nodeType){if(!n(e.parentNode).is(r)){let n=e.data.normalize("NFD").replace(/[\u0300-\u036f]/g,"").match(t);if(n){let t,r=document.createElement(i||"span");r.className=o||"highlight",t=/\.|,|\s/.test(n[0].charAt(0))?n.index+1:n.index;let s=e.splitText(t);s.splitText(n[1].length);let l=s.cloneNode(!0);return r.appendChild(l),s.parentNode.replaceChild(r,s),1}}}else if(1===e.nodeType&&e.childNodes&&!/(script|style)/i.test(e.tagName)&&!n(e).closest(r).length>0&&(e.tagName!==i.toUpperCase()||e.className!==o))for(let n=0;n=0;t-=1)if(""!==e.elements[t].name)switch(e.elements[t].nodeName){case"INPUT":switch(e.elements[t].type){case"checkbox":case"radio":e.elements[t].checked&&i.push(e.elements[t].name+"="+encodeURIComponent(e.elements[t].value));break;case"file":break;default:i.push(e.elements[t].name+"="+encodeURIComponent(e.elements[t].value))}break;case"TEXTAREA":i.push(e.elements[t].name+"="+encodeURIComponent(e.elements[t].value));break;case"SELECT":switch(e.elements[t].type){case"select-one":i.push(e.elements[t].name+"="+encodeURIComponent(e.elements[t].value));break;case"select-multiple":for(n=e.elements[t].options.length-1;n>=0;n-=1)e.elements[t].options[n].selected&&i.push(e.elements[t].name+"="+encodeURIComponent(e.elements[t].options[n].value))}break;case"BUTTON":switch(e.elements[t].type){case"reset":case"submit":case"button":i.push(e.elements[t].name+"="+encodeURIComponent(e.elements[t].value))}}return i.join("&")},i.fn.serializeObject=function(e,t){let n,o=[];for(n in e)if(e.hasOwnProperty(n)){let r=t?t+"["+n+"]":n,s=e[n];o.push(null!==s&&"object"==typeof s?i.fn.serializeObject(s,r):encodeURIComponent(r)+"="+encodeURIComponent(s))}return o.join("&")},i.fn.inViewPort=function(e,t){let n,i,o=this.get(0);if(null==o)return!1;e=void 0===e?0:e,t=void 0===t?window:"string"==typeof t?document.querySelector(t):t;let r=o.getBoundingClientRect(),s=r.top,l=r.bottom,f=r.left,a=r.right,c=!1;if(null==t&&(t=window),t===window)n=window.innerWidth||0,i=window.innerHeight||0;else{n=t.clientWidth,i=t.clientHeight;let e=t.getBoundingClientRect();s-=e.top,l-=e.top,f-=e.left,a-=e.left}return e=~~Math.round(parseFloat(e)),a<=0||f>=n||(c=e>0?s>=e&&l0&&s<=i-e)|(s<=0&&l>e)),c},i.fn.ajax=function(e){if("cors"==(e=this.extend({url:"",method:"GET",cors:"cors",data:{},success:null,fail:null,accept:"text/html",contentType:"application/x-www-form-urlencoded; charset=UTF-8"},e)).cors){let t=new XMLHttpRequest;return t.onreadystatechange=function(){null!=e.success&&4==this.readyState&&this.status>=200&&this.status<400&&e.success(this.responseText),null!=e.fail&&4==this.readyState&&this.status>=400&&e.fail(this)},t.open(e.method.toUpperCase(),e.url,!0),t.setRequestHeader("Content-type",e.contentType),t.setRequestHeader("Accept",e.accept),t.send(this.serializeObject(e.data)),t}{let t="ajax_cb_"+"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(e){let t=16*Math.random()|0;return("x"==e?t:3&t|8).toString(16)})).replaceAll("-","");i.fn[t]=function(){e.success.apply(this,arguments),delete i.fn[e.data.fn]},e.data.callback="DoMini.fn."+t,e.data.fn=t;let n=document.createElement("script");n.type="text/javascript",n.src=e.url+"?"+this.serializeObject(e.data),n.onload=function(){this.remove()},document.body.appendChild(n)}};const r=o;return t.default})())); \ No newline at end of file diff --git a/package.json b/package.json index e785e5a..f49d11d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "domini", - "version": "0.2.2", + "version": "0.2.3", "description": "Minimalistic DOM manipulation tool", "main": "dist/domini.js", "scripts": { diff --git a/src/base.js b/src/base.js index 7213782..9429fdd 100644 --- a/src/base.js +++ b/src/base.js @@ -40,7 +40,7 @@ if ( typeof window.DoMini == 'undefined' ) { if ( typeof node != "undefined" ) { if ( node instanceof DoMini ) { return node.find(s); - } else if ( node instanceof Element || typeof node == 'string' ) { + } else if ( this.isValidNode(node) || typeof node == 'string' ) { return DoMini(node).find(s); } } else { @@ -49,7 +49,7 @@ if ( typeof window.DoMini == 'undefined' ) { } else { if ( s instanceof DoMini ) { return s; - } else if ( s instanceof Element ) { + } else if ( this.isValidNode(s) ) { this.push(s) } } @@ -70,6 +70,8 @@ if ( typeof window.DoMini == 'undefined' ) { return [...document.querySelectorAll(s)]; }, + isValidNode: (node)=>node instanceof Element || node instanceof Document || node instanceof Window, + // This makes it act more like an array push: Array.prototype.push, pop: Array.prototype.pop, diff --git a/src/core/selector.js b/src/core/selector.js index ba2a4b1..b708bcf 100644 --- a/src/core/selector.js +++ b/src/core/selector.js @@ -137,7 +137,8 @@ DoMini.fn.find = function (s) { if ( typeof s == 'string' ) { let found = []; this.get().forEach(function(el){ - found = found.concat( Array.from(el.querySelectorAll(s)) ); + const matches = el.querySelectorAll?.(s) ?? []; + found = found.concat( Array.from(matches) ); }); if ( found.length > 0 ) { newDomini.add(found); diff --git a/test/core/base.js b/test/core/base.js index 9d1fa55..fcfd5f0 100644 --- a/test/core/base.js +++ b/test/core/base.js @@ -9,7 +9,7 @@ QUnit.module("base.js tests", function(hooks) { let $title = $('#title'), title = document.getElementById('title'); - assert.expect(40); + assert.expect(42); assert.equal(typeof DoMini, 'function', "typeof DoMini = 'function'"); assert.equal(typeof $title, 'object', "typeof $('#title') = 'object'"); @@ -19,6 +19,9 @@ QUnit.module("base.js tests", function(hooks) { assert.equal($([]).length, 0, "$([]).length = 0"); assert.equal($(undefined).length, 0, "$(undefined).length = 0"); + assert.equal($(document).length, 1, "$(document).length = 1"); + assert.equal($(window).length, 1, "$(window).length = 1"); + assert.true($title instanceof DoMini, "$('#title') instanceof DoMini"); assert.true($title instanceof Object, "$('#title') instanceof Object"); diff --git a/test/core/event.js b/test/core/event.js index fcae144..974eb5c 100644 --- a/test/core/event.js +++ b/test/core/event.js @@ -11,7 +11,7 @@ QUnit.module("events.js tests", function(hooks) { f.innerHTML = fixture; }); - QUnit.test('on("event") regular', function(assert) { + QUnit.test('on("event") regular Element', function(assert) { $("#title").on('click', cb); $("#title").trigger('click'); @@ -28,7 +28,41 @@ QUnit.module("events.js tests", function(hooks) { assert.equal(x, 4, 'final click trigger'); }); - QUnit.test('on("event") dynamic', function(assert) { + QUnit.test('on("event") regular Window', function(assert) { + $(window).on('click', cb); + + $(window).trigger('click'); + assert.equal(x, 1, 'click trigger 1'); + $(window).trigger('click'); + assert.equal(x, 2, 'click trigger 2'); + $(window).off('keypress').trigger('click'); + assert.equal(x, 3, 'wrong event trigger'); + $(window).off('click', nocb).trigger('click'); + assert.equal(x, 4, 'wrong callback off() trigger'); + $(window).off('click', cb).trigger('click'); + assert.equal(x, 4, 'correct callback off() trigger'); + $(window).trigger('click'); + assert.equal(x, 4, 'final click trigger'); + }); + + QUnit.test('on("event") regular Document', function(assert) { + $(document).on('click', cb); + + $(document).trigger('click'); + assert.equal(x, 1, 'click trigger 1'); + $(document).trigger('click'); + assert.equal(x, 2, 'click trigger 2'); + $(document).off('keypress').trigger('click'); + assert.equal(x, 3, 'wrong event trigger'); + $(document).off('click', nocb).trigger('click'); + assert.equal(x, 4, 'wrong callback off() trigger'); + $(document).off('click', cb).trigger('click'); + assert.equal(x, 4, 'correct callback off() trigger'); + $(document).trigger('click'); + assert.equal(x, 4, 'final click trigger'); + }); + + QUnit.test('on("event") dynamic Element', function(assert) { // The list has 3 items $("#list-container").on('click', 'li', cb); @@ -62,7 +96,42 @@ QUnit.module("events.js tests", function(hooks) { assert.equal(x, 0, 'All callback removal'); }); - QUnit.test('on("event") multiple', function(assert) { + + QUnit.test('on("event") dynamic Document', function(assert) { + // The list has 3 items + $(document).find('#list-container').on('click', 'li', cb); + + // Trigger will execute 3 times, x=3 + $("#list-container li").trigger('click'); + assert.equal(x, 3, 'click trigger 1'); + + // Add 1 more list item + $("#list-container ul").append( + $("#list-container li:last-child").clone() + ); + + // Trigger will execute 4 times, x=4 + x = 0; + $("#list-container li").trigger('click'); + assert.equal(x, 4, 'click trigger 2'); + + // Fake callback removal + x = 0; + $(document).find('#list-container').off('click', nocb).trigger('click'); + assert.equal(x, 1, 'Fake callback removal'); + + // Real callback removal + x = 0; + $(document).find('#list-container').off('click', cb).trigger('click'); + assert.equal(x, 0, 'Real callback removal'); + + // All callback removal + x = 0; + $(document).find('#list-container').off('click').trigger('click'); + assert.equal(x, 0, 'All callback removal'); + }); + + QUnit.test('on("event") multiple on Element', function(assert) { $("#title").on('click keypress keyup custom_event', cb); $("#title").trigger('click').trigger('keyup'); @@ -111,4 +180,104 @@ QUnit.module("events.js tests", function(hooks) { .trigger('keyup').trigger('custom_event'); assert.equal(x, 4, 'Trigger all 4, double register'); }); + + QUnit.test('on("event") multiple on Window', function(assert) { + $(window).on('click keypress keyup custom_event', cb); + + $(window).trigger('click').trigger('keyup'); + assert.equal(x, 2, 'multiple trigger 1'); + + x = 0; + //Trigger all + $(window) + .trigger('click').trigger('keypress') + .trigger('keyup').trigger('custom_event'); + assert.equal(x, 4, 'trigger all of registered'); + + x = 0; + // Fake and real trigger + $(window).trigger('fake').trigger('keyup'); + assert.equal(x, 1, 'multiple trigger 1'); + + x = 0; + // Remove one and trigger + $(window).off('click', cb).trigger('click'); + assert.equal(x, 0, 'remove and trigger same'); + + x = 0; + // Remove two more and trigger + $(window).off('keyup', cb).off('keypress'); + $(window) + .trigger('click').trigger('keypress') + .trigger('keyup').trigger('custom_event'); + assert.equal(x, 1, 'one remaining trigger "custom_event"'); + + x = 0; + // Add back all & trigger all + $(window).on('click keypress keyup custom_event', cb); + $(window) + .trigger('click').trigger('keypress') + .trigger('keyup').trigger('custom_event'); + assert.equal(x, 4, 'Trigger all 4 after re-adding'); + + x = 0; + // Try registering multiple times the same, still should + // only register once for each event. + $(window).on('click keypress keyup custom_event', cb); + $(window).on('click keypress keyup custom_event', cb); + $(window) + .trigger('click').trigger('keypress') + .trigger('keyup').trigger('custom_event'); + assert.equal(x, 4, 'Trigger all 4, double register'); + }); + + QUnit.test('on("event") multiple on Document', function(assert) { + $(document).on('click keypress keyup custom_event', cb); + + $(document).trigger('click').trigger('keyup'); + assert.equal(x, 2, 'multiple trigger 1'); + + x = 0; + //Trigger all + $(document) + .trigger('click').trigger('keypress') + .trigger('keyup').trigger('custom_event'); + assert.equal(x, 4, 'trigger all of registered'); + + x = 0; + // Fake and real trigger + $(document).trigger('fake').trigger('keyup'); + assert.equal(x, 1, 'multiple trigger 1'); + + x = 0; + // Remove one and trigger + $(document).off('click', cb).trigger('click'); + assert.equal(x, 0, 'remove and trigger same'); + + x = 0; + // Remove two more and trigger + $(document).off('keyup', cb).off('keypress'); + $(document) + .trigger('click').trigger('keypress') + .trigger('keyup').trigger('custom_event'); + assert.equal(x, 1, 'one remaining trigger "custom_event"'); + + x = 0; + // Add back all & trigger all + $(document).on('click keypress keyup custom_event', cb); + $(document) + .trigger('click').trigger('keypress') + .trigger('keyup').trigger('custom_event'); + assert.equal(x, 4, 'Trigger all 4 after re-adding'); + + x = 0; + // Try registering multiple times the same, still should + // only register once for each event. + $(document).on('click keypress keyup custom_event', cb); + $(document).on('click keypress keyup custom_event', cb); + $(document) + .trigger('click').trigger('keypress') + .trigger('keyup').trigger('custom_event'); + assert.equal(x, 4, 'Trigger all 4, double register'); + }); }); \ No newline at end of file diff --git a/test/core/selector.js b/test/core/selector.js index 3ae0c5b..e580a5a 100644 --- a/test/core/selector.js +++ b/test/core/selector.js @@ -260,7 +260,7 @@ QUnit.module("selector.js tests", function(hooks) { ); }); - QUnit.test('.find()', function(assert) { + QUnit.test('.find() Element', function(assert) { let nativeListLi = document.querySelectorAll("#list-container li"); assert.true($().find().length == 0, 'on empty'); assert.true($(null).find().length == 0, 'on null'); @@ -289,4 +289,9 @@ QUnit.module("selector.js tests", function(hooks) { ); }); }); + + QUnit.test('.find() Window', function(assert) { + assert.equal($(window).find("div").length, 0, 'window does not have querySelector'); + assert.equal($(window).find("li").length, 0, 'window does not have querySelector'); + }); }); \ No newline at end of file