!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;ni;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.$progress.attr("id",this.params.selector),this.$progress.addClass(this.params.selector),this.$progressBar=r.dom(""),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("
"),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("
"),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("
"),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("