2 lines
54 KiB
JavaScript
2 lines
54 KiB
JavaScript
!function(){var t={};t.settings={},t.post=function(t){return new e("post",t)},t.get=function(t){return new e("get",t)};var e=function(e,i){var s={method:e,url:"",before:function(){},success:function(){},error:function(){},data:!1,async:!0,headers:{}};this.p=this.extend(s,i),this.p=this.extend(this.p,t.settings),this.p.method=this.p.method.toUpperCase(),this.prepareData(),this.xhr=new XMLHttpRequest,this.xhr.open(this.p.method,this.p.url,this.p.async),this.setHeaders();var n="function"==typeof this.p.before?this.p.before(this.xhr):!0;n!==!1&&this.send()};e.prototype={extend:function(t,e){if(e)for(var i in e)t[i]=e[i];return t},prepareData:function(){"POST"!==this.p.method||this.isFormData()||(this.p.headers["Content-Type"]="application/x-www-form-urlencoded"),"object"!=typeof this.p.data||this.isFormData()||(this.p.data=this.toParams(this.p.data)),"GET"===this.p.method&&(this.p.url=this.p.data?this.p.url+"?"+this.p.data:this.p.url)},setHeaders:function(){this.xhr.setRequestHeader("X-Requested-With",this.p.headers["X-Requested-With"]||"XMLHttpRequest");for(var t in this.p.headers)this.xhr.setRequestHeader(t,this.p.headers[t])},isFormData:function(){return"undefined"!=typeof window.FormData&&this.p.data instanceof window.FormData},isComplete:function(){return!(this.xhr.status<200||this.xhr.status>=300&&304!==this.xhr.status)},send:function(){this.p.async?(this.xhr.onload=this.loaded.bind(this),this.xhr.send(this.p.data)):(this.xhr.send(this.p.data),this.loaded.call(this))},loaded:function(){if(this.isComplete()){var t=this.xhr.response,e=this.parseJson(t);t=e?e:t,"function"==typeof this.p.success&&this.p.success(t,this.xhr)}else"function"==typeof this.p.error&&this.p.error(this.xhr.statusText)},parseJson:function(t){try{var e=JSON.parse(t);if(e&&"object"==typeof e)return e}catch(i){}return!1},toParams:function(t){return Object.keys(t).map(function(e){return encodeURIComponent(e)+"="+encodeURIComponent(t[e])}).join("&")}};var i=[0],s="data"+ +new Date,n="is-hidden",o="is-hidden-mobile",a=function(t,e){return this.parse(t,e)};a.ready=function(t){"loading"!=document.readyState?t():document.addEventListener("DOMContentLoaded",t)},a.prototype={get dom(){return!0},get length(){return this.nodes.length},parse:function(t,e){var i,s=/^\s*<(\w+|!)[^>]*>/;if(t){if(t.dom)return this.nodes=t.nodes,t;i="string"!=typeof t?t.nodeType&&11===t.nodeType?t.childNodes:t.nodeType||t===window?[t]:t:s.test(t)?this.create(t):this._query(t,e)}else i=[];this.nodes=this._slice(i)},create:function(t){if(/^<(\w+)\s*\/?>(?:<\/\1>|)$/.test(t))return[document.createElement(RegExp.$1)];var e=[],i=document.createElement("div"),s=i.childNodes;i.innerHTML=t;for(var n=0,o=s.length;o>n;n++)e.push(s[n]);return e},add:function(t){this.nodes=this.nodes.concat(this._toArray(t))},get:function(t){return this.nodes[t||0]||!1},getAll:function(){return this.nodes},eq:function(t){return new a(this.nodes[t])},first:function(){return new a(this.nodes[0])},last:function(){return new a(this.nodes[this.nodes.length-1])},contents:function(){return this.get().childNodes},each:function(t){for(var e=this.nodes.length,i=0;e>i;i++)t.call(this,this.nodes[i].dom?this.nodes[i].get():this.nodes[i],i);return this},is:function(t){return this.filter(t).length>0},filter:function(t){var e;return void 0===t?this:(e="function"==typeof t?t:function(e){return t instanceof Node?t===e:t&&t.dom?-1!==t.nodes.indexOf(e):(e.matches=e.matches||e.msMatchesSelector||e.webkitMatchesSelector,1===e.nodeType?e.matches(t||"*"):!1)},new a(this.nodes.filter(e)))},not:function(t){return this.filter(function(e){return!new a(e).is(t||!0)})},find:function(t){var e=[];return this.each(function(i){for(var s=this._query(t||"*",i),n=0;n<s.length;n++)e.push(s[n])}),new a(e)},children:function(t){var e=[];return this.each(function(t){if(t.children)for(var i=t.children,s=0;s<i.length;s++)e.push(i[s])}),new a(e).filter(t)},parent:function(t){var e=[];return this.each(function(t){t.parentNode&&e.push(t.parentNode)}),new a(e).filter(t)},parents:function(t,e){e=this._getContext(e);var i=[];return this.each(function(s){for(var n=s.parentNode;n&&n!==e;)t?new a(n).is(t)&&i.push(n):i.push(n),n=n.parentNode}),new a(i)},closest:function(t,e){e=this._getContext(e),t=t.dom?t.get():t;var i=[],s=t&&t.nodeType;return this.each(function(n){do if(s&&n===t||new a(n).is(t))return i.push(n);while((n=n.parentNode)&&n!==e)}),new a(i)},next:function(t){return this._getSibling(t,"nextSibling")},nextElement:function(t){return this._getSibling(t,"nextElementSibling")},prev:function(t){return this._getSibling(t,"previousSibling")},prevElement:function(t){return this._getSibling(t,"previousElementSibling")},css:function(t,e){if(void 0===e&&"object"!=typeof t){var i=this.get();return"width"===t||"height"===t?i.style?this._getHeightOrWidth(t,i,!1)+"px":void 0:i.style?getComputedStyle(i,null)[t]:void 0}return this.each(function(i){var s={};"object"==typeof t?s=t:s[t]=e;for(var n in s)i.style&&(i.style[n]=s[n])})},attr:function(t,e,i){if(i=i?"data-":"",void 0===e&&"object"!=typeof t){var s=this.get();return s&&3!==s.nodeType?"checked"===t?s.checked:this._getBooleanFromStr(s.getAttribute(i+t)):void 0}return this.each(function(s){var n={};"object"==typeof t?n=t:n[t]=e;for(var o in n)3!==s.nodeType&&("checked"===o?s.checked=n[o]:s.setAttribute(i+o,n[o]))})},data:function(t,e){if(void 0===t){var i=/^data\-(.+)$/,s=this.get().attributes,n={},o=function(t){return t[1].toUpperCase()};for(var a in s)if(s[a]&&i.test(s[a].nodeName)){var r=s[a].nodeName.match(i)[1],h=s[a].value;r=r.replace(/-([a-z])/g,o),h=this._isObjectString(h)?this._toObject(h):this._isNumber(h)?parseFloat(h):this._getBooleanFromStr(h),n[r]=h}return n}return this.attr(t,e,!0)},val:function(t){if(void 0===t){var e=this.get();return e.type&&"checkbox"===e.type?e.checked:e.value}return this.each(function(e){e.value=t})},removeAttr:function(t){return this.each(function(e){var i=function(t){3!==e.nodeType&&e.removeAttribute(t)};t.split(" ").forEach(i)})},removeData:function(t){return this.each(function(e){var i=function(t){3!==e.nodeType&&e.removeAttribute("data-"+t)};t.split(" ").forEach(i)})},dataset:function(t,e){return this.each(function(s){i[this.dataindex(s)][t]=e})},dataget:function(t){return i[this.dataindex(this.get())][t]},dataindex:function(t){var e=t[s],n=i.length;return e||(e=t[s]=n,i[e]={}),e},addClass:function(t){return this._eachClass(t,"add")},removeClass:function(t){return this._eachClass(t,"remove")},toggleClass:function(t){return this._eachClass(t,"toggle")},hasClass:function(t){return this.nodes.some(function(e){return e.classList?e.classList.contains(t):!1})},empty:function(){return this.each(function(t){t.innerHTML=""})},html:function(t){return void 0===t?this.get().innerHTML||"":this.empty().append(t)},text:function(t){return void 0===t?this.get().textContent||"":this.each(function(e){e.textContent=t})},after:function(t){return this._inject(t,function(t,e){if("string"==typeof t)e.insertAdjacentHTML("afterend",t);else for(var i=t instanceof Node?[t]:this._toArray(t).reverse(),s=0;s<i.length;s++)e.parentNode.insertBefore(i[s],e.nextSibling);return e})},before:function(t){return this._inject(t,function(t,e){if("string"==typeof t)e.insertAdjacentHTML("beforebegin",t);else for(var i=t instanceof Node?[t]:this._toArray(t),s=0;s<i.length;s++)e.parentNode.insertBefore(i[s],e);return e})},append:function(t){return this._inject(t,function(t,e){if("string"==typeof t||"number"==typeof t)e.insertAdjacentHTML("beforeend",t);else for(var i=t instanceof Node?[t]:this._toArray(t),s=0;s<i.length;s++)e.appendChild(i[s]);return e})},prepend:function(t){return this._inject(t,function(t,e){if("string"==typeof t||"number"==typeof t)e.insertAdjacentHTML("afterbegin",t);else for(var i=t instanceof Node?[t]:this._toArray(t).reverse(),s=0;s<i.length;s++)e.insertBefore(i[s],e.firstChild);return e})},wrap:function(t){return this._inject(t,function(t,e){var i="string"==typeof t||"number"==typeof t?this.create(t)[0]:t instanceof Node?t:this._toArray(t)[0];return e.parentNode&&e.parentNode.insertBefore(i,e),i.appendChild(e),new a(i)})},unwrap:function(){return this.each(function(t){var e=new a(t);return e.replaceWith(e.contents())})},replaceWith:function(t){return this._inject(t,function(t,e){for(var i=document.createDocumentFragment(),s="string"==typeof t||"number"==typeof t?this.create(t):t instanceof Node?[t]:this._toArray(t),n=0;n<s.length;n++)i.appendChild(s[n]);var o=i.childNodes[0];return e.parentNode.replaceChild(i,e),o})},remove:function(){return this.each(function(t){t.parentNode&&t.parentNode.removeChild(t)})},clone:function(t){var e=[];return this.each(function(i){var s=this._clone(i);t&&(s=this._cloneEvents(i,s)),e.push(s)}),new a(e)},show:function(){return this.each(function(t){if(t.style&&this._hasDisplayNone(t)){var e,i=t.getAttribute("domTargetShow"),s=t.classList?t.classList.contains(n):!1,a=t.classList?t.classList.contains(o):!1;s?(e=n,t.classList.remove(n)):a?(e=o,t.classList.remove(o)):t.style.display=i?i:"block",e&&t.setAttribute("domTargetHide",e),t.removeAttribute("domTargetShow")}}.bind(this))},hide:function(){return this.each(function(t){if(t.style&&!this._hasDisplayNone(t)){var e=t.style.display,i=t.getAttribute("domTargetHide");i===n?t.classList.add(n):i===o?t.classList.add(o):("block"!==e&&t.setAttribute("domTargetShow",e),t.style.display="none"),t.removeAttribute("domTargetHide")}})},scrollTop:function(t){var e=this.get(),i=e===window,s=9===e.nodeType,n=s?document.scrollingElement||document.body.parentNode||document.body||document.documentElement:e;return void 0!==t?void(i?window.scrollTo(0,t):n.scrollTop=t):s?"undefined"!=typeof window.pageYOffset?window.pageYOffset:document.documentElement.scrollTop?document.documentElement.scrollTop:document.body.scrollTop?document.body.scrollTop:0:i?window.pageYOffset:n.scrollTop},offset:function(){return this._getDim("Offset")},position:function(){return this._getDim("Position")},width:function(t,e){return this._getSize("width","Width",t,e)},height:function(t,e){return this._getSize("height","Height",t,e)},outerWidth:function(){return this._getInnerOrOuter("width","outer")},outerHeight:function(){return this._getInnerOrOuter("height","outer")},innerWidth:function(){return this._getInnerOrOuter("width","inner")},innerHeight:function(){return this._getInnerOrOuter("height","inner")},click:function(){return this._triggerEvent("click")},focus:function(){return this._triggerEvent("focus")},trigger:function(t){return this.each(function(e){for(var i=t.split(" "),s=0;s<i.length;s++){var n,o={bubbles:!0,cancelable:!0};try{n=new window.CustomEvent(i[s],o)}catch(a){n=document.createEvent("CustomEvent"),n.initCustomEvent(i[s],!0,!0)}e.dispatchEvent(n)}})},on:function(t,e,i){return this.each(function(s){for(var n=t.split(" "),o=0;o<n.length;o++){var a=this._getEventName(n[o]),r=this._getEventNamespace(n[o]);e=i?this._getOneHandler(e,t):e,s.addEventListener(a,e),s._e=s._e||{},s._e[r]=s._e[r]||{},s._e[r][a]=s._e[r][a]||[],s._e[r][a].push(e)}})},one:function(t,e){return this.on(t,e,!0)},off:function(t,e){var i=function(t,e,i){return t===i},s=function(t,e,i,s){return e===s},n=function(t,e,i,s){return t===i&&e===s},o=function(){return!0};return void 0===t?this.each(function(t){this._offEvent(t,!1,!1,e,o)}):this.each(function(o){for(var a=t.split(" "),r=0;r<a.length;r++){var h=this._getEventName(a[r]),d=this._getEventNamespace(a[r]);"_events"===d?this._offEvent(o,h,d,e,i):h||"_events"===d?this._offEvent(o,h,d,e,n):this._offEvent(o,h,d,e,s)}})},serialize:function(t){for(var e={},i=this.get().elements,s=0;s<i.length;s++){var n=i[s];if((!/(checkbox|radio)/.test(n.type)||n.checked)&&n.name&&!n.disabled&&"file"!==n.type){if("select-multiple"===n.type)for(var o=0;o<n.options.length;o++){var a=n.options[o];a.selected&&(e[n.name]=a.value)}e[n.name]=this._isNumber(n.value)?parseFloat(n.value):this._getBooleanFromStr(n.value)}}return t?e:this._toParams(e)},ajax:function(t,i){if("undefined"!=typeof e){var s=this.attr("method")||"post",n={url:this.attr("action"),data:this.serialize(),success:t,error:i};return new e(s,n)}},_queryContext:function(t,e){return e=this._getContext(e),3!==e.nodeType&&"function"==typeof e.querySelectorAll?e.querySelectorAll(t):[]},_query:function(t,e){if(e)return this._queryContext(t,e);if(/^[.#]?[\w-]*$/.test(t)){if("#"===t[0]){var i=document.getElementById(t.slice(1));return i?[i]:[]}return"."===t[0]?document.getElementsByClassName(t.slice(1)):document.getElementsByTagName(t)}return document.querySelectorAll(t)},_getContext:function(t){return t="string"==typeof t?document.querySelector(t):t,t&&t.dom?t.get():t||document},_inject:function(t,e){for(var i=this.nodes.length,s=[];i--;){var n="function"==typeof t?t.call(this,this.nodes[i]):t,o=0===i?n:this._clone(n),r=e.call(this,o,this.nodes[i]);r&&(r.dom?s.push(r.get()):s.push(r))}return new a(s)},_cloneEvents:function(t,e){var i=t._e;if(i){e._e=i;for(var s in i._events)for(var n=0;n<i._events[s].length;n++)e.addEventListener(s,i._events[s][n])}return e},_clone:function(t){return"undefined"!=typeof t?"string"==typeof t?t:t instanceof Node||t.nodeType?t.cloneNode(!0):"length"in t?[].map.call(this._toArray(t),function(t){return t.cloneNode(!0)}):void 0:void 0},_slice:function(t){return t&&0!==t.length?t.length?[].slice.call(t.nodes||t):[t]:[]},_eachClass:function(t,e){return this.each(function(i){if(t){var s=function(t){i.classList&&i.classList[e](t)};t.split(" ").forEach(s)}})},_triggerEvent:function(t){var e=this.get();return e&&3!==e.nodeType&&e[t](),this},_getOneHandler:function(t,e){var i=this;return function(){t.apply(this,arguments),i.off(e)}},_getEventNamespace:function(t){var e=t.split("."),i=e[1]?e[1]:"_events";return e[2]?i+e[2]:i},_getEventName:function(t){return t.split(".")[0]},_offEvent:function(t,e,i,s,n){for(var o in t._e)for(var a in t._e[o])if(n(a,o,e,i))for(var r=t._e[o][a],h=0;h<r.length;h++)"undefined"!=typeof s&&r[h].toString()!==s.toString()||(t.removeEventListener(a,r[h]),t._e[o][a].splice(h,1),0===t._e[o][a].length&&delete t._e[o][a],0===Object.keys(t._e[o]).length&&delete t._e[o])},_getInnerOrOuter:function(t,e){return this[t](void 0,e)},_getDocSize:function(t,e){var i=t.body,s=t.documentElement;return Math.max(i["scroll"+e],i["offset"+e],s["client"+e],s["scroll"+e],s["offset"+e])},_getSize:function(t,e,i,s){if(void 0===i){var n=this.get();return i=3===n.nodeType?0:9===n.nodeType?this._getDocSize(n,e):n===window?window["inner"+e]:this._getHeightOrWidth(t,n,s||"normal"),Math.round(i)}return this.each(function(e){i=parseFloat(i),i+=this._adjustResultHeightOrWidth(t,e,s||"normal"),new a(e).css(t,i+"px")}.bind(this))},_getHeightOrWidth:function(t,e,i){if(!e)return 0;var s=t.charAt(0).toUpperCase()+t.slice(1),n=0,o=getComputedStyle(e,null),r=new a(e),h=r.parents().filter(function(t){return 1===t.nodeType&&"none"===getComputedStyle(t,null).display?t:!1});if("none"===o.display&&h.add(e),0!==h.length){var d="visibility: hidden !important; display: block !important;",l=[];h.each(function(t){var e=new a(t),i=e.attr("style");null!==i&&l.push(i),e.attr("style",null!==i?i+";"+d:d)}),n=r.get()["offset"+s]-this._adjustResultHeightOrWidth(t,e,i),h.each(function(t,e){var i=new a(t);void 0===l[e]?i.removeAttr("style"):i.attr("style",l[e])})}else n=e["offset"+s]-this._adjustResultHeightOrWidth(t,e,i);return n},_adjustResultHeightOrWidth:function(t,e,i){if(!e||i===!1)return 0;var s=0,n=getComputedStyle(e,null),o="border-box"===n.boxSizing;return"height"===t?(("inner"===i||"normal"===i&&o)&&(s+=(parseFloat(n.borderTopWidth)||0)+(parseFloat(n.borderBottomWidth)||0)),"outer"===i&&(s-=(parseFloat(n.marginTop)||0)+(parseFloat(n.marginBottom)||0))):(("inner"===i||"normal"===i&&o)&&(s+=(parseFloat(n.borderLeftWidth)||0)+(parseFloat(n.borderRightWidth)||0)),"outer"===i&&(s-=(parseFloat(n.marginLeft)||0)+(parseFloat(n.marginRight)||0))),s},_getDim:function(t){var e=this.get();return 3===e.nodeType?{top:0,left:0}:this["_get"+t](e)},_getPosition:function(t){return{top:t.offsetTop,left:t.offsetLeft}},_getOffset:function(t){var e=t.getBoundingClientRect(),i=t.ownerDocument,s=i.documentElement,n=i.defaultView;return{top:e.top+n.pageYOffset-s.clientTop,left:e.left+n.pageXOffset-s.clientLeft}},_getSibling:function(t,e){t=t&&t.dom?t.get():t;var i,s=t&&t.nodeType;return this.each(function(n){for(;n=n[e];)if(s&&n===t||new a(n).is(t))return void(i=n)}),new a(i)},_toArray:function(t){if(t instanceof NodeList){for(var e=[],i=0;i<t.length;i++)e[i]=t[i];return e}return void 0===t?[]:t.dom?t.nodes:t},_toParams:function(t){var e="";for(var i in t)e+="&"+this._encodeUri(i)+"="+this._encodeUri(t[i]);return e.replace(/^&/,"")},_toObject:function(t){return new Function("return "+t)()},_encodeUri:function(t){return encodeURIComponent(t).replace(/!/g,"%21").replace(/'/g,"%27").replace(/\(/g,"%28").replace(/\)/g,"%29").replace(/\*/g,"%2A").replace(/%20/g,"+")},_isNumber:function(t){return!isNaN(t)&&!isNaN(parseFloat(t))},_isObjectString:function(t){return-1!==t.search(/^{/)},_getBooleanFromStr:function(t){return"true"===t?!0:"false"===t?!1:t},_hasDisplayNone:function(t){return"none"===t.style.display||"none"===(t.currentStyle?t.currentStyle.display:getComputedStyle(t,null).display)}};var r={};r.app=[],r.version="7.2.1",r.options={},r.modules={},r.services={},r.plugins={},r.classes={},r["extends"]={},r.lang={},r.dom=function(t,e){return new a(t,e)},r.ajax=t,r.Dom=a,r.env={module:"modules",service:"services",plugin:"plugins","class":"classes",extend:"extends"};var h=function(t,e){return r.app=new d(t)};r.init=function(t){return new h(t,[].slice.call(arguments,1))},r.api=function(t){var e=r.app,i=[].slice.call(arguments,1);e&&(i.unshift(t),e.api.apply(e,i))},r.add=function(t,e,i){if("undefined"!=typeof r.env[t])if(i.translations&&(r.lang=r.extend(!0,{},r.lang,i.translations)),"extend"===t)r[r.env[t]][e]=i;else{var s=function(){};if(s.prototype=i,i["extends"])for(var n=0;n<i["extends"].length;n++)r.inherit(s,r["extends"][i["extends"][n]]);r[r.env[t]][e]=s}},r.addLang=function(t,e){"undefined"==typeof r.lang[t]&&(r.lang[t]={}),r.lang[t]=r.extend(r.lang[t],e)},r.create=function(t){var e=t.split("."),i=[].slice.call(arguments,1),s="classes";"undefined"!=typeof r.env[e[0]]&&(s=r.env[e[0]],t=e.slice(1).join("."));var n=new r[s][t];if(n._type=e[0],n._name=t,n.init){var o=n.init.apply(n,i);return o?o:n}return n},r.inherit=function(t,e){var i=function(){};i.prototype=e;var s=new i;for(var n in t.prototype)t.prototype.__lookupGetter__(n)?s.__defineGetter__(n,t.prototype.__lookupGetter__(n)):s[n]=t.prototype[n];return t.prototype=s,t.prototype["super"]=e,t},r.error=function(t){throw t},r.extend=function(){var t={},e=!1,i=0,s=arguments.length;"[object Boolean]"===Object.prototype.toString.call(arguments[0])&&(e=arguments[0],i++);for(var n=function(i){for(var s in i)Object.prototype.hasOwnProperty.call(i,s)&&(e&&"[object Object]"===Object.prototype.toString.call(i[s])?t[s]=r.extend(!0,t[s],i[s]):t[s]=i[s])};s>i;i++){var o=arguments[i];n(o)}return t};var d=function(t){this.modules={},this.services=[],this.queueStart={service:{},module:{}},this.queueStop={service:{},module:{}},this.started=!1,this.stopped=!1,this.namespace="kube",this.dataNamespace="data-kube",this.instancePrefix="kube-instance-",this.rootOpts=t,this.$win=r.dom(window),this.$doc=r.dom(document),this.$body=r.dom("body"),this.coreServices=["options","lang","utils"],this.bindableServices=["opts","lang","utils","$win","$doc","$body"],this.utils=r.create("service.utils",this),this.opts=r.create("service.options",this,"global",t),this.lang=r.create("service.lang",this),this.appcallback=new d.Callback(this),this.appstarter=new d.Starter(this),this.appbuilder=new d.Builder(this),this.appbroadcast=new d.Broadcast(this),this.appapi=new d.Api(this),this.build(),this.start()};d.prototype={build:function(){this.appbuilder.build()},start:function(){this.stopped=!1,this.broadcast("start",this),this.appstarter.start(),this.broadcast("started",this),this.started=!0},stop:function(){this.started=!1,this.stopped=!0,this.broadcast("stop",this),this.appstarter.stop(),this.broadcast("stopped",this)},starter:function(t,e){var i="service"!==t._type?"module":t._type;this.queueStart[i][e]=t._name},stopper:function(t,e){var i="service"!==t._type?"module":t._type;this.queueStop[i][e]=t._name},isStarted:function(){return this.started},isStopped:function(){return this.stopped},broadcast:function(t,e){this.appbroadcast.trigger(t,e,[].slice.call(arguments,2))},on:function(t,e){this.appcallback.add(t,e)},off:function(t,e){this.appcallback.remove(t,e)},api:function(t){return this.appapi.trigger(t,[].slice.call(arguments,1))}},d.Module=function(t,e,i,s){return this.app=t,this.instancePrefix=t.instancePrefix,this.eventTypes=["click","mouseover","mouseout","mousedown","mouseup","mousemove","keydown","keyup","focus","submit","change","contextmenu","input"],this._build(e,i,s)},d.Module.prototype={_build:function(t,e,i){var s=t.dataget(this.instancePrefix+e);if(!s&&"undefined"!=typeof r.modules[e]){var n=new d.Context(this.app,t,i),o=n.getTarget();s=r.create("module."+e,this.app,n),s._id=i,t.dataset(this.instancePrefix+e,s),t.attr("data-loaded",!0),this._delegateModuleEvents(s,t,e),this._delegateModuleCommands(s,t),o.is()&&this._delegateModuleCommands(s,o)}return s},_delegateModuleCommands:function(t,e){e.find("[data-command]").each(function(e){this._delegateCommand(t,e,e.getAttribute("data-command"))}.bind(this))},_delegateCommand:function(t,e,i){"undefined"==typeof t._eventCommands&&(t._eventCommands=[]);var s=this,n=r.dom(e);t._eventCommands.push(n),n.on("click.generatedcommand",function(e){e.preventDefault();var o=n.data();o.event=e,s.app.broadcast(i,t,n,o)})},_delegateModuleEvents:function(t,e,i){e.find("[data-type]").each(function(e){var s=e.getAttribute("data-type").split("."),n=s[0],o=i;2===s.length&&(o=s[0],n=s[1]),o===i&&this._delegateEvent(t,i,e,n)}.bind(this))},_delegateEvent:function(t,e,i,s){"undefined"==typeof t._eventNodes&&(t._eventNodes=[]);var n=r.dom(i),o=function(e,i,s,n,o){return t["on"+i].call(t,e,s,n,o)};t._eventNodes.push(n);for(var a=0;a<this.eventTypes.length;a++){var h="on"+this.eventTypes[a];"function"==typeof t[h]&&n.on(this.eventTypes[a]+".generatedevent",function(t){var e=n.data();o(t,t.type,this,s,e)})}}},d.Context=function(t,e,i){this.app=t,this.opts=t.opts,this.$element=this._buildElement(e),this.params=this._buildParams(),this.name=this._buildName(i),this.$target=this._buildTarget()},d.Context.prototype={getElement:function(){return this.$element},getTarget:function(){return this.$target},getParams:function(t){return t?r.extend({},t,this.params):this.params},getName:function(){return this.name},_buildName:function(t){return this.params.name?this.params.name:t},_buildParams:function(){return r.create("service.options",this.app,"element",this.$element)},_buildElement:function(t){return new d.Element(this.app,t)},_buildTarget:function(){return new d.Target(this.app,this.params.target)}},d.Callback=function(t){this.app=t,this.opts=t.opts,this.callbacks={},this._build()},d.Callback.prototype={stop:function(){this.callbacks={}},add:function(t,e){"undefined"==typeof this.callbacks[t]&&(this.callbacks[t]=[]),this.callbacks[t].push(e)},remove:function(t,e){if(void 0===e)delete this.callbacks[t];else{for(var i=0;i<this.callbacks[t].length;i++)this.callbacks[t].splice(i,1);0===this.callbacks[t].length&&delete this.callbacks[t]}},trigger:function(t,e){if("undefined"!=typeof this.callbacks[t])for(var i=0;i<this.callbacks[t].length;i++)this.callbacks[t][i].apply(this.app,e)},_build:function(){if(this.opts.callbacks)for(var t in this.opts.callbacks)if("function"==typeof this.opts.callbacks[t])"undefined"==typeof this.callbacks[t]&&(this.callbacks[t]=[]),this.callbacks[t].push(this.opts.callbacks[t]);else for(var e in this.opts.callbacks[t])"undefined"==typeof this.callbacks[t+"."+e]&&(this.callbacks[t+"."+e]=[]),this.callbacks[t+"."+e].push(this.opts.callbacks[t][e])}},d.Element=function(t,e){this.app=t,this.parse(e)},d.Element.prototype={isOpened:function(){return!this.isClosed()},isClosed:function(){return this.hasClass("is-hidden")||"none"===this.css("display")}},r.inherit(d.Element,a.prototype),d.Target=function(t,e){this.app=t,this.parse(e)},d.Target.prototype={isOpened:function(){return!this.isClosed()},isClosed:function(){var t=0,e=this.length;return this.each(function(e){var i=r.dom(e);(i.hasClass("is-hidden")||"none"===i.css("display"))&&t++}),t===e}},r.inherit(d.Target,a.prototype),d.Api=function(t){this.app=t,this.modules=t.modules},d.Api.prototype={trigger:function(t,e){var i=t.split("."),s=3===i.length,n=1===i.length,o="on"===i[0]||"off"===i[0],a=i[0],r=i[1],h=!1;if(n?(a=!1,r=i[0]):s&&(r=i[2],h=i[1]),n){if("function"==typeof this.app[r])return this._call(this.app,r,e)}else{if(o)return"on"===a?this.app.on(a,e[0]):this.app.off(a,e[0]||void 0);if(this._isInstanceExists(this.app,a))return this._call(this.app[a],r,e);this._isInstanceExists(this.modules,a)&&this._doApi(a,r,h,e)}},_isInstanceExists:function(t,e){return"undefined"!=typeof t[e]},_doApi:function(t,e,i,s){for(var n in this.modules[t])if(i===!1||i===n){var o=this.modules[t][n];this._call(o,e,s)}},_call:function(t,e,i){return"function"==typeof t[e]?t[e].apply(t,i):void 0}},d.Broadcast=function(t){this.app=t,this.modules=t.modules,this.callback=t.appcallback},d.Broadcast.prototype={trigger:function(t,e,i){Array.isArray(t)?(e._id=t[0],t=t[1]):e&&"undefined"!=typeof e.context&&(e._id=e.context.getName()),i.unshift(e);for(var s in this.modules)for(var n in this.modules[s]){var o=this.modules[s][n];this._call(o,t,i,e)}this.callback.trigger(t,i)},_call:function(t,e,i,s){if("undefined"!=typeof t.onmessage){var n=e.split("."),o=t.onmessage[n[0]];1===n.length&&"function"==typeof o?o.apply(t,i):2===n.length&&"undefined"!=typeof o&&"function"==typeof o[n[1]]&&o[n[1]].apply(t,i)}var n=e.split(".");if(1===n.length)"function"==typeof t["on"+e]&&t["on"+e].apply(t,i);else{n[0]="on"+n[0];var o=this.app.utils.checkProperty(t,n);if("function"==typeof o&&o.apply(t,i),s&&s._id){var a=[n[0],s._id,n[1]],o=this.app.utils.checkProperty(t,a);"function"==typeof o&&o.apply(t,i)}}}},d.Builder=function(t){this.app=t,this.opts=t.opts,this.$doc=t.$doc,this.dataNamespace=t.dataNamespace},d.Builder.prototype={build:function(){this._buildServices(),this._buildModules()},_buildServices:function(){var t=[],e=[];for(var i in r.services)-1===this.app.coreServices.indexOf(i)&&(this.app[i]=r.create("service."+i,this.app),this.app.bindableServices.push(i),t.push(i),e.push(i));for(var s=0;s<this.app.coreServices.length;s++){var i=this.app.coreServices[s];"options"!==i&&t.push(i)}for(var s=0;s<t.length;s++)for(var n=t[s],o=0;o<this.app.bindableServices.length;o++){var a=this.app.bindableServices[o];n!==a&&(this.app[n][a]=this.app[a])}this.app.services=e},_buildModules:function(){this.$doc.find("["+this.dataNamespace+"]").each(function(t,e){var i=r.dom(t),s=i.attr(this.dataNamespace),n=i.attr("id")?i.attr("id"):s+"-"+e;n=i.attr("data-name")?i.attr("data-name"):n;var o=new d.Module(this.app,i,s,n);this._storeElementModule(o,s,n)}.bind(this))},_storeElementModule:function(t,e,i){t&&("undefined"==typeof this.app.modules[e]&&(this.app.modules[e]={}),this.app.modules[e][i]=t)}},d.Starter=function(t){this.app=t,this.queue={start:t.queueStart,stop:t.queueStop},this.priority={start:{service:[],module:[]},stop:{service:[],module:[]}}},d.Starter.prototype={start:function(){this._stopStart("service","start"),this._stopStart("module","start")},stop:function(){this._stopStart("service","stop"),this._stopStart("module","stop")},_stopStart:function(t,e){var i=this.queue[e][t];for(var s in i){var n=i[s],o="service"===t?this.app[n]:this.app.modules[n];this._callInstances(t,e,o),this.priority[e][t].push(n)}var a="service"===t?this.app.services:this.app.modules;for(var s in a){var n="service"===t?a[s]:s;if(-1===this.priority[e][t].indexOf(n)){var o="service"===t?this.app[n]:a[n];this._callInstances(t,e,o)}}},_stopModuleEvents:function(t,e){if("stop"===t){if("undefined"!=typeof e._eventNodes)for(var i=0;i<e._eventNodes.length;i++)e._eventNodes[i].off(".generatedevent");if("undefined"!=typeof e._eventCommands)for(var i=0;i<e._eventCommands.length;i++)e._eventCommands[i].off(".generatedcommand")}},_callInstances:function(t,e,i){if("service"===t)this._call(i,e);else for(var s in i)this._call(i[s],e),this._stopModuleEvents(e,i[s])},_call:function(t,e,i){return"function"==typeof t[e]?t[e].apply(t,i):void 0}},r.add("extend","dom",r.Dom.prototype),r.add("service","animate",{init:function(t){this.app=t,this.animationOpt=!0},run:function(t,e,i){return new r.AnimatePlay(this.app,t,e,i,this.animationOpt)},remove:function(t){this.$el=r.dom(t);var e=this.$el.attr("kube-animate-effect");this.$el.hide(),this.$el.removeClass(e),this.$el.off("animationend webkitAnimationEnd")}}),r.AnimatePlay=function(t,e,i,s,n){this.hidableEffects=["fadeOut","flipOut","slideUp","zoomOut","slideOutUp","slideOutRight","slideOutLeft"],this.prefix="kube-",this.prefixes=["","-webkit-"],this.utils=t.utils,this.$el=r.dom(e),this.$body=r.dom("body"),this.callback=s,this.animation=n?i:this._buildAnimationOff(i),this._setHeight(),this._isAnimate()?this._animate():this._toggle()},r.AnimatePlay.prototype={_setHeight:function(){"slideUp"!==this.animation&&"slideDown"!==this.animation||this.$el.height(this.$el.height())},_buildAnimationOff:function(t){return this._isHidable(t)?"hide":"show"},_isAnimate:function(){return"show"!==this.animation&&"hide"!==this.animation},_isHidable:function(t){return-1!==this.hidableEffects.indexOf(t)},_clean:function(){this.$body.removeClass("is-no-scroll-x"),this.$el.removeClass(this.prefix+this.animation),this.$el.removeAttr("kube-animate-effect")},_toggle:function(){"show"===this.animation?this.$el.show():this.$el.hide(),"function"==typeof this.callback&&this.callback(this)},_animate:function(){this.$body.addClass("is-no-scroll-x"),this.$el.show(),this.$el.addClass(this.prefix+this.animation),this.$el.attr("kube-animate-effect",this.prefix+this.animation),this._complete()},_complete:function(){this.$el.one("animationend webkitAnimationEnd",function(t){this.$el.hasClass(this.prefix+this.animation)&&this._clean(),this._isHidable(this.animation)&&this.$el.hide(),"slideUp"!==this.animation&&"slideDown"!==this.animation||this.$el.css("height",""),"function"==typeof this.callback&&this.callback(this.$el)}.bind(this))}},r.add("service","transition",{init:function(t){this.transitionOpt=!0},run:function(t,e){return new r.TransitionPlay(e,t,this.transitionOpt)},remove:function(t){this.$el=r.dom(t);var e=this.$el.attr("kube-transition-class");e&&(this.$el.removeClass(e),this.$el.removeAttr("kube-transition-class"));var i=this.$el.attr("kube-transition-css");if(i){for(var s=i.split(","),n=0;n<s.length;n++)this.$el.css(s[n],"");this.$el.removeAttr("kube-transition-css")}this.$el.off("transitionend webkitTransitionEnd")}}),r.TransitionPlay=function(t,e,i){this.$el=r.dom(e),this.params=t,this._transition()},r.TransitionPlay.prototype={_transition:function(){if(this.params.classname&&(this.$el.addClass(this.params.classname),this.$el.attr("kube-transition-class",this.params.classname)),this.params.css){this.$el.css(this.params.css);var t=[];for(var e in this.params.css)t.push(e);this.$el.attr("kube-transition-css",t.join(","))}this._complete()},_complete:function(){this.$el.one("transitionend webkitTransitionEnd",function(t){"function"==typeof this.params.callback&&this.params.callback(this.$el)}.bind(this))}},r.add("service","lang",{init:function(t){this.app=t,this.opts=t.opts;var e=this.opts.lang?this.opts.lang:"en";this.vars=this.build(e)},build:function(t){return t=void 0===r.lang[t]?"en":t,void 0!==r.lang[t]?r.lang[t]:[]},rebuild:function(t){this.opts.lang=t,this.vars=this.build(t)},extend:function(t){this.vars=r.extend(this.vars,t)},parse:function(t){if(void 0===t)return"";var e=t.match(/## (.*?) ##/g);if(e)for(var i=0;i<e.length;i++){var s=e[i].replace(/^##\s/g,"").replace(/\s##$/g,"");
|
|
t=t.replace(e[i],this.get(s))}return t},get:function(t){return"undefined"!=typeof this.vars[t]?this.vars[t]:""}}),r.add("service","options",{init:function(t,e,i){return this.app=t,this.utils=t.utils,"global"===e?this._build(i):this._buildElement(i)},_build:function(t){return t?this._extendFromElements(t):{}},_buildElement:function(t){return r.extend({},t.data())},_extendFromElements:function(t){return t.hasOwnProperty("append")?this.utils.extendData(t,t.append):t}}),r.add("service","response",{init:function(t){this.app=t},parse:function(t){if(""===t)return!1;var e="object"==typeof t?t:JSON.parse(t);if(void 0!==e[0])for(var i in e)this._parseItem(e[i]);else this._parseItem(e);return e},_parseItem:function(t){if("location"===t.type)top.location.href=t.data;else if("message"===t.type)this.message.show(t.data);else for(var e in t.data){var i=t.data[e],s=r.dom(e);"value"===t.type?(i=null===i||i===!1?0:i,i=i===!0?1:i,s.val(i)):"html"===t.type?(i=null===i||i===!1?"":i,s.html(this._stripslashes(i))):"addClass"===t.type?s.addClass(i):"removeClass"===t.type?s.removeClass(i):"show"===t.type?s.removeClass("is-hidden"):"hide"===t.type?s.addClass("is-hidden"):"animate"===t.type&&this.animate.run(s,i)}return t},_stripslashes:function(t){return(t+"").replace(/\0/g,"0").replace(/\\([\\'"])/g,"$1")}}),r.add("service","progress",{init:function(t){this.app=t,this.$body=t.$body,this.defaults={selector:"kube-progress",target:!1,value:100},this.$progress=!1,this.$progressBar=!1},stop:function(){if(this.$progress=!1,this.$progressBar=!1,r.dom("#"+this.params.selector).remove(),this.params.target){var t=r.dom(this.params.target);t.removeClass("is-relative")}},show:function(t){this._buildDefaults(t),this._build()},hide:function(t){this.$progress&&(this._buildDefaults(t),this.animate.run(this.$progress,"fadeOut",this.stop.bind(this)))},update:function(t){this._buildDefaults(t),this.$progress||this._build(),this._setValue()},_buildDefaults:function(t){this.params=r.extend({},this.defaults,t)},_build:function(){if(this.stop(),this.$progress=r.dom("<div>"),this.$progress.attr("id",this.params.selector),this.$progress.addClass(this.params.selector),this.$progressBar=r.dom("<span>"),this.$progress.append(this.$progressBar),this.params.target){var t=r.dom(this.params.target);"static"===t.css("position")&&t.addClass("is-relative"),t.append(this.$progress)}else this.$progress.addClass("is-fixed"),this.$body.append(this.$progress)},_setValue:function(){this.$progressBar.css("width",this.params.value+"%")}}),r.add("service","message",{init:function(t){this.app=t,this.defaults={name:!1,delay:7,message:"",position:"right",positions:["is-left","is-right","is-center","is-centered","is-line"],type:!1,types:["is-error","is-success","is-focus","is-black"],selector:"kube-message"},this.currentAnimation=[],this.animation={line:["slideInDown","slideOutUp"],centered:["slideInDown","slideOutUp"],left:["slideInLeft","slideOutLeft"],right:["slideInRight","slideOutRight"]},this.$message=!1,this.timeout=!1},stop:function(){clearTimeout(this.timeout),r.dom("#"+this.params.selector).remove(),this.$message=!1,this.$doc.off(".kube.message")},show:function(t){this._buildDefaults(t),this.stop(),this._build(),this._open()},hide:function(t){this._buildDefaults(t),this._close()},_broadcast:function(t){t="message."+t,t=this.params.name!==!1?[this.params.name,t]:t,this.app.broadcast(t,this)},_buildDefaults:function(t){this.params=r.extend({},this.defaults,t)},_buildAnimation:function(){this.currentAnimation=this.animation[this.params.position]},_buildClose:function(){this.$message.on("click.kube.message",this._close.bind(this))},_buildType:function(){this.params.type&&(this.$message.removeClass(this.params.types.join(" ")),this.$message.addClass(this.params.type))},_buildPosition:function(){this.$message.removeClass(this.params.positions.join(" ")),this.$message.addClass("is-"+this.params.position)},_buildMessage:function(){this.$message.html(this.params.message)},_build:function(){this.$message=r.dom("<div>"),this.$message.attr("id",this.params.selector),this.$message.addClass("message is-hidden"),this.$body.append(this.$message)},_handleKeyboard:function(t){27===t.which&&this._close()},_open:function(){this._broadcast("open"),this._buildClose(),this._buildType(),this._buildPosition(),this._buildAnimation(),this._buildMessage(),this.animate.run(this.$message,this.currentAnimation[0],this._opened.bind(this))},_close:function(t){this.$message&&(this._broadcast("close"),this.animate.run(this.$message,this.currentAnimation[1],this._closed.bind(this)))},_opened:function(){this.$doc.on("keyup.kube.message",this._handleKeyboard.bind(this)),this.timeout=setTimeout(this._close.bind(this),1e3*this.params.delay),this._broadcast("opened")},_closed:function(){this.stop(),this._broadcast("closed")}}),r.add("service","modal",{init:function(t){this.app=t,this.defaults={target:!1,name:!1,url:!1,title:!1,width:"600px",height:!1,handle:!1,commands:!1},this.$box=!1,this.$modal=!1},stop:function(){this.$box&&(this.$box.remove(),this.$box=!1,this.$modal=!1,this.$doc.off(".kube.modal"),this.$win.off(".kube.modal")),this.$overlay&&this.$overlay.remove()},open:function(t){this._buildDefaults(t),this.params.url?this._openUrl():this.params.target&&this._openTarget()},close:function(){this._close()},resize:function(){this.$modal.setWidth(this.params.width),this.$modal.updatePosition()},_broadcast:function(t){t="modal."+t,this.app.broadcast([this.params.name,t],this,this.$modal,this.$modalForm)},_isOpened:function(){return this.$modal&&this.$modal.hasClass("is-open")},_openUrl:function(){r.ajax.post({url:this.params.url,success:this._doOpen.bind(this)})},_openTarget:function(){var t=r.dom(this.params.target).clone().html();this._doOpen(t)},_doOpen:function(t){this.stop(),this._isDesktop()||document.activeElement.blur(),this._createModal(t),this._buildModalBox(),this._buildOverlay(),this._buildModal(),this._buildModalForm(),this._buildModalCommands(),this.$modal.updatePosition(),this._broadcast("open"),this.animate.run(this.$box,"fadeIn",this._opened.bind(this)),this.animate.run(this.$overlay,"fadeIn")},_opened:function(){this.$modal.addClass("is-open"),this.$box.on("mousedown.kube.modal",this._close.bind(this)),this.$doc.on("keyup.kube.modal",this._handleEscape.bind(this)),this.$win.on("resize.kube.modal",this.resize.bind(this)),this.$modal.getBody().find("input[type=text],input[type=url],input[type=email]").on("keydown.kube.modal",this._handleEnter.bind(this)),this._broadcast("opened")},_close:function(t){if(this.$box&&this._isOpened()){if(t){if(!this._needToClose(t.target))return;t.stopPropagation(),t.preventDefault()}this._broadcast("close"),this.animate.run(this.$box,"fadeOut",this._closed.bind(this)),this.animate.run(this.$overlay,"fadeOut")}},_closed:function(){this.$modal.removeClass("is-open"),this.$box.off(".kube.modal"),this.$doc.off(".kube.modal"),this.$win.off(".kube.modal"),this._broadcast("closed")},_createModal:function(t){this.$modal=r.create("class.modal.element",this.app,t)},_buildDefaults:function(t){this.params=r.extend({},this.defaults,t)},_buildModalBox:function(){this.$box=r.dom("<div>"),this.$box.attr("id","kube-modal"),this.$box.addClass("modal-box is-hidden"),this.$box.html(""),this.$body.append(this.$box)},_buildOverlay:function(){this.$overlay=r.dom("#kube-overlay"),0===this.$overlay.length&&(this.$overlay=r.dom("<div>"),this.$overlay.attr("id","kube-overlay"),this.$overlay.addClass("overlay is-hidden"),this.$body.prepend(this.$overlay))},_buildModal:function(){this.$box.append(this.$modal),this.$modal.setTitle(this.params.title),this.$modal.setHeight(this.params.height),this.$modal.setWidth(this.params.width)},_buildModalCommands:function(){if(this.params.commands){var t=this.params.commands,e=this.$modal.getFooter();for(var i in t){var s=r.dom("<button>");s.addClass("button"),s.html(t[i].title),s.attr("data-command",i),"undefined"!=typeof t[i].classname&&s.addClass(t[i].classname),"undefined"!=typeof t[i].close?(s.attr("data-action","close"),s.on("click",this._close.bind(this))):s.on("click",this._handleCommand.bind(this)),e.append(s)}}},_buildModalForm:function(){this.$modalForm=r.create("modal.form",this.app,this.$modal.getForm())},_needToClose:function(t){var e=r.dom(t);return!("close"!==e.attr("data-action")&&!this.$modal.isCloseNode(t)&&0!==e.closest(".modal").length)},_handleCommand:function(t){var e=r.dom(t.target).closest("button"),i=e.attr("data-command");"cancel"!==i&&t.preventDefault(),this._broadcast(i)},_handleEnter:function(t){13===t.which&&this.params.handle&&(t.preventDefault(),this._broadcast(this.params.handle))},_handleEscape:function(t){27===t.which&&this._close()},_isDesktop:function(){return!/(iPhone|iPod|iPad|Android)/.test(navigator.userAgent)}}),r.add("class","modal.form",{"extends":["dom"],init:function(t,e){this.app=t,this.build(e)},build:function(t){this.parse(t)},getData:function(){var t={};return this.find("[name]").each(function(e){var i=r.dom(e);t[i.attr("name")]=i.val()}),t},setData:function(t){this.find("[name]").each(function(e){var i=r.dom(e),s=i.attr("name");t.hasOwnProperty(s)&&(e.type&&"checkbox"===e.type?e.checked=t[s]:i.val(t[s]))})},getItem:function(t){return this.find("[name="+t+"]")}}),r.add("class","modal.element",{"extends":["dom"],init:function(t,e){this.app=t,this.opts=t.opts,this.$win=t.$win,this._init(e)},getForm:function(){return this.find("form")},getHeader:function(){return this.$modalHeader},getBody:function(){return this.$modalBody},getFooter:function(){return this.$modalFooter},setTitle:function(t){t&&this.$modalHeader.html(t)},setWidth:function(t){t=parseInt(t)>=this.$win.width()?"96%":t,this.css("max-width",t)},setHeight:function(t){t!==!1&&this.$modalBody.css("height",t)},updatePosition:function(){var t=this.width();this.css({left:"50%","margin-left":"-"+t/2+"px"});var e=this.$win.height(),i=this.height(),s=e/2-i/2;e>i&&0!==s&&this.css("margin-top",s+"px")},isCloseNode:function(t){return t===this.$modalClose.get()},_init:function(t){this._build(),this._buildClose(),this._buildHeader(),this._buildBody(),this._buildFooter(),this._buildTemplate(t)},_build:function(){this.parse("<div>"),this.addClass("modal"),this.attr("dir",this.opts.direction)},_buildClose:function(){this.$modalClose=r.dom("<span>"),this.$modalClose.addClass("close"),this.append(this.$modalClose)},_buildHeader:function(){this.$modalHeader=r.dom("<div>"),this.$modalHeader.addClass("modal-header"),this.append(this.$modalHeader)},_buildBody:function(){this.$modalBody=r.dom("<div>"),this.$modalBody.addClass("modal-body"),this.append(this.$modalBody)},_buildFooter:function(){this.$modalFooter=r.dom("<div>"),this.$modalFooter.addClass("modal-footer"),this.append(this.$modalFooter)},_buildTemplate:function(t){this.$modalBody.html(t)}}),r.add("service","observer",{init:function(t){this.app=t,this.opts=t.opts,this._isObserve()&&this._build()},_isObserve:function(){return"undefined"!=typeof this.opts.observer&&window.MutationObserver},_build:function(){var t=this,e=new MutationObserver(function(e){e.forEach(function(e){var i=e.addedNodes;0===i.length||1===i.length&&3===i.nodeType||t._iterate()})});e.observe(document,{subtree:!0,childList:!0})},_iterate:function(){var t=this,e=r.dom("[data-kube]").not("[data-loaded]");e.each(function(e,i){var s=r.dom(e),n=s.attr("data-kube"),o=s.attr("id")?s.attr("id"):n+"-"+(t.app.servicesIndex+i),a=new d.Module(t.app,s,n,o);t._storeElementModule(a,n,o),t._call(a,"start")}),"undefined"!=typeof $R&&$R("[data-redactor]")},_call:function(t,e,i){return"function"==typeof t[e]?t[e].apply(t,i):void 0},_storeElementModule:function(t,e,i){t&&("undefined"==typeof this.app.modules[e]&&(this.app.modules[e]={}),this.app.modules[e][i]=t)}}),r.add("service","utils",{init:function(t){this.app=t},parseOptsString:function(t){var e=t.replace("{","").replace("}","").trim().replace(/;$/,"").split(";"),i={};return e.forEach(function(t){var e=t.split(":");i[e[0].trim()]=e[1].trim().replace(/'/g,"")}),i},ucfirst:function(t){return t.charAt(0).toUpperCase()+t.slice(1)},checkProperty:function(t){for(var e=arguments[1]&&Array.isArray(arguments[1])?arguments[1]:[].slice.call(arguments,1),i=0;i<e.length;i++){if(!t||"undefined"==typeof t[e[i]])return!1;t=t[e[i]]}return t},extendData:function(t,e){if("object"==typeof e)t=r.extend({},t,e);else if("string"==typeof e){var i=r.dom(e);i.each(function(e){var i=r.dom(e);if("FORM"===e.tagName)t=r.extend({},t,i.serialize(!0));else{var s=i.attr("name")?i.attr("name"):i.attr("id"),n=i.val();t[s]=this._isNumber(n)?parseFloat(n):this._getBooleanFromStr(n)}})}return t},_isNumber:function(t){return!isNaN(t)&&!isNaN(parseFloat(t))},_getBooleanFromStr:function(t){return"true"===t?!0:"false"===t?!1:t}}),window.Kube=window.$K=r}(),function(t){t.add("module","alert",{init:function(t,e){this.app=t,this.animate=t.animate,this.context=e,this.$element=e.getElement()},onclick:function(t,e,i){"close"===i&&this.close(t)},open:function(t){this.$element.isOpened()||(t&&t.preventDefault(),this.app.broadcast("alert.open",this),this.animate.run(this.$element,"fadeIn",this._opened.bind(this)))},close:function(t){this.$element.isClosed()||(t&&t.preventDefault(),this.app.broadcast("alert.close",this),this.animate.run(this.$element,"fadeOut",this._closed.bind(this)))},_opened:function(){this.app.broadcast("alert.opened",this)},_closed:function(){this.app.broadcast("alert.closed",this)}})}(Kube),function(t){t.add("module","toggle",{init:function(t,e){this.app=t,this.animate=t.animate;var i={target:!1};this.context=e,this.params=e.getParams(i),this.$element=e.getElement(),this.$target=e.getTarget()},start:function(){this.$element.on("click.kube.toggle",this.toggle.bind(this))},stop:function(){this.$element.off(".kube.toggle")},toggle:function(t){return this.$target.isOpened()?this.close(t):this.open(t)},open:function(t){this.$target.isOpened()||(t&&t.preventDefault(),this.app.broadcast("toggle.open",this),this.animate.run(this.$target,"slideDown",this._opened.bind(this)))},close:function(t){this.$target.isClosed()||(t&&t.preventDefault(),this.app.broadcast("toggle.close",this),this.animate.run(this.$target,"slideUp",this._closed.bind(this)))},_opened:function(){this.app.broadcast("toggle.opened",this)},_closed:function(){this.app.broadcast("toggle.closed",this)}})}(Kube),function(t){t.add("module","sticky",{init:function(t,e){this.app=t,this.$win=t.$win;var i={offset:0};this.context=e,this.params=e.getParams(i),this.$element=e.getElement()},start:function(){this.offsetTop=this._getOffsetTop(),this._load(),this.$win.on("scroll.kube.sticky",this._load.bind(this))},stop:function(){this.$win.off("scroll.kube.sticky"),this.$element.removeClass("fixed").css("top","")},_load:function(){return this._isFix()?this._setFixed():this._setUnfixed()},_isFix:function(){return this.$win.scrollTop()>this.offsetTop+parseInt(this.params.offset,10)},_setFixed:function(){this.$element.addClass("is-fixed").css("top",this.params.offset),this.app.broadcast("sticky.fixed",this)},_setUnfixed:function(){this.$element.removeClass("is-fixed").css("top",""),this.app.broadcast("sticky.unfixed",this)},_getOffsetTop:function(){return this.$element.offset().top}})}(Kube),function(t){t.add("module","offcanvas",{init:function(t,e){this.app=t,this.$doc=t.$doc,this.$body=t.$body,this.utils=t.utils,this.animate=t.animate,this.transition=t.transition;var i={clickOutside:!0,target:!1};this.context=e,this.params=e.getParams(i),this.$element=e.getElement(),this.$target=e.getTarget(),this._build()},start:function(){this.$element.on("click.kube.offcanvas",this.toggle.bind(this))},stop:function(){this._clear()},toggle:function(t){return this.$target.isOpened()?this.close(t):this.open(t)},open:function(t){return t&&(t.stopPropagation(),t.preventDefault()),this._clear(),this.$body.addClass("is-no-scroll-x"),this.$target.addClass("is-offcanvas"),this.targetWidth=this.$target.width(),this._resize(),this.app.broadcast("offcanvas.open",this),this.isSlide?this._openSlide():this._openPush()},close:function(e){if(!this.eventScroll){if(e){var i=t.dom(e.target),s=i.get(),n="A"===s.tagName||"BUTTON"===s.tagName;n&&s!==this.$element.get()||(e.stopPropagation(),e.preventDefault())}return this.app.broadcast("offcanvas.close",this),this.isSlide?this._closeSlide():this._closePush()}},_build:function(){this.isSlide=!this.$target.hasClass("is-offcanvas-push"),this.slideDirection=this.$target.hasClass("is-offcanvas-right")?"Right":"Left",this.pushSign="Left"===this.slideDirection?"":"-",this.eventScroll=!1},_handleKeyboard:function(t){27===t.which&&this.close()},_openSlide:function(){this.animate.run(this.$target,"slideIn"+this.slideDirection,this._opened.bind(this))},_openPush:function(){this.$target.show(),this._pushBody(this.pushSign+this.targetWidth+"px",this._opened.bind(this))},_opened:function(){this.$doc.on("touchmove.kube.offcanvas",function(){this.eventScroll=!0}.bind(this)),this.$doc.on("touchstart.kube.offcanvas",function(){this.eventScroll=!1}.bind(this)),this.$doc.on("keyup.kube.offcanvas",this._handleKeyboard.bind(this)),this.params.clickOutside&&this.$doc.on("click.kube.offcanvas touchend.kube.offcanvas",this.close.bind(this)),this.app.broadcast("offcanvas.opened",this)},_closeSlide:function(){this.animate.run(this.$target,"slideOut"+this.slideDirection,this._closed.bind(this))},_closePush:function(){this._pushBody("0",this._closed.bind(this))},_closed:function(){this.$doc.off(".kube.offcanvas"),this.$body.removeClass("is-no-scroll-x"),this.transition.remove(this.$body),this.$target.removeClass("is-offcanvas"),this.$target.hide(),this.app.broadcast("offcanvas.closed",this)},_pushBody:function(t,e){var i={classname:"is-offcanvasTransition",css:{transform:"translateX("+t+")"},callback:e};this.transition.run(this.$body,i,e)},_resize:function(){var t=function(){this.$target.height(this.$doc.height())}.bind(this);t(),this.$doc.on("resize.kube.offcanvas",t)},_clear:function(){this.$doc.off(".kube.offcanvas"),this.transition.remove(this.$body),t.dom(".is-offcanvas").each(function(e){var i=t.dom(e);this.animate.remove(i),i.hide(),i.removeClass("is-offcanvas")}.bind(this))}})}(Kube),function(t){t.add("module","tabs",{init:function(e,i){this.app=e,this.$body=e.$body;var s={equal:!1};this.context=i,this.params=i.getParams(s),this.$element=i.getElement(),this.$boxes=t.dom([]),this.$tabActive=!1,this.$boxActive=!1},start:function(){this._buildControls(),this._buildBoxes(),this._setEqualBoxes(),this._open()},stop:function(){this.$tabsControls.off(".kube.tabs")},getActiveTab:function(){return this.$tabActive},getActiveBox:function(){return this.$boxActive},_toggle:function(e){e&&(e.stopPropagation(),e.preventDefault());var i=t.dom(e.target);this._getBox(i);i.hasClass("is-active")||(this._open(i),this.app.broadcast("tabs.opened",this))},_buildControls:function(){this.$tabsControls=this.$element.find("a"),this.$tabsControls.on("click.kube.tabs",this._toggle.bind(this))},_buildBoxes:function(){this.$tabsControls.each(function(e,i){var s=t.dom(e),n=this._getBox(s);this.$boxes.add(n),0===i&&(this.$tabActive=s),s.hasClass("is-active")&&(this.$tabActive=s)}.bind(this))},_open:function(t){this.$tabActive=t?t:this.$tabActive,this.$tabsControls.removeClass("is-active"),this.$tabActive.addClass("is-active"),this.$boxActive=this._getBox(this.$tabActive),this.$boxes.addClass("is-hidden").removeClass("is-open"),this.$boxActive.removeClass("is-hidden").addClass("is-open")},_getBox:function(e){return t.dom(e.attr("href"))},_setEqualBoxes:function(){if(this.params.equal){var t=this._getItemMaxHeight()+"px";this.$boxes.css("min-height",t)}},_getItemMaxHeight:function(){var e=0;return this.$boxes.each(function(i){var s=t.dom(i),n=s.height();e=n>e?n:e}),e}})}(Kube),function(t){t.add("module","dropdown",{init:function(t,e){this.app=t,this.$doc=t.$doc,this.$win=t.$win,this.$body=t.$body,this.utils=t.utils,this.animate=t.animate;var i={target:!1};this.context=e,this.params=e.getParams(i),this.$element=e.getElement(),this.$target=e.getTarget(),this.animationOpen="slideDown",this.animationClose="slideUp"},start:function(){this.$element.on("click.kube.dropdown",this.toggle.bind(this))},stop:function(){this.animate.clear(this.$target),this.$target.hide(),this.$element.off(".kube.dropdown"),this.$doc.off(".kube.dropdown"),this.$win.off(".kube.dropdown")},toggle:function(t){return this.$target.isOpened()?this.close(t):this.open(t)},open:function(e){this.$target.isOpened()||(e&&(e.stopPropagation(),e.preventDefault()),this.$doc.off(".kube.dropdown"),this.$win.off(".kube.dropdown"),this.$body.find(".dropdown").each(function(e){var i=t.dom(e);this.animate.remove(i),i.hide()}.bind(this)),this._openCaret(),this._setPosition(),this.$element.addClass("dropdown-in"),this.app.broadcast("dropdown.open",this),this.animate.run(this.$target,this.animationOpen,this._opened.bind(this)))},close:function(e){if(!this.$target.isClosed()){if(e){var i=e.target,s=t.dom(i),n="A"===i.tagName||"BUTTON"===i.tagName;(!n||i===this.$element.get()||"A"===i.tagName&&s.hasClass("is-active"))&&(e.stopPropagation(),e.preventDefault())}this.app.broadcast("dropdown.close",this),this.animate.run(this.$target,this.animationClose,this._closed.bind(this))}},_getPlacement:function(){var t=this.$element.position(),e=parseFloat(this.$element.css("height"))+t.top+parseFloat(this.$target.css("height"));return this.$doc.height()<e?"top":"bottom"},_setPosition:function(){var t=parseFloat(this.$element.css("height")),e=this.$element.offset(),i=e.top+t,s=e.left,n=parseFloat(this.$target.css("height")),o=this._getPlacement(),a=parseFloat(this.$target.css("width")),r=parseFloat(this.$element.css("border-left-width"))+parseFloat(this.$element.css("border-right-width")),h=this.$win.width()<s+a?a-this.$element.width()-r:0;"top"===o?(i=i-n-t,this.animationOpen="show",this.animationClose="hide"):(this.animationOpen="slideDown",this.animationClose="slideUp"),this.$target.css({top:i+"px",left:s-h+"px"})},_handleKeyboard:function(t){27===t.which&&this.close()},_opened:function(){this.$doc.on("keyup.kube.dropdown",this._handleKeyboard.bind(this)),this.$doc.on("click.kube.dropdown touchstart.kube.dropdown",this.close.bind(this)),this.$doc.on("scroll.kube.dropdown",this._setPosition.bind(this)),this.$win.on("resize.kube.dropdown",this._setPosition.bind(this)),this.app.broadcast("dropdown.opened",this)},_closed:function(){this.$doc.off(".kube.dropdown"),this.$win.off(".kube.dropdown"),this._closeCaret(),this.$element.removeClass("dropdown-in"),this.app.broadcast("dropdown.closed",this)},_openCaret:function(){var t=this.$element.find(".caret");t.removeClass("is-down").addClass("is-left")},_closeCaret:function(){var t=this.$element.find(".caret");t.removeClass("is-left").addClass("is-down")}})}(Kube); |