text: !function(t){t.add("module","autocomplete",{init:function(t,e){this.app=t,this.$doc=t.$doc,this.$win=t.$win,this.$body=t.$body,this.animate=t.animate;this.context=e,this.params=e.getParams({url:!1,min:2,labelClass:!1,target:!1,param:!1}),this.$element=e.getElement(),this.$target=e.getTarget()},start:function(){this._build(),this.timeout=null,this.$element.on("keyup.kube.autocomplete",this._open.bind(this))},stop:function(){this.$box.remove(),this.$element.off(".kube.autocomplete"),this.$doc.off(".kube.autocomplete"),this.$win.off(".kube.autocomplete")},_build:function(){(this.$box=t.dom("<div />"),this.$box.addClass("autocomplete"),this.$box.addClass("is-hidden"),this.$body.append(this.$box),this.$target&&!this._isInputTarget())&&(this.$target.addClass("autocomplete-labels"),this.$target.find(".close").on("click",this._removeLabel.bind(this)))},_open:function(t){t&&t.preventDefault(),clearTimeout(this.timeout),this.$element.val().length>=this.params.min?(this._resize(),this.$win.on("resize.kube.autocomplete",this._resize.bind(this)),this.$doc.on("click.kube.autocomplete",this._close.bind(this)),this.$box.addClass("is-open"),this._listen(t)):this._close(t)},_close:function(t){t&&t.preventDefault(),this.$box.removeClass("is-open"),this.$box.addClass("is-hidden"),this.$doc.off(".kube.autocomplete"),this.$win.off(".kube.autocomplete")},_getPlacement:function(t,e){return this.$doc.height()-(t.top+e)<this.$box.height()?"top":"bottom"},_resize:function(){this.$box.width(this.$element.width())},_getParamName:function(){return this.params.param?this.params.param:this.$element.attr("name")},_getTargetName:function(){var t=this.$target.attr("data-name");return t||this.$target.attr("id")},_lookup:function(){var e=this._getParamName()+"="+this.$element.val();t.ajax.post({url:this.params.url,data:e,success:this._complete.bind(this)})},_complete:function(e){if(this.$box.html(""),0===e.length)return this._close();for(var i=0;i<e.length;i++){var s=t.dom("<a>");s.attr("href","#"),s.attr("rel",e[i].id),s.html(e[i].name),s.on("click",this._set.bind(this)),this.$box.append(s)}var a=this.$element.offset(),n=this.$element.height(),o=this.$element.width(),h="top"===this._getPlacement(a,n)?a.top-this.$box.height()-n:a.top+n;this.$box.css({width:o+"px",top:h+"px",left:a.left+"px"}),this.$box.removeClass("is-hidden")},_listen:function(t){switch(t.which){case 40:t.preventDefault(),this._select("next");break;case 38:t.preventDefault(),this._select("prev");break;case 13:t.preventDefault(),this._set();break;case 27:this._close(t);break;default:this.timeout=setTimeout(this._lookup.bind(this),300)}},_select:function(t){var e=this.$box.find("a"),i=this.$box.find(".is-active");e.removeClass("is-active"),this._selectItem(i,e,t).addClass("is-active")},_selectItem:function(t,e,i){var s,a=0!==t.length,n="next"===i?0:e.length-1;return a&&(s=t[i]()),a&&s&&0!==s.length||(s=e.eq(n)),s},_set:function(e){var i=this.$box.find(".is-active");e&&(e.preventDefault(),i=t.dom(e.target));var s=i.attr("rel"),a=i.html();if(0!==this.$target.length){if(this._isInputTarget())this.$target.val(a);else 0===this.$target.find('[data-id="'+s+'"]').length&&this._addLabel(s,a);this.$element.val("")}else this.$element.val(a);this.$element.focus(),this.app.broadcast("autocomplete.set",this,a),this._close()},_addLabel:function(e,i){var s=t.dom("<span>");s.addClass("label"),s.attr("data-id",e),s.text(i+" "),this.params.labelClass&&s.addClass(this.params.labelClass);var a=t.dom("<span>");a.addClass("close"),a.on("click",this._removeLabel.bind(this));var n=t.dom("<input>");n.attr("type","hidden"),n.attr("name",this._getTargetName()+"[]"),n.val(i),s.append(a),s.append(n),this.$target.append(s)},_isInputTarget:function(){return"INPUT"===this.$target.get().tagName},_removeLabel:function(e){e.preventDefault();var i=t.dom(e.target).closest(".label");this.animate.run(i,"fadeOut",function(){i.remove()}.bind(this))}})}(Kube),function(t){t.add("module","combobox",{init:function(t,e){this.app=t,this.$win=t.$win;this.context=e,this.params=e.getParams({placeholder:""}),this.$element=e.getElement()},start:function(){this._buildSource(),this._buildCaret(),this._buildEvent()},stop:function(){this.$sourceBox.after(this.$element),this.$sourceBox.remove(),this.$element.off(".kube.combobox"),this.$win.off(".kube.combobox")},_buildSource:function(){this.$sourceBox=t.dom("<div>"),this.$sourceBox.addClass("combobox"),this.$source=t.dom("<input>"),this.$source.attr("type","text"),this.$source.attr("placeholder",this.params.placeholder),this.$sourceBox.width(this.$element.width()),this.$sourceBox.append(this.$source),this.$element.after(this.$sourceBox),this.$element.attr("class",""),this.$element.attr("style",""),this.$sourceBox.append(this.$element),this.$win.on("resize.kube.combobox",this._resize.bind(this))},_buildCaret:function(){this.$sourceCaret=t.dom("<span>"),this.$sourceCaret.addClass("combobox-caret"),this.$sourceBox.append(this.$sourceCaret)},_buildEvent:function(){this.$element.on("change.kube.combobox",this._select.bind(this)),this.$source.on("keyup.kube.combobox",this._type.bind(this))},_resize:function(){this.$sourceBox.width(this.$element.width())},_type:function(e){var i=this.$source.val();this.app.broadcast("combobox.set",this,i),this.$sourceValue&&this.$sourceValue.remove(),""!==i.trim()&&(this.$sourceValue=t.dom("<option>"),this.$sourceValue.attr("value",i),this.$sourceValue.attr("selected",!0),this.$sourceValue.text(i),this.$sourceValue.addClass("is-hidden"),this.$element.append(this.$sourceValue))},_select:function(t){var e=t.target,i=e.options[e.selectedIndex].text;this.$sourceValue&&this.$sourceValue.remove(),this.$source.val(i),this.app.broadcast("combobox.set",this,i)}})}(Kube),Kube.add("module","editable",{init:function(t,e){this.app=t,this.context=e,this.params=e.getParams({classname:"editable",focus:!1}),this.$element=e.getElement()},start:function(){this.$element.addClass(this.params.classname).attr("contenteditable",!0),this._setFocus(),this._setEvents()},stop:function(){this.$element.removeClass(this.params.classname).removeAttr("contenteditable"),this.$element.off(".kube.editable")},_setEvents:function(){this.$element.on("keydown.kube.editable",this._keydown.bind(this)),this.$element.on("paste.kube.editable",this._paste.bind(this)),this.$element.on("blur.kube.editable",this._blur.bind(this))},_setFocus:function(){this.params.focus&&this.$element.focus()},_checkEmpty:function(){this.$element.text().replace(" ","").length||this.$element.empty()},_paste:function(t){t.preventDefault();var e=t.originalEvent||t,i="";e.clipboardData?(i=e.clipboardData.getData("text/plain"),document.execCommand("insertText",!1,i)):window.clipboardData&&(i=window.clipboardData.getData("Text"),document.selection.createRange().pasteHTML(i))},_blur:function(t){this._checkEmpty()},_keydown:function(t){13===t.which&&t.preventDefault()}}),function(t){t.add("module","magicquery",{init:function(t,e){this.app=t,this.response=t.response;this.context=e,this.params=e.getParams({url:!1}),this.$element=e.getElement()},start:function(){this.$element.on("click.kube.magicquery",this._send.bind(this))},stop:function(){this._enable(),this.$element.off(".kube.magicquery")},_disable:function(){this.$element.attr("disabled",!0)},_enable:function(){this.$element.removeAttr("disabled")},_send:function(e){e.preventDefault(),this._disable(),t.ajax.post({url:this.params.url,success:this._parse.bind(this)})},_parse:function(t){this._enable();var e=this.response.parse(t);e&&this.app.broadcast("magicquery.success",this,e)}})}(Kube),Kube.add("module","number",{init:function(t,e){this.app=t,this.context=e,this.$element=e.getElement()},start:function(){this.$input=this.$element.find('input[type="number"]'),this.$btnUp=this.$element.find(".is-up"),this.$btnDown=this.$element.find(".is-down"),this._buildStep(),this._buildMin(),this._buildMax(),this._isDisabled()||(this.$btnUp.on("click.kube.number",this._increase.bind(this)),this.$btnDown.on("click.kube.number",this._decrease.bind(this)))},stop:function(){this.$btnUp.off(".kube.number"),this.$btnDown.off(".kube.number")},_buildStep:function(){var t=this.$input.attr("step");this.step=t?parseFloat(t):1},_buildMin:function(){var t=this.$input.attr("min");this.min=!!t&&parseFloat(t)},_buildMax:function(){var t=this.$input.attr("max");this.max=!!t&&parseFloat(t)},_isDisabled:function(){return this.$input.attr("disabled")},_getValue:function(){var t=parseFloat(this.$input.val()),e=!1===this.min?0:this.min;return isNaN(t)?e:t},_increase:function(t){t&&(t.preventDefault(),t.stopPropagation());var e=this._getValue(),i=!1!==this.max&&e>=this.max?e:e+this.step;this.$input.val(i)},_decrease:function(t){t&&(t.preventDefault(),t.stopPropagation());var e=this._getValue(),i=!1!==this.min&&e<=this.min?e:e-this.step;this.$input.val(i)}}),function(t){t.add("module","selector",{init:function(t,e){this.app=t,this.context=e,this.$element=e.getElement()},start:function(){this.$selector=this._buildSelector(),this.$selector.on("change.kube.selector",this._toggle.bind(this))},stop:function(){this.$selector.off(".kube.selector")},_isSelect:function(){return"SELECT"===this.$element.get().tagName},_isHashValue:function(t){return 0===t.search(/^#/)},_buildSelector:function(){return this._isSelect()?this.$element:this.$element.find('input[type="radio"]')},_getValue:function(){return this._isSelect()?this.$selector.val():this.$selector.filter(":checked").val()},_getBoxes:function(){var e=t.dom([]);return(this._isSelect()?this.$selector.find("option"):this.$selector).each(function(i){this._isHashValue(i.value)&&e.add(t.dom(i.value))}.bind(this)),e},_toggle:function(){var e=this._getValue(),i=this._getBoxes(),s=t.dom(e);i.addClass("is-hidden"),s.removeClass("is-hidden"),this.app.broadcast("selector.opened",this,s)}})}(Kube),function(t){t.add("module","slider",{init:function(t,e){this.app=t,this.$win=t.$win,this.$doc=t.$doc;this.context=e,this.params=e.getParams({min:0,max:100,step:1,value:0,target:!1}),this.$element=e.getElement(),this.$target=e.getTarget(),this.isTicks=!1},start:function(){this._buildTrack(),this._buildFill(),this._buildHandle(),this._buildTicks(),this.update(),this.$win.on("resize.kube.slider",this._resize.bind(this)),this.$element.on("mousedown.kube.slider touchstart.kube.slider",this._handleDown.bind(this))},stop:function(){this.$win.off(".kube.slider"),this.$doc.off(".kube.slider"),this.$element.off(".kube.slider")},update:function(t){this.value=t||this.params.value,this.value=this.value<this.params.min?this.params.min:this.value,this.handleWidth=this.$handle.width(),this.trackWidth=this.$track.width(),this.maxHandlePosition=this.trackWidth-this.handleWidth,this.fixPosition=this.handleWidth/2,this.position=this._getPositionFromValue(this.value),this._setPosition(this.position),this._setTarget()},_resize:function(){this._buildTicks(),this.update(this.value)},_isDisabled:function(){return this.$element.hasClass("is-disabled")||this.$element.attr("disabled")},_buildTrack:function(){this.$track=t.dom("<div />"),this.$track.addClass("slider-track"),this.$element.prepend(this.$track)},_buildFill:function(){this.$fill=t.dom("<div />"),this.$fill.addClass("slider-fill"),this.$track.append(this.$fill)},_buildHandle:function(){this.$handle=t.dom("<div />"),this.$handle.addClass("slider-handle"),this.$track.append(this.$handle)},_buildTicks:function(){this.$ticks=this.$element.find(".slider-ticks span");var e=this.$ticks.length;if(this.isTicks=0!==e,this.isTicks){var i=this.$handle.width(),s=i/2,a=(this.$element.width()-i)/(e-1),n=s;this.$ticks.each(function(e,i){var o=t.dom(e),h=n+a*i;o.css({left:h+"px",width:a+"px","text-indent":"-"+(a-s)+"px"})})}},_handleDown:function(t){if(t.preventDefault(),!this._isDisabled()){this.$doc.on("mousemove.kube.slider touchmove.kube.slider",this._handleMove.bind(this)),this.$doc.on("mouseup.kube.slider touchend.kube.slider",this._handleEnd.bind(this));var e=(t.touches&&t.touches.length>0?t.changedTouches[0].clientX:t.clientX)-this.$track.offset().left-this.fixPosition;this._setPosition(e),this._setTarget()}},_handleMove:function(t){t.preventDefault();var e=(t.touches&&t.touches.length>0?t.changedTouches[0].clientX:t.clientX)-this.$track.offset().left-this.fixPosition;this._setPosition(e),this._setTarget()},_handleEnd:function(t){t.preventDefault(),this.$doc.off(".kube.slider")},_setPosition:function(t){t=this._getEdge(t,0,this.maxHandlePosition);var e=this._getValueFromPosition(t),i=this._getPositionFromValue(e);this.$fill.css("width",i+this.fixPosition+"px"),this.$handle.css("left",i+"px"),this.position=i,this.value=e},_setTarget:function(){if(this.app.broadcast("slider.set",this,this.value),0!==this.$target.length){var t=this.$target.get().tagName;"INPUT"===t||"SELECT"===t?this.$target.val(this.value):this.$target.text(this.value)}},_getPositionFromValue:function(t){var e=(t-this.params.min)/(this.params.max-this.params.min);return pos=Number.isNaN(e)?0:e*this.maxHandlePosition},_getValueFromPosition:function(t){var e=t/(this.maxHandlePosition||1),i=this.params.step*Math.round(e*(this.params.max-this.params.min)/this.params.step)+this.params.min;return Number(i.toFixed((this.params.step+"").replace(".","").length-1))},_getEdge:function(t,e,i){return t<e?e:t>i?i:t}})}(Kube),function(t){t.add("module","upload",{init:function(t,e){this.app=t,this.utils=t.utils,this.animate=t.animate,this.response=t.response,this.progress=t.progress;this.context=e,this.params=e.getParams({size:120,url:!1,urlRemove:!1,param:!1,type:!1,multiple:!1,placeholder:"Drop files here or click to upload",progress:!1,target:!1,append:!1}),this.$element=e.getElement(),this.$target=e.getTarget(),this.statusMap=["hover","error","success","drop"]},start:function(){this._buildBox(),this._buildInput(),this._buildCount(),this._buildType(),this._buildPlaceholder(),this._buildSize(),this._buildMultiple(),this._buildItems(),this._buildEvents()},stop:function(){this.$box.remove(),this.$element.off(".kube.upload")},_buildBox:function(){"image"===this.params.type?this.$box=this.$element.find(".upload-item"):this.$box=this.$element},_buildInput:function(){this.$input=t.dom("<input>"),this.$input.attr("type","file"),this.$input.attr("name",this._getParamName()),this.$input.hide(),this.$element.before(this.$input)},_buildCount:function(){this.$inputCount=t.dom("<input>"),this.$inputCount.attr("type","hidden"),this.$inputCount.attr("name",this._getParamName()+"-count"),this.$inputCount.val(0),this.$element.before(this.$inputCount)},_buildType:function(){this.isBox=this.$element.hasClass("upload")},_buildPlaceholder:function(){if(this.isBox){var e=t.dom("<span>");e.addClass("upload-placeholder"),e.html(this.params.placeholder),this.$element.append(e)}},_buildSize:function(){this.isBox?this.$box.css({height:this.params.size+"px"}):"image"===this.params.type&&this.$box.css({width:this.params.size+"px",height:this.params.size+"px"})},_buildMultiple:function(){this.isMultiple=this.params.multiple,this.isMultiple&&this.$input.attr("multiple","true")},_buildItems:function(){if(this.params.type){var t="file"===this.params.type,e=t?this.$target:this.$element,i=t?"_removeFile":"_removeImage",s=e.find(".close");s.on("click",this[i].bind(this)),t||s.closest(".upload-item").addClass("is-uploaded"),this.$inputCount.val(s.length)}},_buildEvents:function(){this.$input.on("change.redactor.upload",this._change.bind(this)),this.$box.on("click.redactor.upload",this._click.bind(this)),this.$box.on("drop.redactor.upload",this._drop.bind(this)),this.$box.on("dragover.redactor.upload",this._dragover.bind(this)),this.$box.on("dragleave.redactor.upload",this._dragleave.bind(this))},_click:function(e){e.preventDefault(),t.dom(e.target).hasClass("close")||this.$input.click()},_change:function(t){this.app.broadcast("upload.start",this),this._send(t,this.$input.get().files)},_drop:function(t){t.preventDefault(),this._clearStatuses(),this._setStatus("drop"),this.app.broadcast("upload.start",this),this._send(t)},_dragover:function(t){return t.preventDefault(),this._setStatus("hover"),!1},_dragleave:function(t){return t.preventDefault(),this._removeStatus("hover"),!1},_upCount:function(){var t=this.$inputCount.val();t++,this.$inputCount.val(t)},_downCount:function(){var t=this.$inputCount.val();t=--t<0?0:t,this.$inputCount.val(t)},_clearCount:function(){this.$inputCount.val(0)},_getParamName:function(){return this.params.param?this.params.param:"file"},_getHiddenName:function(){var t=this._getParamName();return this.isMultiple?t+"-uploaded[]":t+"-uploaded"},_clearStatuses:function(){this.$box.removeClass("is-upload-"+this.statusMap.join(" is-upload-"))},_setStatus:function(t){this.$box.addClass("is-upload-"+t)},_removeStatus:function(t){this.$box.removeClass("is-upload-"+t)},_clearTarget:function(){this.$target.find(".upload-item").each(function(e){var i=t.dom(e);this._removeFileRequest(i.attr("data-id"))}.bind(this)),this._clearCount(),this.$target.html("")},_clearBox:function(){this.$target.find(".upload-item").each(function(e){var i=t.dom(e);this._removeFileRequest(i.attr("data-id"))}.bind(this)),this._clearCount(),this.$target.html("")},_removeFile:function(e){e.preventDefault();var i=t.dom(e.target).closest(".upload-item"),s=i.attr("data-id");this.animate.run(i,"fadeOut",function(){i.remove(),this._downCount(),this._removeFileRequest(s),0===this.$target.find(".upload-item").length&&this.$target.html("")}.bind(this))},_removeImage:function(e){e.preventDefault();var i=t.dom(e.target),s=i.closest(".upload-item"),a=s.attr("data-id");if(this.isMultiple)this.animate.run(s,"fadeOut",function(){s.remove(),this._downCount(),this._removeFileRequest(a)}.bind(this));else{var n=s.find("img");i.hide(),this.animate.run(n,"fadeOut",function(){this.$box.html(""),this.$box.removeClass("is-uploaded"),this._clearCount(),this._removeFileRequest(a)}.bind(this))}},_removeFileRequest:function(e){this.params.urlRemove&&t.ajax.post({url:this.params.urlRemove,data:{id:e}})},_send:function(t,e){t=t.originalEvent||t,e=e||t.dataTransfer.files;var i=new FormData,s=this._getParamName();i=this._buildData(s,e,i),this.params.append&&(i=this.utils.extendData(i,this.params.append)),this._sendData(i,e,t)},_sendData:function(e,i,s){this.params.progress&&this.progress.show(),t.ajax.post({url:this.params.url,data:e,before:function(t){return this.app.broadcast("upload.beforeSend",this,t)}.bind(this),success:function(t){this._complete(t,s)}.bind(this)})},_buildData:function(t,e,i){for(var s=0;s<e.length;s++)i.append(t+"[]",e[s]);return i},_complete:function(t,e){this._clearStatuses(),this.params.progress&&this.progress.hide();var i=Array.isArray(t)?t[0]:t;if(void 0!==i.type&&"error"===i.type)this._setStatus("error"),this.response.parse(t),this.app.broadcast("upload.error",this,t);else{switch(this._setStatus("success"),this.params.type){case"image":this._completeBoxImage(t);break;case"file":this._completeBoxFile(t);break;default:this._completeBoxUpload(t)}this.app.broadcast("upload.complete",this,t),setTimeout(this._clearStatuses.bind(this),500)}},_completeBoxUpload:function(t){this.response.parse(t)},_completeBoxImage:function(e){for(var i in e){var s=t.dom("<img>");s.attr("src",e[i].url);var a=t.dom("<span>");a.addClass("close"),a.on("click",this._removeImage.bind(this));var n=t.dom("<input>");n.attr("type","hidden"),n.attr("name",this._getHiddenName()),n.val(e[i].id);var o=t.dom("<div>");if(o.addClass("upload-item is-uploaded"),o.attr("data-id",e[i].id),!this.isMultiple)return 0!==this.$box.find("img").length&&this._removeFileRequest(this.$box.attr("data-id")),this.$box.html(""),this.$box.attr("data-id",e[i].id),this.$box.append(a),this.$box.append(s),void this.$box.append(n);o.append(a),o.append(s),o.append(n),this.$box.last().before(o)}},_completeBoxFile:function(e){for(var i in this.isMultiple||this._clearTarget(),e){var s=t.dom("<div>");s.addClass("upload-item"),s.attr("data-id",e[i].id);var a=t.dom("<span>");a.html(e[i].name);var n=t.dom("<span>");n.addClass("close"),n.on("click",this._removeFile.bind(this));var o=t.dom("<input>");if(o.attr("type","hidden"),o.attr("name",this._getHiddenName()),o.val(e[i].id),void 0!==e[i].size){var h=t.dom("<em>");h.html(e[i].size),a.append(h)}s.append(n),s.append(a),s.append(o),this.$target.append(s),this._upCount()}}})}(Kube),function(t){t.add("module","validate",{init:function(t,e){this.app=t,this.$win=t.$win,this.progress=t.progress,this.response=t.response;this.context=e,this.params=e.getParams({errorClass:"is-error",send:!0,trigger:!1,shortcut:!1,progress:!1}),this.$element=e.getElement()},start:function(){this._disableDefaultValidation(),this._enableShortcut(),this.params.trigger?this._startTrigger():this._startSubmit()},stop:function(){this.enableButtons(),this.clear(),this.$element.off(".kube.validate"),this.$win.off(".kube.validate"),this.$trigger&&this.$trigger.off(".")},clear:function(){this.$element.find("."+this.params.errorClass).each(this._clearError.bind(this))},disableButtons:function(){this.$element.find("button").attr("disabled",!0)},enableButtons:function(){this.$element.find("button").removeAttr("disabled")},_build:function(t){return t.preventDefault(),this.params.send?this._send():this.app.broadcast("validate.send",this),!1},_send:function(){return this.params.progress&&this.progress.show(),this.disableButtons(),this._saveCodeMirror(),this.app.broadcast("validate.send",this),t.ajax.post({url:this.$element.attr("action"),data:this.$element.serialize(),success:this._parse.bind(this)}),!1},_parse:function(t){this.enableButtons(),this.clear(),this.params.progress&&this.progress.hide();var e=this.response.parse(t);e?void 0!==e.type&&"error"===e.type?(this._setErrors(e.errors),this.app.broadcast("validate.error",this,e.errors)):this.app.broadcast("validate.success",this,e):this.app.broadcast("validate.error",this,e)},_setErrors:function(t){for(var e in t){var i=t[e],s=this.$element.find("[name="+e+"]");0!==s.length&&(s.addClass(this.params.errorClass),this._setFieldEvent(s,e),""!==i&&this._showErrorText(e,i))}},_setFieldEvent:function(t,e){var i=this._getFieldEventName(t);t.on(i+".kube.validate",function(){this._clearError(t)}.bind(this))},_showErrorText:function(t,e){var i=this.$element.find("#"+t+"-validation-error");i.addClass(this.params.errorClass),i.html(e),i.removeClass("is-hidden")},_getFieldEventName:function(t){return"SELECT"===t.get().tagName||"checkbox"===t.attr("type")||"radio"===t.attr("type")?"change":"keyup"},_clearError:function(e){var i=t.dom(e),s=this.$element.find("#"+i.attr("name")+"-validation-error");s.removeClass(this.params.errorClass),s.html(""),s.addClass("is-hidden"),i.removeClass(this.params.errorClass).off(".kube.validate")},_saveCodeMirror:function(){t.dom(".CodeMirror").each(function(t){t.CodeMirror.save()})},_disableDefaultValidation:function(){this.$element.attr("novalidate","novalidate")},_enableShortcut:function(){this.params.shortcut&&this.$win.on("keydown.kube.validate",this._handleShortcut.bind(this))},_handleShortcut:function(t){return!t.ctrlKey&&!t.metaKey||83!==t.which||(t.preventDefault(),this._send())},_startTrigger:function(){this.$trigger=$(this.opts.trigger),this.$element.on("submit",function(){return!1}),this.$trigger.off(".kube.validate"),this.$trigger.on("click.kube.validate",this._build.bind(this))},_startSubmit:function(){this.$element.on("submit.kube.validate",this._build.bind(this))}})}(Kube),Kube.add("module","visibility",{init:function(t,e){this.app=t,this.$win=t.$win,this.context=e,this.params=e.getParams({tolerance:15}),this.$element=e.getElement()},start:function(){this.$win.on("scroll.kube.visibility resize.kube.visibility",this._check.bind(this)),this._check()},stop:function(){this.$win.off(".kube.visibility")},_check:function(){var t=this.$win.scrollTop(),e=t+this.$win.height(),i=this.$element.offset().top,s=i+this.$element.height();s>=t&&i<=e&&s<=e+this.params.tolerance&&i>=t?this.app.broadcast("visibility.visible",this,this.$element):this.app.broadcast("visibility.invisible",this,this.$element)}});