/*! Qoopido.js library 3.7.0, 2015-07-23 | https://github.com/dlueth/qoopido.js | (c) 2015 Dirk Lueth */
!function(e){var t=["../base","../function/unique/uuid","../hook/css","./event"];window.CustomEvent||t.push("../polyfill/window/customevent"),window.addEventListener||t.push("../polyfill/window/addeventlistener"),window.removeEventListener||t.push("../polyfill/window/removeeventlistener"),window.dispatchEvent||t.push("../polyfill/window/dispatchevent"),Element.prototype.matches||t.push("../polyfill/element/matches"),document.querySelector||t.push("../polyfill/document/queryselector"),document.querySelectorAll||t.push("../polyfill/document/queryselectorall"),String.prototype.trim||t.push("../polyfill/string/trim"),window.qoopido.register("dom/element",e,t)}(function(e,t,n,r,i,o,s){"use strict";function l(e){var t,n,r;for(t in C)n=C[t],(!n.regex||n.regex.test(e))&&(r=n);return r}function u(e,t,n){var r=this,i=l(e),s=o.createEvent(i.type);s[i.method](e,"load"===e?!1:!0,!0,t),n&&(s._quid=n,s.isDelegate=!0),r.element.dispatchEvent(s)}function a(e){var t;if("string"==typeof e)try{y.test(e)===!0?(t=e.replace(y,"$1").toLowerCase(),e=o.createElement(t)):e=o.querySelector(e)}catch(n){e=null}if(!e)throw new Error("[Qoopido.js] Element could not be resolved");return e}function f(e,t){for(var n,r=0;(n=e.path[r])!==s;r++){if(n.matches(t))return e.currentTarget=n,!0;if(n===e.currentTarget)break}return!1}var c="object",m="string",p=e["function/unique/uuid"],d=o.getElementsByTagName("head")[0],h="textContent"in o.createElement("a")?"textContent":"innerText",v="undefined"!=typeof d.previousElementSibling?function(){return this.previousElementSibling}:function(){for(var e=this;e=e.previousSibling;)if(1===e.nodeType)return e},g="undefined"!=typeof d.nextElementSibling?function(){return this.nextElementSibling}:function(){for(var e=this;e=e.nextSibling;)if(1===e.nodeType)return e},y=new RegExp("^<(\\w+)\\s*/>$"),b=new RegExp("^[^-]+"),E=e["pool/module"]&&e["pool/module"].create(e["dom/event"],null,!0)||null,S=e["hook/css"],w={},C={custom:{type:"CustomEvent",method:"initCustomEvent"},html:{regex:new RegExp("^(?:load|unload|abort|error|select|change|submit|reset|focus|blur|resize|scroll)$"),type:"HTMLEvents",method:"initEvent"},mouse:{regex:new RegExp("^(?:mouse|pointer|contextmenu|touch|click|dblclick|drag|drop)"),type:"MouseEvents",method:"initMouseEvent"}};return e.base.extend({type:null,element:null,_listener:null,_constructor:function(e,t,n){var r,i=this;return e=a(e),r=e._quid,r?i=w[r]:(r=e._quid=p(),i.type=e.tagName,i.element=e,i._listener={},w[r]=i),"object"==typeof t&&null!==t&&i.setAttributes(t),"object"==typeof n&&null!==n&&i.setStyles(n),i!==this&&i.dispose&&i.dispose(),i},_obtain:function(e,t,n){this._constructor(e,t,n)},_dispose:function(){var e,t,n=this;for(e in n._listener)t=e.match(b),n.element.removeEventListener(t,n._listener[e]),delete n._listener[e];n.type=null,n.element=null},getContent:function(e){var t=this.element;return e&&e!==!1?t.innerHTML:t[h]},setContent:function(e,t){var n=this,r=n.element;return t&&t!==!1?r.innerHTML=e:r[h]=e,n},getAttribute:function(e){var t=this;return e&&typeof e===m?t.element.getAttribute(e):void 0},getAttributes:function(e){var t,n=this,r={},i=0;if(e)for(e=typeof e===m?e.split(" "):e;(t=e[i])!==s;i++)r[t]=n.element.getAttributes(t);return r},setAttribute:function(e,t){var n=this;return e&&typeof e===m&&n.element.setAttribute(e,t),n},setAttributes:function(e){var t,n=this;if(e&&typeof e===c&&!e.length)for(t in e)n.element.setAttribute(t,e[t]);return n},removeAttribute:function(e){var t=this;return e&&typeof e===m&&t.element.removeAttribute(e),t},removeAttributes:function(e){var t,n=this,r=0;if(e)for(e=typeof e===m?e.split(" "):e;(t=e[r])!==s;r++)n.element.removeAttribute(t);return n},getStyle:function(e){var t=this;return e&&typeof e===m?S.process("get",t.element,e):void 0},getStyles:function(e){var t,n=this,r={},i=0;if(e)for(e=typeof e===m?e.split(" "):e;(t=e[i])!==s;i++)r[t]=S.process("get",n.element,t);return r},setStyle:function(e,t){var n=this;return e&&typeof e===m&&S.process("set",n.element,e,t),n},setStyles:function(e){var t,n=this;if(e&&typeof e===c&&!e.length)for(t in e)S.process("set",n.element,t,e[t]);return n},removeStyle:function(e){var t=this;return e&&typeof e===m&&t.setStyle(e,""),t},removeStyles:function(e){var t,n=this,r=0;if(e)for(e=typeof e===m?e.split(" "):e;(t=e[r])!==s;r++)n.setStyle(t,"");return n},siblings:function(e){for(var t=this.element,n=t.parentNode.firstChild,r=[];n;n=g.call(n))n===t||e&&!n.matches(e)||r.push(n);return r},siblingsBefore:function(e){for(var t=this.element.previousSibling,n=[];t;t=v.call(t))(!e||t.matches(e))&&n.push(t);return n},siblingsAfter:function(e){for(var t=this.element.nextSibling,n=[];t;t=g.call(t))(!e||t.matches(e))&&n.push(t);return n},previous:function(e){var t=v.call(this.element);if(!e)return t;for(;t;t=v.call(t))if(t.matches(e))return t},next:function(e){var t=g.call(this.element);if(!e)return t;for(;t;t=g.call(t))if(t.matches(e))return t},find:function(e){var t,n,r=this.element;return e=e.trim(),">"===e.charAt(0)?(t=r._quid,r.setAttribute("data-quid",t),e='[data-quid="'+t+'"] '+e,n=r.parentNode.querySelectorAll(e),r.removeAttribute("data-quid")):n=r.querySelectorAll(e),n},parent:function(e){var t;if(!e)return this.element.parentNode;for(t=this.element;t;t=t.parentNode)if(t.matches(e))return t},parents:function(e){for(var t=this.element.parentNode,n=[];t;t=t.parentNode){if(9===t.nodeType)return n;1===t.nodeType&&(!e||t.matches(e))&&n.push(t)}},isVisible:function(){var e=this,t=e.element;return!(t.offsetWidth<=0&&t.offsetHeight<=0||"hidden"===e.getStyle("visibility")||e.getStyle("opacity")<=0)},hasClass:function(e){return e?new RegExp("(?:^|\\s)"+e+"(?:\\s|$)").test(this.element.className):!1},addClass:function(e){var t=this;return e&&!t.hasClass(e)&&(t.element.className+=t.element.className?" "+e:e),t},removeClass:function(e){var t=this;return e&&t.hasClass(e)&&(t.element.className=t.element.className.replace(new RegExp("(?:^|\\s)"+e+"(?!\\S)"),"")),t},toggleClass:function(e){var t=this;return e&&(t.hasClass(e)?t.removeClass(e):t.addClass(e)),t},prepend:function(e){var t=this,n=t.element;if(e)try{e=e.element||a(e),n.firstChild?n.insertBefore(e,n.firstChild):t.append(e)}catch(r){n.insertAdjacentHTML("afterBegin",e)}return t},append:function(e){var t=this,n=t.element;if(e)try{n.appendChild(e.element||a(e))}catch(r){n.insertAdjacentHTML("beforeEnd",e)}return t},prependTo:function(e){var t=this,n=t.element;return e&&((e=e.element||a(e)).firstChild?e.insertBefore(n,e.firstChild):t.appendTo(e)),t},appendTo:function(e){var t=this;return e&&(e.element||a(e)).appendChild(t.element),t},insertBefore:function(e){var t=this,n=t.element;return e&&(e=e.element||a(e)).parentNode.insertBefore(n,e),t},insertAfter:function(e){var t=this,n=t.element;return e&&((e=e.element||a(e)).nextSibling?e.parentNode.insertBefore(n,e.nextSibling):t.appendTo(e.parentNode)),t},replace:function(e){var t=this,n=t.element;return e&&(e=e.element||a(e)).parentNode.replaceChild(n,e),t},replaceWith:function(e){var t=this,n=t.element;return e&&(e=e.element||a(e),n.parentNode.replaceChild(e,n)),t},remove:function(){var e=this,t=e.element;return t.parentNode.removeChild(t),e},on:function(t){var n,r=this,i=r.element,o=arguments.length>2?arguments[1]:null,l=arguments.length>2?arguments[2]:arguments[1],a=l._quid||(l._quid=p()),c=0;for(t=t.split(" ");(n=t[c])!==s;c++){var m=n+"-"+a,d=function(t){var n;t=E&&E.obtain(t)||e["dom/event"].create(t),t.isPropagationStopped||(n=t.delegate,t._quid=p(),(!o||f(t,o))&&l.call(t.currentTarget,t,t.originalEvent.detail),n&&(delete t.delegate,u.call(r,n))),t.dispose&&t.dispose()};d.type=n,r._listener[m]=d,i.addEventListener(n,d)}return r},one:function(e){var t=this,n=arguments.length>3||"string"==typeof arguments[1]?arguments[1]:null,r=arguments.length>3||"function"==typeof arguments[2]?arguments[2]:arguments[1],i=(arguments.length>3?arguments[3]:arguments[2])!==!1,o=function(n){t.off(i===!0?n.type:e,o),r.call(this,n,n.originalEvent.detail)};return r._quid=o._quid=p(),n?t.on(e,n,o):t.on(e,o),t},off:function(e,t){var n,r,i,o=this,l=o.element,u=0;for(e=e.split(" ");(n=e[u])!==s;u++)r=t._quid&&n+"-"+t._quid||null,i=r&&o._listener[r]||null,i?(l.removeEventListener(n,i),delete o._listener[r]):l.removeEventListener(n,t);return o},emit:function(e,t){var n=this;return u.call(n,e,t),n}})});