summaryrefslogtreecommitdiff
path: root/assets/js/app.min.js
blob: 62835bb571c229f90fcc665a1415721e0c78fd26 (plain)
1
2
!function(){function e(e,a,i){if(!o)throw new Error("textarea-caret-position#getCaretCoordinates should only be called in a browser");var r=i&&i.debug||!1;if(r){var d=document.querySelector("#input-textarea-caret-position-mirror-div");d&&d.parentNode.removeChild(d)}var s=document.createElement("div");s.id="input-textarea-caret-position-mirror-div",document.body.appendChild(s);var l=s.style,c=window.getComputedStyle?getComputedStyle(e):e.currentStyle;l.whiteSpace="pre-wrap","INPUT"!==e.nodeName&&(l.wordWrap="break-word"),l.position="absolute",r||(l.visibility="hidden"),t.forEach(function(e){l[e]=c[e]}),n?e.scrollHeight>parseInt(c.height)&&(l.overflowY="scroll"):l.overflow="hidden",s.textContent=e.value.substring(0,a),"INPUT"===e.nodeName&&(s.textContent=s.textContent.replace(/\s/g," "));var u=document.createElement("span");u.textContent=e.value.substring(a)||".",s.appendChild(u);var m={top:u.offsetTop+parseInt(c.borderTopWidth),left:u.offsetLeft+parseInt(c.borderLeftWidth)};return r?u.style.backgroundColor="#aaa":document.body.removeChild(s),m}var t=["direction","boxSizing","width","height","overflowX","overflowY","borderTopWidth","borderRightWidth","borderBottomWidth","borderLeftWidth","borderStyle","paddingTop","paddingRight","paddingBottom","paddingLeft","fontStyle","fontVariant","fontWeight","fontStretch","fontSize","fontSizeAdjust","lineHeight","fontFamily","textAlign","textTransform","textIndent","textDecoration","letterSpacing","wordSpacing","tabSize","MozTabSize"],o="undefined"!=typeof window,n=o&&null!=window.mozInnerScreenX;"undefined"!=typeof module&&void 0!==module.exports?module.exports=e:o&&(window.getCaretCoordinates=e)}(),function(){function e(){if(!("KeyboardEvent"in window)||"key"in KeyboardEvent.prototype)return!1;var e={get:function(e){var t=o.keys[this.which||this.keyCode];return Array.isArray(t)&&(t=t[+this.shiftKey]),t}};return Object.defineProperty(KeyboardEvent.prototype,"key",e),e}var t,o={polyfill:e,keys:{3:"Cancel",6:"Help",8:"Backspace",9:"Tab",12:"Clear",13:"Enter",16:"Shift",17:"Control",18:"Alt",19:"Pause",20:"CapsLock",27:"Escape",28:"Convert",29:"NonConvert",30:"Accept",31:"ModeChange",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",41:"Select",42:"Print",43:"Execute",44:"PrintScreen",45:"Insert",46:"Delete",48:["0",")"],49:["1","!"],50:["2","@"],51:["3","#"],52:["4","$"],53:["5","%"],54:["6","^"],55:["7","&"],56:["8","*"],57:["9","("],91:"OS",93:"ContextMenu",144:"NumLock",145:"ScrollLock",181:"VolumeMute",182:"VolumeDown",183:"VolumeUp",186:[";",":"],187:["=","+"],188:[",","<"],189:["-","_"],190:[".",">"],191:["/","?"],192:["`","~"],219:["[","{"],220:["\\","|"],221:["]","}"],222:["'",'"'],224:"Meta",225:"AltGraph",246:"Attn",247:"CrSel",248:"ExSel",249:"EraseEof",250:"Play",251:"ZoomOut"}};for(t=1;t<25;t++)o.keys[111+t]="F"+t;var n="";for(t=65;t<91;t++)n=String.fromCharCode(t),o.keys[t]=[n.toLowerCase(),n.toUpperCase()];o.polyfill()}(),Element.prototype.matches||(Element.prototype.matches=Element.prototype.matchesSelector||Element.prototype.mozMatchesSelector||Element.prototype.msMatchesSelector||Element.prototype.oMatchesSelector||Element.prototype.webkitMatchesSelector||function(e){for(var t=(this.document||this.ownerDocument).querySelectorAll(e),o=t.length;--o>=0&&t.item(o)!==this;);return o>-1});var KB={components:{},utils:{},html:{},http:{},listeners:{clicks:{},changes:{},keys:[],internals:{}}};KB.on=function(e,t){this.listeners.internals.hasOwnProperty(e)||(this.listeners.internals[e]=[]),this.listeners.internals[e].push(t)},KB.trigger=function(e,t){if(this.listeners.internals.hasOwnProperty(e))for(var o=0;o<this.listeners.internals[e].length;o++)this.listeners.internals[e][o](t)},KB.removeListener=function(e,t){if(this.listeners.internals.hasOwnProperty(e))for(var o=0;o<this.listeners.internals[e].length;o++)this.listeners.internals[e][o]===t&&this.listeners.internals[e].splice(o,1)},KB.onClick=function(e,t,o){this.listeners.clicks[e]={callback:t,noPreventDefault:!0===o}},KB.onChange=function(e,t){this.listeners.changes[e]=t},KB.onKey=function(e,t,o,n,a){this.listeners.keys.push({combination:e,callback:t,ignoreInputField:o||!1,ctrlKey:n||!1,metaKey:a||!1})},KB.listen=function(){function e(e){for(var t in n.listeners.clicks)n.listeners.clicks.hasOwnProperty(t)&&e.target.matches(t)&&(n.listeners.clicks[t].noPreventDefault||e.preventDefault(),n.listeners.clicks[t].callback(e))}function t(e){for(var t in n.listeners.changes)n.listeners.changes.hasOwnProperty(t)&&e.target.matches(t)&&n.listeners.changes[t](e.target)}function o(e){var t=KB.utils.getKey(e),o=KB.utils.isInputField(e);if(o&&-1===["Escape","Enter"].indexOf(t)||a.push(t),a.length>0){for(var i=!0,r=0;r<n.listeners.keys.length;r++){var d=n.listeners.keys[r],s=d.combination,l=s.split("+");if(KB.utils.arraysIdentical(a,l)&&e.ctrlKey===d.ctrlKey&&e.metaKey===d.metaKey){if(o&&!d.ignoreInputField)return void(a=[]);e.preventDefault(),e.stopPropagation(),a=[],d.callback(e);break}KB.utils.arraysStartsWith(a,l)&&a.length<l.length&&(i=!1)}i&&(a=[])}}var n=this,a=[];document.addEventListener("click",e,!1),document.addEventListener("change",t,!1),window.addEventListener("keydown",o,!1)},KB.component=function(e,t){this.components[e]=t},KB.getComponent=function(e,t,o){return new(0,this.components[e])(t,o)},KB.render=function(){for(var e in this.components)for(var t=document.querySelectorAll(".js-"+e),o=0;o<t.length;o++)if(this.components.hasOwnProperty(e)){var n;t[o].dataset.params&&(n=JSON.parse(t[o].dataset.params));var a=KB.getComponent(e,t[o],n);a.render(),t[o].className=t[o].className+"-rendered"}},KB.interval=function(e,t){setInterval(t,1e3*e)},KB.dom=function(e){function t(e){var t="string"==typeof e?document.createElement(e):e;this.attr=function(e,o){return null!==o&&void 0!==o?(t.setAttribute(e,o),this):t.getAttribute(e)},this.data=function(e,o){return 1===arguments.length?t.dataset[e]:(t.dataset[e]=o,this)},this.hide=function(){return t.style.display="none",this},this.show=function(){return t.style.display="block",this},this.toggle=function(){return"none"===t.style.display?this.show():this.hide(),this},this.style=function(e,o){return t.style[e]=o,this},this.on=function(e,o,n){return t.addEventListener(e,function(e){n||e.preventDefault(),o(e.target)}),this},this.click=function(e){return this.on("click",e)},this.mouseover=function(e){return this.on("mouseover",e)},this.change=function(e){return this.on("change",e)},this.add=function(e){return t.appendChild(e),this},this.replace=function(e){return t.parentNode.replaceChild(e,t),this},this.html=function(e){return t.innerHTML=e,this},this.text=function(e){return t.appendChild(document.createTextNode(e)),this},this.replaceText=function(e){return t.textContent=e,this},this.addClass=function(e){return t.classList.add(e),this},this.removeClass=function(e){return t.classList.remove(e),this},this.toggleClass=function(e){return t.classList.toggle(e),this},this.hasClass=function(e){return t.classList.contains(e)},this.disable=function(){return t.disabled=!0,this},this.enable=function(){return t.disabled=!1,this},this.remove=function(){return t.parentNode.removeChild(t),this},this.empty=function(){for(;t.firstChild;)t.removeChild(t.firstChild);return this},this.parent=function(e){for(;t&&t!==document;t=t.parentNode)if(t.matches(e))return t;return null},this.find=function(e){return t.querySelector(e)},this.for=function(e,o){for(var n=0;n<o.length;n++){var a=o[n];if("object"!=typeof a)t.appendChild(KB.dom(e).text(a).build());else{var i=KB.dom(e);for(var r in a)a.hasOwnProperty(r)&&r in this&&"function"==typeof this[r]?i[r](a[r]):i.attr(r,a[r]);t.appendChild(i.build())}}return this},this.build=function(){return t}}return new t(e)},KB.find=function(e){var t=document.querySelector(e);return t?KB.dom(t):null},KB.exists=function(e){return!!document.querySelector(e)},KB.focus=function(e){var t=document.querySelector(e);if(t)return t.focus()},KB.html.label=function(e,t){return KB.dom("label").attr("for",t).text(e).build()},KB.html.radio=function(e,t,o){return KB.dom("label").add(KB.dom("input").attr("type","radio").attr("name",t).attr("value",o).build()).text(e).build()},KB.html.radios=function(e){var t=KB.dom("div");for(var o in e)e.hasOwnProperty(o)&&t.add(KB.html.radio(o.label,o.name,o.value))},KB.http.request=function(e,t,o,n){function a(e){var t=e.getResponseHeader("X-Ajax-Redirect"),o=e.getResponseHeader("Location");if("self"===t)window.location.reload();else if(t&&t.indexOf("#")>-1)window.location=t.split("#")[0];else if(t)window.location=t;else if(o)window.location=o;else if("application/json"===e.getResponseHeader("Content-Type"))try{return JSON.parse(e.responseText)}catch(e){}return e.responseText}var i=function(){},r=function(){};this.execute=function(){var d=new XMLHttpRequest;d.open(e,t,!0),d.setRequestHeader("X-Requested-With","XMLHttpRequest");for(var s in o)o.hasOwnProperty(s)&&d.setRequestHeader(s,o[s]);return d.onerror=function(){r()},d.onreadystatechange=function(){if(d.readyState===XMLHttpRequest.DONE){var e=a(d);200===d.status?i(e):r(e)}},d.send(n),this},this.success=function(e){return i=e,this},this.error=function(e){return r=e,this}},KB.http.get=function(e){return new KB.http.request("GET",e).execute()},KB.http.postJson=function(e,t){var o={"Content-Type":"application/json",Accept:"application/json"};return new KB.http.request("POST",e,o,JSON.stringify(t)).execute()},KB.http.postForm=function(e,t){var o=new FormData(t);return new KB.http.request("POST",e,{},o).execute()},KB.http.uploadFile=function(e,t,o,n,a,i){var r=new FormData;r.append("files[]",t);var d=new XMLHttpRequest;d.upload.addEventListener("progress",o),d.upload.addEventListener("error",a),d.open("POST",e,!0),d.setRequestHeader("X-Requested-With","XMLHttpRequest"),d.onreadystatechange=function(){d.readyState===XMLHttpRequest.DONE&&(200===d.status?n():void 0!==i&&i(JSON.parse(d.responseText)))},d.send(r)},function(){function e(e){e.target.matches("#modal-overlay")&&(e.stopPropagation(),e.preventDefault(),s())}function t(){KB.trigger("modal.close")}function o(){KB.trigger("modal.loading"),a()}function n(){return document.querySelector("#modal-content form:not(.js-modal-ignore-form)")}function a(){var e=n();if(e){var t=e.getAttribute("action");t&&KB.http.postForm(t,e).success(function(e){KB.trigger("modal.stop"),e?r(e):s()}).error(function(e){KB.trigger("modal.stop"),e.hasOwnProperty("message")&&window.alert(e.message)})}}function i(){var e=KB.find("#modal-content form");e&&e.on("submit",o,!1);var t=document.querySelector("#modal-content input[autofocus]");t&&t.focus(),KB.render(),_KB.datePicker(),_KB.autoComplete(),_KB.tagAutoComplete(),_KB.get("Task").onPopoverOpened(),KB.trigger("modal.afterRender")}function r(e){var t=KB.find("#modal-content");t&&(t.replace(KB.dom("div").attr("id","modal-content").html(e).build()),i())}function d(o,n,a){var r=KB.dom("a").attr("href","#").attr("id","modal-close-button").html('<i class="fa fa-times"></i>').click(t).build(),d=KB.dom("div").attr("id","modal-header").add(r).build(),s=KB.dom("div").attr("id","modal-content").html(o).build(),l=KB.dom("div").attr("id","modal-box").style("width",n).add(d).add(s).build(),c=KB.dom("div").attr("id","modal-overlay").add(l).build();a&&c.addEventListener("click",e,!1),document.body.appendChild(c),i()}function s(){c=!1;var e=KB.find("#modal-overlay");e&&(KB.trigger("modal.beforeDestroy"),e.remove())}function l(e){var t=KB.utils.getViewportSize();if(t.width<700)return"99%";switch(e){case"large":return t.width<1350?"98%":"1350px";case"medium":return t.width<1024?"70%":"1024px"}return t.width<800?"75%":"800px"}var c=!1;KB.on("modal.close",function(){s()}),KB.on("modal.submit",function(){a()}),KB.modal={open:function(e,t,o){KB.trigger("modal.open"),_KB.get("Dropdown").close(),s(),void 0===o&&(o=!0),KB.http.get(e).success(function(e){c=!0,d(e,l(t),o)})},close:function(){s()},isOpen:function(){return c},replace:function(e){KB.http.get(e).success(function(e){r(e)})},getForm:n,submitForm:a}}(),KB.utils.formatDuration=function(e){return e>=86400?Math.round(e/86400)+"d":e>=3600?Math.round(e/3600)+"h":e>=60?Math.round(e/60)+"m":e+"s"},KB.utils.getSelectionPosition=function(e){var t,o;return t=e.value.length<e.selectionStart?e.value.length:e.selectionStart,o=e.selectionStart===e.selectionEnd?t:e.selectionEnd,{selectionStart:t,selectionEnd:o}},KB.utils.arraysIdentical=function(e,t){var o=e.length;if(o!==t.length)return!1;for(;o--;)if(e[o]!==t[o])return!1;return!0},KB.utils.arraysStartsWith=function(e,t){for(var o=Math.min(e.length,t.length),n=0;n<o;n++)if(e[n]!==t[n])return!1;return!0},KB.utils.isInputField=function(e){var t=e.target;return!("INPUT"!==t.tagName&&"SELECT"!==t.tagName&&"TEXTAREA"!==t.tagName&&!t.isContentEditable)},KB.utils.getKey=function(e){var t={Esc:"Escape",Up:"ArrowUp",Down:"ArrowDown",Left:"ArrowLeft",Right:"ArrowRight"};for(var o in t)if(t.hasOwnProperty(o)&&o===e.key)return t[o];return e.key},KB.utils.getViewportSize=function(){return{width:Math.max(document.documentElement.clientWidth,window.innerWidth||0),height:Math.max(document.documentElement.clientHeight,window.innerHeight||0)}},KB.utils.isVisible=function(){var e="";return void 0!==document.hidden?e="visibilityState":void 0!==document.mozHidden?e="mozVisibilityState":void 0!==document.msHidden?e="msVisibilityState":void 0!==document.webkitHidden&&(e="webkitVisibilityState"),""===e||"visible"===document[e]},KB.onClick(".accordion-toggle",function(e){var t=KB.dom(e.target).parent(".accordion-section");t&&KB.dom(t).toggleClass("accordion-collapsed")}),KB.onClick(".js-autocomplete-email",function(e){var t=e.target.dataset.email,o=document.querySelector('.js-mail-form input[name="emails"]');t&&o&&(""!==o.value?o.value+=", "+t:o.value=t,_KB.controllers.Dropdown.close())}),KB.onClick(".js-autocomplete-subject",function(e){var t=KB.dom(e.target).data("subject"),o=KB.find('.js-mail-form input[name="subject"]');t&&o&&(o.build().value=t),_KB.controllers.Dropdown.close()}),function(){function e(e){if(!KB.dom(e.target).parent("a, .task-board-change-assignee")){var t=KB.dom(e.target).parent(".task-board");if(t){var o=KB.dom(t).data("taskUrl");o&&(window.location=o)}}}function t(e){var t=KB.dom(e.target).parent(".task-board-change-assignee"),o=KB.dom(t).data("url");o&&KB.modal.open(o,"medium",!1)}KB.onClick(".task-board *",e,!0),KB.onClick(".task-board-change-assignee *",t,!0)}(),KB.component("chart-project-avg-time-column",function(e,t){this.render=function(){var o=t.metrics,n=[t.label],a=[];for(var i in o)n.push(o[i].average),a.push(o[i].title);KB.dom(e).add(KB.dom("div").attr("id","chart").build()),c3.generate({data:{columns:[n],type:"bar"},bar:{width:{ratio:.5}},axis:{x:{type:"category",categories:a},y:{tick:{format:KB.utils.formatDuration}}},legend:{show:!1}})}}),KB.component("chart-project-burndown",function(e,t){this.render=function(){for(var o=t.metrics,n=[[t.labelTotal]],a=[],i=d3.time.format("%Y-%m-%d"),r=d3.time.format(t.dateFormat),d=0;d<o.length;d++)for(var s=0;s<o[d].length;s++){var l=o[d][s];0===d?s>0&&n.push([l]):s>0?(n[s].push(l),void 0===n[0][d]&&n[0].push(0),n[0][d]+=l):a.push(r(i.parse(l)))}KB.dom(e).add(KB.dom("div").attr("id","chart").build()),c3.generate({data:{columns:n},axis:{x:{type:"category",categories:a}}})}}),KB.component("chart-project-cumulative-flow",function(e,t){this.render=function(){for(var o=t.metrics,n=[],a=[],i=[],r=d3.time.format("%Y-%m-%d"),d=d3.time.format(t.dateFormat),s=0;s<o.length;s++)for(var l=0;l<o[s].length;l++){var c=o[s][l];0===s?l>0&&(a.push(c),n.push([c])):l>0?n[l-1].push(c):i.push(d(r.parse(c)))}KB.dom(e).add(KB.dom("div").attr("id","chart").build()),c3.generate({data:{columns:n.reverse(),type:"area-spline",groups:[a],order:null},axis:{x:{type:"category",categories:i}}})}}),KB.component("chart-project-lead-cycle-time",function(e,t){this.render=function(){var o=t.metrics,n=[t.labelCycle],a=[t.labelLead],i=[],r={};r[t.labelCycle]="area",r[t.labelLead]="area-spline";var d={};d[t.labelLead]="#afb42b",d[t.labelCycle]="#4e342e";for(var s=0;s<o.length;s++)n.push(parseInt(o[s].avg_cycle_time)),a.push(parseInt(o[s].avg_lead_time)),i.push(o[s].day);KB.dom(e).add(KB.dom("div").attr("id","chart").build()),c3.generate({data:{columns:[a,n],types:r,colors:d},axis:{x:{type:"category",categories:i},y:{tick:{format:KB.utils.formatDuration}}}})}}),KB.component("chart-project-task-distribution",function(e,t){this.render=function(){for(var o=[],n=0;n<t.metrics.length;n++)o.push([t.metrics[n].column_title,t.metrics[n].nb_tasks]);KB.dom(e).add(KB.dom("div").attr("id","chart").build()),c3.generate({data:{columns:o,type:"donut"}})}}),KB.component("chart-project-time-comparison",function(e,t){this.render=function(){var o=[t.labelSpent],n=[t.labelEstimated],a=[];for(var i in t.metrics)o.push(t.metrics[i].time_spent),n.push(t.metrics[i].time_estimated),a.push("open"===i?t.labelOpen:t.labelClosed);KB.dom(e).add(KB.dom("div").attr("id","chart").build()),c3.generate({data:{columns:[o,n],type:"bar"},bar:{width:{ratio:.2}},axis:{x:{type:"category",categories:a}},legend:{show:!0}})}}),KB.component("chart-project-user-distribution",function(e,t){this.render=function(){for(var o=[],n=0;n<t.metrics.length;n++)o.push([t.metrics[n].user,t.metrics[n].nb_tasks]);KB.dom(e).add(KB.dom("div").attr("id","chart").build()),c3.generate({data:{columns:o,type:"donut"}})}}),KB.component("chart-task-time-column",function(e,t){this.render=function(){for(var o=t.metrics,n=[t.label],a=[],i=0;i<o.length;i++)n.push(o[i].time_spent),a.push(o[i].title);KB.dom(e).add(KB.dom("div").attr("id","chart-task-time-column").build()),c3.generate({bindto:"#chart-task-time-column",data:{columns:[n],type:"bar"},bar:{width:{ratio:.5}},axis:{x:{type:"category",categories:a},y:{tick:{format:KB.utils.formatDuration}}},legend:{show:!1}})}}),KB.on("dom.ready",function(){function e(){if(0===window.location.hash.indexOf("#comment-")){var e=KB.find(window.location.hash);if(e){document.querySelectorAll(".comment").forEach(function(e){KB.dom(e).removeClass("comment-highlighted")}),e.addClass("comment-highlighted")}}}window.addEventListener("hashchange",e),e()}),KB.component("confirm-buttons",function(e,t){function o(){r=!0,KB.find("#modal-confirm-button").replace(i()),KB.http.get(t.url)}function n(){KB.trigger("modal.close")}function a(){r=!1,KB.find("#modal-confirm-button").replace(i())}function i(){var e=KB.dom("button").click(o).attr("id","modal-confirm-button").attr("type","button").attr("class","btn btn-red");return r&&e.disable().add(KB.dom("i").attr("class","fa fa-spinner fa-pulse").build()).text(" "),t.tabindex&&e.attr("tabindex",t.tabindex),e.text(t.submitLabel).build()}var r=!1;this.render=function(){KB.on("modal.stop",a),KB.on("modal.close",function(){KB.removeListener("modal.stop",a)});var o=KB.dom("div").attr("class","form-actions").add(i()).text(" "+t.orLabel+" ").add(KB.dom("a").attr("href","#").click(n).text(t.cancelLabel).build()).build();e.appendChild(o)}}),KB.component("external-task-view",function(e,t){this.render=function(){KB.dom(e).html('<div id="external-task-view"><i class="fa fa-spinner fa-2x fa-pulse"></div>'),$.ajax({cache:!1,url:t.url,success:function(t){KB.dom(e).html('<div id="external-task-view">'+t+"</div>")}})}}),KB.component("file-upload",function(e,t){function o(e){if(e.lengthComputable){var t=e.loaded/e.total,o=Math.floor(100*t);KB.find("#file-progress-"+y).attr("value",t),KB.find("#file-percentage-"+y).replaceText("("+o+"%)")}}function n(){var e=KB.dom("div").addClass("file-error").text(t.labelUploadError).build();KB.find("#file-item-"+y).add(e)}function a(e){var t=KB.dom("div").addClass("file-error").text(e.message).build();KB.find("#file-item-"+y).add(t),KB.trigger("modal.stop")}function i(){if(++y<w.length)KB.http.uploadFile(t.url,w[y],o,i,n,a);else{KB.trigger("modal.stop"),KB.trigger("modal.hide");var e=KB.dom("div").addClass("alert").addClass("alert-success").text(t.labelSuccess).build(),d=KB.dom("button").attr("type","button").addClass("btn").addClass("btn-blue").click(r).text(t.labelCloseSuccess).build();KB.dom(B).replace(KB.dom("div").add(e).add(d).build())}}function r(){window.location.reload()}function d(){y=0,m()}function s(){for(var e=0;e<K.files.length;e++)w.push(K.files[e]);p()}function l(){w=[],y=0,K.click()}function c(e){e.stopPropagation(),e.preventDefault()}function u(e){e.stopPropagation(),e.preventDefault();for(var t=0;t<e.dataTransfer.files.length;t++)w.push(e.dataTransfer.files[t]);p()}function m(){w.length>0&&KB.http.uploadFile(t.url,w[y],o,i,n,a)}function p(){w.length>0?(KB.trigger("modal.enable"),KB.dom(B).empty().add(b())):(KB.trigger("modal.disable"),KB.dom(B).empty().add(h()))}function f(){return KB.dom("input").attr("id","file-input-element").attr("type","file").attr("name","files[]").attr("multiple",!0).on("change",s).hide().build()}function h(){var e=KB.dom("a").attr("href","#").text(t.labelChooseFiles).click(l).build();return KB.dom("div").attr("id","file-dropzone-inner").text(t.labelDropzone+" "+t.labelOr+" ").add(e).build()}function g(){var e=KB.dom("div").attr("id","file-dropzone").add(h()).build();return e.ondragover=c,e.ondrop=u,e.ondragover=c,e}function v(e){var o=!1,n=KB.dom("progress").attr("id","file-progress-"+e).attr("value",0).build(),a=KB.dom("span").attr("id","file-percentage-"+e).text("(0%)").build(),i=KB.dom("span").attr("id","file-delete-"+e).html('<a href="#"><i class="fa fa-trash fa-fw"></i></a>').on("click",function(){w.splice(e,1),KB.find("#file-item-"+e).remove(),p()}).build(),r=KB.dom("li").attr("id","file-item-"+e).add(i).add(n).text(" "+w[e].name+" ").add(a);return w[e].size>t.maxSize&&(r.add(KB.dom("div").addClass("file-error").text(t.labelOversize).build()),o=!0),o&&KB.trigger("modal.disable"),r.build()}function b(){for(var e=KB.dom("ul").attr("id","file-list").build(),t=0;t<w.length;t++)e.appendChild(v(t));return e}var K=null,B=null,w=[],y=0;this.render=function(){KB.on("modal.submit",d),KB.on("modal.close",function(){KB.removeListener("modal.submit",d)}),K=f(),B=g(),e.appendChild(K),e.appendChild(B)}}),KB.onClick(".js-form-export",function(e){var t=document.querySelector("#modal-content form"),o=t.querySelector("#form-from"),n=t.querySelector("#form-to");""!==o.value&&""!==n.value&&t.submit()}),KB.component("image-slideshow",function(e,t){function o(e){switch(KB.utils.getKey(e)){case"Escape":s();break;case"ArrowRight":i();break;case"ArrowLeft":r()}}function n(e){e.matches(".slideshow-next-icon")?i():e.matches(".slideshow-previous-icon")?r():e.matches(".slideshow-download-icon")?window.location.href=e.href:s()}function a(e){var t=KB.dom(e).data("imageId");l(t);d()}function i(){s();for(var e=0;e<t.images.length;e++)if(t.images[e].id===m.id){var o=e+1;o>=t.images.length&&(o=0),m=t.images[o];break}d()}function r(){s();for(var e=0;e<t.images.length;e++)if(t.images[e].id===m.id){var o=e-1;o<0&&(o=t.images.length-1),m=t.images[o];break}d()}function d(){var e=KB.dom("div").attr("class","fa fa-window-close slideshow-icon slideshow-close-icon").build(),t=KB.dom("a").attr("class","fa fa-download slideshow-icon slideshow-download-icon").attr("href",c(m,"download")).build(),a=KB.dom("div").attr("class","fa fa-chevron-circle-left slideshow-icon slideshow-previous-icon").build(),i=KB.dom("div").attr("class","fa fa-chevron-circle-right slideshow-icon slideshow-next-icon").build(),r=KB.dom("img").attr("src",c(m,"image")).attr("alt",m.name).attr("title",m.name).style("maxHeight",window.innerHeight-50+"px").build(),d=KB.dom("figcaption").text(m.name).build(),s=KB.dom("figure").add(r).add(d).build(),l=KB.dom("div").addClass("image-slideshow-overlay").add(e).add(t).add(a).add(i).add(s).click(n).build();document.body.appendChild(l),document.addEventListener("keydown",o,!1)}function s(){var e=KB.find(".image-slideshow-overlay");null!==e&&(document.removeEventListener("keydown",o,!1),e.remove())}function l(e){for(var o=0;o<t.images.length;o++)if(t.images[o].id===e)return t.images[o];return null}function c(e,o){var n=new RegExp(t.regex,"g");return t.url[o].replace(n,e.id)}function u(e){return KB.dom("img").attr("src",c(e,"thumbnail")).attr("alt",e.name).attr("title",e.name).data("imageId",e.id).click(a).build()}var m;this.render=function(){m=t.image,e.appendChild(u(m))}}),KB.keyboardShortcuts=function(){function e(e){if(!KB.modal.isOpen()){var t=KB.find(e);null!==t&&(window.location=t.attr("href"))}}function t(){if(KB.modal.isOpen())KB.modal.submitForm();else{var e=$("form");1==e.length?e.submit():e.length>1&&("INPUT"!==document.activeElement.tagName&&"TEXTAREA"!==document.activeElement.tagName||$(document.activeElement).parents("form").submit())}}KB.onKey("?",function(){KB.modal.isOpen()||KB.modal.open(KB.find("body").data("keyboardShortcutUrl"))}),KB.onKey("Escape",function(){KB.exists("#suggest-menu")||(KB.trigger("modal.close"),_KB.get("Dropdown").close())}),KB.onKey("Enter",t,!0,!0),KB.onKey("Enter",t,!0,!1,!0),KB.onKey("b",function(){KB.modal.isOpen()||KB.trigger("board.selector.open")}),KB.exists("#board")&&(KB.onKey("c",function(){KB.modal.isOpen()||_KB.get("BoardHorizontalScrolling").toggle()}),KB.onKey("s",function(){KB.modal.isOpen()||_KB.get("BoardCollapsedMode").toggle()}),KB.onKey("n",function(){KB.modal.isOpen()||KB.modal.open(KB.find("#board").data("taskCreationUrl"),"large",!1)})),KB.exists("#task-view")&&(KB.onKey("e",function(){KB.modal.isOpen()||KB.modal.open(KB.find("#task-view").data("editUrl"),"large",!1)}),KB.onKey("c",function(){KB.modal.isOpen()||KB.modal.open(KB.find("#task-view").data("commentUrl"),"medium",!1)}),KB.onKey("s",function(){KB.modal.isOpen()||KB.modal.open(KB.find("#task-view").data("subtaskUrl"),"medium",!1)}),KB.onKey("l",function(){KB.modal.isOpen()||KB.modal.open(KB.find("#task-view").data("internalLinkUrl"),"medium",!1)})),KB.onKey("f",function(){KB.modal.isOpen()||KB.focus("#form-search")}),KB.onKey("r",function(){if(!KB.modal.isOpen()){var e=$(".filter-reset").data("filter");$("#form-search").val(e),$("form.search").submit()}}),KB.onKey("v+o",function(){e("a.view-overview")}),KB.onKey("v+b",function(){e("a.view-board")}),KB.onKey("v+l",function(){e("a.view-listing")})},function(){function e(e){return"I"===e.target.tagName?e.target.parentNode.getAttribute("href"):e.target.getAttribute("href")}KB.onClick(".js-modal-large",function(t){KB.modal.open(e(t),"large",!1)}),KB.onClick(".js-modal-medium",function(t){KB.modal.isOpen()?KB.modal.replace(e(t)):KB.modal.open(e(t),"medium",!1)}),KB.onClick(".js-modal-small",function(t){KB.modal.open(e(t),"small",!1)}),KB.onClick(".js-modal-confirm",function(t){KB.modal.open(e(t),"small")}),KB.onClick(".js-modal-close",function(){KB.modal.close()}),KB.onClick(".js-modal-replace",function(t){var o=e(t);KB.modal.isOpen()?KB.modal.replace(o):window.location.href=o})}(),KB.onChange(".js-project-creation-select-options",function(e){"0"===e.value?KB.find(".js-project-creation-options").hide():KB.find(".js-project-creation-options").show()}),KB.component("project-select-role",function(e,t){function o(e){d=!0,t.role=e.value,a(),n()}function n(){KB.http.postJson(t.url,{id:t.id,role:t.role}).success(function(){d=!1,s=!0,a()}).error(function(){d=!1,s=!1,l=!0,a()})}function a(){KB.dom(r).remove(),r=i(),e.appendChild(r)}function i(){var e=[],n=KB.dom("div");for(var a in t.roles)if(t.roles.hasOwnProperty(a)){var i={value:a,text:t.roles[a]};t.role===a&&(i.selected="selected"),e.push(i)}return n.add(KB.dom("select").change(o).for("option",e).build()),d?(n.text(" "),n.add(KB.dom("i").attr("class","fa fa-spinner fa-pulse fa-fw").build())):s?(n.text(" "),n.add(KB.dom("i").attr("class","fa fa-check fa-fw icon-fade-out icon-success").build())):l&&(n.text(" "),n.add(KB.dom("i").attr("class","fa fa-check fa-fw icon-fade-out icon-error").build())),n.build()}var r,d=!1,s=!1,l=!1;this.render=function(){r=i(),e.appendChild(r)}}),KB.component("screenshot",function(e){function t(e){d(e.target.result)}function o(e){if(e.clipboardData&&e.clipboardData.items){var o=e.clipboardData.items;if(o)for(var n=0;n<o.length;n++)if(-1!==o[n].type.indexOf("image")){var a=o[n].getAsFile(),i=new FileReader;i.onload=t,i.readAsDataURL(a)}}else setTimeout(r,100)}function n(){a(),window.Clipboard||(s=document.createElement("div"),s.id="screenshot-pastezone",s.contentEditable=!0,s.style.opacity=0,s.style.position="fixed",s.style.top=0,s.style.right=0,s.style.width=0,document.body.insertBefore(s,document.body.firstChild),s.focus(),document.addEventListener("click",i),document.getElementById("screenshot-zone").addEventListener("click",i)),window.addEventListener("paste",o,!1)}function a(){KB.exists("#screenshot-pastezone")&&KB.find("#screenshot-pastezone").remove(),document.removeEventListener("click",i),s=null}function i(){null!==s&&s.focus()}function r(){var e=s.childNodes[0];e&&"IMG"===e.tagName&&d(e.src),s.innerHTML=""}function d(e){var t=new Image;t.src=e,t.onload=function(){var t=e.split("base64,");l.value=t[1]};var o=document.getElementById("screenshot-zone");o.innerHTML="",o.className="screenshot-pasted",o.appendChild(t),a(),n()}var s=null,l=null;KB.on("modal.close",function(){a()}),this.render=function(){l=KB.dom("input").attr("type","hidden").attr("name","screenshot").build(),e.appendChild(l),n()}}),KB.component("select-dropdown-autocomplete",function(e,t){function o(){KB.dom(k).show(),KB.dom(x).hide()}function n(){KB.dom(k).hide(),KB.dom(x).show()}function a(){var e=KB.find("#select-dropdown-menu");if(e){var t=w.getBoundingClientRect();e.style("top",document.body.scrollTop+t.bottom+"px")}}function i(e){switch(KB.utils.getKey(e)){case"Escape":y.value="",b();break;case"ArrowUp":e.preventDefault(),e.stopImmediatePropagation(),p();break;case"ArrowDown":e.preventDefault(),e.stopImmediatePropagation(),f();break;case"Enter":e.preventDefault(),e.stopImmediatePropagation(),u()}}function r(){b(),K()}function d(e){KB.dom(e).hasClass("select-dropdown-menu-item")&&(KB.find(".select-dropdown-menu-item.active").removeClass("active"),KB.dom(e).addClass("active"))}function s(){u()}function l(t){e.contains(t.target)||(y.value="",b())}function c(){null===KB.find("#select-dropdown-menu")?K():b()}function u(){var e=KB.find(".select-dropdown-menu-item.active"),n=e.data("value");C.value=n,y.value=t.items[n],b(),t.redirect?window.location=t.redirect.url.replace(new RegExp(t.redirect.regex,"g"),n):t.replace&&(o(),KB.modal.replace(t.replace.url.replace(new RegExp(t.replace.regex,"g"),n)))}function m(){for(var e=document.querySelectorAll(".select-dropdown-menu-item"),t=0;t<e.length;t++)if(KB.dom(e[t]).hasClass("active")){KB.dom(e[t]).removeClass("active");break}return{items:e,index:t}}function p(){var e=m();e.index>0&&(e.index=e.index-1),KB.dom(e.items[e.index]).addClass("active")}function f(){var e=m();e.index<e.items.length-1&&e.index++,KB.dom(e.items[e.index]).addClass("active")}function h(e){var o=[];for(var n in e)e.hasOwnProperty(n)&&o.push({class:"select-dropdown-menu-item",text:e[n],"data-label":e[n],"data-value":n});return t.sortByKeys?o.sort(function(e,t){var o=e["data-value"].toLowerCase(),n=t["data-value"].toLowerCase();return o<n?-1:o>n?1:0}):o.sort(function(e,t){var o=e["data-label"].toLowerCase(),n=t["data-label"].toLowerCase();return o<n?-1:o>n?1:0}),o}function g(e,o){for(var n=[],a=!1,i=0;i<o.length;i++)if(0===e.length||o[i]["data-label"].toLowerCase().indexOf(e.toLowerCase())>-1){var r=o[i];void 0!==t.defaultValue&&String(t.defaultValue)===r["data-value"]&&(r.class+=" active",a=!0),n.push(r)}return!a&&n.length>0&&(n[0].class+=" active"),n}function v(){var e=g(y.value,h(t.items)),o=w.getBoundingClientRect(),n=document.body.scrollTop||document.documentElement.scrollTop;return 0===e.length?null:KB.dom("ul").attr("id","select-dropdown-menu").style("top",n+o.bottom+"px").style("left",o.left+"px").style("width",o.width+"px").style("maxHeight",window.innerHeight-o.bottom-20+"px").mouseover(d).click(s).for("li",e).build()}function b(){var e=KB.find("#select-dropdown-menu");null!==e&&e.remove(),
document.removeEventListener("keydown",i,!1),document.removeEventListener("click",l,!1)}function K(){var e=v();null!==e&&document.body.appendChild(e),document.addEventListener("keydown",i,!1),document.addEventListener("click",l,!1)}function B(){return t.defaultValue&&t.defaultValue in t.items?t.items[t.defaultValue]:t.placeholder?t.placeholder:""}var w,y,C,x,k;this.render=function(){KB.on("select.dropdown.loading.start",o),KB.on("select.dropdown.loading.stop",n),KB.on("modal.close",function(){KB.removeListener("select.dropdown.loading.start",o),KB.removeListener("select.dropdown.loading.stop",n)}),x=KB.dom("i").attr("class","fa fa-chevron-down select-dropdown-chevron").click(c).build(),k=KB.dom("span").hide().addClass("select-loading-icon").add(KB.dom("i").attr("class","fa fa-spinner fa-pulse").build()).build(),C=KB.dom("input").attr("type","hidden").attr("name",t.name).attr("value",t.defaultValue||"").build(),y=KB.dom("input").attr("type","text").attr("placeholder",B()).addClass("select-dropdown-input").style("width",e.offsetWidth-30+"px").on("focus",c).on("input",r,!0).build(),w=KB.dom("div").addClass("select-dropdown-input-container").add(C).add(y).add(x).add(k).build(),e.appendChild(w),t.onFocus&&t.onFocus.forEach(function(e){KB.on(e,function(){y.focus()})}),window.addEventListener("scroll",a,!1)}}),KB.interval(60,function(){var e=KB.find("body").data("statusUrl"),t=KB.find("body").data("loginUrl");null===KB.find(".form-login")&&KB.http.get(e).error(function(){window.location=t})}),KB.component("submit-buttons",function(e,t){function o(){u=!0,c(),KB.trigger("modal.submit")}function n(){KB.trigger("modal.close")}function a(){u=!1,c()}function i(){u=!1,m=!0,c()}function r(){u=!1,m=!1,c()}function d(){KB.dom(f).hide()}function s(e){p=e.submitLabel,c()}function l(){var e=KB.dom("button").attr("type","submit").attr("class","btn btn-"+(t.color||"blue"));return KB.modal.isOpen()&&e.click(o),t.tabindex&&e.attr("tabindex",t.tabindex),u&&e.disable().add(KB.dom("i").attr("class","fa fa-spinner fa-pulse").build()).text(" "),m&&e.disable(),e.text(p).build()}function c(){var e=l();KB.dom(h).replace(e),h=e}var u=!1,m=t.disabled||!1,p=t.submitLabel,f=null,h=null;this.render=function(){KB.on("modal.stop",a),KB.on("modal.disable",i),KB.on("modal.enable",r),KB.on("modal.hide",d),KB.on("modal.submit.label",s),KB.on("modal.close",function(){KB.removeListener("modal.stop",a),KB.removeListener("modal.disable",i),KB.removeListener("modal.enable",r),KB.removeListener("modal.hide",d),KB.removeListener("modal.submit.label",s)}),h=l();var o=KB.dom("div").attr("class","form-actions").add(h);KB.modal.isOpen()&&o.text(" "+t.orLabel+" ").add(KB.dom("a").attr("href","#").click(n).text(t.cancelLabel).build()),f=o.build(),e.appendChild(f)}}),KB.on("dom.ready",function(){function e(e,t){var o=$(".subtasks-table").data("save-position-url");$.ajax({cache:!1,url:o,contentType:"application/json",type:"POST",processData:!1,data:JSON.stringify({subtask_id:e,position:t})})}$(".draggable-row-handle").mouseenter(function(){$(this).parent().parent().addClass("draggable-item-hover")}).mouseleave(function(){$(this).parent().parent().removeClass("draggable-item-hover")}),$(".subtasks-table tbody").sortable({forcePlaceholderSize:!0,handle:"td:first i",helper:function(e,t){return t.children().each(function(){$(this).width($(this).width())}),t},stop:function(t,o){var n=o.item;n.removeClass("draggable-item-selected"),e(n.data("subtask-id"),n.index()+1)},start:function(e,t){t.item.addClass("draggable-item-selected")}}).disableSelection()}),KB.on("dom.ready",function(){$(document).on("click",".js-subtask-toggle-status",function(e){var t=$(this),o=t.attr("href");e.preventDefault(),$.ajax({cache:!1,url:o,success:function(e){-1!=o.indexOf("fragment=table")?$(".subtasks-table").replaceWith(e):-1!=o.indexOf("fragment=rows")?$(t).closest(".task-list-subtasks").replaceWith(e):$(t).closest(".subtask-title").replaceWith(e)}})}),$(document).on("click",".js-subtask-toggle-timer",function(e){var t=$(this);e.preventDefault(),$.ajax({cache:!1,url:t.attr("href"),success:function(e){$(t).closest(".subtask-time-tracking").replaceWith(e)}})})}),KB.component("suggest-menu",function(e,t){function o(e){switch(KB.utils.getKey(e)){case"Escape":u();break;case"ArrowUp":e.preventDefault(),e.stopImmediatePropagation(),l();break;case"ArrowDown":e.preventDefault(),e.stopImmediatePropagation(),c();break;case"Enter":e.preventDefault(),e.stopImmediatePropagation(),i()}}function n(){i()}function a(e){KB.dom(e).hasClass("suggest-menu-item")&&(KB.find(".suggest-menu-item.active").removeClass("active"),KB.dom(e).addClass("active"))}function i(){e.focus();var t=KB.find(".suggest-menu-item.active"),o=t.data("value"),n=t.data("trigger"),a=e.value,i=r(e),d=n+o+" ",s=KB.utils.getSelectionPosition(e),l=a.substring(0,s.selectionStart-i.length),c=a.substring(s.selectionEnd),m=l.length+d.length;e.value=l+d+c,e.setSelectionRange(m,m),u()}function r(e){var t=e.value.substring(0,e.selectionEnd).split("\n"),o=t[t.length-1],n=o.split(" ");return n[n.length-1]}function d(){for(var e=["#modal-content form","#modal-content","body"],t=0;t<e.length;t++){var o=document.querySelector(e[t]);if(null!==o)return o}return null}function s(){for(var e=document.querySelectorAll(".suggest-menu-item"),t=0;t<e.length;t++)if(KB.dom(e[t]).hasClass("active")){KB.dom(e[t]).removeClass("active");break}return{items:e,index:t}}function l(){var e=s();e.index>0&&(e.index=e.index-1),KB.dom(e.items[e.index]).addClass("active")}function c(){var e=s();e.index<e.items.length-1&&e.index++,KB.dom(e.items[e.index]).addClass("active")}function u(){var e=KB.find("#suggest-menu");null!==e&&e.remove(),document.removeEventListener("keydown",o,!1)}function m(e){var o=r(e),n=p(o,t.triggers);u(),null!==n&&f(n,o.substring(n.length),t.triggers[n])}function p(e,t){for(var o in t)if(t.hasOwnProperty(o)&&0===e.indexOf(o))return o;return null}function f(e,t,o){if("string"==typeof o){var n=new RegExp("SEARCH_TERM","g"),a=o.replace(n,t);KB.http.get(a).success(function(o){h(e,t,o)})}else h(e,t,o)}function h(e,t,o){o=g(t,o),o.length>0&&b(v(e,o))}function g(e,t){var o=[];if(0===e.length)return t;for(var n=0;n<t.length;n++)0===t[n].value.toLowerCase().indexOf(e.toLowerCase())&&o.push(t[n]);return o}function v(e,t){for(var o=[],n=0;n<t.length;n++){var a="suggest-menu-item";0===n&&(a+=" active"),o.push({class:a,html:t[n].html,"data-value":t[n].value,"data-trigger":e})}return o}function b(t){var i=d(),r=getCaretCoordinates(e,e.selectionEnd),s=r.left+e.offsetLeft-e.scrollLeft,l=r.top+e.offsetTop-e.scrollTop+16;document.addEventListener("keydown",o,!1);var c=KB.dom("ul").attr("id","suggest-menu").click(n).mouseover(a).style("left",s+"px").style("top",l+"px").for("li",t).build();i.appendChild(c)}this.render=function(){e.addEventListener("input",function(){m(this)})}}),KB.component("task-move-position",function(e,t){function o(e){var t=KB.dom(document).find("#"+e);return t?parseInt(t.options[t.selectedIndex].value):null}function n(){var e=o("form-swimlanes");return null===e?t.board[0].id:e}function a(){var e=o("form-columns");return null===e?t.board[0].columns[0].id:e}function i(){var e=o("form-position");return null===e?1:e}function r(){var e=KB.find("input[name=positionChoice]:checked");return e?e.value:"before"}function d(){var e=KB.dom(document).find("#form-columns");KB.dom(e).replace(m());var t=KB.dom(document).find("#form-tasks");KB.dom(t).replace(p())}function s(){var e=KB.dom(document).find("#form-tasks");KB.dom(e).replace(p())}function l(e){KB.trigger("modal.stop"),KB.find("#message-container").replace(KB.dom("div").attr("id","message-container").attr("class","alert alert-error").text(e).build())}function c(){var e=i();"after"===r()&&e++,KB.find("#message-container").replace(KB.dom("div").attr("id","message-container").build()),KB.http.postJson(t.saveUrl,{column_id:a(),swimlane_id:n(),position:e}).error(function(e){e&&l(e.message)})}function u(){var e=[];return t.board.forEach(function(t){e.push({value:t.id,text:t.name})}),KB.dom("select").attr("id","form-swimlanes").change(d).for("option",e).build()}function m(){var e=[],o=n();return t.board.forEach(function(t){o===t.id&&t.columns.forEach(function(t){e.push({value:t.id,text:t.title})})}),KB.dom("select").attr("id","form-columns").change(s).for("option",e).build()}function p(){var e=[],o=n(),i=a(),r=KB.dom("div").attr("id","form-tasks");return t.board.forEach(function(t){o===t.id&&t.columns.forEach(function(t){i===t.id&&t.tasks.forEach(function(t){e.push({value:t.position,text:"#"+t.id+" - "+t.title})})})}),e.length>0&&r.add(KB.html.label(t.positionLabel,"form-position")).add(KB.dom("select").attr("id","form-position").for("option",e).build()).add(KB.html.radio(t.beforeLabel,"positionChoice","before")).add(KB.html.radio(t.afterLabel,"positionChoice","after")),r.build()}this.render=function(){KB.on("modal.submit",c),KB.on("modal.close",function(){KB.removeListener("modal.submit",c)});var o=KB.dom("div").add(KB.dom("div").attr("id","message-container").build()).add(KB.html.label(t.swimlaneLabel,"form-swimlanes")).add(u()).add(KB.html.label(t.columnLabel,"form-columns")).add(m()).add(p()).build();e.appendChild(o)}}),KB.onClick(".js-template",function(e){var t=KB.dom(e.target).data("template"),o=KB.dom(e.target).data("templateTarget"),n=KB.find(o);n&&(n.build().value=t),_KB.controllers.Dropdown.close()}),KB.component("text-editor",function(e,t){function o(){var e=KB.dom("div").attr("class","text-editor-toolbar").for("a",[{href:"#",html:'<i class="fa fa-pencil-square-o fa-fw"></i> '+t.labelWrite,click:function(){a()}}]).build();return h=KB.dom("div").attr("class","text-editor-preview-area markdown").build(),KB.dom("div").attr("class","text-editor-view-mode").add(e).add(h).hide().build()}function n(){var e=KB.dom("div").attr("class","text-editor-toolbar").for("a",[{href:"#",html:'<i class="fa fa-eye fa-fw"></i> '+t.labelPreview,click:function(){a()}},{href:"#",html:'<i class="fa fa-bold fa-fw"></i>',click:function(){d("**")}},{href:"#",html:'<i class="fa fa-italic fa-fw"></i>',click:function(){d("_")}},{href:"#",html:'<i class="fa fa-strikethrough fa-fw"></i>',click:function(){d("~~")}},{href:"#",html:'<i class="fa fa-quote-right fa-fw"></i>',click:function(){l("> ")}},{href:"#",html:'<i class="fa fa-list-ul fa-fw"></i>',click:function(){l("* ")}},{href:"#",html:'<i class="fa fa-code fa-fw"></i>',click:function(){s("```")}}]).build(),o=KB.dom("textarea");return o.attr("name",t.name),t.tabindex&&o.attr("tabindex",t.tabindex),t.required&&o.attr("required","required"),o.text(t.text),t.placeholder&&o.attr("placeholder",t.placeholder),m=o.build(),t.suggestOptions&&KB.getComponent("suggest-menu",m,t.suggestOptions).render(),KB.dom("div").attr("class","text-editor-write-mode").add(e).add(m).build()}function a(){KB.dom(h).html(marked(m.value,{sanitize:!0})),KB.dom(p).toggle(),KB.dom(f).toggle()}function i(){return m.value.substring(m.selectionStart,m.selectionEnd)}function r(e,t,o,n){return e.substring(0,t)+n+e.substring(o)}function d(e){c(e+i()+e),u(e)}function s(e){c("\n"+e+"\n"+i()+"\n"+e),u(e,2)}function l(e){var t=i();if(-1===t.indexOf("\n"))c("\n"+e+t);else{for(var o=t.split("\n"),n=0;n<o.length;n++)-1===o[n].indexOf(e)&&(o[n]=e+o[n]);c(o.join("\n"))}u(e,1)}function c(e){m.focus();var t=!1,o=KB.utils.getSelectionPosition(m);if(g=o.selectionStart,v=o.selectionEnd,document.queryCommandSupported("insertText")&&(t=document.execCommand("insertText",!1,e)),!t){try{document.execCommand("ms-beginUndoUnit")}catch(e){}m.value=r(m.value,g,v,e);try{document.execCommand("ms-endUndoUnit")}catch(e){}}}function u(e,t){t=t||0;var o=v+e.length+t;m.setSelectionRange(o,o)}var m,p,f,h,g,v;this.render=function(){f=n(),p=o(),e.appendChild(KB.dom("div").attr("class","text-editor").add(p).add(f).build()),t.autofocus&&m.focus()}}),document.addEventListener("DOMContentLoaded",function(){KB.render(),KB.listen(),KB.keyboardShortcuts(),KB.trigger("dom.ready")});var Kanboard={};Kanboard.App=function(){this.controllers={}},Kanboard.App.prototype.get=function(e){return this.controllers[e]},Kanboard.App.prototype.execute=function(){for(var e in Kanboard)if("App"!==e){var t=new Kanboard[e](this);this.controllers[e]=t,"function"==typeof t.execute&&t.execute(),"function"==typeof t.listen&&t.listen(),"function"==typeof t.focus&&t.focus()}this.focus(),this.datePicker(),this.autoComplete(),this.tagAutoComplete()},Kanboard.App.prototype.focus=function(){$(document).on("focus",".auto-select",function(){$(this).select()}),$(document).on("mouseup",".auto-select",function(e){e.preventDefault()})},Kanboard.App.prototype.datePicker=function(){var e=$("body"),t=e.data("js-date-format"),o=e.data("js-time-format"),n=e.data("js-lang");$.datepicker.setDefaults($.datepicker.regional[n]),$.timepicker.setDefaults($.timepicker.regional[n]),$(".form-date").datepicker({showOtherMonths:!0,selectOtherMonths:!0,dateFormat:t,constrainInput:!1}),$(".form-datetime").datetimepicker({dateFormat:t,timeFormat:o,constrainInput:!1})},Kanboard.App.prototype.tagAutoComplete=function(){$(".tag-autocomplete").select2({tags:!0})},Kanboard.App.prototype.autoComplete=function(){$(".autocomplete").each(function(){var e=$(this),t=e.data("dst-field"),o=e.data("dst-extra-fields");""===$("#form-"+t).val()&&e.parent().find("button[type=submit]").attr("disabled","disabled"),e.autocomplete({source:e.data("search-url"),minLength:1,select:function(n,a){if($("input[name="+t+"]").val(a.item.id),o)for(var i=o.split(","),r=0;r<i.length;r++){var d=i[r].trim();$("input[name="+d+"]").val(a.item[d])}e.parent().find("button[type=submit]").removeAttr("disabled")}})})},Kanboard.App.prototype.hasId=function(e){return!!document.getElementById(e)},Kanboard.App.prototype.showLoadingIcon=function(){$("body").append('<span id="app-loading-icon">&nbsp;<i class="fa fa-spinner fa-spin"></i></span>')},Kanboard.App.prototype.hideLoadingIcon=function(){$("#app-loading-icon").remove()},Kanboard.BoardCollapsedMode=function(e){this.app=e},Kanboard.BoardCollapsedMode.prototype.toggle=function(){var e=this;this.app.showLoadingIcon(),$.ajax({cache:!1,url:$('.filter-display-mode:not([style="display: none;"]) a').attr("href"),success:function(t){$(".filter-display-mode").toggle(),e.app.get("BoardDragAndDrop").refresh(t)}})},Kanboard.BoardColumnView=function(e){this.app=e},Kanboard.BoardColumnView.prototype.execute=function(){this.app.hasId("board")&&this.render()},Kanboard.BoardColumnView.prototype.listen=function(){var e=this;$(document).on("click",".board-toggle-column-view",function(){e.toggle($(this).data("column-id"))})},Kanboard.BoardColumnView.prototype.onBoardRendered=function(){this.render()},Kanboard.BoardColumnView.prototype.render=function(){var e=this;$(".board-column-header").each(function(){var t=$(this).data("column-id");localStorage.getItem("hidden_column_"+t)&&e.hideColumn(t)})},Kanboard.BoardColumnView.prototype.toggle=function(e){localStorage.getItem("hidden_column_"+e)?this.showColumn(e):this.hideColumn(e),this.app.get("BoardDragAndDrop").dragAndDrop()},Kanboard.BoardColumnView.prototype.hideColumn=function(e){$(".board-column-"+e+" .board-column-expanded").hide(),$(".board-column-"+e+" .board-column-collapsed").show(),$(".board-column-header-"+e+" .board-column-expanded").hide(),$(".board-column-header-"+e+" .board-column-collapsed").show(),$(".board-column-header-"+e).each(function(){$(this).removeClass("board-column-compact"),$(this).addClass("board-column-header-collapsed")}),$(".board-column-"+e).each(function(){$(this).addClass("board-column-task-collapsed")}),$(".board-column-"+e+" .board-rotation").each(function(){$(this).css("width",$(".board-column-"+e).height())}),localStorage.setItem("hidden_column_"+e,1)},Kanboard.BoardColumnView.prototype.showColumn=function(e){$(".board-column-"+e+" .board-column-expanded").show(),$(".board-column-"+e+" .board-column-collapsed").hide(),$(".board-column-header-"+e+" .board-column-expanded").show(),$(".board-column-header-"+e+" .board-column-collapsed").hide(),$(".board-column-header-"+e).removeClass("board-column-header-collapsed"),$(".board-column-"+e).removeClass("board-column-task-collapsed"),0==localStorage.getItem("horizontal_scroll")&&$(".board-column-header-"+e).addClass("board-column-compact"),localStorage.removeItem("hidden_column_"+e)},Kanboard.BoardHorizontalScrolling=function(e){this.app=e},Kanboard.BoardHorizontalScrolling.prototype.execute=function(){this.app.hasId("board")&&this.render()},Kanboard.BoardHorizontalScrolling.prototype.listen=function(){var e=this;$(document).on("click",".filter-toggle-scrolling",function(t){t.preventDefault(),e.toggle()})},Kanboard.BoardHorizontalScrolling.prototype.onBoardRendered=function(){this.render()},Kanboard.BoardHorizontalScrolling.prototype.toggle=function(){var e=localStorage.getItem("horizontal_scroll")||1;localStorage.setItem("horizontal_scroll",0==e?1:0),this.render()},Kanboard.BoardHorizontalScrolling.prototype.render=function(){0==localStorage.getItem("horizontal_scroll")?($(".filter-wide").show(),$(".filter-compact").hide(),$("#board-container").addClass("board-container-compact"),$("#board th:not(.board-column-header-collapsed)").addClass("board-column-compact")):($(".filter-wide").hide(),$(".filter-compact").show(),$("#board-container").removeClass("board-container-compact"),$("#board th").removeClass("board-column-compact"))},Kanboard.BoardPolling=function(e){this.app=e},Kanboard.BoardPolling.prototype.execute=function(){if(this.app.hasId("board")){var e=parseInt($("#board").attr("data-check-interval"));e>0&&window.setInterval(this.check.bind(this),1e3*e)}},Kanboard.BoardPolling.prototype.check=function(){if(KB.utils.isVisible()&&!this.app.get("BoardDragAndDrop").savingInProgress){var e=this;this.app.showLoadingIcon(),$.ajax({cache:!1,url:$("#board").data("check-url"),statusCode:{200:function(t){e.app.get("BoardDragAndDrop").refresh(t)},304:function(){e.app.hideLoadingIcon()}}})}},Kanboard.Column=function(e){this.app=e},Kanboard.Column.prototype.listen=function(){this.dragAndDrop()},Kanboard.Column.prototype.dragAndDrop=function(){var e=this;$(".draggable-row-handle").mouseenter(function(){$(this).parent().parent().addClass("draggable-item-hover")}).mouseleave(function(){$(this).parent().parent().removeClass("draggable-item-hover")}),$(".columns-table tbody").sortable({forcePlaceholderSize:!0,handle:"td:first i",helper:function(e,t){return t.children().each(function(){$(this).width($(this).width())}),t},stop:function(t,o){var n=o.item;n.removeClass("draggable-item-selected"),e.savePosition(n.data("column-id"),n.index()+1)},start:function(e,t){t.item.addClass("draggable-item-selected")}}).disableSelection()},Kanboard.Column.prototype.savePosition=function(e,t){var o=$(".columns-table").data("save-position-url"),n=this;this.app.showLoadingIcon(),$.ajax({cache:!1,url:o,contentType:"application/json",type:"POST",processData:!1,data:JSON.stringify({column_id:e,position:t}),complete:function(){n.app.hideLoadingIcon()}})},Kanboard.Dropdown=function(e){this.app=e},Kanboard.Dropdown.prototype.listen=function(){var e=this;$(document).on("click",function(){e.close()}),$(document).on("click",".dropdown-menu",function(t){t.preventDefault(),t.stopImmediatePropagation(),e.close();var o=$(this).next("ul"),n=$(this).offset();$("body").append(jQuery("<div>",{id:"dropdown"})),o.clone().appendTo("#dropdown");var a=$("#dropdown ul");a.addClass("dropdown-submenu-open");var i=a.outerHeight(),r=a.outerWidth();n.top+i-$(window).scrollTop()<$(window).height()||$(window).scrollTop()+n.top<i?a.css("top",n.top+$(this).height()):a.css("top",n.top-i-5),n.left+r>$(window).width()?a.css("left",n.left-r+$(this).outerWidth()):a.css("left",n.left),null!==document.getElementById("dropdown")&&KB.trigger("dropdown.afterRender")}),$(document).on("click",".dropdown-submenu-open li",function(e){if($(e.target).is("li")){KB.trigger("dropdown.clicked");var t=$(this).find("a:visible");t.length>0&&t[0].click()}})},Kanboard.Dropdown.prototype.close=function(){null!==document.getElementById("dropdown")&&KB.trigger("dropdown.beforeDestroy"),$("#dropdown").remove()},Kanboard.Search=function(e){this.app=e},Kanboard.Search.prototype.focus=function(){$(document).on("focus","#form-search",function(){var e=$("#form-search");if(e[0].setSelectionRange){var t=2*e.val().length;e[0].setSelectionRange(t,t)}})},Kanboard.Search.prototype.listen=function(){$(document).on("click",".filter-helper",function(e){e.preventDefault();var t=$(this).data("filter"),o=$(this).data("append-filter"),n=$(this).data("unique-filter"),a=$("#form-search");if(n){var i=n.substr(0,n.indexOf(":"));t=a.val().replace(new RegExp("("+i+":[#a-z0-9]+)","g"),""),t=t.replace(new RegExp("("+i+':"(.+)")',"g"),""),t=t.trim(),t+=" "+n}else o&&(t=a.val()+" "+o);a.val(t),$("form.search").submit()})},Kanboard.Swimlane=function(e){this.app=e},Kanboard.Swimlane.prototype.execute=function(){$(".swimlanes-table").length&&this.dragAndDrop()},Kanboard.Swimlane.prototype.listen=function(){var e=this;$(document).on("click",".board-swimlane-toggle",function(t){t.preventDefault();var o=$(this).data("swimlane-id");e.isCollapsed(o)?e.expand(o):e.collapse(o)})},Kanboard.Swimlane.prototype.onBoardRendered=function(){for(var e=this.getAllCollapsed(),t=0;t<e.length;t++)this.collapse(e[t])},Kanboard.Swimlane.prototype.getStorageKey=function(){return"hidden_swimlanes_"+$("#board").data("project-id")},Kanboard.Swimlane.prototype.expand=function(e){var t=this.getAllCollapsed(),o=t.indexOf(e);o>-1&&t.splice(o,1),localStorage.setItem(this.getStorageKey(),JSON.stringify(t)),$(".board-swimlane-columns-"+e).css("display","table-row"),$(".board-swimlane-tasks-"+e).css("display","table-row"),$(".hide-icon-swimlane-"+e).css("display","inline"),$(".show-icon-swimlane-"+e).css("display","none")},Kanboard.Swimlane.prototype.collapse=function(e){var t=this.getAllCollapsed();t.indexOf(e)<0&&(t.push(e),localStorage.setItem(this.getStorageKey(),JSON.stringify(t))),$(".board-swimlane-columns-"+e+":not(:first-child)").css("display","none"),$(".board-swimlane-tasks-"+e).css("display","none"),$(".hide-icon-swimlane-"+e).css("display","none"),$(".show-icon-swimlane-"+e).css("display","inline")},Kanboard.Swimlane.prototype.isCollapsed=function(e){return this.getAllCollapsed().indexOf(e)>-1},Kanboard.Swimlane.prototype.getAllCollapsed=function(){return JSON.parse(localStorage.getItem(this.getStorageKey()))||[]},Kanboard.Swimlane.prototype.dragAndDrop=function(){var e=this;$(".draggable-row-handle").mouseenter(function(){$(this).parent().parent().addClass("draggable-item-hover")}).mouseleave(function(){$(this).parent().parent().removeClass("draggable-item-hover")}),$(".swimlanes-table tbody").sortable({forcePlaceholderSize:!0,handle:"td:first i",helper:function(e,t){return t.children().each(function(){$(this).width($(this).width())}),t},stop:function(t,o){var n=o.item;n.removeClass("draggable-item-selected"),e.savePosition(n.data("swimlane-id"),n.index()+1)},start:function(e,t){t.item.addClass("draggable-item-selected")}}).disableSelection()},Kanboard.Swimlane.prototype.savePosition=function(e,t){var o=$(".swimlanes-table").data("save-position-url"),n=this;this.app.showLoadingIcon(),$.ajax({cache:!1,url:o,contentType:"application/json",type:"POST",processData:!1,data:JSON.stringify({swimlane_id:e,position:t}),complete:function(){n.app.hideLoadingIcon()}})},Kanboard.Task=function(e){this.app=e},Kanboard.Task.prototype.onPopoverOpened=function(){this.renderColorPicker(),$(document).on("click",".assign-me",function(e){var t=$(this).data("current-id"),o="#"+$(this).data("target-id");e.preventDefault(),$(o+" option[value="+t+"]").length&&$(o).val(t)})},Kanboard.Task.prototype.renderColorPicker=function(){function e(e){return $('<div class="color-picker-option"><div class="color-picker-square color-'+e.id+'"></div><div class="color-picker-label">'+e.text+"</div></div>")}$(".color-picker").select2({minimumResultsForSearch:1/0,templateResult:e,templateSelection:e})},Kanboard.Tooltip=function(e){this.app=e},Kanboard.Tooltip.prototype.onBoardRendered=function(){this.execute()},Kanboard.Tooltip.prototype.execute=function(){$(".tooltip").tooltip({track:!1,show:!1,hide:!1,position:{my:"left-20 top",at:"center bottom+9",using:function(e,t){$(this).css(e);var o=t.target.left+t.target.width/2-t.element.left-20;$("<div>").addClass("tooltip-arrow").addClass(t.vertical).addClass(o<1?"align-left":"align-right").appendTo(this)}},content:function(){var e=this,t=$(this).attr("data-href");return t?($.get(t,function(t){var o=$(".ui-tooltip:visible");$(".ui-tooltip-content:visible").html(t),o.css({top:"",left:""}),o.children(".tooltip-arrow").remove();var n=$(e).tooltip("option","position");n.of=$(e),o.position(n)}),'<i class="fa fa-spinner fa-spin"></i>'):'<div class="markdown">'+$(this).attr("title")+"</div>"}}).on("mouseenter",function(){var e=this;$(this).tooltip("open"),$(".ui-tooltip").on("mouseleave",function(){$(e).tooltip("close")})}).on("mouseleave focusout",function(e){e.stopImmediatePropagation();var t=this;setTimeout(function(){$(".ui-tooltip:hover").length||$(t).tooltip("close")},100)})},Kanboard.BoardDragAndDrop=function(e){this.app=e,this.savingInProgress=!1},Kanboard.BoardDragAndDrop.prototype.execute=function(){this.app.hasId("board")&&(this.executeListeners(),this.dragAndDrop())},Kanboard.BoardDragAndDrop.prototype.dragAndDrop=function(){var e=this,t=$(".board-task-list"),o={forcePlaceholderSize:!0,tolerance:"pointer",connectWith:".sortable-column",placeholder:"draggable-placeholder",items:".draggable-item",stop:function(t,o){var n=o.item,a=n.attr("data-task-id"),i=n.attr("data-position"),r=n.attr("data-column-id"),d=n.attr("data-swimlane-id"),s=n.parent().attr("data-column-id"),l=n.parent().attr("data-swimlane-id"),c=n.index()+1;n.removeClass("draggable-item-selected"),s==r&&l==d&&c==i||(e.changeTaskState(a),e.save(a,r,s,c,l))},start:function(e,t){t.item.addClass("draggable-item-selected"),t.placeholder.height(t.item.height())}};isMobile.any&&($(".task-board-sort-handle").css("display","inline"),o.handle=".task-board-sort-handle"),t.each(function(){$(this).css("min-height",$(this).parent().height())}),t.sortable(o)},Kanboard.BoardDragAndDrop.prototype.changeTaskState=function(e){var t=$("div[data-task-id="+e+"]");t.addClass("task-board-saving-state"),t.find(".task-board-saving-icon").show()},Kanboard.BoardDragAndDrop.prototype.save=function(e,t,o,n,a){var i=this;i.app.showLoadingIcon(),i.savingInProgress=!0,$.ajax({cache:!1,url:$("#board").data("save-url"),contentType:"application/json",type:"POST",processData:!1,data:JSON.stringify({task_id:e,src_column_id:t,dst_column_id:o,swimlane_id:a,position:n}),success:function(e){i.refresh(e),i.savingInProgress=!1},error:function(){i.app.hideLoadingIcon(),i.savingInProgress=!1},statusCode:{403:function(e){window.alert(e.responseJSON.message),document.location.reload(!0)}}})},Kanboard.BoardDragAndDrop.prototype.refresh=function(e){$("#board-container").replaceWith(e),this.app.hideLoadingIcon(),this.executeListeners(),this.dragAndDrop()},Kanboard.BoardDragAndDrop.prototype.executeListeners=function(){for(var e in this.app.controllers){var t=this.app.get(e);"function"==typeof t.onBoardRendered&&t.onBoardRendered()}};var _KB=null;jQuery(document).ready(function(){_KB=new Kanboard.App,_KB.execute()});