!function(){function e(e,a,i){if(!n)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]}),o?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"],n="undefined"!=typeof window,o=n&&null!=window.mozInnerScreenX;"undefined"!=typeof module&&"undefined"!=typeof module.exports?module.exports=e:n&&(window.getCaretCoordinates=e)}(),function(){function e(){if(!("KeyboardEvent"in window)||"key"in KeyboardEvent.prototype)return!1;var e={get:function(e){var t=n.keys[this.which||this.keyCode];return Array.isArray(t)&&(t=t[+this.shiftKey]),t}};return Object.defineProperty(KeyboardEvent.prototype,"key",e),e}var t,n={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++)n.keys[111+t]="F"+t;var o="";for(t=65;t<91;t++)o=String.fromCharCode(t),n.keys[t]=[o.toLowerCase(),o.toUpperCase()];n.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),n=t.length;--n>=0&&t.item(n)!==this;);return n>-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 n=0;n0){for(var i=!0,r=0;r-1)window.location=t.split("#")[0];else if(t)window.location=t;else if(n)window.location=n;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 n)n.hasOwnProperty(s)&&d.setRequestHeader(s,n[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(o),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 n={"Content-Type":"application/json",Accept:"application/json"};return new KB.http.request("POST",e,n,JSON.stringify(t)).execute()},KB.http.postForm=function(e,t){var n=new FormData(t);return new KB.http.request("POST",e,{},n).execute()},KB.http.uploadFile=function(e,t,n,o,a,i){var r=new FormData;r.append("files[]",t);var d=new XMLHttpRequest;d.upload.addEventListener("progress",n),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?o():"undefined"!=typeof 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 n(){KB.trigger("modal.loading"),a()}function o(){return document.querySelector("#modal-content form:not(.js-modal-ignore-form)")}function a(){var e=o();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",n,!1);var t=document.querySelector("#modal-content input[autofocus]");t&&t.focus(),KB.render(),_KB.datePicker(),_KB.autoComplete(),_KB.tagAutoComplete(),_KB.get("Task").onPopoverOpened()}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(n,o,a){var r=KB.dom("a").attr("href","#").attr("id","modal-close-button").html('').click(t).build(),d=KB.dom("div").attr("id","modal-header").add(r).build(),s=KB.dom("div").attr("id","modal-content").html(n).build(),l=KB.dom("div").attr("id","modal-box").style("width",o).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&&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,n){_KB.get("Dropdown").close(),s(),"undefined"==typeof n&&(n=!0),KB.http.get(e).success(function(e){c=!0,d(e,l(t),n)})},close:function(){s()},isOpen:function(){return c},replace:function(e){KB.http.get(e).success(function(e){r(e)})},getForm:o,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,n;return t=e.value.length0&&o.push([l]):s>0?(o[s].push(l),"undefined"==typeof o[0][d]&&o[0].push(0),o[0][d]+=l):a.push(r(i.parse(l)))}KB.dom(e).add(KB.dom("div").attr("id","chart").build()),c3.generate({data:{columns:o},axis:{x:{type:"category",categories:a}}})}}),KB.component("chart-project-cumulative-flow",function(e,t){this.render=function(){for(var n=t.metrics,o=[],a=[],i=[],r=d3.time.format("%Y-%m-%d"),d=d3.time.format(t.dateFormat),s=0;s0&&(a.push(c),o.push([c])):l>0?o[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:o.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 n=t.metrics,o=[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'+t+"")}})}}),KB.component("file-upload",function(e,t){function n(e){if(e.lengthComputable){var t=e.loaded/e.total,n=Math.floor(100*t);KB.find("#file-progress-"+y).attr("value",t),KB.find("#file-percentage-"+y).replaceText("("+n+"%)")}}function o(){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++,y0&&KB.http.uploadFile(t.url,w[y],n,i,o,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 n=!1,o=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("li").attr("id","file-item-"+e).add(o).text(" "+w[e].name+" ").add(a);return w[e].size>t.maxSize&&(i.add(KB.dom("div").addClass("file-error").text(t.labelOversize).build()),n=!0),n&&KB.trigger("modal.disable"),i.build()}function b(){for(var e=KB.dom("ul").attr("id","file-list").build(),t=0;t=t.images.length&&(n=0),m=t.images[n];break}d()}function r(){s();for(var e=0;e1&&("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"),t=$("#form-search");t.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 n=e(t);KB.modal.isOpen()?KB.modal.replace(n):window.location.href=n})}(),KB.onChange(".js-project-creation-select-options",function(e){var t=e.value;"0"===t?KB.find(".js-project-creation-options").hide():KB.find(".js-project-creation-options").show()}),KB.component("project-select-role",function(e,t){function n(e){d=!0,t.role=e.value,a(),o()}function o(){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=[],o=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 o.add(KB.dom("select").change(n).for("option",e).build()),d?(o.text(" "),o.add(KB.dom("i").attr("class","fa fa-spinner fa-pulse fa-fw").build())):s?(o.text(" "),o.add(KB.dom("i").attr("class","fa fa-check fa-fw icon-fade-out icon-success").build())):l&&(o.text(" "),o.add(KB.dom("i").attr("class","fa fa-check fa-fw icon-fade-out icon-error").build())),o.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 n(e){if(e.clipboardData&&e.clipboardData.items){var n=e.clipboardData.items;if(n)for(var o=0;o0&&(e.index=e.index-1),KB.dom(e.items[e.index]).addClass("active")}function f(){var e=m();e.indexo?1:0}):n.sort(function(e,t){var n=e["data-label"].toLowerCase(),o=t["data-label"].toLowerCase();return no?1:0}),n}function g(e,n){for(var o=[],a=!1,i=0;i-1){var r=n[i];"undefined"!=typeof t.defaultValue&&String(t.defaultValue)===r["data-value"]&&(r.class+=" active",a=!0),o.push(r)}return!a&&o.length>0&&(o[0].class+=" active"),o}function v(){var e=g(y.value,h(t.items)),n=w.getBoundingClientRect();return 0===e.length?null:KB.dom("ul").attr("id","select-dropdown-menu").style("top",document.body.scrollTop+n.bottom+"px").style("left",n.left+"px").style("width",n.width+"px").style("maxHeight",window.innerHeight-n.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",n),KB.on("select.dropdown.loading.stop",o),KB.on("modal.close",function(){KB.removeListener("select.dropdown.loading.start",n),KB.removeListener("select.dropdown.loading.stop",o)}),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 n(){u=!0,c(),KB.trigger("modal.submit")}function o(){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(n),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 n=KB.dom("div").attr("class","form-actions").add(h);KB.modal.isOpen()&&n.text(" "+t.orLabel+" ").add(KB.dom("a").attr("href","#").click(o).text(t.cancelLabel).build()),f=n.build(),e.appendChild(f)}}),KB.on("dom.ready",function(){function e(e,t){var n=$(".subtasks-table").data("save-position-url");$.ajax({cache:!1,url:n,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,n){var o=n.item;o.removeClass("draggable-item-selected"),e(o.data("subtask-id"),o.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),n=t.attr("href");e.preventDefault(),$.ajax({cache:!1,url:n,success:function(e){n.indexOf("fragment=table")!=-1?$(".subtasks-table").replaceWith(e):n.indexOf("fragment=rows")!=-1?$(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 n(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 o(){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"),n=t.data("value"),o=t.data("trigger"),a=e.value,i=r(e),d=o+n+" ",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"),n=t[t.length-1],o=n.split(" ");return o[o.length-1]}function d(){for(var e=["#modal-content form","#modal-content","body"],t=0;t0&&(e.index=e.index-1),KB.dom(e.items[e.index]).addClass("active")}function c(){var e=s();e.index0&&b(v(e,n))}function g(e,t){var n=[];if(0===e.length)return t;for(var o=0;o0&&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 n=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(n)}}),KB.component("text-editor",function(e,t){function n(){var e=KB.dom("div").attr("class","text-editor-toolbar").for("a",[{href:"#",html:' '+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 o(){var e=KB.dom("div").attr("class","text-editor-toolbar").for("a",[{href:"#",html:' '+t.labelPreview,click:function(){a()}},{href:"#",html:'',click:function(){d("**")}},{href:"#",html:'',click:function(){d("_")}},{href:"#",html:'',click:function(){d("~~")}},{href:"#",html:'',click:function(){l("> ")}},{href:"#",html:'',click:function(){l("* ")}},{href:"#",html:'',click:function(){s("```")}}]).build(),n=KB.dom("textarea");return n.attr("name",t.name),t.tabindex&&n.attr("tabindex",t.tabindex),t.required&&n.attr("required","required"),n.text(t.text),t.placeholder&&n.attr("placeholder",t.placeholder),m=n.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,n,o){return e.substring(0,t)+o+e.substring(n)}function d(e){var t=i();c(e+t+e),u(e)}function s(e){var t=i();c("\n"+e+"\n"+t+"\n"+e),u(e,2)}function l(e){var t=i();if(t.indexOf("\n")===-1)c("\n"+e+t);else{for(var n=t.split("\n"),o=0;o ')},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,n){var o=n.item;o.removeClass("draggable-item-selected"),e.savePosition(o.data("column-id"),o.index()+1)},start:function(e,t){t.item.addClass("draggable-item-selected")}}).disableSelection()},Kanboard.Column.prototype.savePosition=function(e,t){var n=$(".columns-table").data("save-position-url"),o=this;this.app.showLoadingIcon(),$.ajax({cache:!1,url:n,contentType:"application/json",type:"POST",processData:!1,data:JSON.stringify({column_id:e,position:t}),complete:function(){o.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 n=$(this).next("ul"),o=$(this).offset();$("body").append(jQuery("
",{id:"dropdown"})),n.clone().appendTo("#dropdown");var a=$("#dropdown ul");a.addClass("dropdown-submenu-open");var i=a.outerHeight(),r=a.outerWidth();o.top+i-$(window).scrollTop()<$(window).height()||$(window).scrollTop()+o.top$(window).width()?a.css("left",o.left-r+$(this).outerWidth()):a.css("left",o.left)}),$(document).on("click",".dropdown-submenu-open li",function(e){$(e.target).is("li")&&$(this).find("a:visible")[0].click()})},Kanboard.Dropdown.prototype.close=function(){$("#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"),n=$(this).data("append-filter"),o=$(this).data("unique-filter"),a=$("#form-search");if(o){var i=o.substr(0,o.indexOf(":"));t=a.val().replace(new RegExp("("+i+":[#a-z0-9]+)","g"),""),t=t.replace(new RegExp("("+i+':"(.+)")',"g"),""),t=t.trim(),t+=" "+o}else n&&(t=a.val()+" "+n);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 n=$(this).data("swimlane-id");e.isCollapsed(n)?e.expand(n):e.collapse(n)})},Kanboard.Swimlane.prototype.onBoardRendered=function(){for(var e=this.getAllCollapsed(),t=0;t-1&&t.splice(n,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,n){var o=n.item;o.removeClass("draggable-item-selected"),e.savePosition(o.data("swimlane-id"),o.index()+1)},start:function(e,t){t.item.addClass("draggable-item-selected")}}).disableSelection()},Kanboard.Swimlane.prototype.savePosition=function(e,t){var n=$(".swimlanes-table").data("save-position-url"),o=this;this.app.showLoadingIcon(),$.ajax({cache:!1,url:n,contentType:"application/json",type:"POST",processData:!1,data:JSON.stringify({swimlane_id:e,position:t}),complete:function(){o.app.hideLoadingIcon()}})},Kanboard.Task=function(e){this.app=e},Kanboard.Task.prototype.onPopoverOpened=function(){var e=this;e.renderColorPicker(),$(document).on("click",".assign-me",function(e){var t=$(this).data("current-id"),n="#"+$(this).data("target-id");e.preventDefault(),$(n+" option[value="+t+"]").length&&$(n).val(t)})},Kanboard.Task.prototype.renderColorPicker=function(){function e(e){return $('
'+e.text+"
")}$(".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 n=t.target.left+t.target.width/2-t.element.left-20;$("
").addClass("tooltip-arrow").addClass(t.vertical).addClass(n<1?"align-left":"align-right").appendTo(this)}},content:function(){var e=this,t=$(this).attr("data-href");return t?($.get(t,function(t){var n=$(".ui-tooltip:visible");$(".ui-tooltip-content:visible").html(t),n.css({top:"",left:""}),n.children(".tooltip-arrow").remove();var o=$(e).tooltip("option","position");o.of=$(e),n.position(o)}),''):'
'+$(this).attr("title")+"
"}}).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"),n={forcePlaceholderSize:!0,tolerance:"pointer",connectWith:".sortable-column",placeholder:"draggable-placeholder",items:".draggable-item",stop:function(t,n){var o=n.item,a=o.attr("data-task-id"),i=o.attr("data-position"),r=o.attr("data-column-id"),d=o.attr("data-swimlane-id"),s=o.parent().attr("data-column-id"),l=o.parent().attr("data-swimlane-id"),c=o.index()+1;o.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"),n.handle=".task-board-sort-handle"),t.each(function(){$(this).css("min-height",$(this).parent().height())}),t.sortable(n)},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,n,o,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:n,swimlane_id:a,position:o}),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()});