!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 l=document.createElement("div");l.id="input-textarea-caret-position-mirror-div",document.body.appendChild(l);var s=l.style,c=window.getComputedStyle?window.getComputedStyle(e):e.currentStyle,u="INPUT"===e.nodeName;s.whiteSpace="pre-wrap",u||(s.wordWrap="break-word"),s.position="absolute",r||(s.visibility="hidden"),t.forEach(function(e){u&&"lineHeight"===e?s.lineHeight=c.height:s[e]=c[e]}),o?e.scrollHeight>parseInt(c.height)&&(s.overflowY="scroll"):s.overflow="hidden",l.textContent=e.value.substring(0,a),u&&(l.textContent=l.textContent.replace(/\s/g," "));var m=document.createElement("span");m.textContent=e.value.substring(a)||".",l.appendChild(m);var f={top:m.offsetTop+parseInt(c.borderTopWidth),left:m.offsetLeft+parseInt(c.borderLeftWidth),height:parseInt(c.lineHeight)};return r?m.style.backgroundColor="#aaa":document.body.removeChild(l),f}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&&void 0!==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(){},d=function(){},l=function(){};this.execute=function(){var s=new XMLHttpRequest;s.open(e,t,!0),s.setRequestHeader("X-Requested-With","XMLHttpRequest");for(var c in n)n.hasOwnProperty(c)&&s.setRequestHeader(c,n[c]);return s.onerror=function(){l()},s.onreadystatechange=function(){if(s.readyState===XMLHttpRequest.DONE){var e=a(s);switch(s.status){case 200:return void i(e);case 401:r(e),l(e);break;case 0:d(e),l(e);break;default:l(e)}}},s.send(o),this},this.success=function(e){return i=e,this},this.authError=function(e){return r=e,this},this.netError=function(e){return d=e,this},this.error=function(e){return l=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,r){var d=new FormData;d.append("files[]",t),d.append("csrf_token",n);var l=new XMLHttpRequest;l.upload.addEventListener("progress",o),l.upload.addEventListener("error",i),l.open("POST",e,!0),l.setRequestHeader("X-Requested-With","XMLHttpRequest"),l.onreadystatechange=function(){l.readyState===XMLHttpRequest.DONE&&(200===l.status?a():void 0!==r&&r(JSON.parse(l.responseText)))},l.send(d)},function(){function e(){return 0==p||window.confirm($("body").data("js-modal-close-msg").replace(/\\n/g,"\n"))}function t(t){t.target.matches("#modal-overlay")&&e()&&(t.stopPropagation(),t.preventDefault(),u())}function n(e){e.preventDefault(),e.returnValue=""}function o(){KB.trigger("modal.close")}function a(){p=!0,window.addEventListener("beforeunload",n,!1)}function i(){KB.trigger("modal.loading"),d()}function r(){return document.querySelector("#modal-content form:not(.js-modal-ignore-form)")}function d(){var e=r();if(e){var t=e.getAttribute("action");t&&KB.http.postForm(t,e).success(function(e){KB.trigger("modal.stop"),e?s(e):u()}).error(function(e){KB.trigger("modal.stop"),e.hasOwnProperty("message")&&window.alert(e.message)})}}function l(){var e=KB.find("#modal-content form");e&&(e.on("change",a,!1),e.on("submit",i,!1));var t=document.querySelector("#modal-content input[autofocus]");t&&t.focus(),KB.render(),_KB.datePicker(),_KB.autoComplete(),_KB.tagAutoComplete(),_KB.get("Task").onPopoverOpened(),e&&($(".form-date").datepicker("option","onSelect",a),$(".form-datetime").datepicker("option","onSelect",a),$(".color-picker").on("change",a),$(".tag-autocomplete").on("change",a)),KB.trigger("modal.afterRender")}function s(e){var t=KB.find("#modal-content");t&&(t.replace(KB.dom("div").attr("id","modal-content").html(e).build()),l())}function c(e,n,a){var i=KB.dom("a").attr("href","#").attr("id","modal-close-button").html('').click(o).build(),r=KB.dom("div").attr("id","modal-header").add(i).build(),d=KB.dom("div").attr("id","modal-content").html(e).build(),s=KB.dom("div").attr("id","modal-box").style("width",n).add(r).add(d).build(),c=KB.dom("div").attr("id","modal-overlay").add(s).build();a&&c.addEventListener("click",t,!1),document.body.appendChild(c),l()}function u(){f=!1,p=!1,window.removeEventListener("beforeunload",n,!1);var e=KB.find("#modal-overlay");e&&(KB.trigger("modal.beforeDestroy"),e.remove())}function m(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 f=!1,p=!1;KB.on("modal.close",function(){u()}),KB.on("modal.submit",function(){d()}),KB.modal={open:function(e,t,n){KB.trigger("modal.open"),_KB.get("Dropdown").close(),u(),void 0===n&&(n=!0),KB.http.get(e).success(function(e){f=!0,c(e,m(t),n)})},close:function(){u()},isOpen:function(){return f},replace:function(e){KB.http.get(e).success(function(e){s(e)})},getForm:r,submitForm:d}}(),KB.tooltip=function(){function e(e){r()||n(e.target)}function t(){setTimeout(i,500)}function n(e){var t=e.querySelector("script");if(t)return void a(e,t.innerHTML);var n=e.dataset.href;n&&o(n,function(t){t&&a(e,t)})}function o(e,t){var n=new XMLHttpRequest;n.open("GET",e,!0),n.setRequestHeader("X-Requested-With","XMLHttpRequest"),n.onreadystatechange=function(){n.readyState===XMLHttpRequest.DONE&&200===n.status&&t(n.responseText)},n.send(null)}function a(e,n){var o=document.createElement("div");o.id="tooltip-container",o.innerHTML=n,o.addEventListener("mouseleave",t,!1);var a=e.getBoundingClientRect(),r=a.top+window.scrollY+a.height;if(o.style.top=r+"px",a.left>window.innerWidth-600){var d=window.innerWidth-a.right-window.scrollX;o.style.right=d+"px"}else{var l=a.left+window.scrollX;o.style.left=l+"px"}document.body.appendChild(o),document.body.onclick=function(e){o.contains(e.target)||i()}}function i(){var e=document.getElementById("tooltip-container");e&&e.parentNode.removeChild(e)}function r(){return!!document.getElementById("tooltip-container")}for(var d=document.querySelectorAll(".tooltip"),l=0;l=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([s]):l>0?(o[l].push(s),void 0===o[0][d]&&o[0].push(0),o[0][d]+=s):a.push(r(i.parse(s)))}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),l=0;l0&&(a.push(c),o.push([c])):s>0?o[s-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 l=0;l'),$.ajax({cache:!1,url:t.url,success:function(t){KB.dom(e).html('
'+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(++y0&&KB.http.uploadFile(t.url,w[y],t.csrf,n,i,o,a)}function f(){w.length>0?(KB.trigger("modal.enable"),KB.dom(B).empty().add(b())):(KB.trigger("modal.disable"),KB.dom(B).empty().add(h()))}function p(){return KB.dom("input").attr("id","file-input-element").attr("type","file").attr("name","files[]").attr("multiple",!0).on("change",l).hide().build()}function h(){var e=KB.dom("a").attr("href","#").text(t.labelChooseFiles).click(s).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("span").attr("id","file-delete-"+e).html('').on("click",function(){w.splice(e,1),KB.find("#file-item-"+e).remove(),f()}).build(),r=KB.dom("li").attr("id","file-item-"+e).add(i).add(o).text(" "+w[e].name+" ").add(a);return w[e].size>t.maxSize&&(r.add(KB.dom("div").addClass("file-error").text(t.labelOversize).build()),n=!0),n&&KB.trigger("modal.disable"),r.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(){l();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"),"",!0)}),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",!0)})),KB.exists("#task-view")&&(KB.onKey("e",function(){KB.modal.isOpen()||KB.modal.open(KB.find("#task-view").data("editUrl"),"large",!0)}),KB.onKey("c",function(){KB.modal.isOpen()||KB.modal.open(KB.find("#task-view").data("commentUrl"),"medium",!0)}),KB.onKey("s",function(){KB.modal.isOpen()||KB.modal.open(KB.find("#task-view").data("subtaskUrl"),"medium",!0)}),KB.onKey("l",function(){KB.modal.isOpen()||KB.modal.open(KB.find("#task-view").data("internalLinkUrl"),"medium",!0)})),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")})},document.addEventListener("DOMContentLoaded",function(){function e(e){e.preventDefault();for(var t=document.querySelectorAll("input[data-list-item=selectable]"),n=0;n0&&o()}function o(){var e=document.querySelector(".list-item-actions");e&&e.classList.remove("list-item-action-hidden")}function a(){var e=document.querySelector(".list-item-actions");e&&!e.classList.contains("list-item-action-hidden")&&e.classList.add("list-item-action-hidden")}function i(e){e.preventDefault();for(var t=document.querySelectorAll("input[data-list-item=selectable]:checked"),n=[],o=0;o0&&(e.index=e.index-1),KB.dom(e.items[e.index]).addClass("active")}function p(){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];void 0!==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(),o=document.body.scrollTop||document.documentElement.scrollTop;return 0===e.length?null:KB.dom("ul").attr("id","select-dropdown-menu").style("top",o+n.bottom+"px").style("left",n.left+"px").style("width",n.width+"px").style("maxHeight",window.innerHeight-n.bottom-20+"px").mouseover(d).click(l).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",s,!1)}function K(){var e=v();null!==e&&document.body.appendChild(e),document.addEventListener("keydown",i,!1),document.addEventListener("click",s,!1)}function B(){return t.defaultValue&&t.defaultValue in t.items?t.items[t.defaultValue]:t.placeholder?t.placeholder:""}var w,y,k,C,x;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)}),C=KB.dom("i").attr("class","fa fa-chevron-down select-dropdown-chevron").click(c).build(),x=KB.dom("span").hide().addClass("select-loading-icon").add(KB.dom("i").attr("class","fa fa-spinner fa-pulse").build()).build(),k=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").on("focus",c).on("input",r,!0).build(),w=KB.dom("div").addClass("select-dropdown-input-container").add(k).add(y).add(C).add(x).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).authError(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(p).hide()}function l(e){f=e.submitLabel,c()}function s(){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(f).build()}function c(){var e=s();KB.dom(h).replace(e),h=e}var u=!1,m=t.disabled||!1,f=t.submitLabel,p=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",l),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",l)}),h=s();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()),p=n.build(),e.appendChild(p)}}),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){-1!=n.indexOf("fragment=table")?$(".subtasks-table").replaceWith(e):-1!=n.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 n(e){switch(KB.utils.getKey(e)){case"Escape":u();break;case"ArrowUp":e.preventDefault(),e.stopImmediatePropagation(),s();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+" ",l=KB.utils.getSelectionPosition(e),s=a.substring(0,l.selectionStart-i.length),c=a.substring(l.selectionEnd),m=s.length+d.length;e.value=s+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=l();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(f()).build();e.appendChild(n)}}),KB.onClick(".js-template",function(e){var t=KB.dom(e.target).data("template"),n=KB.dom(e.target).data("templateTarget"),o=KB.find(n);o&&(o.build().value=t),_KB.controllers.Dropdown.close()}),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 n=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(){s("> ")}},{href:"#",html:'',click:function(){s("* ")}},{href:"#",html:'',click:function(){l("```")}}]).build(),o=KB.dom("textarea");o.attr("name",t.name),t.tabindex&&o.attr("tabindex",t.tabindex),t.required&&o.attr("required","required");var i=KB.dom(e).find("script");return o.text(i.innerText),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(n).add(m).build()}function a(){KB.dom(h).html(marked(m.value,{sanitize:!0})),KB.dom(f).toggle(),KB.dom(p).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){c(e+i()+e),u(e)}function l(e){c("\n"+e+"\n"+i()+"\n"+e),u(e,2)}function s(e){var t=i();if(-1===t.indexOf("\n"))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),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"),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(){this.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.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:visible",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"),l=o.parent().attr("data-column-id"),s=o.parent().attr("data-swimlane-id"),c=o.index()+1;o.removeClass("draggable-item-selected"),l==r&&s==d&&c==i||(e.changeTaskState(a),e.save(a,r,l,c,s))},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(),KB.tooltip()},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()});