diff options
Diffstat (limited to 'assets/js')
-rw-r--r-- | assets/js/app.min.js | 6 | ||||
-rw-r--r-- | assets/js/components/confirm-buttons.js (renamed from assets/js/components/submit-cancel.js) | 21 | ||||
-rw-r--r-- | assets/js/components/file-upload.js | 192 | ||||
-rw-r--r-- | assets/js/components/keyboard-shortcuts.js | 18 | ||||
-rw-r--r-- | assets/js/components/modal.js | 29 | ||||
-rw-r--r-- | assets/js/components/screenshot.js | 120 | ||||
-rw-r--r-- | assets/js/components/select-dropdown-autocomplete.js | 45 | ||||
-rw-r--r-- | assets/js/components/submit-buttons.js | 94 | ||||
-rw-r--r-- | assets/js/components/suggest-menu.js | 2 | ||||
-rw-r--r-- | assets/js/components/task-move-position.js | 3 | ||||
-rw-r--r-- | assets/js/core/base.js | 4 | ||||
-rw-r--r-- | assets/js/core/dom.js | 12 | ||||
-rw-r--r-- | assets/js/core/http.js | 35 | ||||
-rw-r--r-- | assets/js/core/modal.js | 172 | ||||
-rw-r--r-- | assets/js/core/utils.js | 7 | ||||
-rw-r--r-- | assets/js/src/BoardTask.js | 1 | ||||
-rw-r--r-- | assets/js/src/Dropdown.js | 9 | ||||
-rw-r--r-- | assets/js/src/FileUpload.js | 125 | ||||
-rw-r--r-- | assets/js/src/Popover.js | 161 | ||||
-rw-r--r-- | assets/js/src/Screenshot.js | 134 | ||||
-rw-r--r-- | assets/js/src/Search.js | 1 | ||||
-rw-r--r-- | assets/js/src/Task.js | 25 |
22 files changed, 726 insertions, 490 deletions
diff --git a/assets/js/app.min.js b/assets/js/app.min.js index 274b6ded..015f4a25 100644 --- a/assets/js/app.min.js +++ b/assets/js/app.min.js @@ -1,3 +1,3 @@ -!function(){function t(t,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 s=document.querySelector("#input-textarea-caret-position-mirror-div");s&&s.parentNode.removeChild(s)}var d=document.createElement("div");d.id="input-textarea-caret-position-mirror-div",document.body.appendChild(d);var l=d.style,c=window.getComputedStyle?getComputedStyle(t):t.currentStyle;l.whiteSpace="pre-wrap","INPUT"!==t.nodeName&&(l.wordWrap="break-word"),l.position="absolute",r||(l.visibility="hidden"),e.forEach(function(t){l[t]=c[t]}),n?t.scrollHeight>parseInt(c.height)&&(l.overflowY="scroll"):l.overflow="hidden",d.textContent=t.value.substring(0,a),"INPUT"===t.nodeName&&(d.textContent=d.textContent.replace(/\s/g," "));var u=document.createElement("span");u.textContent=t.value.substring(a)||".",d.appendChild(u);var p={top:u.offsetTop+parseInt(c.borderTopWidth),left:u.offsetLeft+parseInt(c.borderLeftWidth)};return r?u.style.backgroundColor="#aaa":document.body.removeChild(d),p}var e=["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&&"undefined"!=typeof module.exports?module.exports=t:o&&(window.getCaretCoordinates=t)}(),function(){function t(){if(!("KeyboardEvent"in window)||"key"in KeyboardEvent.prototype)return!1;var t={get:function(t){var e=o.keys[this.which||this.keyCode];return Array.isArray(e)&&(e=e[+this.shiftKey]),e}};return Object.defineProperty(KeyboardEvent.prototype,"key",t),t}var e,o={polyfill:t,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(e=1;e<25;e++)o.keys[111+e]="F"+e;var n="";for(e=65;e<91;e++)n=String.fromCharCode(e),o.keys[e]=[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(t){for(var e=(this.document||this.ownerDocument).querySelectorAll(t),o=e.length;--o>=0&&e.item(o)!==this;);return o>-1});var KB={components:{},utils:{},html:{},http:{},listeners:{clicks:{},changes:{},keys:{},internals:{}}};KB.on=function(t,e){this.listeners.internals.hasOwnProperty(t)||(this.listeners.internals[t]=[]),this.listeners.internals[t].push(e)},KB.trigger=function(t,e){if(this.listeners.internals.hasOwnProperty(t))for(var o=0;o<this.listeners.internals[t].length&&this.listeners.internals[t][o](e);o++);},KB.onClick=function(t,e){this.listeners.clicks[t]=e},KB.onChange=function(t,e){this.listeners.changes[t]=e},KB.onKey=function(t,e,o){this.listeners.keys[t]={callback:e,ignoreInputField:o||!1}},KB.listen=function(){function t(t){for(var e in n.listeners.clicks)n.listeners.clicks.hasOwnProperty(e)&&t.target.matches(e)&&(t.preventDefault(),n.listeners.clicks[e](t))}function e(t){for(var e in n.listeners.changes)n.listeners.changes.hasOwnProperty(e)&&t.target.matches(e)&&n.listeners.changes[e](t.target)}function o(t){var e=KB.utils.getKey(t),o=KB.utils.isInputField(t);if(o&&["Escape","Meta","Enter","Control"].indexOf(e)===-1||a.push(e),a.length>0){var i=!0;for(var r in n.listeners.keys)if(n.listeners.keys.hasOwnProperty(r)){var s=n.listeners.keys[r],d=r.split("+");if(KB.utils.arraysIdentical(a,d)){if(o&&!s.ignoreInputField)return void(a=[]);t.preventDefault(),t.stopPropagation(),a=[],s.callback(t);break}KB.utils.arraysStartsWith(a,d)&&(i=!1)}i&&(a=[])}}var n=this,a=[];document.addEventListener("click",t,!1),document.addEventListener("change",e,!1),window.addEventListener("keydown",o,!1)},KB.component=function(t,e){this.components[t]=e},KB.getComponent=function(t,e,o){var n=this.components[t];return new n(e,o)},KB.render=function(){for(var t in this.components)for(var e=document.querySelectorAll(".js-"+t),o=0;o<e.length;o++)if(this.components.hasOwnProperty(t)){var n;e[o].dataset.params&&(n=JSON.parse(e[o].dataset.params));var a=KB.getComponent(t,e[o],n);a.render(),e[o].className=e[o].className+"-rendered"}},KB.interval=function(t,e){setInterval(e,1e3*t)},KB.dom=function(t){function e(t){var e="string"==typeof t?document.createElement(t):t;this.attr=function(t,o){return null!==o&&"undefined"!=typeof o?(e.setAttribute(t,o),this):e.getAttribute(t)},this.data=function(t,o){return 1===arguments.length?e.dataset[t]:(e.dataset[t]=o,this)},this.hide=function(){return e.style.display="none",this},this.show=function(){return e.style.display="block",this},this.toggle=function(){return"none"===e.style.display?this.show():this.hide(),this},this.style=function(t,o){return e.style[t]=o,this},this.on=function(t,o,n){return e.addEventListener(t,function(t){n||t.preventDefault(),o(t.target)}),this},this.click=function(t){return this.on("click",t)},this.mouseover=function(t){return this.on("mouseover",t)},this.change=function(t){return this.on("change",t)},this.add=function(t){return e.appendChild(t),this},this.replace=function(t){return e.parentNode.replaceChild(t,e),this},this.html=function(t){return e.innerHTML=t,this},this.text=function(t){return e.appendChild(document.createTextNode(t)),this},this.addClass=function(t){return e.classList.add(t),this},this.removeClass=function(t){return e.classList.remove(t),this},this.toggleClass=function(t){return e.classList.toggle(t),this},this.hasClass=function(t){return e.classList.contains(t)},this.disable=function(){return e.disabled=!0,this},this.enable=function(){return e.disabled=!1,this},this.remove=function(){return e.parentNode.removeChild(e),this},this.parent=function(t){for(;e&&e!==document;e=e.parentNode)if(e.matches(t))return e;return null},this.find=function(t){return e.querySelector(t)},this["for"]=function(t,o){for(var n=0;n<o.length;n++){var a=o[n];if("object"!=typeof a)e.appendChild(KB.dom(t).text(a).build());else{var i=KB.dom(t);for(var r in a)a.hasOwnProperty(r)&&r in this&&"function"==typeof this[r]?i[r](a[r]):i.attr(r,a[r]);e.appendChild(i.build())}}return this},this.build=function(){return e}}return new e(t)},KB.find=function(t){var e=document.querySelector(t);return e?KB.dom(e):null},KB.exists=function(t){return!!document.querySelector(t)},KB.focus=function(t){var e=document.querySelector(t);if(e)return e.focus()},KB.html.label=function(t,e){return KB.dom("label").attr("for",e).text(t).build()},KB.html.radio=function(t,e,o){return KB.dom("label").add(KB.dom("input").attr("type","radio").attr("name",e).attr("value",o).build()).text(t).build()},KB.html.radios=function(t){var e=KB.dom("div");for(var o in t)t.hasOwnProperty(o)&&e.add(KB.html.radio(o.label,o.name,o.value))},KB.http.request=function(t,e,o,n){function a(t){try{return JSON.parse(t.responseText)}catch(e){return t.responseText}}var i=function(){},r=function(){};this.execute=function(){var s=new XMLHttpRequest;s.open(t,e,!0),s.setRequestHeader("X-Requested-With","XMLHttpRequest");for(var d in o)o.hasOwnProperty(d)&&s.setRequestHeader(d,o[d]);return s.onerror=function(){r()},s.onreadystatechange=function(){if(s.readyState===XMLHttpRequest.DONE){var t=a(s);200===s.status?i(t):r(t)}},s.send(n),this},this.success=function(t){return i=t,this},this.error=function(t){return r=t,this}},KB.http.get=function(t){return new KB.http.request("GET",t).execute()},KB.http.postJson=function(t,e){var o={"Content-Type":"application/json",Accept:"application/json"};return new KB.http.request("POST",t,o,JSON.stringify(e)).execute()},KB.utils.formatDuration=function(t){return t>=86400?Math.round(t/86400)+"d":t>=3600?Math.round(t/3600)+"h":t>=60?Math.round(t/60)+"m":t+"s"},KB.utils.getSelectionPosition=function(t){var e,o;return e=t.value.length<t.selectionStart?t.value.length:t.selectionStart,o=t.selectionStart===t.selectionEnd?e:t.selectionEnd,{selectionStart:e,selectionEnd:o}},KB.utils.arraysIdentical=function(t,e){var o=t.length;if(o!==e.length)return!1;for(;o--;)if(t[o]!==e[o])return!1;return!0},KB.utils.arraysStartsWith=function(t,e){for(var o=Math.min(t.length,e.length),n=0;n<o;n++)if(t[n]!==e[n])return!1;return!0},KB.utils.isInputField=function(t){var e=t.target;return!("INPUT"!==e.tagName&&"SELECT"!==e.tagName&&"TEXTAREA"!==e.tagName&&!e.isContentEditable)},KB.utils.getKey=function(t){var e={Esc:"Escape",Up:"ArrowUp",Down:"ArrowDown",Left:"ArrowLeft",Right:"ArrowRight"};for(var o in e)if(e.hasOwnProperty(o)&&o===t.key)return e[o];return t.key},KB.onClick(".accordion-toggle",function(t){var e=KB.dom(t.target).parent(".accordion-section");e&&(KB.dom(e).toggleClass("accordion-collapsed"),KB.dom(KB.dom(e).find(".accordion-content")).toggle())}),KB.component("calendar",function(t,e){this.render=function(){var o=$(t);o.fullCalendar({locale:$("body").data("js-lang"),editable:!0,eventLimit:!0,defaultView:"month",header:{left:"prev,next today",center:"title",right:"month,agendaWeek,agendaDay"},eventDrop:function(t){$.ajax({cache:!1,url:e.saveUrl,contentType:"application/json",type:"POST",processData:!1,data:JSON.stringify({task_id:t.id,date_due:t.start.format()})})},viewRender:function(){var t=e.checkUrl,n={start:o.fullCalendar("getView").start.format(),end:o.fullCalendar("getView").end.format()};for(var a in n)t+="&"+a+"="+n[a];$.getJSON(t,function(t){o.fullCalendar("removeEvents"),o.fullCalendar("addEventSource",t),o.fullCalendar("rerenderEvents")})}})}}),KB.component("chart-project-avg-time-column",function(t,e){this.render=function(){var o=e.metrics,n=[e.label],a=[];for(var i in o)n.push(o[i].average),a.push(o[i].title);KB.dom(t).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(t,e){this.render=function(){for(var o=e.metrics,n=[[e.labelTotal]],a=[],i=d3.time.format("%Y-%m-%d"),r=d3.time.format(e.dateFormat),s=0;s<o.length;s++)for(var d=0;d<o[s].length;d++)0===s?n.push([o[s][d]]):(n[d+1].push(o[s][d]),d>0&&(void 0===n[0][s]&&n[0].push(0),n[0][s]+=o[s][d]),0===d&&a.push(r(i.parse(o[s][d]))));KB.dom(t).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(t,e){this.render=function(){for(var o=e.metrics,n=[],a=[],i=[],r=d3.time.format("%Y-%m-%d"),s=d3.time.format(e.dateFormat),d=0;d<o.length;d++)for(var l=0;l<o[d].length;l++)0===d?(n.push([o[d][l]]),l>0&&a.push(o[d][l])):(n[l].push(o[d][l]),0===l&&i.push(s(r.parse(o[d][l]))));KB.dom(t).add(KB.dom("div").attr("id","chart").build()),c3.generate({data:{columns:n,type:"area-spline",groups:[a]},axis:{x:{type:"category",categories:i}}})}}),KB.component("chart-project-lead-cycle-time",function(t,e){this.render=function(){var o=e.metrics,n=[e.labelCycle],a=[e.labelLead],i=[],r={};r[e.labelCycle]="area",r[e.labelLead]="area-spline";var s={};s[e.labelLead]="#afb42b",s[e.labelCycle]="#4e342e";for(var d=0;d<o.length;d++)n.push(parseInt(o[d].avg_cycle_time)),a.push(parseInt(o[d].avg_lead_time)),i.push(o[d].day);KB.dom(t).add(KB.dom("div").attr("id","chart").build()),c3.generate({data:{columns:[a,n],types:r,colors:s},axis:{x:{type:"category",categories:i},y:{tick:{format:KB.utils.formatDuration}}}})}}),KB.component("chart-project-task-distribution",function(t,e){this.render=function(){for(var o=[],n=0;n<e.metrics.length;n++)o.push([e.metrics[n].column_title,e.metrics[n].nb_tasks]);KB.dom(t).add(KB.dom("div").attr("id","chart").build()),c3.generate({data:{columns:o,type:"donut"}})}}),KB.component("chart-project-time-comparison",function(t,e){this.render=function(){var o=[e.labelSpent],n=[e.labelEstimated],a=[];for(var i in e.metrics)o.push(e.metrics[i].time_spent),n.push(e.metrics[i].time_estimated),a.push("open"===i?e.labelOpen:e.labelClosed);KB.dom(t).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(t,e){this.render=function(){for(var o=[],n=0;n<e.metrics.length;n++)o.push([e.metrics[n].user,e.metrics[n].nb_tasks]);KB.dom(t).add(KB.dom("div").attr("id","chart").build()),c3.generate({data:{columns:o,type:"donut"}})}}),KB.component("chart-task-time-column",function(t,e){this.render=function(){for(var o=e.metrics,n=[e.label],a=[],i=0;i<o.length;i++)n.push(o[i].time_spent),a.push(o[i].title);KB.dom(t).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("external-task-view",function(t,e){this.render=function(){$.ajax({cache:!1,url:e.url,success:function(e){KB.dom(t).html('<div id="external-task-view">'+e+"</div>")}})}}),KB.component("image-slideshow",function(t,e){function o(t){switch(KB.utils.getKey(t)){case"Escape":d();break;case"ArrowRight":i();break;case"ArrowLeft":r()}}function n(t){t.matches(".slideshow-next-icon")?i():t.matches(".slideshow-previous-icon")?r():t.matches(".slideshow-download-icon")?window.location.href=t.href:d()}function a(t){var e=KB.dom(t).data("imageId"),o=l(e);s(o)}function i(){d();for(var t=0;t<e.images.length;t++)if(e.images[t].id===p.id){var o=t+1;o>=e.images.length&&(o=0),p=e.images[o];break}s()}function r(){d();for(var t=0;t<e.images.length;t++)if(e.images[t].id===p.id){var o=t-1;o<0&&(o=e.images.length-1),p=e.images[o];break}s()}function s(){var t=KB.dom("div").attr("class","fa fa-window-close slideshow-icon slideshow-close-icon").build(),e=KB.dom("a").attr("class","fa fa-download slideshow-icon slideshow-download-icon").attr("href",c(p,"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(p,"image")).attr("alt",p.name).attr("title",p.name).style("maxHeight",window.innerHeight-50+"px").build(),s=KB.dom("figcaption").text(p.name).build(),d=KB.dom("figure").add(r).add(s).build(),l=KB.dom("div").addClass("image-slideshow-overlay").add(t).add(e).add(a).add(i).add(d).click(n).build();document.body.appendChild(l),document.addEventListener("keydown",o,!1)}function d(){var t=KB.find(".image-slideshow-overlay");null!==t&&(document.removeEventListener("keydown",o,!1),t.remove())}function l(t){for(var o=0;o<e.images.length;o++)if(e.images[o].id===t)return e.images[o];return null}function c(t,o){var n=new RegExp(e.regex,"g");return e.url[o].replace(n,t.id)}function u(t){return KB.dom("img").attr("src",c(t,"thumbnail")).attr("alt",t.name).attr("title",t.name).data("imageId",t.id).click(a).build()}var p;this.render=function(){p=e.image,t.appendChild(u(p))}}),KB.keyboardShortcuts=function(){function t(t){var e=KB.find(t);null!==e&&(window.location=e.attr("href"))}function e(){var t=$("form");1==t.length?t.submit():t.length>1&&("INPUT"===document.activeElement.tagName||"TEXTAREA"===document.activeElement.tagName?$(document.activeElement).parents("form").submit():_KB.get("Popover").isOpen()&&$("#popover-container form").submit())}KB.onKey("?",function(){_KB.get("Popover").open($("body").data("keyboard-shortcut-url"))}),KB.onKey("Escape",function(){KB.exists("#suggest-menu")||(_KB.get("Popover").close(),_KB.get("Dropdown").close())}),KB.onKey("Meta+Enter",e,!0),KB.onKey("Control+Enter",e,!0),KB.onKey("b",function(){KB.trigger("board.selector.open")}),KB.exists("#board")&&(KB.onKey("c",function(){_KB.get("BoardHorizontalScrolling").toggle()}),KB.onKey("s",function(){_KB.get("BoardCollapsedMode").toggle()}),KB.onKey("n",function(){_KB.get("Popover").open($("#board").data("task-creation-url"))})),KB.exists("#task-view")&&(KB.onKey("e",function(){_KB.get("Popover").open(KB.find("#task-view").data("editUrl"))}),KB.onKey("c",function(){_KB.get("Popover").open(KB.find("#task-view").data("commentUrl"))}),KB.onKey("s",function(){_KB.get("Popover").open(KB.find("#task-view").data("subtaskUrl"))}),KB.onKey("l",function(){_KB.get("Popover").open(KB.find("#task-view").data("internalLinkUrl"))})),KB.onKey("f",function(){KB.focus("#form-search")}),KB.onKey("r",function(){var t=$(".filter-reset").data("filter"),e=$("#form-search");e.val(t),$("form.search").submit()}),KB.onKey("v+o",function(){t("a.view-overview")}),KB.onKey("v+b",function(){t("a.view-board")}),KB.onKey("v+c",function(){t("a.view-calendar")}),KB.onKey("v+l",function(){t("a.view-listing")}),KB.onKey("v+g",function(){t("a.view-gantt")})},KB.onChange(".js-project-creation-select-options",function(t){var e=t.value;"0"===e?KB.find(".js-project-creation-options").hide():KB.find(".js-project-creation-options").show()}),KB.component("project-select-role",function(t,e){function o(t){s=!0,e.role=t.value,a(),n()}function n(){KB.http.postJson(e.url,{id:e.id,role:e.role}).success(function(){s=!1,d=!0,a()}).error(function(){s=!1,d=!1,l=!0,a()})}function a(){KB.dom(r).remove(),r=i(),t.appendChild(r)}function i(){var t=[],n=KB.dom("div");for(var a in e.roles)if(e.roles.hasOwnProperty(a)){var i={value:a,text:e.roles[a]};e.role===a&&(i.selected="selected"),t.push(i)}return n.add(KB.dom("select").change(o)["for"]("option",t).build()),s?(n.text(" "),n.add(KB.dom("i").attr("class","fa fa-spinner fa-pulse fa-fw").build())):d?(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,s=!1,d=!1,l=!1;this.render=function(){r=i(),t.appendChild(r)}}),KB.component("select-dropdown-autocomplete",function(t,e){function o(t){switch(KB.utils.getKey(t)){case"Escape":y.value="",m();break;case"ArrowUp":t.preventDefault(),t.stopImmediatePropagation(),c();break;case"ArrowDown":t.preventDefault(),t.stopImmediatePropagation(),u();break;case"Enter":t.preventDefault(),t.stopImmediatePropagation(),d()}}function n(){m(),v()}function a(t){KB.dom(t).hasClass("select-dropdown-menu-item")&&(KB.find(".select-dropdown-menu-item.active").removeClass("active"),KB.dom(t).addClass("active"))}function i(){d()}function r(e){t.contains(e.target)||(y.value="",m())}function s(){var t=KB.find("#select-dropdown-menu");null===t?v():m()}function d(){var t=KB.find(".select-dropdown-menu-item.active"),o=t.data("value");if(K.value=o,y.value=e.items[o],m(),e.redirect){var n=new RegExp(e.redirect.regex,"g");window.location=e.redirect.url.replace(n,o)}}function l(){for(var t=document.querySelectorAll(".select-dropdown-menu-item"),e=0;e<t.length;e++)if(KB.dom(t[e]).hasClass("active")){KB.dom(t[e]).removeClass("active");break}return{items:t,index:e}}function c(){var t=l();t.index>0&&(t.index=t.index-1),KB.dom(t.items[t.index]).addClass("active")}function u(){var t=l();t.index<t.items.length-1&&t.index++,KB.dom(t.items[t.index]).addClass("active")}function p(t){var o=[],n=Object.keys(t);e.sortByKeys&&n.sort();for(var a=0;a<n.length;a++)o.push({"class":"select-dropdown-menu-item",text:t[n[a]],"data-label":t[n[a]],"data-value":n[a]});return o}function h(t,o){for(var n=[],a=!1,i=0;i<o.length;i++)if(0===t.length||0===o[i]["data-label"].toLowerCase().indexOf(t.toLowerCase())){var r=o[i];"undefined"!=typeof e.defaultValue&&String(e.defaultValue)===r["data-value"]&&(r["class"]+=" active",a=!0),n.push(r)}return!a&&n.length>0&&(n[0]["class"]+=" active"),n}function f(){var t=h(y.value,p(e.items)),o=b.getBoundingClientRect();return 0===t.length?null:KB.dom("ul").attr("id","select-dropdown-menu").style("top",o.bottom+"px").style("left",o.left+"px").style("width",o.width+"px").style("maxHeight",window.innerHeight-o.bottom-20+"px").mouseover(a).click(i)["for"]("li",t).build()}function m(){var t=KB.find("#select-dropdown-menu");null!==t&&t.remove(),document.removeEventListener("keydown",o,!1),document.removeEventListener("click",r,!1)}function v(){var t=f();null!==t&&document.body.appendChild(t),document.addEventListener("keydown",o,!1),document.addEventListener("click",r,!1)}function g(){return e.defaultValue&&e.defaultValue in e.items?e.items[e.defaultValue]:e.placeholder?e.placeholder:""}var b,y,K;this.render=function(){var o=KB.dom("i").attr("class","fa fa-chevron-down select-dropdown-chevron").click(s).build();K=KB.dom("input").attr("type","hidden").attr("name",e.name).attr("value",e.defaultValue||"").build(),y=KB.dom("input").attr("type","text").attr("placeholder",g()).addClass("select-dropdown-input").style("width",t.offsetWidth-30+"px").on("focus",s).on("input",n,!0).build(),b=KB.dom("div").addClass("select-dropdown-input-container").add(K).add(y).add(o).build(),t.appendChild(b),e.onFocus&&e.onFocus.forEach(function(t){KB.on(t,function(){y.focus()})})}}),KB.interval(60,function(){var t=KB.find("body").data("statusUrl"),e=KB.find("body").data("loginUrl");null===KB.find(".form-login")&&KB.http.get(t).error(function(){window.location=e})}),KB.component("submit-cancel",function(t,e){function o(){r=!0,KB.find("#modal-submit-button").replace(i()),KB.trigger("modal.submit")}function n(){KB.trigger("modal.cancel"),_KB.get("Popover").close()}function a(){r=!1,KB.find("#modal-submit-button").replace(i())}function i(){var t=KB.dom("button").click(o).attr("id","modal-submit-button").attr("type","submit").attr("class","btn btn-blue");return r&&t.disable().add(KB.dom("i").attr("class","fa fa-spinner fa-pulse").build()).text(" "),t.text(e.submitLabel).build()}var r=!1;this.render=function(){KB.on("modal.stop",a);var o=KB.dom("div").attr("class","form-actions").add(i()).text(" "+e.orLabel+" ").add(KB.dom("a").attr("href","#").click(n).text(e.cancelLabel).build()).build();t.appendChild(o)}}),KB.component("suggest-menu",function(t,e){function o(t){switch(KB.utils.getKey(t)){case"Escape":u();break;case"ArrowUp":t.preventDefault(),t.stopImmediatePropagation(),l();break;case"ArrowDown":t.preventDefault(),t.stopImmediatePropagation(),c();break;case"Enter":t.preventDefault(),t.stopImmediatePropagation(),i()}}function n(){i()}function a(t){KB.dom(t).hasClass("suggest-menu-item")&&(KB.find(".suggest-menu-item.active").removeClass("active"),KB.dom(t).addClass("active"))}function i(){t.focus();var e=KB.find(".suggest-menu-item.active"),o=e.data("value"),n=e.data("trigger"),a=t.value,i=r(t),s=n+o+" ",d=KB.utils.getSelectionPosition(t),l=a.substring(0,d.selectionStart-i.length),c=a.substring(d.selectionEnd),p=l.length+s.length;t.value=l+s+c,t.setSelectionRange(p,p),u()}function r(t){var e=t.value.substring(0,t.selectionEnd).split("\n"),o=e[e.length-1],n=o.split(" ");return n[n.length-1]}function s(){for(var t=[".popover-form","#popover-content","body"],e=0;e<t.length;e++){var o=document.querySelector(t[e]);if(null!==o)return o}return null}function d(){for(var t=document.querySelectorAll(".suggest-menu-item"),e=0;e<t.length;e++)if(KB.dom(t[e]).hasClass("active")){KB.dom(t[e]).removeClass("active");break}return{items:t,index:e}}function l(){var t=d();t.index>0&&(t.index=t.index-1),KB.dom(t.items[t.index]).addClass("active")}function c(){var t=d();t.index<t.items.length-1&&t.index++,KB.dom(t.items[t.index]).addClass("active")}function u(){var t=KB.find("#suggest-menu");null!==t&&t.remove(),document.removeEventListener("keydown",o,!1)}function p(t){var o=r(t),n=h(o,e.triggers);u(),null!==n&&f(n,o.substring(n.length),e.triggers[n])}function h(t,e){for(var o in e)if(e.hasOwnProperty(o)&&0===t.indexOf(o))return o;return null}function f(t,e,o){if("string"==typeof o){var n=new RegExp("SEARCH_TERM","g"),a=o.replace(n,e);KB.http.get(a).success(function(o){m(t,e,o)})}else m(t,e,o)}function m(t,e,o){o=v(e,o),o.length>0&&b(g(t,o))}function v(t,e){var o=[];if(0===t.length)return e;for(var n=0;n<e.length;n++)0===e[n].value.toLowerCase().indexOf(t.toLowerCase())&&o.push(e[n]);return o}function g(t,e){for(var o=[],n=0;n<e.length;n++){var a="suggest-menu-item";0===n&&(a+=" active"),o.push({"class":a,html:e[n].html,"data-value":e[n].value,"data-trigger":t})}return o}function b(e){var i=s(),r=getCaretCoordinates(t,t.selectionEnd),d=r.left+t.offsetLeft-t.scrollLeft,l=r.top+t.offsetTop-t.scrollTop+16;document.addEventListener("keydown",o,!1);var c=KB.dom("ul").attr("id","suggest-menu").click(n).mouseover(a).style("left",d+"px").style("top",l+"px")["for"]("li",e).build();i.appendChild(c)}this.render=function(){t.addEventListener("input",function(){p(this)})}}),KB.component("task-move-position",function(t,e){function o(t){var e=KB.dom(document).find("#"+t);return e?parseInt(e.options[e.selectedIndex].value):null}function n(){var t=o("form-swimlanes");return null===t?e.board[0].id:t}function a(){var t=o("form-columns");return null===t?e.board[0].columns[0].id:t}function i(){var t=o("form-position");return null===t?1:t}function r(){var t=KB.find("input[name=positionChoice]:checked");return t?t.value:"before"}function s(){var t=KB.dom(document).find("#form-columns");KB.dom(t).replace(p());var e=KB.dom(document).find("#form-tasks");KB.dom(e).replace(h())}function d(){var t=KB.dom(document).find("#form-tasks");KB.dom(t).replace(h())}function l(t){KB.trigger("modal.stop"),KB.find("#message-container").replace(KB.dom("div").attr("id","message-container").attr("class","alert alert-error").text(t).build())}function c(){var t=i(),o=r();"after"===o&&t++,KB.find("#message-container").replace(KB.dom("div").attr("id","message-container").build()),KB.http.postJson(e.saveUrl,{column_id:a(),swimlane_id:n(),position:t}).success(function(){window.location.reload(!0)}).error(function(t){t&&l(t.message)})}function u(){var t=[];return e.board.forEach(function(e){t.push({value:e.id,text:e.name})}),KB.dom("select").attr("id","form-swimlanes").change(s)["for"]("option",t).build()}function p(){var t=[],o=n();return e.board.forEach(function(e){o===e.id&&e.columns.forEach(function(e){t.push({value:e.id,text:e.title})})}),KB.dom("select").attr("id","form-columns").change(d)["for"]("option",t).build()}function h(){var t=[],o=n(),i=a(),r=KB.dom("div").attr("id","form-tasks");return e.board.forEach(function(e){o===e.id&&e.columns.forEach(function(e){i===e.id&&e.tasks.forEach(function(e){t.push({value:e.position,text:"#"+e.id+" - "+e.title})})})}),t.length>0&&r.add(KB.html.label(e.positionLabel,"form-position")).add(KB.dom("select").attr("id","form-position")["for"]("option",t).build()).add(KB.html.radio(e.beforeLabel,"positionChoice","before")).add(KB.html.radio(e.afterLabel,"positionChoice","after")),r.build()}this.render=function(){KB.on("modal.submit",c);var o=KB.dom("div").on("submit",c).add(KB.dom("div").attr("id","message-container").build()).add(KB.html.label(e.swimlaneLabel,"form-swimlanes")).add(u()).add(KB.html.label(e.columnLabel,"form-columns")).add(p()).add(h()).build();t.appendChild(o)}}),KB.component("text-editor",function(t,e){function o(){var t=KB.dom("div").attr("class","text-editor-toolbar")["for"]("a",[{href:"#",html:'<i class="fa fa-pencil-square-o fa-fw"></i> '+e.labelWrite,click:function(){a()}}]).build();return m=KB.dom("div").attr("class","text-editor-preview-area markdown").build(),KB.dom("div").attr("class","text-editor-view-mode").add(t).add(m).hide().build()}function n(){var t=KB.dom("div").attr("class","text-editor-toolbar")["for"]("a",[{href:"#",html:'<i class="fa fa-eye fa-fw"></i> '+e.labelPreview,click:function(){a()}},{href:"#",html:'<i class="fa fa-bold fa-fw"></i>',click:function(){s("**")}},{href:"#",html:'<i class="fa fa-italic fa-fw"></i>',click:function(){s("_")}},{href:"#",html:'<i class="fa fa-strikethrough fa-fw"></i>',click:function(){s("~~")}},{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(){d("```")}}]).build(),o=KB.dom("textarea");return o.attr("name",e.name),e.tabindex&&o.attr("tabindex",e.tabindex),e.required&&o.attr("required","required"),o.text(e.text),e.placeholder&&o.attr("placeholder",e.placeholder),p=o.build(),e.suggestOptions&&KB.getComponent("suggest-menu",p,e.suggestOptions).render(),KB.dom("div").attr("class","text-editor-write-mode").add(t).add(p).build()}function a(){KB.dom(m).html(marked(p.value,{sanitize:!0})),KB.dom(h).toggle(),KB.dom(f).toggle()}function i(){return p.value.substring(p.selectionStart,p.selectionEnd)}function r(t,e,o,n){return t.substring(0,e)+n+t.substring(o)}function s(t){var e=i();c(t+e+t),u(t)}function d(t){var e=i();c("\n"+t+"\n"+e+"\n"+t),u(t,2)}function l(t){var e=i();if(e.indexOf("\n")===-1)c("\n"+t+e);else{for(var o=e.split("\n"),n=0;n<o.length;n++)o[n].indexOf(t)===-1&&(o[n]=t+o[n]);c(o.join("\n"))}u(t,1)}function c(t){p.focus();var e=!1,o=KB.utils.getSelectionPosition(p);if(v=o.selectionStart,g=o.selectionEnd,document.queryCommandSupported("insertText")&&(e=document.execCommand("insertText",!1,t)),!e){try{document.execCommand("ms-beginUndoUnit")}catch(n){}p.value=r(p.value,v,g,t);try{document.execCommand("ms-endUndoUnit")}catch(n){}}}function u(t,e){e=e||0;var o=g+t.length+e;p.setSelectionRange(o,o)}var p,h,f,m,v,g;this.render=function(){f=n(),h=o(),t.appendChild(KB.dom("div").attr("class","text-editor").add(h).add(f).build()),e.autofocus&&p.focus()}}),document.addEventListener("DOMContentLoaded",function(){KB.render(),KB.listen(),KB.keyboardShortcuts()});var Kanboard={};Kanboard.App=function(){this.controllers={}},Kanboard.App.prototype.get=function(t){return this.controllers[t]},Kanboard.App.prototype.execute=function(){for(var t in Kanboard)if("App"!==t){var e=new Kanboard[t](this);this.controllers[t]=e,"function"==typeof e.execute&&e.execute(),"function"==typeof e.listen&&e.listen(),"function"==typeof e.focus&&e.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(t){t.preventDefault()})},Kanboard.App.prototype.datePicker=function(){var t=$("body"),e=t.data("js-date-format"),o=t.data("js-time-format"),n=t.data("js-lang");$.datepicker.setDefaults($.datepicker.regional[n]),$.timepicker.setDefaults($.timepicker.regional[n]),$(".form-date").datepicker({showOtherMonths:!0,selectOtherMonths:!0,dateFormat:e,constrainInput:!1}),$(".form-datetime").datetimepicker({dateFormat:e,timeFormat:o,constrainInput:!1})},Kanboard.App.prototype.tagAutoComplete=function(){$(".tag-autocomplete").select2({tags:!0})},Kanboard.App.prototype.autoComplete=function(){$(".autocomplete").each(function(){var t=$(this),e=t.data("dst-field"),o=t.data("dst-extra-field");""===$("#form-"+e).val()&&t.parent().find("button[type=submit]").attr("disabled","disabled"),t.autocomplete({source:t.data("search-url"),minLength:1, -select:function(n,a){$("input[name="+e+"]").val(a.item.id),o&&$("input[name="+o+"]").val(a.item[o]),t.parent().find("button[type=submit]").removeAttr("disabled")}})})},Kanboard.App.prototype.hasId=function(t){return!!document.getElementById(t)},Kanboard.App.prototype.showLoadingIcon=function(){$("body").append('<span id="app-loading-icon"> <i class="fa fa-spinner fa-spin"></i></span>')},Kanboard.App.prototype.hideLoadingIcon=function(){$("#app-loading-icon").remove()},Kanboard.App.prototype.isVisible=function(){var t="";return"undefined"!=typeof document.hidden?t="visibilityState":"undefined"!=typeof document.mozHidden?t="mozVisibilityState":"undefined"!=typeof document.msHidden?t="msVisibilityState":"undefined"!=typeof document.webkitHidden&&(t="webkitVisibilityState"),""===t||"visible"==document[t]},Kanboard.BoardCollapsedMode=function(t){this.app=t},Kanboard.BoardCollapsedMode.prototype.toggle=function(){var t=this;this.app.showLoadingIcon(),$.ajax({cache:!1,url:$('.filter-display-mode:not([style="display: none;"]) a').attr("href"),success:function(e){$(".filter-display-mode").toggle(),t.app.get("BoardDragAndDrop").refresh(e)}})},Kanboard.BoardColumnView=function(t){this.app=t},Kanboard.BoardColumnView.prototype.execute=function(){this.app.hasId("board")&&this.render()},Kanboard.BoardColumnView.prototype.listen=function(){var t=this;$(document).on("click",".board-toggle-column-view",function(){t.toggle($(this).data("column-id"))})},Kanboard.BoardColumnView.prototype.onBoardRendered=function(){this.render()},Kanboard.BoardColumnView.prototype.render=function(){var t=this;$(".board-column-header").each(function(){var e=$(this).data("column-id");localStorage.getItem("hidden_column_"+e)&&t.hideColumn(e)})},Kanboard.BoardColumnView.prototype.toggle=function(t){localStorage.getItem("hidden_column_"+t)?this.showColumn(t):this.hideColumn(t)},Kanboard.BoardColumnView.prototype.hideColumn=function(t){$(".board-column-"+t+" .board-column-expanded").hide(),$(".board-column-"+t+" .board-column-collapsed").show(),$(".board-column-header-"+t+" .board-column-expanded").hide(),$(".board-column-header-"+t+" .board-column-collapsed").show(),$(".board-column-header-"+t).each(function(){$(this).removeClass("board-column-compact"),$(this).addClass("board-column-header-collapsed")}),$(".board-column-"+t).each(function(){$(this).addClass("board-column-task-collapsed")}),$(".board-column-"+t+" .board-rotation").each(function(){$(this).css("width",$(".board-column-"+t).height())}),localStorage.setItem("hidden_column_"+t,1)},Kanboard.BoardColumnView.prototype.showColumn=function(t){$(".board-column-"+t+" .board-column-expanded").show(),$(".board-column-"+t+" .board-column-collapsed").hide(),$(".board-column-header-"+t+" .board-column-expanded").show(),$(".board-column-header-"+t+" .board-column-collapsed").hide(),$(".board-column-header-"+t).removeClass("board-column-header-collapsed"),$(".board-column-"+t).removeClass("board-column-task-collapsed"),0==localStorage.getItem("horizontal_scroll")&&$(".board-column-header-"+t).addClass("board-column-compact"),localStorage.removeItem("hidden_column_"+t)},Kanboard.BoardHorizontalScrolling=function(t){this.app=t},Kanboard.BoardHorizontalScrolling.prototype.execute=function(){this.app.hasId("board")&&this.render()},Kanboard.BoardHorizontalScrolling.prototype.listen=function(){var t=this;$(document).on("click",".filter-toggle-scrolling",function(e){e.preventDefault(),t.toggle()})},Kanboard.BoardHorizontalScrolling.prototype.onBoardRendered=function(){this.render()},Kanboard.BoardHorizontalScrolling.prototype.toggle=function(){var t=localStorage.getItem("horizontal_scroll")||1;localStorage.setItem("horizontal_scroll",0==t?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(t){this.app=t},Kanboard.BoardPolling.prototype.execute=function(){if(this.app.hasId("board")){var t=parseInt($("#board").attr("data-check-interval"));t>0&&window.setInterval(this.check.bind(this),1e3*t)}},Kanboard.BoardPolling.prototype.check=function(){if(this.app.isVisible()&&!this.app.get("BoardDragAndDrop").savingInProgress){var t=this;this.app.showLoadingIcon(),$.ajax({cache:!1,url:$("#board").data("check-url"),statusCode:{200:function(e){t.app.get("BoardDragAndDrop").refresh(e)},304:function(){t.app.hideLoadingIcon()}}})}},Kanboard.BoardTask=function(t){this.app=t},Kanboard.BoardTask.prototype.listen=function(){var t=this;$(document).on("click",".task-board-change-assignee",function(e){e.preventDefault(),e.stopPropagation(),t.app.get("Popover").open($(this).data("url"))}),$(document).on("click",".task-board",function(t){"A"!=t.target.tagName&&"IMG"!=t.target.tagName&&(window.location=$(this).data("task-url"))})},Kanboard.Column=function(t){this.app=t},Kanboard.Column.prototype.listen=function(){this.dragAndDrop()},Kanboard.Column.prototype.dragAndDrop=function(){var t=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(t,e){return e.children().each(function(){$(this).width($(this).width())}),e},stop:function(e,o){var n=o.item;n.removeClass("draggable-item-selected"),t.savePosition(n.data("column-id"),n.index()+1)},start:function(t,e){e.item.addClass("draggable-item-selected")}}).disableSelection()},Kanboard.Column.prototype.savePosition=function(t,e){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:t,position:e}),complete:function(){n.app.hideLoadingIcon()}})},Kanboard.Dropdown=function(t){this.app=t},Kanboard.Dropdown.prototype.listen=function(){var t=this;$(document).on("click",function(){t.close()}),$(document).on("click","#popover-content",function(){t.close()}),$(document).on("click",".dropdown-menu",function(e){e.preventDefault(),e.stopImmediatePropagation(),t.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)}),$(document).on("click",".dropdown-submenu-open li",function(t){$(t.target).is("li")&&$(this).find("a:visible")[0].click()})},Kanboard.Dropdown.prototype.close=function(){$("#dropdown").remove()},Kanboard.Dropdown.prototype.onPopoverOpened=function(){this.close()},Kanboard.FileUpload=function(t){this.app=t,this.files=[],this.currentFile=0},Kanboard.FileUpload.prototype.onPopoverOpened=function(){var t=document.getElementById("file-dropzone"),e=this;t&&(t.ondragover=t.ondragenter=function(t){t.stopPropagation(),t.preventDefault()},t.ondrop=function(t){t.stopPropagation(),t.preventDefault(),e.files=t.dataTransfer.files,e.show(),$("#file-error-max-size").hide()},$(document).on("click","#file-browser",function(t){t.preventDefault(),$("#file-form-element").get(0).click()}),$(document).on("click","#file-upload-button",function(t){t.preventDefault(),e.currentFile=0,e.checkFiles()}),$("#file-form-element").change(function(){e.files=document.getElementById("file-form-element").files,e.show(),$("#file-error-max-size").hide()}))},Kanboard.FileUpload.prototype.show=function(){if($("#file-list").remove(),this.files.length>0){$("#file-upload-button").prop("disabled",!1),$("#file-dropzone-inner").hide();for(var t=jQuery("<ul>",{id:"file-list"}),e=0;e<this.files.length;e++){var o=jQuery("<span>",{id:"file-percentage-"+e}).append("(0%)"),n=jQuery("<progress>",{id:"file-progress-"+e,value:0}),a=jQuery("<li>",{id:"file-label-"+e}).append(n).append(" ").append(this.files[e].name).append(" ").append(o);t.append(a)}$("#file-dropzone").append(t)}else $("#file-dropzone-inner").show()},Kanboard.FileUpload.prototype.checkFiles=function(){for(var t=parseInt($("#file-dropzone").data("max-size")),e=0;e<this.files.length;e++)if(this.files[e].size>t)return $("#file-error-max-size").show(),$("#file-label-"+e).addClass("file-error"),void $("#file-upload-button").prop("disabled",!0);this.uploadFiles()},Kanboard.FileUpload.prototype.uploadFiles=function(){this.files.length>0&&this.uploadFile(this.files[this.currentFile])},Kanboard.FileUpload.prototype.uploadFile=function(t){var e=document.getElementById("file-dropzone"),o=e.dataset.url,n=new XMLHttpRequest,a=new FormData;n.upload.addEventListener("progress",this.updateProgress.bind(this)),n.upload.addEventListener("load",this.transferComplete.bind(this)),n.open("POST",o,!0),a.append("files[]",t),n.send(a)},Kanboard.FileUpload.prototype.updateProgress=function(t){t.lengthComputable&&($("#file-progress-"+this.currentFile).val(t.loaded/t.total),$("#file-percentage-"+this.currentFile).text("("+Math.floor(t.loaded/t.total*100)+"%)"))},Kanboard.FileUpload.prototype.transferComplete=function(){if(this.currentFile++,this.currentFile<this.files.length)this.uploadFile(this.files[this.currentFile]);else{var t=$("#file-upload-button");t.prop("disabled",!0),t.parent().hide(),$("#file-done").show()}},Kanboard.Gantt=function(t){this.app=t,this.data=[],this.options={container:"#gantt-chart",showWeekends:!0,allowMoves:!0,allowResizes:!0,cellWidth:21,cellHeight:31,slideWidth:1e3,vHeaderWidth:200}},Kanboard.Gantt.prototype.execute=function(){this.app.hasId("gantt-chart")&&this.show()},Kanboard.Gantt.prototype.saveRecord=function(t){this.app.showLoadingIcon(),$.ajax({cache:!1,url:$(this.options.container).data("save-url"),contentType:"application/json",type:"POST",processData:!1,data:JSON.stringify(t),complete:this.app.hideLoadingIcon.bind(this)})},Kanboard.Gantt.prototype.show=function(){this.data=this.prepareData($(this.options.container).data("records"));var t=Math.floor(this.options.slideWidth/this.options.cellWidth+5),e=this.getDateRange(t),o=e[0],n=e[1],a=$(this.options.container),i=jQuery("<div>",{"class":"ganttview"});i.append(this.renderVerticalHeader()),i.append(this.renderSlider(o,n)),a.append(i),jQuery("div.ganttview-grid-row div.ganttview-grid-row-cell:last-child",a).addClass("last"),jQuery("div.ganttview-hzheader-days div.ganttview-hzheader-day:last-child",a).addClass("last"),jQuery("div.ganttview-hzheader-months div.ganttview-hzheader-month:last-child",a).addClass("last"),$(this.options.container).data("readonly")?(this.options.allowResizes=!1,this.options.allowMoves=!1):(this.listenForBlockResize(o),this.listenForBlockMove(o))},Kanboard.Gantt.prototype.renderVerticalHeader=function(){for(var t=jQuery("<div>",{"class":"ganttview-vtheader"}),e=jQuery("<div>",{"class":"ganttview-vtheader-item"}),o=jQuery("<div>",{"class":"ganttview-vtheader-series"}),n=0;n<this.data.length;n++){var a=jQuery("<span>").append(jQuery("<i>",{"class":"fa fa-info-circle tooltip",title:this.getVerticalHeaderTooltip(this.data[n])})).append(" ");"task"==this.data[n].type?a.append(jQuery("<a>",{href:this.data[n].link,title:this.data[n].title}).append(this.data[n].title)):a.append(jQuery("<a>",{href:this.data[n].board_link,title:$(this.options.container).data("label-board-link")}).append('<i class="fa fa-th"></i>')).append(" ").append(jQuery("<a>",{href:this.data[n].gantt_link,title:$(this.options.container).data("label-gantt-link")}).append('<i class="fa fa-sliders"></i>')).append(" ").append(jQuery("<a>",{href:this.data[n].link}).append(this.data[n].title)),o.append(jQuery("<div>",{"class":"ganttview-vtheader-series-name"}).append(a))}return e.append(o),t.append(e),t},Kanboard.Gantt.prototype.renderSlider=function(t,e){var o=jQuery("<div>",{"class":"ganttview-slide-container"}),n=this.getDates(t,e);return o.append(this.renderHorizontalHeader(n)),o.append(this.renderGrid(n)),o.append(this.addBlockContainers()),this.addBlocks(o,t),o},Kanboard.Gantt.prototype.renderHorizontalHeader=function(t){var e=jQuery("<div>",{"class":"ganttview-hzheader"}),o=jQuery("<div>",{"class":"ganttview-hzheader-months"}),n=jQuery("<div>",{"class":"ganttview-hzheader-days"}),a=0;for(var i in t)for(var r in t[i]){var s=t[i][r].length*this.options.cellWidth;a+=s,o.append(jQuery("<div>",{"class":"ganttview-hzheader-month",css:{width:s-1+"px"}}).append($.datepicker.regional[$("body").data("js-lang")].monthNames[r]+" "+i));for(var d in t[i][r])n.append(jQuery("<div>",{"class":"ganttview-hzheader-day"}).append(t[i][r][d].getDate()))}return o.css("width",a+"px"),n.css("width",a+"px"),e.append(o).append(n),e},Kanboard.Gantt.prototype.renderGrid=function(t){var e=jQuery("<div>",{"class":"ganttview-grid"}),o=jQuery("<div>",{"class":"ganttview-grid-row"});for(var n in t)for(var a in t[n])for(var i in t[n][a]){var r=jQuery("<div>",{"class":"ganttview-grid-row-cell"});this.options.showWeekends&&this.isWeekend(t[n][a][i])&&r.addClass("ganttview-weekend"),o.append(r)}var s=jQuery("div.ganttview-grid-row-cell",o).length*this.options.cellWidth;o.css("width",s+"px"),e.css("width",s+"px");for(var d=0;d<this.data.length;d++)e.append(o.clone());return e},Kanboard.Gantt.prototype.addBlockContainers=function(){for(var t=jQuery("<div>",{"class":"ganttview-blocks"}),e=0;e<this.data.length;e++)t.append(jQuery("<div>",{"class":"ganttview-block-container"}));return t},Kanboard.Gantt.prototype.addBlocks=function(t,e){for(var o=jQuery("div.ganttview-blocks div.ganttview-block-container",t),n=0,a=0;a<this.data.length;a++){var i=this.data[a],r=this.daysBetween(i.start,i.end)+1,s=this.daysBetween(e,i.start),d=jQuery("<div>",{"class":"ganttview-block-text"}),l=jQuery("<div>",{"class":"ganttview-block tooltip"+(this.options.allowMoves?" ganttview-block-movable":""),title:this.getBarTooltip(i),css:{width:r*this.options.cellWidth-9+"px","margin-left":s*this.options.cellWidth+"px"}}).append(d);r>=2&&d.append(i.progress),l.data("record",i),this.setBarColor(l,i),jQuery(o[n]).append(l),n+=1}},Kanboard.Gantt.prototype.getVerticalHeaderTooltip=function(t){var e="";if("task"==t.type)e="<strong>"+t.column_title+"</strong> ("+t.progress+")<br/>"+t.title;else{var o=["project-manager","project-member"];for(var n in o){var a=o[n];if(!jQuery.isEmptyObject(t.users[a])){var i=jQuery("<ul>");for(var r in t.users[a])r&&i.append(jQuery("<li>").append(t.users[a][r]));e+="<p><strong>"+$(this.options.container).data("label-"+a)+"</strong></p>"+i[0].outerHTML}}}return e},Kanboard.Gantt.prototype.getBarTooltip=function(t){var e="";return t.not_defined?e=$(this.options.container).data("label-not-defined"):("task"==t.type&&(e="<strong>"+t.progress+"</strong><br/>"+$(this.options.container).data("label-assignee")+" "+(t.assignee?t.assignee:"")+"<br/>"),e+=$(this.options.container).data("label-start-date")+" "+$.datepicker.formatDate("yy-mm-dd",t.start)+"<br/>",e+=$(this.options.container).data("label-end-date")+" "+$.datepicker.formatDate("yy-mm-dd",t.end)),e},Kanboard.Gantt.prototype.setBarColor=function(t,e){e.not_defined?t.addClass("ganttview-block-not-defined"):(t.css("background-color",e.color.background),t.css("border-color",e.color.border),"0%"!=e.progress&&t.append(jQuery("<div>",{css:{"z-index":0,position:"absolute",top:0,bottom:0,"background-color":e.color.border,width:e.progress,opacity:.4}})))},Kanboard.Gantt.prototype.listenForBlockResize=function(t){var e=this;jQuery("div.ganttview-block",this.options.container).resizable({grid:this.options.cellWidth,handles:"e,w",delay:300,stop:function(){var o=jQuery(this);e.updateDataAndPosition(o,t),e.saveRecord(o.data("record"))}})},Kanboard.Gantt.prototype.listenForBlockMove=function(t){var e=this;jQuery("div.ganttview-block",this.options.container).draggable({axis:"x",delay:300,grid:[this.options.cellWidth,this.options.cellWidth],stop:function(){var o=jQuery(this);e.updateDataAndPosition(o,t),e.saveRecord(o.data("record"))}})},Kanboard.Gantt.prototype.updateDataAndPosition=function(t,e){var o=jQuery("div.ganttview-slide-container",this.options.container),n=o.scrollLeft(),a=t.offset().left-o.offset().left-1+n,i=t.data("record");i.not_defined=!1,this.setBarColor(t,i);var r=Math.round(a/this.options.cellWidth),s=this.addDays(this.cloneDate(e),r);i.start=s;var d=t.outerWidth(),l=Math.round(d/this.options.cellWidth)-1;i.end=this.addDays(this.cloneDate(s),l),"task"===i.type&&l>0&&jQuery("div.ganttview-block-text",t).text(i.progress),t.attr("title",this.getBarTooltip(i)),t.data("record",i),t.css("top","").css("left","").css("position","relative").css("margin-left",a+"px")},Kanboard.Gantt.prototype.getDates=function(t,e){var o=[];o[t.getFullYear()]=[],o[t.getFullYear()][t.getMonth()]=[t];for(var n=t;this.compareDate(n,e)==-1;){var a=this.addDays(this.cloneDate(n),1);o[a.getFullYear()]||(o[a.getFullYear()]=[]),o[a.getFullYear()][a.getMonth()]||(o[a.getFullYear()][a.getMonth()]=[]),o[a.getFullYear()][a.getMonth()].push(a),n=a}return o},Kanboard.Gantt.prototype.prepareData=function(t){for(var e=0;e<t.length;e++){var o=new Date(t[e].start[0],t[e].start[1]-1,t[e].start[2],0,0,0,0);t[e].start=o;var n=new Date(t[e].end[0],t[e].end[1]-1,t[e].end[2],0,0,0,0);t[e].end=n}return t},Kanboard.Gantt.prototype.getDateRange=function(t){for(var e=new Date,o=new Date,n=0;n<this.data.length;n++){var a=new Date;a.setTime(Date.parse(this.data[n].start));var i=new Date;i.setTime(Date.parse(this.data[n].end)),0==n&&(e=a,o=i),1==this.compareDate(e,a)&&(e=a),this.compareDate(o,i)==-1&&(o=i)}return this.daysBetween(e,o)<t&&(o=this.addDays(this.cloneDate(e),t)),e.setDate(e.getDate()-1),[e,o]},Kanboard.Gantt.prototype.daysBetween=function(t,e){if(!t||!e)return 0;for(var o=0,n=this.cloneDate(t);this.compareDate(n,e)==-1;)o+=1,this.addDays(n,1);return o},Kanboard.Gantt.prototype.isWeekend=function(t){return t.getDay()%6==0},Kanboard.Gantt.prototype.cloneDate=function(t){return new Date(t.getTime())},Kanboard.Gantt.prototype.addDays=function(t,e){return t.setDate(t.getDate()+1*e),t},Kanboard.Gantt.prototype.compareDate=function(t,e){if(isNaN(t)||isNaN(e))throw new Error(t+" - "+e);if(t instanceof Date&&e instanceof Date)return t<e?-1:t>e?1:0;throw new TypeError(t+" - "+e)},Kanboard.Popover=function(t){this.app=t},Kanboard.Popover.prototype.listen=function(){var t=this;$(document).on("click",".popover",function(e){t.onClick(e)}),$(document).on("click",".close-popover",function(e){t.close(e)}),$(document).on("click","#popover-close-button",function(e){t.close(e)}),$(document).on("click","#popover-content",function(t){t.stopPropagation()})},Kanboard.Popover.prototype.onClick=function(t){t.preventDefault(),t.stopPropagation();var e=t.currentTarget||t.target,o=e.getAttribute("href");o||(o=e.getAttribute("data-href")),o&&this.open(o)},Kanboard.Popover.prototype.isOpen=function(){return $("#popover-container").size()>0},Kanboard.Popover.prototype.open=function(t){var e=this;e.isOpen()||$.get(t,function(t){$("body").prepend('<div id="popover-container"><div id="popover-content"><div id="popover-content-header"><a href="#" id="popover-close-button"><i class="fa fa-times"></i></a></div>'+t+"</div></div>"),e.executeOnOpenedListeners()})},Kanboard.Popover.prototype.close=function(t){this.isOpen()&&(t&&t.preventDefault(),$("#popover-container").remove(),this.executeOnClosedListeners())},Kanboard.Popover.prototype.ajaxReload=function(t,e,o){var n=e.getResponseHeader("X-Ajax-Redirect");"self"===n?window.location.reload():n&&n.indexOf("#")>-1?window.location=n.split("#")[0]:n?window.location=n:($("#popover-content").html(t),$("#popover-content input[autofocus]").focus(),o.executeOnOpenedListeners())},Kanboard.Popover.prototype.executeOnOpenedListeners=function(){for(var t in this.app.controllers){var e=this.app.get(t);"function"==typeof e.onPopoverOpened&&e.onPopoverOpened()}this.afterOpen()},Kanboard.Popover.prototype.executeOnClosedListeners=function(){for(var t in this.app.controllers){var e=this.app.get(t);"function"==typeof e.onPopoverClosed&&e.onPopoverClosed()}},Kanboard.Popover.prototype.afterOpen=function(){var t=this,e=$("#popover-content .popover-form");e&&e.on("submit",function(o){o.preventDefault(),$.ajax({type:"POST",url:e.attr("action"),data:e.serialize(),success:function(e,o,n){t.ajaxReload(e,n,t)},beforeSend:function(){var t=$('.popover-form button[type="submit"]');t.html('<i class="fa fa-spinner fa-pulse"></i> '+t.html()),t.attr("disabled",!0)}})}),$(document).on("click",".popover-link",function(e){e.preventDefault(),$.ajax({type:"GET",url:$(this).attr("href"),success:function(e,o,n){t.ajaxReload(e,n,t)}})}),$("#popover-content input[autofocus]").each(function(){$(this).focus()}),this.app.datePicker(),this.app.autoComplete(),this.app.tagAutoComplete(),KB.render()},Kanboard.Screenshot=function(t){this.app=t,this.pasteCatcher=null},Kanboard.Screenshot.prototype.onPopoverOpened=function(){this.app.hasId("screenshot-zone")&&this.initialize()},Kanboard.Screenshot.prototype.initialize=function(){this.destroy(),window.Clipboard||(this.pasteCatcher=document.createElement("div"),this.pasteCatcher.id="screenshot-pastezone",this.pasteCatcher.contentEditable="true",this.pasteCatcher.style.opacity=0,this.pasteCatcher.style.position="fixed",this.pasteCatcher.style.top=0,this.pasteCatcher.style.right=0,this.pasteCatcher.style.width=0,document.body.insertBefore(this.pasteCatcher,document.body.firstChild),this.pasteCatcher.focus(),document.addEventListener("click",this.setFocus.bind(this)),document.getElementById("screenshot-zone").addEventListener("click",this.setFocus.bind(this))),window.addEventListener("paste",this.pasteHandler.bind(this))},Kanboard.Screenshot.prototype.destroy=function(){null!==this.pasteCatcher?document.body.removeChild(this.pasteCatcher):document.getElementById("screenshot-pastezone")&&document.body.removeChild(document.getElementById("screenshot-pastezone")),document.removeEventListener("click",this.setFocus.bind(this)),this.pasteCatcher=null},Kanboard.Screenshot.prototype.setFocus=function(){null!==this.pasteCatcher&&this.pasteCatcher.focus()},Kanboard.Screenshot.prototype.pasteHandler=function(t){if(t.clipboardData&&t.clipboardData.items){var e=t.clipboardData.items;if(e)for(var o=0;o<e.length;o++)if(e[o].type.indexOf("image")!==-1){var n=e[o].getAsFile(),a=new FileReader,i=this;a.onload=function(t){i.createImage(t.target.result)},a.readAsDataURL(n)}}else setTimeout(this.checkInput.bind(this),100)},Kanboard.Screenshot.prototype.checkInput=function(){var t=this.pasteCatcher.childNodes[0];t&&"IMG"===t.tagName&&this.createImage(t.src),this.pasteCatcher.innerHTML=""},Kanboard.Screenshot.prototype.createImage=function(t){var e=new Image;e.src=t,e.onload=function(){var e=t.split("base64,"),o=e[1];$("input[name=screenshot]").val(o)};var o=document.getElementById("screenshot-zone");o.innerHTML="",o.className="screenshot-pasted",o.appendChild(e),this.destroy(),this.initialize()},Kanboard.Search=function(t){this.app=t},Kanboard.Search.prototype.focus=function(){$(document).on("focus","#form-search",function(){var t=$("#form-search");if(t[0].setSelectionRange){var e=2*t.val().length;t[0].setSelectionRange(e,e)}})},Kanboard.Search.prototype.listen=function(){$(document).on("click",".filter-helper",function(t){t.preventDefault();var e=$(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(":"));e=a.val().replace(new RegExp("("+i+":[#a-z0-9]+)","g"),""),e=e.replace(new RegExp("("+i+':"(.+)")',"g"),""),e=e.trim(),e+=" "+n}else o&&(e=a.val()+" "+o);a.val(e),$("form.search").submit()})},Kanboard.Subtask=function(t){this.app=t},Kanboard.Subtask.prototype.listen=function(){var t=this;this.dragAndDrop(),$(document).on("click",".subtask-toggle-status",function(e){var o=$(this);e.preventDefault(),$.ajax({cache:!1,url:o.attr("href"),success:function(e){o.hasClass("subtask-refresh-table")?$(".subtasks-table").replaceWith(e):o.replaceWith(e),t.dragAndDrop()}})}),$(document).on("click",".subtask-toggle-timer",function(e){var o=$(this);e.preventDefault(),$.ajax({cache:!1,url:o.attr("href"),success:function(e){$(".subtasks-table").replaceWith(e),t.dragAndDrop()}})})},Kanboard.Subtask.prototype.dragAndDrop=function(){var t=this;$(".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(t,e){return e.children().each(function(){$(this).width($(this).width())}),e},stop:function(e,o){var n=o.item;n.removeClass("draggable-item-selected"),t.savePosition(n.data("subtask-id"),n.index()+1)},start:function(t,e){e.item.addClass("draggable-item-selected")}}).disableSelection()},Kanboard.Subtask.prototype.savePosition=function(t,e){var o=$(".subtasks-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({subtask_id:t,position:e}),complete:function(){n.app.hideLoadingIcon()}})},Kanboard.Swimlane=function(t){this.app=t},Kanboard.Swimlane.prototype.execute=function(){$(".swimlanes-table").length&&this.dragAndDrop()},Kanboard.Swimlane.prototype.listen=function(){var t=this;$(document).on("click",".board-swimlane-toggle",function(e){e.preventDefault();var o=$(this).data("swimlane-id");t.isCollapsed(o)?t.expand(o):t.collapse(o)})},Kanboard.Swimlane.prototype.onBoardRendered=function(){for(var t=this.getAllCollapsed(),e=0;e<t.length;e++)this.collapse(t[e])},Kanboard.Swimlane.prototype.getStorageKey=function(){return"hidden_swimlanes_"+$("#board").data("project-id")},Kanboard.Swimlane.prototype.expand=function(t){var e=this.getAllCollapsed(),o=e.indexOf(t);o>-1&&e.splice(o,1),localStorage.setItem(this.getStorageKey(),JSON.stringify(e)),$(".board-swimlane-columns-"+t).css("display","table-row"),$(".board-swimlane-tasks-"+t).css("display","table-row"),$(".hide-icon-swimlane-"+t).css("display","inline"),$(".show-icon-swimlane-"+t).css("display","none")},Kanboard.Swimlane.prototype.collapse=function(t){var e=this.getAllCollapsed();e.indexOf(t)<0&&(e.push(t),localStorage.setItem(this.getStorageKey(),JSON.stringify(e))),$(".board-swimlane-columns-"+t+":not(:first-child)").css("display","none"),$(".board-swimlane-tasks-"+t).css("display","none"),$(".hide-icon-swimlane-"+t).css("display","none"),$(".show-icon-swimlane-"+t).css("display","inline")},Kanboard.Swimlane.prototype.isCollapsed=function(t){return this.getAllCollapsed().indexOf(t)>-1},Kanboard.Swimlane.prototype.getAllCollapsed=function(){return JSON.parse(localStorage.getItem(this.getStorageKey()))||[]},Kanboard.Swimlane.prototype.dragAndDrop=function(){var t=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(t,e){return e.children().each(function(){$(this).width($(this).width())}),e},stop:function(e,o){var n=o.item;n.removeClass("draggable-item-selected"),t.savePosition(n.data("swimlane-id"),n.index()+1)},start:function(t,e){e.item.addClass("draggable-item-selected")}}).disableSelection()},Kanboard.Swimlane.prototype.savePosition=function(t,e){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:t,position:e}),complete:function(){n.app.hideLoadingIcon()}})},Kanboard.Task=function(t){this.app=t},Kanboard.Task.prototype.onPopoverOpened=function(){var t=this,e=0;t.renderColorPicker(),$(document).on("click",".assign-me",function(t){var e=$(this).data("current-id"),o="#"+$(this).data("target-id");t.preventDefault(),$(o+" option[value="+e+"]").length&&$(o).val(e)}),$(document).on("change","select.task-reload-project-destination",function(){if(e>0)$(this).val(e);else{e=$(this).val();var o=$(this).data("redirect").replace(/PROJECT_ID/g,e);$(".loading-icon").show(),$.ajax({type:"GET",url:o,success:function(o,n,a){e=0,$(".loading-icon").hide(),t.app.get("Popover").ajaxReload(o,a,t.app.get("Popover"))}})}})},Kanboard.Task.prototype.renderColorPicker=function(){function t(t){return $('<div class="color-picker-option"><div class="color-picker-square color-'+t.id+'"></div><div class="color-picker-label">'+t.text+"</div></div>")}$(".color-picker").select2({minimumResultsForSearch:1/0,templateResult:t,templateSelection:t})},Kanboard.Tooltip=function(t){this.app=t},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(t,e){$(this).css(t);var o=e.target.left+e.target.width/2-e.element.left-20;$("<div>").addClass("tooltip-arrow").addClass(e.vertical).addClass(o<1?"align-left":"align-right").appendTo(this)}},content:function(){var t=this,e=$(this).attr("data-href");return e?($.get(e,function(e){var o=$(".ui-tooltip:visible");$(".ui-tooltip-content:visible").html(e),o.css({top:"",left:""}),o.children(".tooltip-arrow").remove();var n=$(t).tooltip("option","position");n.of=$(t),o.position(n)}),'<i class="fa fa-spinner fa-spin"></i>'):'<div class="markdown">'+$(this).attr("title")+"</div>"}}).on("mouseenter",function(){var t=this;$(this).tooltip("open"),$(".ui-tooltip").on("mouseleave",function(){$(t).tooltip("close")})}).on("mouseleave focusout",function(t){t.stopImmediatePropagation();var e=this;setTimeout(function(){$(".ui-tooltip:hover").length||$(e).tooltip("close")},100)})},Kanboard.BoardDragAndDrop=function(t){this.app=t,this.savingInProgress=!1},Kanboard.BoardDragAndDrop.prototype.execute=function(){this.app.hasId("board")&&(this.dragAndDrop(),this.executeListeners())},Kanboard.BoardDragAndDrop.prototype.dragAndDrop=function(){var t=this,e=$(".board-task-list"),o={forcePlaceholderSize:!0,tolerance:"pointer",connectWith:".sortable-column",placeholder:"draggable-placeholder",items:".draggable-item",stop:function(e,o){var n=o.item,a=n.attr("data-task-id"),i=n.attr("data-position"),r=n.attr("data-column-id"),s=n.attr("data-swimlane-id"),d=n.parent().attr("data-column-id"),l=n.parent().attr("data-swimlane-id"),c=n.index()+1;n.removeClass("draggable-item-selected"),d==r&&l==s&&c==i||(t.changeTaskState(a),t.save(a,r,d,c,l))},start:function(t,e){e.item.addClass("draggable-item-selected"),e.placeholder.height(e.item.height())}};isMobile.any&&($(".task-board-sort-handle").css("display","inline"),o.handle=".task-board-sort-handle"),e.each(function(){$(this).css("min-height",$(this).parent().height())}),e.sortable(o)},Kanboard.BoardDragAndDrop.prototype.changeTaskState=function(t){var e=$("div[data-task-id="+t+"]");e.addClass("task-board-saving-state"),e.find(".task-board-saving-icon").show()},Kanboard.BoardDragAndDrop.prototype.save=function(t,e,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:t,src_column_id:e,dst_column_id:o,swimlane_id:a,position:n}),success:function(t){i.refresh(t),i.savingInProgress=!1},error:function(){i.app.hideLoadingIcon(),i.savingInProgress=!1; -},statusCode:{403:function(t){window.alert(t.responseJSON.message),document.location.reload(!0)}}})},Kanboard.BoardDragAndDrop.prototype.refresh=function(t){$("#board-container").replaceWith(t),this.app.hideLoadingIcon(),this.dragAndDrop(),this.executeListeners()},Kanboard.BoardDragAndDrop.prototype.executeListeners=function(){for(var t in this.app.controllers){var e=this.app.get(t);"function"==typeof e.onBoardRendered&&e.onBoardRendered()}};var _KB=null;jQuery(document).ready(function(){_KB=new Kanboard.App,_KB.execute()});
\ No newline at end of file +!function(){function t(t,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(t):t.currentStyle;l.whiteSpace="pre-wrap","INPUT"!==t.nodeName&&(l.wordWrap="break-word"),l.position="absolute",r||(l.visibility="hidden"),e.forEach(function(t){l[t]=c[t]}),o?t.scrollHeight>parseInt(c.height)&&(l.overflowY="scroll"):l.overflow="hidden",s.textContent=t.value.substring(0,a),"INPUT"===t.nodeName&&(s.textContent=s.textContent.replace(/\s/g," "));var u=document.createElement("span");u.textContent=t.value.substring(a)||".",s.appendChild(u);var p={top:u.offsetTop+parseInt(c.borderTopWidth),left:u.offsetLeft+parseInt(c.borderLeftWidth)};return r?u.style.backgroundColor="#aaa":document.body.removeChild(s),p}var e=["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=t:n&&(window.getCaretCoordinates=t)}(),function(){function t(){if(!("KeyboardEvent"in window)||"key"in KeyboardEvent.prototype)return!1;var t={get:function(t){var e=n.keys[this.which||this.keyCode];return Array.isArray(e)&&(e=e[+this.shiftKey]),e}};return Object.defineProperty(KeyboardEvent.prototype,"key",t),t}var e,n={polyfill:t,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(e=1;e<25;e++)n.keys[111+e]="F"+e;var o="";for(e=65;e<91;e++)o=String.fromCharCode(e),n.keys[e]=[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(t){for(var e=(this.document||this.ownerDocument).querySelectorAll(t),n=e.length;--n>=0&&e.item(n)!==this;);return n>-1});var KB={components:{},utils:{},html:{},http:{},listeners:{clicks:{},changes:{},keys:{},internals:{}}};KB.on=function(t,e){this.listeners.internals.hasOwnProperty(t)||(this.listeners.internals[t]=[]),this.listeners.internals[t].push(e)},KB.trigger=function(t,e){if(this.listeners.internals.hasOwnProperty(t))for(var n=0;n<this.listeners.internals[t].length;n++)this.listeners.internals[t][n](e)},KB.onClick=function(t,e){this.listeners.clicks[t]=e},KB.onChange=function(t,e){this.listeners.changes[t]=e},KB.onKey=function(t,e,n){this.listeners.keys[t]={callback:e,ignoreInputField:n||!1}},KB.listen=function(){function t(t){for(var e in o.listeners.clicks)o.listeners.clicks.hasOwnProperty(e)&&t.target.matches(e)&&(t.preventDefault(),o.listeners.clicks[e](t))}function e(t){for(var e in o.listeners.changes)o.listeners.changes.hasOwnProperty(e)&&t.target.matches(e)&&o.listeners.changes[e](t.target)}function n(t){var e=KB.utils.getKey(t),n=KB.utils.isInputField(t);if(n&&["Escape","Meta","Enter","Control"].indexOf(e)===-1||a.push(e),a.length>0){var i=!0;for(var r in o.listeners.keys)if(o.listeners.keys.hasOwnProperty(r)){var d=o.listeners.keys[r],s=r.split("+");if(KB.utils.arraysIdentical(a,s)){if(n&&!d.ignoreInputField)return void(a=[]);t.preventDefault(),t.stopPropagation(),a=[],d.callback(t);break}KB.utils.arraysStartsWith(a,s)&&(i=!1)}i&&(a=[])}}var o=this,a=[];document.addEventListener("click",t,!1),document.addEventListener("change",e,!1),window.addEventListener("keydown",n,!1)},KB.component=function(t,e){this.components[t]=e},KB.getComponent=function(t,e,n){var o=this.components[t];return new o(e,n)},KB.render=function(){for(var t in this.components)for(var e=document.querySelectorAll(".js-"+t),n=0;n<e.length;n++)if(this.components.hasOwnProperty(t)){var o;e[n].dataset.params&&(o=JSON.parse(e[n].dataset.params));var a=KB.getComponent(t,e[n],o);a.render(),e[n].className=e[n].className+"-rendered"}},KB.interval=function(t,e){setInterval(e,1e3*t)},KB.dom=function(t){function e(t){var e="string"==typeof t?document.createElement(t):t;this.attr=function(t,n){return null!==n&&"undefined"!=typeof n?(e.setAttribute(t,n),this):e.getAttribute(t)},this.data=function(t,n){return 1===arguments.length?e.dataset[t]:(e.dataset[t]=n,this)},this.hide=function(){return e.style.display="none",this},this.show=function(){return e.style.display="block",this},this.toggle=function(){return"none"===e.style.display?this.show():this.hide(),this},this.style=function(t,n){return e.style[t]=n,this},this.on=function(t,n,o){return e.addEventListener(t,function(t){o||t.preventDefault(),n(t.target)}),this},this.click=function(t){return this.on("click",t)},this.mouseover=function(t){return this.on("mouseover",t)},this.change=function(t){return this.on("change",t)},this.add=function(t){return e.appendChild(t),this},this.replace=function(t){return e.parentNode.replaceChild(t,e),this},this.html=function(t){return e.innerHTML=t,this},this.text=function(t){return e.appendChild(document.createTextNode(t)),this},this.replaceText=function(t){return e.textContent=t,this},this.addClass=function(t){return e.classList.add(t),this},this.removeClass=function(t){return e.classList.remove(t),this},this.toggleClass=function(t){return e.classList.toggle(t),this},this.hasClass=function(t){return e.classList.contains(t)},this.disable=function(){return e.disabled=!0,this},this.enable=function(){return e.disabled=!1,this},this.remove=function(){return e.parentNode.removeChild(e),this},this.empty=function(){for(;e.firstChild;)e.removeChild(e.firstChild);return this},this.parent=function(t){for(;e&&e!==document;e=e.parentNode)if(e.matches(t))return e;return null},this.find=function(t){return e.querySelector(t)},this["for"]=function(t,n){for(var o=0;o<n.length;o++){var a=n[o];if("object"!=typeof a)e.appendChild(KB.dom(t).text(a).build());else{var i=KB.dom(t);for(var r in a)a.hasOwnProperty(r)&&r in this&&"function"==typeof this[r]?i[r](a[r]):i.attr(r,a[r]);e.appendChild(i.build())}}return this},this.build=function(){return e}}return new e(t)},KB.find=function(t){var e=document.querySelector(t);return e?KB.dom(e):null},KB.exists=function(t){return!!document.querySelector(t)},KB.focus=function(t){var e=document.querySelector(t);if(e)return e.focus()},KB.html.label=function(t,e){return KB.dom("label").attr("for",e).text(t).build()},KB.html.radio=function(t,e,n){return KB.dom("label").add(KB.dom("input").attr("type","radio").attr("name",e).attr("value",n).build()).text(t).build()},KB.html.radios=function(t){var e=KB.dom("div");for(var n in t)t.hasOwnProperty(n)&&e.add(KB.html.radio(n.label,n.name,n.value))},KB.http.request=function(t,e,n,o){function a(t){var e=t.getResponseHeader("X-Ajax-Redirect");if("self"===e)window.location.reload();else if(e&&e.indexOf("#")>-1)window.location=e.split("#")[0];else if(e)window.location=e;else if("application/json"===t.getResponseHeader("Content-Type"))try{return JSON.parse(t.responseText)}catch(n){}return t.responseText}var i=function(){},r=function(){};this.execute=function(){var d=new XMLHttpRequest;d.open(t,e,!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 t=a(d);200===d.status?i(t):r(t)}},d.send(o),this},this.success=function(t){return i=t,this},this.error=function(t){return r=t,this}},KB.http.get=function(t){return new KB.http.request("GET",t).execute()},KB.http.postJson=function(t,e){var n={"Content-Type":"application/json",Accept:"application/json"};return new KB.http.request("POST",t,n,JSON.stringify(e)).execute()},KB.http.postForm=function(t,e){var n=new FormData(e);return new KB.http.request("POST",t,{},n).execute()},KB.http.uploadFile=function(t,e,n,o,a){var i=new FormData;i.append("files[]",e);var r=new XMLHttpRequest;r.upload.addEventListener("progress",n),r.upload.addEventListener("load",o),r.upload.addEventListener("error",a),r.open("POST",t,!0),r.send(i)},function(){function t(t){t.target.matches("#modal-overlay")&&(t.stopPropagation(),t.preventDefault(),s())}function e(){s()}function n(){KB.trigger("modal.loading"),a()}function o(){return document.querySelector("#modal-content form")}function a(){var t=o();if(t){var e=t.getAttribute("action");e&&KB.http.postForm(e,t).success(function(t){KB.trigger("modal.stop"),t?r(t):s()})}}function i(){var t=KB.find("#modal-content form");t&&t.on("submit",n,!1);var e=document.querySelector("#modal-content input[autofocus]");e&&e.focus(),KB.render(),_KB.datePicker(),_KB.autoComplete(),_KB.tagAutoComplete(),_KB.get("Task").onPopoverOpened()}function r(t){var e=KB.find("#modal-content");e&&(e.replace(KB.dom("div").attr("id","modal-content").html(t).build()),i())}function d(n,o,a){var r=KB.dom("a").attr("href","#").attr("id","modal-close-button").html('<i class="fa fa-times"></i>').click(e).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",t,!1),document.body.appendChild(c),i()}function s(){var t=KB.find("#modal-overlay");t&&t.remove()}function l(t){var e=KB.utils.getViewportSize();switch(t){case"large":return e.width<1300?"95%":"1300px";case"medium":return e.width<1024?"70%":"1024px"}return e.width<800?"75%":"800px"}var c=!1;KB.on("modal.close",function(){s()}),KB.on("modal.submit",function(){a()}),KB.modal={open:function(t,e,n){_KB.get("Dropdown").close(),s(),"undefined"==typeof n&&(n=!0),KB.http.get(t).success(function(t){c=!0,d(t,l(e),n)})},close:function(){c=!1,s()},isOpen:function(){return c},replace:function(t){KB.http.get(t).success(function(t){r(t)})},getForm:o}}(),KB.utils.formatDuration=function(t){return t>=86400?Math.round(t/86400)+"d":t>=3600?Math.round(t/3600)+"h":t>=60?Math.round(t/60)+"m":t+"s"},KB.utils.getSelectionPosition=function(t){var e,n;return e=t.value.length<t.selectionStart?t.value.length:t.selectionStart,n=t.selectionStart===t.selectionEnd?e:t.selectionEnd,{selectionStart:e,selectionEnd:n}},KB.utils.arraysIdentical=function(t,e){var n=t.length;if(n!==e.length)return!1;for(;n--;)if(t[n]!==e[n])return!1;return!0},KB.utils.arraysStartsWith=function(t,e){for(var n=Math.min(t.length,e.length),o=0;o<n;o++)if(t[o]!==e[o])return!1;return!0},KB.utils.isInputField=function(t){var e=t.target;return!("INPUT"!==e.tagName&&"SELECT"!==e.tagName&&"TEXTAREA"!==e.tagName&&!e.isContentEditable)},KB.utils.getKey=function(t){var e={Esc:"Escape",Up:"ArrowUp",Down:"ArrowDown",Left:"ArrowLeft",Right:"ArrowRight"};for(var n in e)if(e.hasOwnProperty(n)&&n===t.key)return e[n];return t.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.onClick(".accordion-toggle",function(t){var e=KB.dom(t.target).parent(".accordion-section");e&&(KB.dom(e).toggleClass("accordion-collapsed"),KB.dom(KB.dom(e).find(".accordion-content")).toggle())}),KB.component("calendar",function(t,e){this.render=function(){var n=$(t);n.fullCalendar({locale:$("body").data("js-lang"),editable:!0,eventLimit:!0,defaultView:"month",header:{left:"prev,next today",center:"title",right:"month,agendaWeek,agendaDay"},eventDrop:function(t){$.ajax({cache:!1,url:e.saveUrl,contentType:"application/json",type:"POST",processData:!1,data:JSON.stringify({task_id:t.id,date_due:t.start.format()})})},viewRender:function(){var t=e.checkUrl,o={start:n.fullCalendar("getView").start.format(),end:n.fullCalendar("getView").end.format()};for(var a in o)t+="&"+a+"="+o[a];$.getJSON(t,function(t){n.fullCalendar("removeEvents"),n.fullCalendar("addEventSource",t),n.fullCalendar("rerenderEvents")})}})}}),KB.component("chart-project-avg-time-column",function(t,e){this.render=function(){var n=e.metrics,o=[e.label],a=[];for(var i in n)o.push(n[i].average),a.push(n[i].title);KB.dom(t).add(KB.dom("div").attr("id","chart").build()),c3.generate({data:{columns:[o],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(t,e){this.render=function(){for(var n=e.metrics,o=[[e.labelTotal]],a=[],i=d3.time.format("%Y-%m-%d"),r=d3.time.format(e.dateFormat),d=0;d<n.length;d++)for(var s=0;s<n[d].length;s++)0===d?o.push([n[d][s]]):(o[s+1].push(n[d][s]),s>0&&(void 0===o[0][d]&&o[0].push(0),o[0][d]+=n[d][s]),0===s&&a.push(r(i.parse(n[d][s]))));KB.dom(t).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(t,e){this.render=function(){for(var n=e.metrics,o=[],a=[],i=[],r=d3.time.format("%Y-%m-%d"),d=d3.time.format(e.dateFormat),s=0;s<n.length;s++)for(var l=0;l<n[s].length;l++)0===s?(o.push([n[s][l]]),l>0&&a.push(n[s][l])):(o[l].push(n[s][l]),0===l&&i.push(d(r.parse(n[s][l]))));KB.dom(t).add(KB.dom("div").attr("id","chart").build()),c3.generate({data:{columns:o,type:"area-spline",groups:[a]},axis:{x:{type:"category",categories:i}}})}}),KB.component("chart-project-lead-cycle-time",function(t,e){this.render=function(){var n=e.metrics,o=[e.labelCycle],a=[e.labelLead],i=[],r={};r[e.labelCycle]="area",r[e.labelLead]="area-spline";var d={};d[e.labelLead]="#afb42b",d[e.labelCycle]="#4e342e";for(var s=0;s<n.length;s++)o.push(parseInt(n[s].avg_cycle_time)),a.push(parseInt(n[s].avg_lead_time)),i.push(n[s].day);KB.dom(t).add(KB.dom("div").attr("id","chart").build()),c3.generate({data:{columns:[a,o],types:r,colors:d},axis:{x:{type:"category",categories:i},y:{tick:{format:KB.utils.formatDuration}}}})}}),KB.component("chart-project-task-distribution",function(t,e){this.render=function(){for(var n=[],o=0;o<e.metrics.length;o++)n.push([e.metrics[o].column_title,e.metrics[o].nb_tasks]);KB.dom(t).add(KB.dom("div").attr("id","chart").build()),c3.generate({data:{columns:n,type:"donut"}})}}),KB.component("chart-project-time-comparison",function(t,e){this.render=function(){var n=[e.labelSpent],o=[e.labelEstimated],a=[];for(var i in e.metrics)n.push(e.metrics[i].time_spent),o.push(e.metrics[i].time_estimated),a.push("open"===i?e.labelOpen:e.labelClosed);KB.dom(t).add(KB.dom("div").attr("id","chart").build()),c3.generate({data:{columns:[n,o],type:"bar"},bar:{width:{ratio:.2}},axis:{x:{type:"category",categories:a}},legend:{show:!0}})}}),KB.component("chart-project-user-distribution",function(t,e){this.render=function(){for(var n=[],o=0;o<e.metrics.length;o++)n.push([e.metrics[o].user,e.metrics[o].nb_tasks]);KB.dom(t).add(KB.dom("div").attr("id","chart").build()),c3.generate({data:{columns:n,type:"donut"}})}}),KB.component("chart-task-time-column",function(t,e){this.render=function(){for(var n=e.metrics,o=[e.label],a=[],i=0;i<n.length;i++)o.push(n[i].time_spent),a.push(n[i].title);KB.dom(t).add(KB.dom("div").attr("id","chart").build()),c3.generate({data:{columns:[o],type:"bar"},bar:{width:{ratio:.5}},axis:{x:{type:"category",categories:a},y:{tick:{format:KB.utils.formatDuration}}},legend:{show:!1}})}}),KB.component("confirm-buttons",function(t,e){function n(){r=!0,KB.find("#modal-confirm-button").replace(i()),window.location.href=e.url}function o(){KB.trigger("modal.close")}function a(){r=!1,KB.find("#modal-confirm-button").replace(i())}function i(){var t=KB.dom("button").click(n).attr("id","modal-confirm-button").attr("type","button").attr("class","btn btn-red");return r&&t.disable().add(KB.dom("i").attr("class","fa fa-spinner fa-pulse").build()).text(" "),e.tabindex&&t.attr("tabindex",e.tabindex),t.text(e.submitLabel).build()}var r=!1;this.render=function(){KB.on("modal.stop",a);var n=KB.dom("div").attr("class","form-actions").add(i()).text(" "+e.orLabel+" ").add(KB.dom("a").attr("href","#").click(o).text(e.cancelLabel).build()).build();t.appendChild(n)}}),KB.component("external-task-view",function(t,e){this.render=function(){$.ajax({cache:!1,url:e.url,success:function(e){KB.dom(t).html('<div id="external-task-view">'+e+"</div>")}})}}),KB.component("file-upload",function(t,e){function n(t){if(t.lengthComputable){var e=t.loaded/t.total,n=Math.floor(100*e);KB.find("#file-progress-"+w).attr("value",e),KB.find("#file-percentage-"+w).replaceText("("+n+"%)")}}function o(){var t=KB.dom("div").addClass("file-error").text(e.labelUploadError).build();KB.find("#file-item-"+w).add(t)}function a(){if(w++,w<y.length)KB.http.uploadFile(e.url,y[w],n,a,o);else{KB.trigger("modal.stop"),KB.trigger("modal.hide");var t=KB.dom("div").addClass("alert").addClass("alert-success").text(e.labelSuccess).build(),r=KB.dom("button").attr("type","button").addClass("btn").addClass("btn-blue").click(i).text(e.labelCloseSuccess).build();KB.dom(K).replace(KB.dom("div").add(t).add(r).build())}}function i(){window.location.reload()}function r(){w=0,u()}function d(){y=b.files,p()}function s(){y=[],w=0,b.click()}function l(t){t.stopPropagation(),t.preventDefault()}function c(t){t.stopPropagation(),t.preventDefault(),y=t.dataTransfer.files,p()}function u(){y.length>0&&KB.http.uploadFile(e.url,y[w],n,a,o)}function p(){y.length>0?(KB.trigger("modal.enable"),KB.dom(K).empty().add(v())):(KB.trigger("modal.disable"),KB.dom(K).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",d).hide().build()}function h(){var t=KB.dom("a").attr("href","#").text(e.labelChooseFiles).click(s).build();return KB.dom("div").attr("id","file-dropzone-inner").text(e.labelDropzone+" "+e.labelOr+" ").add(t).build()}function m(){var t=KB.dom("div").attr("id","file-dropzone").add(h()).build();return t.ondragover=l,t.ondrop=c,t.ondragover=l,t}function g(t){var n=!1,o=KB.dom("progress").attr("id","file-progress-"+t).attr("value",0).build(),a=KB.dom("span").attr("id","file-percentage-"+t).text("(0%)").build(),i=KB.dom("li").attr("id","file-item-"+t).add(o).text(" "+y[t].name+" ").add(a);return y[t].size>e.maxSize&&(i.add(KB.dom("div").addClass("file-error").text(e.labelOversize).build()),n=!0),n&&KB.trigger("modal.disable"),i.build()}function v(){for(var t=KB.dom("ul").attr("id","file-list").build(),e=0;e<y.length;e++)t.appendChild(g(e));return t}var b=null,K=null,y=[],w=null;this.render=function(){KB.on("modal.submit",r),b=f(),K=m(),t.appendChild(b),t.appendChild(K)}}),KB.component("image-slideshow",function(t,e){function n(t){switch(KB.utils.getKey(t)){case"Escape":s();break;case"ArrowRight":i();break;case"ArrowLeft":r()}}function o(t){t.matches(".slideshow-next-icon")?i():t.matches(".slideshow-previous-icon")?r():t.matches(".slideshow-download-icon")?window.location.href=t.href:s()}function a(t){var e=KB.dom(t).data("imageId"),n=l(e);d(n)}function i(){s();for(var t=0;t<e.images.length;t++)if(e.images[t].id===p.id){var n=t+1;n>=e.images.length&&(n=0),p=e.images[n];break}d()}function r(){s();for(var t=0;t<e.images.length;t++)if(e.images[t].id===p.id){var n=t-1;n<0&&(n=e.images.length-1),p=e.images[n];break}d()}function d(){var t=KB.dom("div").attr("class","fa fa-window-close slideshow-icon slideshow-close-icon").build(),e=KB.dom("a").attr("class","fa fa-download slideshow-icon slideshow-download-icon").attr("href",c(p,"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(p,"image")).attr("alt",p.name).attr("title",p.name).style("maxHeight",window.innerHeight-50+"px").build(),d=KB.dom("figcaption").text(p.name).build(),s=KB.dom("figure").add(r).add(d).build(),l=KB.dom("div").addClass("image-slideshow-overlay").add(t).add(e).add(a).add(i).add(s).click(o).build();document.body.appendChild(l),document.addEventListener("keydown",n,!1)}function s(){var t=KB.find(".image-slideshow-overlay");null!==t&&(document.removeEventListener("keydown",n,!1),t.remove())}function l(t){for(var n=0;n<e.images.length;n++)if(e.images[n].id===t)return e.images[n];return null}function c(t,n){var o=new RegExp(e.regex,"g");return e.url[n].replace(o,t.id)}function u(t){return KB.dom("img").attr("src",c(t,"thumbnail")).attr("alt",t.name).attr("title",t.name).data("imageId",t.id).click(a).build()}var p;this.render=function(){p=e.image,t.appendChild(u(p))}}),KB.keyboardShortcuts=function(){function t(t){var e=KB.find(t);null!==e&&(window.location=e.attr("href"))}function e(){var t=$("form");1==t.length?t.submit():t.length>1&&("INPUT"===document.activeElement.tagName||"TEXTAREA"===document.activeElement.tagName?$(document.activeElement).parents("form").submit():KB.modal.isOpen()&&KB.modal.getForm().submit())}KB.onKey("?",function(){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("Meta+Enter",e,!0),KB.onKey("Control+Enter",e,!0),KB.onKey("b",function(){KB.trigger("board.selector.open")}),KB.exists("#board")&&(KB.onKey("c",function(){_KB.get("BoardHorizontalScrolling").toggle()}),KB.onKey("s",function(){_KB.get("BoardCollapsedMode").toggle()}),KB.onKey("n",function(){KB.modal.open(KB.find("#board").data("taskCreationUrl"),"large",!1)})),KB.exists("#task-view")&&(KB.onKey("e",function(){KB.modal.open(KB.find("#task-view").data("editUrl"),"large")}),KB.onKey("c",function(){KB.modal.open(KB.find("#task-view").data("commentUrl"))}),KB.onKey("s",function(){KB.modal.open(KB.find("#task-view").data("subtaskUrl"))}),KB.onKey("l",function(){KB.modal.open(KB.find("#task-view").data("internalLinkUrl"))})),KB.onKey("f",function(){KB.focus("#form-search")}),KB.onKey("r",function(){var t=$(".filter-reset").data("filter"),e=$("#form-search");e.val(t),$("form.search").submit()}),KB.onKey("v+o",function(){t("a.view-overview")}),KB.onKey("v+b",function(){t("a.view-board")}),KB.onKey("v+c",function(){t("a.view-calendar")}),KB.onKey("v+l",function(){t("a.view-listing")}),KB.onKey("v+g",function(){t("a.view-gantt")})},function(){function t(t){return"I"===t.target.tagName?t.target.parentNode.getAttribute("href"):t.target.getAttribute("href")}KB.onClick(".js-modal-large",function(e){KB.modal.open(t(e),"large",!1)}),KB.onClick(".js-modal-medium",function(e){KB.modal.open(t(e),"medium",!1)}),KB.onClick(".js-modal-small",function(e){KB.modal.open(t(e),"small",!1)}),KB.onClick(".js-modal-confirm",function(e){KB.modal.open(t(e),"small")}),KB.onClick(".js-modal-close",function(){KB.modal.close()})}(),KB.onChange(".js-project-creation-select-options",function(t){var e=t.value;"0"===e?KB.find(".js-project-creation-options").hide():KB.find(".js-project-creation-options").show()}),KB.component("project-select-role",function(t,e){function n(t){d=!0,e.role=t.value,a(),o()}function o(){KB.http.postJson(e.url,{id:e.id,role:e.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(),t.appendChild(r)}function i(){var t=[],o=KB.dom("div");for(var a in e.roles)if(e.roles.hasOwnProperty(a)){var i={value:a,text:e.roles[a]};e.role===a&&(i.selected="selected"),t.push(i)}return o.add(KB.dom("select").change(n)["for"]("option",t).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(),t.appendChild(r)}}),KB.component("screenshot",function(t){function e(t){if(t.clipboardData&&t.clipboardData.items){var e=t.clipboardData.items;if(e)for(var n=0;n<e.length;n++)if(e[n].type.indexOf("image")!==-1){var o=e[n].getAsFile(),a=new FileReader;a.onload=function(t){r(t.target.result)},a.readAsDataURL(o)}}else setTimeout(i,100)}function n(){o(),window.Clipboard||(d=document.createElement("div"),d.id="screenshot-pastezone",d.contentEditable=!0,d.style.opacity=0,d.style.position="fixed",d.style.top=0,d.style.right=0,d.style.width=0,document.body.insertBefore(d,document.body.firstChild),d.focus(),document.addEventListener("click",a),document.getElementById("screenshot-zone").addEventListener("click",a)),window.addEventListener("paste",e,!1)}function o(){null!==d?document.body.removeChild(d):document.getElementById("screenshot-pastezone")&&document.body.removeChild(document.getElementById("screenshot-pastezone")),document.removeEventListener("click",a),d=null}function a(){null!==d&&d.focus()}function i(){var t=d.childNodes[0];t&&"IMG"===t.tagName&&r(t.src),d.innerHTML=""}function r(t){var e=new Image;e.src=t,e.onload=function(){var e=t.split("base64,");s.value=e[1]};var a=document.getElementById("screenshot-zone");a.innerHTML="",a.className="screenshot-pasted",a.appendChild(e),o(),n()}var d=null,s=null;this.render=function(){s=KB.dom("input").attr("type","hidden").attr("name","screenshot").build(),t.appendChild(s),n()}}),KB.component("select-dropdown-autocomplete",function(t,e){function n(){KB.dom(x).show(),KB.dom(C).hide()}function o(){KB.dom(x).hide(),KB.dom(C).show()}function a(){var t=KB.find("#select-dropdown-menu");if(t){var e=w.getBoundingClientRect();t.style("top",document.body.scrollTop+e.bottom+"px")}}function i(t){switch(KB.utils.getKey(t)){case"Escape":B.value="",b();break;case"ArrowUp":t.preventDefault(),t.stopImmediatePropagation(),f();break;case"ArrowDown":t.preventDefault(),t.stopImmediatePropagation(),h();break;case"Enter":t.preventDefault(),t.stopImmediatePropagation(),u()}}function r(){b(),K()}function d(t){KB.dom(t).hasClass("select-dropdown-menu-item")&&(KB.find(".select-dropdown-menu-item.active").removeClass("active"),KB.dom(t).addClass("active"))}function s(){u()}function l(e){t.contains(e.target)||(B.value="",b())}function c(){var t=KB.find("#select-dropdown-menu");null===t?K():b()}function u(){var t=KB.find(".select-dropdown-menu-item.active"),o=t.data("value");k.value=o,B.value=e.items[o],b(),e.redirect?window.location=e.redirect.url.replace(new RegExp(e.redirect.regex,"g"),o):e.replace&&(n(),KB.modal.replace(e.replace.url.replace(new RegExp(e.replace.regex,"g"),o)))}function p(){for(var t=document.querySelectorAll(".select-dropdown-menu-item"),e=0;e<t.length;e++)if(KB.dom(t[e]).hasClass("active")){KB.dom(t[e]).removeClass("active");break}return{items:t,index:e}}function f(){var t=p();t.index>0&&(t.index=t.index-1),KB.dom(t.items[t.index]).addClass("active")}function h(){var t=p();t.index<t.items.length-1&&t.index++,KB.dom(t.items[t.index]).addClass("active")}function m(t){var n=[],o=Object.keys(t);e.sortByKeys&&o.sort();for(var a=0;a<o.length;a++)n.push({"class":"select-dropdown-menu-item",text:t[o[a]],"data-label":t[o[a]],"data-value":o[a]});return n}function g(t,n){for(var o=[],a=!1,i=0;i<n.length;i++)if(0===t.length||0===n[i]["data-label"].toLowerCase().indexOf(t.toLowerCase())){var r=n[i];"undefined"!=typeof e.defaultValue&&String(e.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 t=g(B.value,m(e.items)),n=w.getBoundingClientRect();return 0===t.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",t).build()}function b(){var t=KB.find("#select-dropdown-menu");null!==t&&t.remove(),document.removeEventListener("keydown",i,!1),document.removeEventListener("click",l,!1)}function K(){var t=v();null!==t&&document.body.appendChild(t),document.addEventListener("keydown",i,!1),document.addEventListener("click",l,!1)}function y(){return e.defaultValue&&e.defaultValue in e.items?e.items[e.defaultValue]:e.placeholder?e.placeholder:""}var w,B,k,C,x;this.render=function(){KB.on("select.dropdown.loading.start",n),KB.on("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",e.name).attr("value",e.defaultValue||"").build(),B=KB.dom("input").attr("type","text").attr("placeholder",y()).addClass("select-dropdown-input").style("width",t.offsetWidth-30+"px").on("focus",c).on("input",r,!0).build(),w=KB.dom("div").addClass("select-dropdown-input-container").add(k).add(B).add(C).add(x).build(),t.appendChild(w),e.onFocus&&e.onFocus.forEach(function(t){KB.on(t,function(){B.focus()})}),window.addEventListener("scroll",a,!1)}}),KB.interval(60,function(){var t=KB.find("body").data("statusUrl"),e=KB.find("body").data("loginUrl");null===KB.find(".form-login")&&KB.http.get(t).error(function(){window.location=e})}),KB.component("submit-buttons",function(t,e){function n(){c=!0,KB.find("#modal-submit-button").replace(l()),KB.trigger("modal.submit")}function o(){KB.trigger("modal.close")}function a(){c=!1,KB.find("#modal-submit-button").replace(l())}function i(){c=!1,u=!0,KB.find("#modal-submit-button").replace(l())}function r(){c=!1,u=!1,KB.find("#modal-submit-button").replace(l())}function d(){KB.dom(f).hide()}function s(t){p=t.submitLabel,KB.find("#modal-submit-button").replace(l())}function l(){var t=KB.dom("button").attr("id","modal-submit-button").attr("type","submit").attr("class","btn btn-"+(e.color||"blue"));return KB.modal.isOpen()&&t.click(n),e.tabindex&&t.attr("tabindex",e.tabindex),c&&t.disable().add(KB.dom("i").attr("class","fa fa-spinner fa-pulse").build()).text(" "),u&&t.disable(),t.text(p).build()}var c=!1,u=e.disabled||!1,p=e.submitLabel,f=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);var n=KB.dom("div").attr("class","form-actions").add(l());KB.modal.isOpen()&&n.text(" "+e.orLabel+" ").add(KB.dom("a").attr("href","#").click(o).text(e.cancelLabel).build()),f=n.build(),t.appendChild(f)}}),KB.component("suggest-menu",function(t,e){function n(t){switch(KB.utils.getKey(t)){case"Escape":u();break;case"ArrowUp":t.preventDefault(),t.stopImmediatePropagation(),l();break;case"ArrowDown":t.preventDefault(),t.stopImmediatePropagation(),c();break;case"Enter":t.preventDefault(),t.stopImmediatePropagation(), +i()}}function o(){i()}function a(t){KB.dom(t).hasClass("suggest-menu-item")&&(KB.find(".suggest-menu-item.active").removeClass("active"),KB.dom(t).addClass("active"))}function i(){t.focus();var e=KB.find(".suggest-menu-item.active"),n=e.data("value"),o=e.data("trigger"),a=t.value,i=r(t),d=o+n+" ",s=KB.utils.getSelectionPosition(t),l=a.substring(0,s.selectionStart-i.length),c=a.substring(s.selectionEnd),p=l.length+d.length;t.value=l+d+c,t.setSelectionRange(p,p),u()}function r(t){var e=t.value.substring(0,t.selectionEnd).split("\n"),n=e[e.length-1],o=n.split(" ");return o[o.length-1]}function d(){for(var t=["#modal-content form","#modal-content","body"],e=0;e<t.length;e++){var n=document.querySelector(t[e]);if(null!==n)return n}return null}function s(){for(var t=document.querySelectorAll(".suggest-menu-item"),e=0;e<t.length;e++)if(KB.dom(t[e]).hasClass("active")){KB.dom(t[e]).removeClass("active");break}return{items:t,index:e}}function l(){var t=s();t.index>0&&(t.index=t.index-1),KB.dom(t.items[t.index]).addClass("active")}function c(){var t=s();t.index<t.items.length-1&&t.index++,KB.dom(t.items[t.index]).addClass("active")}function u(){var t=KB.find("#suggest-menu");null!==t&&t.remove(),document.removeEventListener("keydown",n,!1)}function p(t){var n=r(t),o=f(n,e.triggers);u(),null!==o&&h(o,n.substring(o.length),e.triggers[o])}function f(t,e){for(var n in e)if(e.hasOwnProperty(n)&&0===t.indexOf(n))return n;return null}function h(t,e,n){if("string"==typeof n){var o=new RegExp("SEARCH_TERM","g"),a=n.replace(o,e);KB.http.get(a).success(function(n){m(t,e,n)})}else m(t,e,n)}function m(t,e,n){n=g(e,n),n.length>0&&b(v(t,n))}function g(t,e){var n=[];if(0===t.length)return e;for(var o=0;o<e.length;o++)0===e[o].value.toLowerCase().indexOf(t.toLowerCase())&&n.push(e[o]);return n}function v(t,e){for(var n=[],o=0;o<e.length;o++){var a="suggest-menu-item";0===o&&(a+=" active"),n.push({"class":a,html:e[o].html,"data-value":e[o].value,"data-trigger":t})}return n}function b(e){var i=d(),r=getCaretCoordinates(t,t.selectionEnd),s=r.left+t.offsetLeft-t.scrollLeft,l=r.top+t.offsetTop-t.scrollTop+16;document.addEventListener("keydown",n,!1);var c=KB.dom("ul").attr("id","suggest-menu").click(o).mouseover(a).style("left",s+"px").style("top",l+"px")["for"]("li",e).build();i.appendChild(c)}this.render=function(){t.addEventListener("input",function(){p(this)})}}),KB.component("task-move-position",function(t,e){function n(t){var e=KB.dom(document).find("#"+t);return e?parseInt(e.options[e.selectedIndex].value):null}function o(){var t=n("form-swimlanes");return null===t?e.board[0].id:t}function a(){var t=n("form-columns");return null===t?e.board[0].columns[0].id:t}function i(){var t=n("form-position");return null===t?1:t}function r(){var t=KB.find("input[name=positionChoice]:checked");return t?t.value:"before"}function d(){var t=KB.dom(document).find("#form-columns");KB.dom(t).replace(p());var e=KB.dom(document).find("#form-tasks");KB.dom(e).replace(f())}function s(){var t=KB.dom(document).find("#form-tasks");KB.dom(t).replace(f())}function l(t){KB.trigger("modal.stop"),KB.find("#message-container").replace(KB.dom("div").attr("id","message-container").attr("class","alert alert-error").text(t).build())}function c(){var t=i(),n=r();"after"===n&&t++,KB.find("#message-container").replace(KB.dom("div").attr("id","message-container").build()),KB.http.postJson(e.saveUrl,{column_id:a(),swimlane_id:o(),position:t}).error(function(t){t&&l(t.message)})}function u(){var t=[];return e.board.forEach(function(e){t.push({value:e.id,text:e.name})}),KB.dom("select").attr("id","form-swimlanes").change(d)["for"]("option",t).build()}function p(){var t=[],n=o();return e.board.forEach(function(e){n===e.id&&e.columns.forEach(function(e){t.push({value:e.id,text:e.title})})}),KB.dom("select").attr("id","form-columns").change(s)["for"]("option",t).build()}function f(){var t=[],n=o(),i=a(),r=KB.dom("div").attr("id","form-tasks");return e.board.forEach(function(e){n===e.id&&e.columns.forEach(function(e){i===e.id&&e.tasks.forEach(function(e){t.push({value:e.position,text:"#"+e.id+" - "+e.title})})})}),t.length>0&&r.add(KB.html.label(e.positionLabel,"form-position")).add(KB.dom("select").attr("id","form-position")["for"]("option",t).build()).add(KB.html.radio(e.beforeLabel,"positionChoice","before")).add(KB.html.radio(e.afterLabel,"positionChoice","after")),r.build()}this.render=function(){KB.on("modal.submit",c);var n=KB.dom("div").add(KB.dom("div").attr("id","message-container").build()).add(KB.html.label(e.swimlaneLabel,"form-swimlanes")).add(u()).add(KB.html.label(e.columnLabel,"form-columns")).add(p()).add(f()).build();t.appendChild(n)}}),KB.component("text-editor",function(t,e){function n(){var t=KB.dom("div").attr("class","text-editor-toolbar")["for"]("a",[{href:"#",html:'<i class="fa fa-pencil-square-o fa-fw"></i> '+e.labelWrite,click:function(){a()}}]).build();return m=KB.dom("div").attr("class","text-editor-preview-area markdown").build(),KB.dom("div").attr("class","text-editor-view-mode").add(t).add(m).hide().build()}function o(){var t=KB.dom("div").attr("class","text-editor-toolbar")["for"]("a",[{href:"#",html:'<i class="fa fa-eye fa-fw"></i> '+e.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(),n=KB.dom("textarea");return n.attr("name",e.name),e.tabindex&&n.attr("tabindex",e.tabindex),e.required&&n.attr("required","required"),n.text(e.text),e.placeholder&&n.attr("placeholder",e.placeholder),p=n.build(),e.suggestOptions&&KB.getComponent("suggest-menu",p,e.suggestOptions).render(),KB.dom("div").attr("class","text-editor-write-mode").add(t).add(p).build()}function a(){KB.dom(m).html(marked(p.value,{sanitize:!0})),KB.dom(f).toggle(),KB.dom(h).toggle()}function i(){return p.value.substring(p.selectionStart,p.selectionEnd)}function r(t,e,n,o){return t.substring(0,e)+o+t.substring(n)}function d(t){var e=i();c(t+e+t),u(t)}function s(t){var e=i();c("\n"+t+"\n"+e+"\n"+t),u(t,2)}function l(t){var e=i();if(e.indexOf("\n")===-1)c("\n"+t+e);else{for(var n=e.split("\n"),o=0;o<n.length;o++)n[o].indexOf(t)===-1&&(n[o]=t+n[o]);c(n.join("\n"))}u(t,1)}function c(t){p.focus();var e=!1,n=KB.utils.getSelectionPosition(p);if(g=n.selectionStart,v=n.selectionEnd,document.queryCommandSupported("insertText")&&(e=document.execCommand("insertText",!1,t)),!e){try{document.execCommand("ms-beginUndoUnit")}catch(o){}p.value=r(p.value,g,v,t);try{document.execCommand("ms-endUndoUnit")}catch(o){}}}function u(t,e){e=e||0;var n=v+t.length+e;p.setSelectionRange(n,n)}var p,f,h,m,g,v;this.render=function(){h=o(),f=n(),t.appendChild(KB.dom("div").attr("class","text-editor").add(f).add(h).build()),e.autofocus&&p.focus()}}),document.addEventListener("DOMContentLoaded",function(){KB.render(),KB.listen(),KB.keyboardShortcuts()});var Kanboard={};Kanboard.App=function(){this.controllers={}},Kanboard.App.prototype.get=function(t){return this.controllers[t]},Kanboard.App.prototype.execute=function(){for(var t in Kanboard)if("App"!==t){var e=new Kanboard[t](this);this.controllers[t]=e,"function"==typeof e.execute&&e.execute(),"function"==typeof e.listen&&e.listen(),"function"==typeof e.focus&&e.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(t){t.preventDefault()})},Kanboard.App.prototype.datePicker=function(){var t=$("body"),e=t.data("js-date-format"),n=t.data("js-time-format"),o=t.data("js-lang");$.datepicker.setDefaults($.datepicker.regional[o]),$.timepicker.setDefaults($.timepicker.regional[o]),$(".form-date").datepicker({showOtherMonths:!0,selectOtherMonths:!0,dateFormat:e,constrainInput:!1}),$(".form-datetime").datetimepicker({dateFormat:e,timeFormat:n,constrainInput:!1})},Kanboard.App.prototype.tagAutoComplete=function(){$(".tag-autocomplete").select2({tags:!0})},Kanboard.App.prototype.autoComplete=function(){$(".autocomplete").each(function(){var t=$(this),e=t.data("dst-field"),n=t.data("dst-extra-field");""===$("#form-"+e).val()&&t.parent().find("button[type=submit]").attr("disabled","disabled"),t.autocomplete({source:t.data("search-url"),minLength:1,select:function(o,a){$("input[name="+e+"]").val(a.item.id),n&&$("input[name="+n+"]").val(a.item[n]),t.parent().find("button[type=submit]").removeAttr("disabled")}})})},Kanboard.App.prototype.hasId=function(t){return!!document.getElementById(t)},Kanboard.App.prototype.showLoadingIcon=function(){$("body").append('<span id="app-loading-icon"> <i class="fa fa-spinner fa-spin"></i></span>')},Kanboard.App.prototype.hideLoadingIcon=function(){$("#app-loading-icon").remove()},Kanboard.App.prototype.isVisible=function(){var t="";return"undefined"!=typeof document.hidden?t="visibilityState":"undefined"!=typeof document.mozHidden?t="mozVisibilityState":"undefined"!=typeof document.msHidden?t="msVisibilityState":"undefined"!=typeof document.webkitHidden&&(t="webkitVisibilityState"),""===t||"visible"==document[t]},Kanboard.BoardCollapsedMode=function(t){this.app=t},Kanboard.BoardCollapsedMode.prototype.toggle=function(){var t=this;this.app.showLoadingIcon(),$.ajax({cache:!1,url:$('.filter-display-mode:not([style="display: none;"]) a').attr("href"),success:function(e){$(".filter-display-mode").toggle(),t.app.get("BoardDragAndDrop").refresh(e)}})},Kanboard.BoardColumnView=function(t){this.app=t},Kanboard.BoardColumnView.prototype.execute=function(){this.app.hasId("board")&&this.render()},Kanboard.BoardColumnView.prototype.listen=function(){var t=this;$(document).on("click",".board-toggle-column-view",function(){t.toggle($(this).data("column-id"))})},Kanboard.BoardColumnView.prototype.onBoardRendered=function(){this.render()},Kanboard.BoardColumnView.prototype.render=function(){var t=this;$(".board-column-header").each(function(){var e=$(this).data("column-id");localStorage.getItem("hidden_column_"+e)&&t.hideColumn(e)})},Kanboard.BoardColumnView.prototype.toggle=function(t){localStorage.getItem("hidden_column_"+t)?this.showColumn(t):this.hideColumn(t)},Kanboard.BoardColumnView.prototype.hideColumn=function(t){$(".board-column-"+t+" .board-column-expanded").hide(),$(".board-column-"+t+" .board-column-collapsed").show(),$(".board-column-header-"+t+" .board-column-expanded").hide(),$(".board-column-header-"+t+" .board-column-collapsed").show(),$(".board-column-header-"+t).each(function(){$(this).removeClass("board-column-compact"),$(this).addClass("board-column-header-collapsed")}),$(".board-column-"+t).each(function(){$(this).addClass("board-column-task-collapsed")}),$(".board-column-"+t+" .board-rotation").each(function(){$(this).css("width",$(".board-column-"+t).height())}),localStorage.setItem("hidden_column_"+t,1)},Kanboard.BoardColumnView.prototype.showColumn=function(t){$(".board-column-"+t+" .board-column-expanded").show(),$(".board-column-"+t+" .board-column-collapsed").hide(),$(".board-column-header-"+t+" .board-column-expanded").show(),$(".board-column-header-"+t+" .board-column-collapsed").hide(),$(".board-column-header-"+t).removeClass("board-column-header-collapsed"),$(".board-column-"+t).removeClass("board-column-task-collapsed"),0==localStorage.getItem("horizontal_scroll")&&$(".board-column-header-"+t).addClass("board-column-compact"),localStorage.removeItem("hidden_column_"+t)},Kanboard.BoardHorizontalScrolling=function(t){this.app=t},Kanboard.BoardHorizontalScrolling.prototype.execute=function(){this.app.hasId("board")&&this.render()},Kanboard.BoardHorizontalScrolling.prototype.listen=function(){var t=this;$(document).on("click",".filter-toggle-scrolling",function(e){e.preventDefault(),t.toggle()})},Kanboard.BoardHorizontalScrolling.prototype.onBoardRendered=function(){this.render()},Kanboard.BoardHorizontalScrolling.prototype.toggle=function(){var t=localStorage.getItem("horizontal_scroll")||1;localStorage.setItem("horizontal_scroll",0==t?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(t){this.app=t},Kanboard.BoardPolling.prototype.execute=function(){if(this.app.hasId("board")){var t=parseInt($("#board").attr("data-check-interval"));t>0&&window.setInterval(this.check.bind(this),1e3*t)}},Kanboard.BoardPolling.prototype.check=function(){if(this.app.isVisible()&&!this.app.get("BoardDragAndDrop").savingInProgress){var t=this;this.app.showLoadingIcon(),$.ajax({cache:!1,url:$("#board").data("check-url"),statusCode:{200:function(e){t.app.get("BoardDragAndDrop").refresh(e)},304:function(){t.app.hideLoadingIcon()}}})}},Kanboard.BoardTask=function(t){this.app=t},Kanboard.BoardTask.prototype.listen=function(){var t=this;$(document).on("click",".task-board-change-assignee",function(e){e.preventDefault(),e.stopPropagation(),t.app.get("Popover").open($(this).data("url"))}),$(document).on("click",".task-board",function(t){"A"!=t.target.tagName&&"IMG"!=t.target.tagName&&(window.location=$(this).data("task-url"))})},Kanboard.Column=function(t){this.app=t},Kanboard.Column.prototype.listen=function(){this.dragAndDrop()},Kanboard.Column.prototype.dragAndDrop=function(){var t=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(t,e){return e.children().each(function(){$(this).width($(this).width())}),e},stop:function(e,n){var o=n.item;o.removeClass("draggable-item-selected"),t.savePosition(o.data("column-id"),o.index()+1)},start:function(t,e){e.item.addClass("draggable-item-selected")}}).disableSelection()},Kanboard.Column.prototype.savePosition=function(t,e){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:t,position:e}),complete:function(){o.app.hideLoadingIcon()}})},Kanboard.Dropdown=function(t){this.app=t},Kanboard.Dropdown.prototype.listen=function(){var t=this;$(document).on("click",function(){t.close()}),$(document).on("click",".dropdown-menu",function(e){e.preventDefault(),e.stopImmediatePropagation(),t.close();var n=$(this).next("ul"),o=$(this).offset();$("body").append(jQuery("<div>",{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<i?a.css("top",o.top+$(this).height()):a.css("top",o.top-i-5),o.left+r>$(window).width()?a.css("left",o.left-r+$(this).outerWidth()):a.css("left",o.left)}),$(document).on("click",".dropdown-submenu-open li",function(t){$(t.target).is("li")&&$(this).find("a:visible")[0].click()})},Kanboard.Dropdown.prototype.close=function(){$("#dropdown").remove()},Kanboard.Gantt=function(t){this.app=t,this.data=[],this.options={container:"#gantt-chart",showWeekends:!0,allowMoves:!0,allowResizes:!0,cellWidth:21,cellHeight:31,slideWidth:1e3,vHeaderWidth:200}},Kanboard.Gantt.prototype.execute=function(){this.app.hasId("gantt-chart")&&this.show()},Kanboard.Gantt.prototype.saveRecord=function(t){this.app.showLoadingIcon(),$.ajax({cache:!1,url:$(this.options.container).data("save-url"),contentType:"application/json",type:"POST",processData:!1,data:JSON.stringify(t),complete:this.app.hideLoadingIcon.bind(this)})},Kanboard.Gantt.prototype.show=function(){this.data=this.prepareData($(this.options.container).data("records"));var t=Math.floor(this.options.slideWidth/this.options.cellWidth+5),e=this.getDateRange(t),n=e[0],o=e[1],a=$(this.options.container),i=jQuery("<div>",{"class":"ganttview"});i.append(this.renderVerticalHeader()),i.append(this.renderSlider(n,o)),a.append(i),jQuery("div.ganttview-grid-row div.ganttview-grid-row-cell:last-child",a).addClass("last"),jQuery("div.ganttview-hzheader-days div.ganttview-hzheader-day:last-child",a).addClass("last"),jQuery("div.ganttview-hzheader-months div.ganttview-hzheader-month:last-child",a).addClass("last"),$(this.options.container).data("readonly")?(this.options.allowResizes=!1,this.options.allowMoves=!1):(this.listenForBlockResize(n),this.listenForBlockMove(n))},Kanboard.Gantt.prototype.renderVerticalHeader=function(){for(var t=jQuery("<div>",{"class":"ganttview-vtheader"}),e=jQuery("<div>",{"class":"ganttview-vtheader-item"}),n=jQuery("<div>",{"class":"ganttview-vtheader-series"}),o=0;o<this.data.length;o++){var a=jQuery("<span>").append(jQuery("<i>",{"class":"fa fa-info-circle tooltip",title:this.getVerticalHeaderTooltip(this.data[o])})).append(" ");"task"==this.data[o].type?a.append(jQuery("<a>",{href:this.data[o].link,title:this.data[o].title}).append(this.data[o].title)):a.append(jQuery("<a>",{href:this.data[o].board_link,title:$(this.options.container).data("label-board-link")}).append('<i class="fa fa-th"></i>')).append(" ").append(jQuery("<a>",{href:this.data[o].gantt_link,title:$(this.options.container).data("label-gantt-link")}).append('<i class="fa fa-sliders"></i>')).append(" ").append(jQuery("<a>",{href:this.data[o].link}).append(this.data[o].title)),n.append(jQuery("<div>",{"class":"ganttview-vtheader-series-name"}).append(a))}return e.append(n),t.append(e),t},Kanboard.Gantt.prototype.renderSlider=function(t,e){var n=jQuery("<div>",{"class":"ganttview-slide-container"}),o=this.getDates(t,e);return n.append(this.renderHorizontalHeader(o)),n.append(this.renderGrid(o)),n.append(this.addBlockContainers()),this.addBlocks(n,t),n},Kanboard.Gantt.prototype.renderHorizontalHeader=function(t){var e=jQuery("<div>",{"class":"ganttview-hzheader"}),n=jQuery("<div>",{"class":"ganttview-hzheader-months"}),o=jQuery("<div>",{"class":"ganttview-hzheader-days"}),a=0;for(var i in t)for(var r in t[i]){var d=t[i][r].length*this.options.cellWidth;a+=d,n.append(jQuery("<div>",{"class":"ganttview-hzheader-month",css:{width:d-1+"px"}}).append($.datepicker.regional[$("body").data("js-lang")].monthNames[r]+" "+i));for(var s in t[i][r])o.append(jQuery("<div>",{"class":"ganttview-hzheader-day"}).append(t[i][r][s].getDate()))}return n.css("width",a+"px"),o.css("width",a+"px"),e.append(n).append(o),e},Kanboard.Gantt.prototype.renderGrid=function(t){var e=jQuery("<div>",{"class":"ganttview-grid"}),n=jQuery("<div>",{"class":"ganttview-grid-row"});for(var o in t)for(var a in t[o])for(var i in t[o][a]){var r=jQuery("<div>",{"class":"ganttview-grid-row-cell"});this.options.showWeekends&&this.isWeekend(t[o][a][i])&&r.addClass("ganttview-weekend"),n.append(r)}var d=jQuery("div.ganttview-grid-row-cell",n).length*this.options.cellWidth;n.css("width",d+"px"),e.css("width",d+"px");for(var s=0;s<this.data.length;s++)e.append(n.clone());return e},Kanboard.Gantt.prototype.addBlockContainers=function(){for(var t=jQuery("<div>",{"class":"ganttview-blocks"}),e=0;e<this.data.length;e++)t.append(jQuery("<div>",{"class":"ganttview-block-container"}));return t},Kanboard.Gantt.prototype.addBlocks=function(t,e){for(var n=jQuery("div.ganttview-blocks div.ganttview-block-container",t),o=0,a=0;a<this.data.length;a++){var i=this.data[a],r=this.daysBetween(i.start,i.end)+1,d=this.daysBetween(e,i.start),s=jQuery("<div>",{"class":"ganttview-block-text"}),l=jQuery("<div>",{"class":"ganttview-block tooltip"+(this.options.allowMoves?" ganttview-block-movable":""),title:this.getBarTooltip(i),css:{width:r*this.options.cellWidth-9+"px","margin-left":d*this.options.cellWidth+"px"}}).append(s);r>=2&&s.append(i.progress),l.data("record",i),this.setBarColor(l,i),jQuery(n[o]).append(l),o+=1}},Kanboard.Gantt.prototype.getVerticalHeaderTooltip=function(t){var e="";if("task"==t.type)e="<strong>"+t.column_title+"</strong> ("+t.progress+")<br/>"+t.title;else{var n=["project-manager","project-member"];for(var o in n){var a=n[o];if(!jQuery.isEmptyObject(t.users[a])){var i=jQuery("<ul>");for(var r in t.users[a])r&&i.append(jQuery("<li>").append(t.users[a][r]));e+="<p><strong>"+$(this.options.container).data("label-"+a)+"</strong></p>"+i[0].outerHTML}}}return e},Kanboard.Gantt.prototype.getBarTooltip=function(t){var e="";return t.not_defined?e=$(this.options.container).data("label-not-defined"):("task"==t.type&&(e="<strong>"+t.progress+"</strong><br/>"+$(this.options.container).data("label-assignee")+" "+(t.assignee?t.assignee:"")+"<br/>"),e+=$(this.options.container).data("label-start-date")+" "+$.datepicker.formatDate("yy-mm-dd",t.start)+"<br/>",e+=$(this.options.container).data("label-end-date")+" "+$.datepicker.formatDate("yy-mm-dd",t.end)),e},Kanboard.Gantt.prototype.setBarColor=function(t,e){e.not_defined?t.addClass("ganttview-block-not-defined"):(t.css("background-color",e.color.background),t.css("border-color",e.color.border),"0%"!=e.progress&&t.append(jQuery("<div>",{css:{"z-index":0,position:"absolute",top:0,bottom:0,"background-color":e.color.border,width:e.progress,opacity:.4}})))},Kanboard.Gantt.prototype.listenForBlockResize=function(t){var e=this;jQuery("div.ganttview-block",this.options.container).resizable({grid:this.options.cellWidth,handles:"e,w",delay:300,stop:function(){var n=jQuery(this);e.updateDataAndPosition(n,t),e.saveRecord(n.data("record"))}})},Kanboard.Gantt.prototype.listenForBlockMove=function(t){var e=this;jQuery("div.ganttview-block",this.options.container).draggable({axis:"x",delay:300,grid:[this.options.cellWidth,this.options.cellWidth],stop:function(){var n=jQuery(this);e.updateDataAndPosition(n,t),e.saveRecord(n.data("record"))}})},Kanboard.Gantt.prototype.updateDataAndPosition=function(t,e){var n=jQuery("div.ganttview-slide-container",this.options.container),o=n.scrollLeft(),a=t.offset().left-n.offset().left-1+o,i=t.data("record");i.not_defined=!1,this.setBarColor(t,i);var r=Math.round(a/this.options.cellWidth),d=this.addDays(this.cloneDate(e),r);i.start=d;var s=t.outerWidth(),l=Math.round(s/this.options.cellWidth)-1;i.end=this.addDays(this.cloneDate(d),l),"task"===i.type&&l>0&&jQuery("div.ganttview-block-text",t).text(i.progress),t.attr("title",this.getBarTooltip(i)),t.data("record",i),t.css("top","").css("left","").css("position","relative").css("margin-left",a+"px")},Kanboard.Gantt.prototype.getDates=function(t,e){var n=[];n[t.getFullYear()]=[],n[t.getFullYear()][t.getMonth()]=[t];for(var o=t;this.compareDate(o,e)==-1;){var a=this.addDays(this.cloneDate(o),1);n[a.getFullYear()]||(n[a.getFullYear()]=[]),n[a.getFullYear()][a.getMonth()]||(n[a.getFullYear()][a.getMonth()]=[]),n[a.getFullYear()][a.getMonth()].push(a),o=a}return n},Kanboard.Gantt.prototype.prepareData=function(t){for(var e=0;e<t.length;e++){var n=new Date(t[e].start[0],t[e].start[1]-1,t[e].start[2],0,0,0,0);t[e].start=n;var o=new Date(t[e].end[0],t[e].end[1]-1,t[e].end[2],0,0,0,0);t[e].end=o}return t},Kanboard.Gantt.prototype.getDateRange=function(t){for(var e=new Date,n=new Date,o=0;o<this.data.length;o++){var a=new Date;a.setTime(Date.parse(this.data[o].start));var i=new Date;i.setTime(Date.parse(this.data[o].end)),0==o&&(e=a,n=i),1==this.compareDate(e,a)&&(e=a),this.compareDate(n,i)==-1&&(n=i)}return this.daysBetween(e,n)<t&&(n=this.addDays(this.cloneDate(e),t)),e.setDate(e.getDate()-1),[e,n]},Kanboard.Gantt.prototype.daysBetween=function(t,e){if(!t||!e)return 0;for(var n=0,o=this.cloneDate(t);this.compareDate(o,e)==-1;)n+=1,this.addDays(o,1);return n},Kanboard.Gantt.prototype.isWeekend=function(t){return t.getDay()%6==0},Kanboard.Gantt.prototype.cloneDate=function(t){return new Date(t.getTime())},Kanboard.Gantt.prototype.addDays=function(t,e){return t.setDate(t.getDate()+1*e),t},Kanboard.Gantt.prototype.compareDate=function(t,e){if(isNaN(t)||isNaN(e))throw new Error(t+" - "+e);if(t instanceof Date&&e instanceof Date)return t<e?-1:t>e?1:0;throw new TypeError(t+" - "+e)},Kanboard.Search=function(t){this.app=t},Kanboard.Search.prototype.focus=function(){$(document).on("focus","#form-search",function(){var t=$("#form-search");if(t[0].setSelectionRange){var e=2*t.val().length;t[0].setSelectionRange(e,e)}})},Kanboard.Search.prototype.listen=function(){$(document).on("click",".filter-helper",function(t){t.preventDefault();var e=$(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(":"));e=a.val().replace(new RegExp("("+i+":[#a-z0-9]+)","g"),""),e=e.replace(new RegExp("("+i+':"(.+)")',"g"),""),e=e.trim(),e+=" "+o}else n&&(e=a.val()+" "+n);a.val(e),$("form.search").submit()})},Kanboard.Subtask=function(t){this.app=t},Kanboard.Subtask.prototype.listen=function(){var t=this;this.dragAndDrop(),$(document).on("click",".subtask-toggle-status",function(e){var n=$(this);e.preventDefault(),$.ajax({cache:!1,url:n.attr("href"),success:function(e){n.hasClass("subtask-refresh-table")?$(".subtasks-table").replaceWith(e):n.replaceWith(e),t.dragAndDrop()}})}),$(document).on("click",".subtask-toggle-timer",function(e){var n=$(this);e.preventDefault(),$.ajax({cache:!1,url:n.attr("href"),success:function(e){$(".subtasks-table").replaceWith(e),t.dragAndDrop()}})})},Kanboard.Subtask.prototype.dragAndDrop=function(){var t=this;$(".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(t,e){return e.children().each(function(){$(this).width($(this).width())}),e},stop:function(e,n){var o=n.item;o.removeClass("draggable-item-selected"),t.savePosition(o.data("subtask-id"),o.index()+1)},start:function(t,e){e.item.addClass("draggable-item-selected")}}).disableSelection()},Kanboard.Subtask.prototype.savePosition=function(t,e){var n=$(".subtasks-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({subtask_id:t,position:e}),complete:function(){o.app.hideLoadingIcon()}})},Kanboard.Swimlane=function(t){this.app=t},Kanboard.Swimlane.prototype.execute=function(){$(".swimlanes-table").length&&this.dragAndDrop()},Kanboard.Swimlane.prototype.listen=function(){var t=this;$(document).on("click",".board-swimlane-toggle",function(e){e.preventDefault();var n=$(this).data("swimlane-id");t.isCollapsed(n)?t.expand(n):t.collapse(n)})},Kanboard.Swimlane.prototype.onBoardRendered=function(){for(var t=this.getAllCollapsed(),e=0;e<t.length;e++)this.collapse(t[e])},Kanboard.Swimlane.prototype.getStorageKey=function(){return"hidden_swimlanes_"+$("#board").data("project-id")},Kanboard.Swimlane.prototype.expand=function(t){var e=this.getAllCollapsed(),n=e.indexOf(t);n>-1&&e.splice(n,1),localStorage.setItem(this.getStorageKey(),JSON.stringify(e)),$(".board-swimlane-columns-"+t).css("display","table-row"),$(".board-swimlane-tasks-"+t).css("display","table-row"),$(".hide-icon-swimlane-"+t).css("display","inline"),$(".show-icon-swimlane-"+t).css("display","none")},Kanboard.Swimlane.prototype.collapse=function(t){var e=this.getAllCollapsed();e.indexOf(t)<0&&(e.push(t),localStorage.setItem(this.getStorageKey(),JSON.stringify(e))),$(".board-swimlane-columns-"+t+":not(:first-child)").css("display","none"),$(".board-swimlane-tasks-"+t).css("display","none"),$(".hide-icon-swimlane-"+t).css("display","none"),$(".show-icon-swimlane-"+t).css("display","inline")},Kanboard.Swimlane.prototype.isCollapsed=function(t){return this.getAllCollapsed().indexOf(t)>-1},Kanboard.Swimlane.prototype.getAllCollapsed=function(){return JSON.parse(localStorage.getItem(this.getStorageKey()))||[]},Kanboard.Swimlane.prototype.dragAndDrop=function(){var t=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(t,e){return e.children().each(function(){$(this).width($(this).width())}),e},stop:function(e,n){var o=n.item;o.removeClass("draggable-item-selected"),t.savePosition(o.data("swimlane-id"),o.index()+1)},start:function(t,e){e.item.addClass("draggable-item-selected")}}).disableSelection()},Kanboard.Swimlane.prototype.savePosition=function(t,e){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:t,position:e}),complete:function(){o.app.hideLoadingIcon()}})},Kanboard.Task=function(t){this.app=t},Kanboard.Task.prototype.onPopoverOpened=function(){var t=this;t.renderColorPicker(),$(document).on("click",".assign-me",function(t){var e=$(this).data("current-id"),n="#"+$(this).data("target-id");t.preventDefault(),$(n+" option[value="+e+"]").length&&$(n).val(e)})},Kanboard.Task.prototype.renderColorPicker=function(){function t(t){return $('<div class="color-picker-option"><div class="color-picker-square color-'+t.id+'"></div><div class="color-picker-label">'+t.text+"</div></div>")}$(".color-picker").select2({minimumResultsForSearch:1/0,templateResult:t,templateSelection:t})},Kanboard.Tooltip=function(t){this.app=t},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(t,e){$(this).css(t);var n=e.target.left+e.target.width/2-e.element.left-20;$("<div>").addClass("tooltip-arrow").addClass(e.vertical).addClass(n<1?"align-left":"align-right").appendTo(this)}},content:function(){var t=this,e=$(this).attr("data-href");return e?($.get(e,function(e){var n=$(".ui-tooltip:visible");$(".ui-tooltip-content:visible").html(e),n.css({top:"",left:""}),n.children(".tooltip-arrow").remove();var o=$(t).tooltip("option","position");o.of=$(t),n.position(o)}),'<i class="fa fa-spinner fa-spin"></i>'):'<div class="markdown">'+$(this).attr("title")+"</div>"}}).on("mouseenter",function(){var t=this;$(this).tooltip("open"),$(".ui-tooltip").on("mouseleave",function(){$(t).tooltip("close")})}).on("mouseleave focusout",function(t){t.stopImmediatePropagation();var e=this;setTimeout(function(){$(".ui-tooltip:hover").length||$(e).tooltip("close")},100)})},Kanboard.BoardDragAndDrop=function(t){this.app=t,this.savingInProgress=!1},Kanboard.BoardDragAndDrop.prototype.execute=function(){this.app.hasId("board")&&(this.dragAndDrop(),this.executeListeners())},Kanboard.BoardDragAndDrop.prototype.dragAndDrop=function(){var t=this,e=$(".board-task-list"),n={forcePlaceholderSize:!0,tolerance:"pointer",connectWith:".sortable-column",placeholder:"draggable-placeholder",items:".draggable-item",stop:function(e,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||(t.changeTaskState(a),t.save(a,r,s,c,l)); +},start:function(t,e){e.item.addClass("draggable-item-selected"),e.placeholder.height(e.item.height())}};isMobile.any&&($(".task-board-sort-handle").css("display","inline"),n.handle=".task-board-sort-handle"),e.each(function(){$(this).css("min-height",$(this).parent().height())}),e.sortable(n)},Kanboard.BoardDragAndDrop.prototype.changeTaskState=function(t){var e=$("div[data-task-id="+t+"]");e.addClass("task-board-saving-state"),e.find(".task-board-saving-icon").show()},Kanboard.BoardDragAndDrop.prototype.save=function(t,e,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:t,src_column_id:e,dst_column_id:n,swimlane_id:a,position:o}),success:function(t){i.refresh(t),i.savingInProgress=!1},error:function(){i.app.hideLoadingIcon(),i.savingInProgress=!1},statusCode:{403:function(t){window.alert(t.responseJSON.message),document.location.reload(!0)}}})},Kanboard.BoardDragAndDrop.prototype.refresh=function(t){$("#board-container").replaceWith(t),this.app.hideLoadingIcon(),this.dragAndDrop(),this.executeListeners()},Kanboard.BoardDragAndDrop.prototype.executeListeners=function(){for(var t in this.app.controllers){var e=this.app.get(t);"function"==typeof e.onBoardRendered&&e.onBoardRendered()}};var _KB=null;jQuery(document).ready(function(){_KB=new Kanboard.App,_KB.execute()});
\ No newline at end of file diff --git a/assets/js/components/submit-cancel.js b/assets/js/components/confirm-buttons.js index ccb3c1d9..81abe016 100644 --- a/assets/js/components/submit-cancel.js +++ b/assets/js/components/confirm-buttons.js @@ -1,28 +1,27 @@ -KB.component('submit-cancel', function (containerElement, options) { +KB.component('confirm-buttons', function (containerElement, options) { var isLoading = false; function onSubmit() { isLoading = true; - KB.find('#modal-submit-button').replace(buildButton()); - KB.trigger('modal.submit'); + KB.find('#modal-confirm-button').replace(buildButton()); + window.location.href = options.url; } function onCancel() { - KB.trigger('modal.cancel'); - _KB.get('Popover').close(); + KB.trigger('modal.close'); } function onStop() { isLoading = false; - KB.find('#modal-submit-button').replace(buildButton()); + KB.find('#modal-confirm-button').replace(buildButton()); } function buildButton() { var button = KB.dom('button') .click(onSubmit) - .attr('id', 'modal-submit-button') - .attr('type', 'submit') - .attr('class', 'btn btn-blue'); + .attr('id', 'modal-confirm-button') + .attr('type', 'button') + .attr('class', 'btn btn-red'); if (isLoading) { button @@ -32,6 +31,10 @@ KB.component('submit-cancel', function (containerElement, options) { ; } + if (options.tabindex) { + button.attr('tabindex', options.tabindex); + } + return button .text(options.submitLabel) .build(); diff --git a/assets/js/components/file-upload.js b/assets/js/components/file-upload.js new file mode 100644 index 00000000..762eb6e1 --- /dev/null +++ b/assets/js/components/file-upload.js @@ -0,0 +1,192 @@ +KB.component('file-upload', function (containerElement, options) { + var inputFileElement = null; + var dropzoneElement = null; + var files = []; + var currentFileIndex = null; + + function onProgress(e) { + if (e.lengthComputable) { + var progress = e.loaded / e.total; + var percentage = Math.floor(progress * 100); + + KB.find('#file-progress-' + currentFileIndex).attr('value', progress); + KB.find('#file-percentage-' + currentFileIndex).replaceText('(' + percentage + '%)'); + } + } + + function onError() { + var errorElement = KB.dom('div').addClass('file-error').text(options.labelUploadError).build(); + KB.find('#file-item-' + currentFileIndex).add(errorElement); + } + + function onComplete() { + currentFileIndex++; + + if (currentFileIndex < files.length) { + KB.http.uploadFile(options.url, files[currentFileIndex], onProgress, onComplete, onError); + } else { + KB.trigger('modal.stop'); + KB.trigger('modal.hide'); + + var alertElement = KB.dom('div') + .addClass('alert') + .addClass('alert-success') + .text(options.labelSuccess) + .build(); + + var buttonElement = KB.dom('button') + .attr('type', 'button') + .addClass('btn') + .addClass('btn-blue') + .click(onCloseWindow) + .text(options.labelCloseSuccess) + .build(); + + KB.dom(dropzoneElement).replace(KB.dom('div').add(alertElement).add(buttonElement).build()); + } + } + + function onCloseWindow() { + window.location.reload(); + } + + function onSubmit() { + currentFileIndex = 0; + uploadFiles(); + } + + function onFileChange() { + files = inputFileElement.files; + showFiles(); + } + + function onClickFileBrowser() { + files = []; + currentFileIndex = 0; + inputFileElement.click(); + } + + function onDragOver(e) { + e.stopPropagation(); + e.preventDefault(); + } + + function onDrop(e) { + e.stopPropagation(); + e.preventDefault(); + + files = e.dataTransfer.files; + showFiles(); + } + + function uploadFiles() { + if (files.length > 0) { + KB.http.uploadFile(options.url, files[currentFileIndex], onProgress, onComplete, onError); + } + } + + function showFiles() { + if (files.length > 0) { + KB.trigger('modal.enable'); + + KB.dom(dropzoneElement) + .empty() + .add(buildFileListElement()); + } else { + KB.trigger('modal.disable'); + + KB.dom(dropzoneElement) + .empty() + .add(buildInnerDropzoneElement()); + } + } + + function buildFileInputElement() { + return KB.dom('input') + .attr('id', 'file-input-element') + .attr('type', 'file') + .attr('name', 'files[]') + .attr('multiple', true) + .on('change', onFileChange) + .hide() + .build(); + } + + function buildInnerDropzoneElement() { + var dropzoneLinkElement = KB.dom('a') + .attr('href', '#') + .text(options.labelChooseFiles) + .click(onClickFileBrowser) + .build(); + + return KB.dom('div') + .attr('id', 'file-dropzone-inner') + .text(options.labelDropzone + ' ' + options.labelOr + ' ') + .add(dropzoneLinkElement) + .build(); + } + + function buildDropzoneElement() { + var dropzoneElement = KB.dom('div') + .attr('id', 'file-dropzone') + .add(buildInnerDropzoneElement()) + .build(); + + dropzoneElement.ondragover = onDragOver; + dropzoneElement.ondrop = onDrop; + dropzoneElement.ondragover = onDragOver; + + return dropzoneElement; + } + + function buildFileListItem(index) { + var isOversize = false; + var progressElement = KB.dom('progress') + .attr('id', 'file-progress-' + index) + .attr('value', 0) + .build(); + + var percentageElement = KB.dom('span') + .attr('id', 'file-percentage-' + index) + .text('(0%)') + .build(); + + var itemElement = KB.dom('li') + .attr('id', 'file-item-' + index) + .add(progressElement) + .text(' ' + files[index].name + ' ') + .add(percentageElement); + + if (files[index].size > options.maxSize) { + itemElement.add(KB.dom('div').addClass('file-error').text(options.labelOversize).build()); + isOversize = true; + } + + if (isOversize) { + KB.trigger('modal.disable'); + } + + return itemElement.build(); + } + + function buildFileListElement() { + var fileListElement = KB.dom('ul') + .attr('id', 'file-list') + .build(); + + for (var i = 0; i < files.length; i++) { + fileListElement.appendChild(buildFileListItem(i)); + } + + return fileListElement; + } + + this.render = function () { + KB.on('modal.submit', onSubmit); + + inputFileElement = buildFileInputElement(); + dropzoneElement = buildDropzoneElement(); + containerElement.appendChild(inputFileElement); + containerElement.appendChild(dropzoneElement); + }; +}); diff --git a/assets/js/components/keyboard-shortcuts.js b/assets/js/components/keyboard-shortcuts.js index 22859bd6..046e027c 100644 --- a/assets/js/components/keyboard-shortcuts.js +++ b/assets/js/components/keyboard-shortcuts.js @@ -15,19 +15,19 @@ KB.keyboardShortcuts = function () { } else if (forms.length > 1) { if (document.activeElement.tagName === 'INPUT' || document.activeElement.tagName === 'TEXTAREA') { $(document.activeElement).parents("form").submit(); - } else if (_KB.get("Popover").isOpen()) { - $("#popover-container form").submit(); + } else if (KB.modal.isOpen()) { + KB.modal.getForm().submit(); } } } KB.onKey('?', function () { - _KB.get("Popover").open($("body").data("keyboard-shortcut-url")); + KB.modal.open(KB.find('body').data('keyboardShortcutUrl')); }); KB.onKey('Escape', function () { if (! KB.exists('#suggest-menu')) { - _KB.get("Popover").close(); + KB.trigger('modal.close'); _KB.get("Dropdown").close(); } }); @@ -49,25 +49,25 @@ KB.keyboardShortcuts = function () { }); KB.onKey('n', function () { - _KB.get("Popover").open($("#board").data("task-creation-url")); + KB.modal.open(KB.find('#board').data('taskCreationUrl'), 'large', false); }); } if (KB.exists('#task-view')) { KB.onKey('e', function () { - _KB.get("Popover").open(KB.find('#task-view').data('editUrl')); + KB.modal.open(KB.find('#task-view').data('editUrl'), 'large'); }); KB.onKey('c', function () { - _KB.get("Popover").open(KB.find('#task-view').data('commentUrl')); + KB.modal.open(KB.find('#task-view').data('commentUrl')); }); KB.onKey('s', function () { - _KB.get("Popover").open(KB.find('#task-view').data('subtaskUrl')); + KB.modal.open(KB.find('#task-view').data('subtaskUrl')); }); KB.onKey('l', function () { - _KB.get("Popover").open(KB.find('#task-view').data('internalLinkUrl')); + KB.modal.open(KB.find('#task-view').data('internalLinkUrl')); }); } diff --git a/assets/js/components/modal.js b/assets/js/components/modal.js new file mode 100644 index 00000000..f0867289 --- /dev/null +++ b/assets/js/components/modal.js @@ -0,0 +1,29 @@ +(function () { + function getLink(e) { + if (e.target.tagName === 'I') { + return e.target.parentNode.getAttribute('href'); + } + + return e.target.getAttribute('href') + } + + KB.onClick('.js-modal-large', function (e) { + KB.modal.open(getLink(e), 'large', false); + }); + + KB.onClick('.js-modal-medium', function (e) { + KB.modal.open(getLink(e), 'medium', false); + }); + + KB.onClick('.js-modal-small', function (e) { + KB.modal.open(getLink(e), 'small', false); + }); + + KB.onClick('.js-modal-confirm', function (e) { + KB.modal.open(getLink(e), 'small'); + }); + + KB.onClick('.js-modal-close', function () { + KB.modal.close(); + }); +}()); diff --git a/assets/js/components/screenshot.js b/assets/js/components/screenshot.js new file mode 100644 index 00000000..a110f9b1 --- /dev/null +++ b/assets/js/components/screenshot.js @@ -0,0 +1,120 @@ +KB.component('screenshot', function (containerElement) { + var pasteCatcher = null; + var inputElement = null; + + function onPaste(e) { + // Firefox doesn't have the property e.clipboardData.items (only Chrome) + if (e.clipboardData && e.clipboardData.items) { + var items = e.clipboardData.items; + + if (items) { + for (var i = 0; i < items.length; i++) { + // Find an image in pasted elements + if (items[i].type.indexOf("image") !== -1) { + + var blob = items[i].getAsFile(); + + // Get the image as base64 data + var reader = new FileReader(); + reader.onload = function (event) { + createImage(event.target.result); + }; + + reader.readAsDataURL(blob); + } + } + } + } else { + + // Handle Firefox + setTimeout(checkInput, 100); + } + } + + function initialize() { + destroy(); + + if (! window.Clipboard) { + // Insert the content editable at the top to avoid scrolling down in the board view + pasteCatcher = document.createElement('div'); + pasteCatcher.id = 'screenshot-pastezone'; + pasteCatcher.contentEditable = true; + pasteCatcher.style.opacity = 0; + pasteCatcher.style.position = 'fixed'; + pasteCatcher.style.top = 0; + pasteCatcher.style.right = 0; + pasteCatcher.style.width = 0; + document.body.insertBefore(pasteCatcher, document.body.firstChild); + + pasteCatcher.focus(); + + // Set the focus when clicked anywhere in the document + document.addEventListener('click', setFocus); + + // Set the focus when clicked in screenshot dropzone + document.getElementById('screenshot-zone').addEventListener('click', setFocus); + } + + window.addEventListener('paste', onPaste, false); + } + + function destroy() { + if (pasteCatcher !== null) { + document.body.removeChild(pasteCatcher); + } else if (document.getElementById('screenshot-pastezone')) { + document.body.removeChild(document.getElementById('screenshot-pastezone')); + } + + document.removeEventListener('click', setFocus); + pasteCatcher = null; + } + + function setFocus() { + if (pasteCatcher !== null) { + pasteCatcher.focus(); + } + } + + function checkInput() { + var child = pasteCatcher.childNodes[0]; + + if (child) { + // If the user pastes an image, the src attribute + // will represent the image as a base64 encoded string. + if (child.tagName === 'IMG') { + createImage(child.src); + } + } + + pasteCatcher.innerHTML = ''; + } + + function createImage(blob) { + var pastedImage = new Image(); + pastedImage.src = blob; + + // Send the image content to the form variable + pastedImage.onload = function() { + var sourceSplit = blob.split('base64,'); + inputElement.value = sourceSplit[1]; + }; + + var zone = document.getElementById('screenshot-zone'); + zone.innerHTML = ''; + zone.className = 'screenshot-pasted'; + zone.appendChild(pastedImage); + + destroy(); + initialize(); + } + + this.render = function () { + inputElement = KB.dom('input') + .attr('type', 'hidden') + .attr('name', 'screenshot') + .build(); + + containerElement.appendChild(inputElement); + initialize(); + }; +}); diff --git a/assets/js/components/select-dropdown-autocomplete.js b/assets/js/components/select-dropdown-autocomplete.js index 9a8df180..adf48470 100644 --- a/assets/js/components/select-dropdown-autocomplete.js +++ b/assets/js/components/select-dropdown-autocomplete.js @@ -1,5 +1,24 @@ KB.component('select-dropdown-autocomplete', function(containerElement, options) { - var componentElement, inputElement, inputHiddenElement; + var componentElement, inputElement, inputHiddenElement, chevronIconElement, loadingIconElement; + + function onLoadingStart() { + KB.dom(loadingIconElement).show(); + KB.dom(chevronIconElement).hide(); + } + + function onLoadingStop() { + KB.dom(loadingIconElement).hide(); + KB.dom(chevronIconElement).show(); + } + + function onScroll() { + var menuElement = KB.find('#select-dropdown-menu'); + + if (menuElement) { + var componentPosition = componentElement.getBoundingClientRect(); + menuElement.style('top', (document.body.scrollTop + componentPosition.bottom) + 'px'); + } + } function onKeyDown(e) { switch (KB.utils.getKey(e)) { @@ -66,8 +85,10 @@ KB.component('select-dropdown-autocomplete', function(containerElement, options) destroyDropdownMenu(); if (options.redirect) { - var regex = new RegExp(options.redirect.regex, 'g'); - window.location = options.redirect.url.replace(regex, value); + window.location = options.redirect.url.replace(new RegExp(options.redirect.regex, 'g'), value); + } else if (options.replace) { + onLoadingStart(); + KB.modal.replace(options.replace.url.replace(new RegExp(options.replace.regex, 'g'), value)); } } @@ -158,7 +179,7 @@ KB.component('select-dropdown-autocomplete', function(containerElement, options) return KB.dom('ul') .attr('id', 'select-dropdown-menu') - .style('top', componentPosition.bottom + 'px') + .style('top', (document.body.scrollTop + componentPosition.bottom) + 'px') .style('left', componentPosition.left + 'px') .style('width', componentPosition.width + 'px') .style('maxHeight', (window.innerHeight - componentPosition.bottom - 20) + 'px') @@ -203,11 +224,20 @@ KB.component('select-dropdown-autocomplete', function(containerElement, options) } this.render = function () { - var dropdownIconElement = KB.dom('i') + KB.on('select.dropdown.loading.start', onLoadingStart); + KB.on('select.dropdown.loading.stop', onLoadingStop); + + chevronIconElement = KB.dom('i') .attr('class', 'fa fa-chevron-down select-dropdown-chevron') .click(toggleDropdownMenu) .build(); + loadingIconElement = KB.dom('span') + .hide() + .addClass('select-loading-icon') + .add(KB.dom('i').attr('class', 'fa fa-spinner fa-pulse').build()) + .build(); + inputHiddenElement = KB.dom('input') .attr('type', 'hidden') .attr('name', options.name) @@ -227,7 +257,8 @@ KB.component('select-dropdown-autocomplete', function(containerElement, options) .addClass('select-dropdown-input-container') .add(inputHiddenElement) .add(inputElement) - .add(dropdownIconElement) + .add(chevronIconElement) + .add(loadingIconElement) .build(); containerElement.appendChild(componentElement); @@ -237,5 +268,7 @@ KB.component('select-dropdown-autocomplete', function(containerElement, options) KB.on(eventName, function() { inputElement.focus(); }); }); } + + window.addEventListener('scroll', onScroll, false); }; }); diff --git a/assets/js/components/submit-buttons.js b/assets/js/components/submit-buttons.js new file mode 100644 index 00000000..b6ad3769 --- /dev/null +++ b/assets/js/components/submit-buttons.js @@ -0,0 +1,94 @@ +KB.component('submit-buttons', function (containerElement, options) { + var isLoading = false; + var isDisabled = options.disabled || false; + var submitLabel = options.submitLabel; + var formActionElement = null; + + function onSubmit() { + isLoading = true; + KB.find('#modal-submit-button').replace(buildButton()); + KB.trigger('modal.submit'); + } + + function onCancel() { + KB.trigger('modal.close'); + } + + function onStop() { + isLoading = false; + KB.find('#modal-submit-button').replace(buildButton()); + } + + function onDisable() { + isLoading = false; + isDisabled = true; + KB.find('#modal-submit-button').replace(buildButton()); + } + + function onEnable() { + isLoading = false; + isDisabled = false; + KB.find('#modal-submit-button').replace(buildButton()); + } + + function onHide() { + KB.dom(formActionElement).hide(); + } + + function onUpdateSubmitLabel(eventData) { + submitLabel = eventData.submitLabel; + KB.find('#modal-submit-button').replace(buildButton()); + } + + function buildButton() { + var button = KB.dom('button') + .attr('id', 'modal-submit-button') + .attr('type', 'submit') + .attr('class', 'btn btn-' + (options.color || 'blue')); + + if (KB.modal.isOpen()) { + button.click(onSubmit); + } + + if (options.tabindex) { + button.attr('tabindex', options.tabindex); + } + + if (isLoading) { + button + .disable() + .add(KB.dom('i').attr('class', 'fa fa-spinner fa-pulse').build()) + .text(' ') + ; + } + + if (isDisabled) { + button.disable(); + } + + return button + .text(submitLabel) + .build(); + } + + this.render = function () { + KB.on('modal.stop', onStop); + KB.on('modal.disable', onDisable); + KB.on('modal.enable', onEnable); + KB.on('modal.hide', onHide); + KB.on('modal.submit.label', onUpdateSubmitLabel); + + var formActionElementBuilder = KB.dom('div') + .attr('class', 'form-actions') + .add(buildButton()); + + if (KB.modal.isOpen()) { + formActionElementBuilder + .text(' ' + options.orLabel + ' ') + .add(KB.dom('a').attr('href', '#').click(onCancel).text(options.cancelLabel).build()) + } + + formActionElement = formActionElementBuilder.build(); + containerElement.appendChild(formActionElement); + }; +}); diff --git a/assets/js/components/suggest-menu.js b/assets/js/components/suggest-menu.js index 238a7d77..7f3e6f62 100644 --- a/assets/js/components/suggest-menu.js +++ b/assets/js/components/suggest-menu.js @@ -62,7 +62,7 @@ KB.component('suggest-menu', function(containerElement, options) { } function getParentElement() { - var selectors = ['.popover-form', '#popover-content', 'body']; + var selectors = ['#modal-content form', '#modal-content', 'body']; for (var i = 0; i < selectors.length; i++) { var element = document.querySelector(selectors[i]); diff --git a/assets/js/components/task-move-position.js b/assets/js/components/task-move-position.js index e54c1324..a1cd969e 100644 --- a/assets/js/components/task-move-position.js +++ b/assets/js/components/task-move-position.js @@ -74,8 +74,6 @@ KB.component('task-move-position', function (containerElement, options) { "column_id": getColumnId(), "swimlane_id": getSwimlaneId(), "position": position - }).success(function () { - window.location.reload(true); }).error(function (response) { if (response) { onError(response.message); @@ -150,7 +148,6 @@ KB.component('task-move-position', function (containerElement, options) { KB.on('modal.submit', onSubmit); var form = KB.dom('div') - .on('submit', onSubmit) .add(KB.dom('div').attr('id', 'message-container').build()) .add(KB.html.label(options.swimlaneLabel, 'form-swimlanes')) .add(buildSwimlaneSelect()) diff --git a/assets/js/core/base.js b/assets/js/core/base.js index a4fd00ac..033be0a7 100644 --- a/assets/js/core/base.js +++ b/assets/js/core/base.js @@ -22,9 +22,7 @@ KB.on = function (eventType, callback) { KB.trigger = function (eventType, eventData) { if (this.listeners.internals.hasOwnProperty(eventType)) { for (var i = 0; i < this.listeners.internals[eventType].length; i++) { - if (! this.listeners.internals[eventType][i](eventData)) { - break; - } + this.listeners.internals[eventType][i](eventData); } } }; diff --git a/assets/js/core/dom.js b/assets/js/core/dom.js index 84bdade2..250a1f78 100644 --- a/assets/js/core/dom.js +++ b/assets/js/core/dom.js @@ -88,6 +88,11 @@ KB.dom = function (tag) { return this; }; + this.replaceText = function (text) { + element.textContent = text; + return this; + }; + this.addClass = function (className) { element.classList.add(className); return this; @@ -122,6 +127,13 @@ KB.dom = function (tag) { return this; }; + this.empty = function () { + while (element.firstChild) { + element.removeChild(element.firstChild); + } + return this; + }; + this.parent = function (selector) { for (; element && element !== document; element = element.parentNode) { if (element.matches(selector)) { diff --git a/assets/js/core/http.js b/assets/js/core/http.js index b965ad23..21200a0f 100644 --- a/assets/js/core/http.js +++ b/assets/js/core/http.js @@ -3,11 +3,21 @@ KB.http.request = function (method, url, headers, body) { var errorCallback = function() {}; function parseResponse(request) { - try { - return JSON.parse(request.responseText); - } catch (e) { - return request.responseText; + var redirect = request.getResponseHeader('X-Ajax-Redirect'); + + if (redirect === 'self') { + window.location.reload(); + } else if (redirect && redirect.indexOf('#') > -1) { + window.location = redirect.split('#')[0]; + } else if (redirect) { + window.location = redirect; + } else if (request.getResponseHeader('Content-Type') === 'application/json') { + try { + return JSON.parse(request.responseText); + } catch (e) {} } + + return request.responseText; } this.execute = function () { @@ -64,3 +74,20 @@ KB.http.postJson = function (url, body) { return (new KB.http.request('POST', url, headers, JSON.stringify(body))).execute(); }; + +KB.http.postForm = function (url, formElement) { + var formData = new FormData(formElement); + return (new KB.http.request('POST', url, {}, formData)).execute(); +}; + +KB.http.uploadFile = function (url, file, onProgress, onComplete, onError) { + var fd = new FormData(); + fd.append('files[]', file); + + var xhr = new XMLHttpRequest(); + xhr.upload.addEventListener('progress', onProgress); + xhr.upload.addEventListener('load', onComplete); + xhr.upload.addEventListener('error', onError); + xhr.open('POST', url, true); + xhr.send(fd); +}; diff --git a/assets/js/core/modal.js b/assets/js/core/modal.js new file mode 100644 index 00000000..b41dfbac --- /dev/null +++ b/assets/js/core/modal.js @@ -0,0 +1,172 @@ +(function () { + var isOpen = false; + + function onOverlayClick(e) { + if (e.target.matches('#modal-overlay')) { + e.stopPropagation(); + e.preventDefault(); + destroy(); + } + } + + function onCloseButtonClick() { + destroy(); + } + + function onFormSubmit() { + KB.trigger('modal.loading'); + submitForm(); + } + + function getForm() { + return document.querySelector('#modal-content form'); + } + + function submitForm() { + var form = getForm(); + + if (form) { + var url = form.getAttribute('action'); + + if (url) { + KB.http.postForm(url, form).success(function (response) { + KB.trigger('modal.stop'); + + if (response) { + replace(response); + } else { + destroy(); + } + }); + } + } + } + + function afterRendering() { + var formElement = KB.find('#modal-content form'); + if (formElement) { + formElement.on('submit', onFormSubmit, false); + } + + var autoFocusElement = document.querySelector('#modal-content input[autofocus]'); + if (autoFocusElement) { + autoFocusElement.focus(); + } + + KB.render(); + _KB.datePicker(); + _KB.autoComplete(); + _KB.tagAutoComplete(); + _KB.get('Task').onPopoverOpened(); + } + + function replace(html) { + var contentElement = KB.find('#modal-content'); + + if (contentElement) { + contentElement.replace(KB.dom('div') + .attr('id', 'modal-content') + .html(html) + .build() + ); + + afterRendering(); + } + } + + function create(html, width, overlayClickDestroy) { + var closeButtonElement = KB.dom('a') + .attr('href', '#') + .attr('id', 'modal-close-button') + .html('<i class="fa fa-times"></i>') + .click(onCloseButtonClick) + .build(); + + var headerElement = KB.dom('div') + .attr('id', 'modal-header') + .add(closeButtonElement) + .build(); + + var contentElement = KB.dom('div') + .attr('id', 'modal-content') + .html(html) + .build(); + + var boxElement = KB.dom('div') + .attr('id', 'modal-box') + .style('width', width) + .add(headerElement) + .add(contentElement) + .build(); + + var overlayElement = KB.dom('div') + .attr('id', 'modal-overlay') + .add(boxElement) + .build(); + + if (overlayClickDestroy) { + overlayElement.addEventListener('click', onOverlayClick, false); + } + + document.body.appendChild(overlayElement); + afterRendering(); + } + + function destroy() { + var overlayElement = KB.find('#modal-overlay'); + + if (overlayElement) { + overlayElement.remove(); + } + } + + function getWidth(size) { + var viewport = KB.utils.getViewportSize(); + + switch (size) { + case 'large': + return viewport.width < 1300 ? '95%' : '1300px'; + case 'medium': + return viewport.width < 1024 ? '70%' : '1024px'; + } + + return viewport.width < 800 ? '75%' : '800px'; + } + + KB.on('modal.close', function () { + destroy(); + }); + + KB.on('modal.submit', function () { + submitForm(); + }); + + KB.modal = { + open: function (url, size, overlayClickDestroy) { + _KB.get('Dropdown').close(); + destroy(); + + if (typeof overlayClickDestroy === 'undefined') { + overlayClickDestroy = true; + } + + KB.http.get(url).success(function (response) { + isOpen = true; + create(response, getWidth(size), overlayClickDestroy); + }); + }, + close: function () { + isOpen = false; + destroy(); + }, + isOpen: function () { + return isOpen; + }, + replace: function (url) { + KB.http.get(url).success(function (response) { + replace(response); + }); + }, + getForm: getForm + }; +}()); diff --git a/assets/js/core/utils.js b/assets/js/core/utils.js index 4d0f8847..a3683122 100644 --- a/assets/js/core/utils.js +++ b/assets/js/core/utils.js @@ -87,3 +87,10 @@ KB.utils.getKey = function (e) { 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) + }; +}; diff --git a/assets/js/src/BoardTask.js b/assets/js/src/BoardTask.js index cdf32532..9e51002b 100644 --- a/assets/js/src/BoardTask.js +++ b/assets/js/src/BoardTask.js @@ -2,6 +2,7 @@ Kanboard.BoardTask = function(app) { this.app = app; }; +// TODO: rewrite this code Kanboard.BoardTask.prototype.listen = function() { var self = this; diff --git a/assets/js/src/Dropdown.js b/assets/js/src/Dropdown.js index d97b925e..ec033b3e 100644 --- a/assets/js/src/Dropdown.js +++ b/assets/js/src/Dropdown.js @@ -2,6 +2,7 @@ Kanboard.Dropdown = function(app) { this.app = app; }; +// TODO: rewrite this code Kanboard.Dropdown.prototype.listen = function() { var self = this; @@ -9,10 +10,6 @@ Kanboard.Dropdown.prototype.listen = function() { self.close(); }); - $(document).on('click', '#popover-content', function() { - self.close(); - }); - $(document).on('click', '.dropdown-menu', function(e) { e.preventDefault(); e.stopImmediatePropagation(); @@ -56,7 +53,3 @@ Kanboard.Dropdown.prototype.listen = function() { Kanboard.Dropdown.prototype.close = function() { $("#dropdown").remove(); }; - -Kanboard.Dropdown.prototype.onPopoverOpened = function() { - this.close(); -}; diff --git a/assets/js/src/FileUpload.js b/assets/js/src/FileUpload.js deleted file mode 100644 index f53b9bf8..00000000 --- a/assets/js/src/FileUpload.js +++ /dev/null @@ -1,125 +0,0 @@ -Kanboard.FileUpload = function(app) { - this.app = app; - this.files = []; - this.currentFile = 0; -}; - -Kanboard.FileUpload.prototype.onPopoverOpened = function() { - var dropzone = document.getElementById("file-dropzone"); - var self = this; - - if (dropzone) { - dropzone.ondragover = dropzone.ondragenter = function(e) { - e.stopPropagation(); - e.preventDefault(); - }; - - dropzone.ondrop = function(e) { - e.stopPropagation(); - e.preventDefault(); - self.files = e.dataTransfer.files; - self.show(); - $("#file-error-max-size").hide(); - }; - - $(document).on("click", "#file-browser", function(e) { - e.preventDefault(); - $("#file-form-element").get(0).click(); - }); - - $(document).on("click", "#file-upload-button", function(e) { - e.preventDefault(); - self.currentFile = 0; - self.checkFiles(); - }); - - $("#file-form-element").change(function() { - self.files = document.getElementById("file-form-element").files; - self.show(); - $("#file-error-max-size").hide(); - }); - } -}; - -Kanboard.FileUpload.prototype.show = function() { - $("#file-list").remove(); - - if (this.files.length > 0) { - $("#file-upload-button").prop("disabled", false); - $("#file-dropzone-inner").hide(); - - var ul = jQuery("<ul>", {"id": "file-list"}); - - for (var i = 0; i < this.files.length; i++) { - var percentage = jQuery("<span>", {"id": "file-percentage-" + i}).append("(0%)"); - var progress = jQuery("<progress>", {"id": "file-progress-" + i, "value": 0}); - var li = jQuery("<li>", {"id": "file-label-" + i}) - .append(progress) - .append(" ") - .append(this.files[i].name) - .append(" ") - .append(percentage); - - ul.append(li); - } - - $("#file-dropzone").append(ul); - } else { - $("#file-dropzone-inner").show(); - } -}; - -Kanboard.FileUpload.prototype.checkFiles = function() { - var max = parseInt($("#file-dropzone").data("max-size")); - - for (var i = 0; i < this.files.length; i++) { - if (this.files[i].size > max) { - $("#file-error-max-size").show(); - $("#file-label-" + i).addClass("file-error"); - $("#file-upload-button").prop("disabled", true); - return; - } - } - - this.uploadFiles(); -}; - -Kanboard.FileUpload.prototype.uploadFiles = function() { - if (this.files.length > 0) { - this.uploadFile(this.files[this.currentFile]); - } -}; - -Kanboard.FileUpload.prototype.uploadFile = function(file) { - var dropzone = document.getElementById("file-dropzone"); - var url = dropzone.dataset.url; - var xhr = new XMLHttpRequest(); - var fd = new FormData(); - - xhr.upload.addEventListener("progress", this.updateProgress.bind(this)); - xhr.upload.addEventListener("load", this.transferComplete.bind(this)); - - xhr.open("POST", url, true); - fd.append('files[]', file); - xhr.send(fd); -}; - -Kanboard.FileUpload.prototype.updateProgress = function(e) { - if (e.lengthComputable) { - $("#file-progress-" + this.currentFile).val(e.loaded / e.total); - $("#file-percentage-" + this.currentFile).text('(' + Math.floor((e.loaded / e.total) * 100) + '%)'); - } -}; - -Kanboard.FileUpload.prototype.transferComplete = function() { - this.currentFile++; - - if (this.currentFile < this.files.length) { - this.uploadFile(this.files[this.currentFile]); - } else { - var uploadButton = $("#file-upload-button"); - uploadButton.prop("disabled", true); - uploadButton.parent().hide(); - $("#file-done").show(); - } -}; diff --git a/assets/js/src/Popover.js b/assets/js/src/Popover.js deleted file mode 100644 index ab71505a..00000000 --- a/assets/js/src/Popover.js +++ /dev/null @@ -1,161 +0,0 @@ -Kanboard.Popover = function(app) { - this.app = app; -}; - -Kanboard.Popover.prototype.listen = function() { - var self = this; - - $(document).on("click", ".popover", function(e) { - self.onClick(e); - }); - - $(document).on("click", ".close-popover", function(e) { - self.close(e); - }); - - $(document).on("click", "#popover-close-button", function(e) { - self.close(e); - }); - - $(document).on("click", "#popover-content", function(e) { - e.stopPropagation(); - }); -}; - -Kanboard.Popover.prototype.onClick = function(e) { - e.preventDefault(); - e.stopPropagation(); - - var target = e.currentTarget || e.target; - var link = target.getAttribute("href"); - - if (! link) { - link = target.getAttribute("data-href"); - } - - if (link) { - this.open(link); - } -}; - -Kanboard.Popover.prototype.isOpen = function() { - return $('#popover-container').size() > 0; -}; - -Kanboard.Popover.prototype.open = function(link) { - var self = this; - - if (!self.isOpen()) { - $.get(link, function(content) { - $("body").prepend( - '<div id="popover-container">' + - '<div id="popover-content">' + - '<div id="popover-content-header"><a href="#" id="popover-close-button"><i class="fa fa-times"></i></a></div>' + - content + - '</div>' + - '</div>' - ); - - self.executeOnOpenedListeners(); - }); - } -}; - -Kanboard.Popover.prototype.close = function(e) { - if (this.isOpen()) { - if (e) { - e.preventDefault(); - } - - $("#popover-container").remove(); - this.executeOnClosedListeners(); - } -}; - -Kanboard.Popover.prototype.ajaxReload = function(data, request, self) { - var redirect = request.getResponseHeader("X-Ajax-Redirect"); - - if (redirect === 'self') { - window.location.reload(); - } else if (redirect && redirect.indexOf('#') > -1) { - window.location = redirect.split('#')[0]; - } else if (redirect) { - window.location = redirect; - } else { - $("#popover-content").html(data); - $("#popover-content input[autofocus]").focus(); - self.executeOnOpenedListeners(); - } -}; - -Kanboard.Popover.prototype.executeOnOpenedListeners = function() { - for (var className in this.app.controllers) { - var controller = this.app.get(className); - - if (typeof controller.onPopoverOpened === "function") { - controller.onPopoverOpened(); - } - } - - this.afterOpen(); -}; - -Kanboard.Popover.prototype.executeOnClosedListeners = function() { - for (var className in this.app.controllers) { - var controller = this.app.get(className); - - if (typeof controller.onPopoverClosed === "function") { - controller.onPopoverClosed(); - } - } -}; - -Kanboard.Popover.prototype.afterOpen = function() { - var self = this; - var popoverForm = $("#popover-content .popover-form"); - - // Submit forms with Ajax request - if (popoverForm) { - popoverForm.on("submit", function(e) { - e.preventDefault(); - - $.ajax({ - type: "POST", - url: popoverForm.attr("action"), - data: popoverForm.serialize(), - success: function(data, textStatus, request) { - self.ajaxReload(data, request, self); - }, - beforeSend: function() { - var button = $('.popover-form button[type="submit"]'); - button.html('<i class="fa fa-spinner fa-pulse"></i> ' + button.html()); - button.attr("disabled", true); - } - }); - }); - } - - // Submit link with Ajax request - $(document).on("click", ".popover-link", function(e) { - e.preventDefault(); - - $.ajax({ - type: "GET", - url: $(this).attr("href"), - success: function(data, textStatus, request) { - self.ajaxReload(data, request, self); - } - }); - }); - - // Autofocus fields (html5 autofocus works only with page onload) - $("#popover-content input[autofocus]").each(function() { - $(this).focus(); - }); - - this.app.datePicker(); - this.app.autoComplete(); - this.app.tagAutoComplete(); - - KB.render(); -}; diff --git a/assets/js/src/Screenshot.js b/assets/js/src/Screenshot.js deleted file mode 100644 index 4f69e9c3..00000000 --- a/assets/js/src/Screenshot.js +++ /dev/null @@ -1,134 +0,0 @@ -Kanboard.Screenshot = function(app) { - this.app = app; - this.pasteCatcher = null; -}; - -Kanboard.Screenshot.prototype.onPopoverOpened = function() { - if (this.app.hasId("screenshot-zone")) { - this.initialize(); - } -}; - -// Setup event listener and workarounds -Kanboard.Screenshot.prototype.initialize = function() { - this.destroy(); - - if (! window.Clipboard) { - - // Create a contenteditable element - this.pasteCatcher = document.createElement("div"); - this.pasteCatcher.id = "screenshot-pastezone"; - this.pasteCatcher.contentEditable = "true"; - - // Insert the content editable at the top to avoid scrolling down in the board view - this.pasteCatcher.style.opacity = 0; - this.pasteCatcher.style.position = "fixed"; - this.pasteCatcher.style.top = 0; - this.pasteCatcher.style.right = 0; - this.pasteCatcher.style.width = 0; - - document.body.insertBefore(this.pasteCatcher, document.body.firstChild); - - // Set focus on the contenteditable element - this.pasteCatcher.focus(); - - // Set the focus when clicked anywhere in the document - document.addEventListener("click", this.setFocus.bind(this)); - - // Set the focus when clicked in screenshot dropzone (popover) - document.getElementById("screenshot-zone").addEventListener("click", this.setFocus.bind(this)); - } - - window.addEventListener("paste", this.pasteHandler.bind(this)); -}; - -// Destroy contentEditable element -Kanboard.Screenshot.prototype.destroy = function() { - if (this.pasteCatcher !== null) { - document.body.removeChild(this.pasteCatcher); - } - else if (document.getElementById("screenshot-pastezone")) { - document.body.removeChild(document.getElementById("screenshot-pastezone")); - } - - document.removeEventListener("click", this.setFocus.bind(this)); - this.pasteCatcher = null; -}; - -// Set focus on contentEditable element -Kanboard.Screenshot.prototype.setFocus = function() { - if (this.pasteCatcher !== null) { - this.pasteCatcher.focus(); - } -}; - -// Paste event callback -Kanboard.Screenshot.prototype.pasteHandler = function(e) { - // Firefox doesn't have the property e.clipboardData.items (only Chrome) - if (e.clipboardData && e.clipboardData.items) { - - var items = e.clipboardData.items; - - if (items) { - - for (var i = 0; i < items.length; i++) { - - // Find an image in pasted elements - if (items[i].type.indexOf("image") !== -1) { - - var blob = items[i].getAsFile(); - - // Get the image as base64 data - var reader = new FileReader(); - var self = this; - reader.onload = function(event) { - self.createImage(event.target.result); - }; - - reader.readAsDataURL(blob); - } - } - } - } - else { - - // Handle Firefox - setTimeout(this.checkInput.bind(this), 100); - } -}; - -// Parse the input in the paste catcher element -Kanboard.Screenshot.prototype.checkInput = function() { - var child = this.pasteCatcher.childNodes[0]; - - if (child) { - // If the user pastes an image, the src attribute - // will represent the image as a base64 encoded string. - if (child.tagName === "IMG") { - this.createImage(child.src); - } - } - - this.pasteCatcher.innerHTML = ""; -}; - -// Creates a new image from a given source -Kanboard.Screenshot.prototype.createImage = function(blob) { - var pastedImage = new Image(); - pastedImage.src = blob; - - // Send the image content to the form variable - pastedImage.onload = function() { - var sourceSplit = blob.split("base64,"); - var sourceString = sourceSplit[1]; - $("input[name=screenshot]").val(sourceString); - }; - - var zone = document.getElementById("screenshot-zone"); - zone.innerHTML = ""; - zone.className = "screenshot-pasted"; - zone.appendChild(pastedImage); - - this.destroy(); - this.initialize(); -}; diff --git a/assets/js/src/Search.js b/assets/js/src/Search.js index de78c896..b61710a4 100644 --- a/assets/js/src/Search.js +++ b/assets/js/src/Search.js @@ -15,6 +15,7 @@ Kanboard.Search.prototype.focus = function() { }); }; +// TODO: rewrite this code Kanboard.Search.prototype.listen = function() { $(document).on("click", ".filter-helper", function (e) { e.preventDefault(); diff --git a/assets/js/src/Task.js b/assets/js/src/Task.js index be9c2bfa..19cf39e8 100644 --- a/assets/js/src/Task.js +++ b/assets/js/src/Task.js @@ -2,9 +2,9 @@ Kanboard.Task = function(app) { this.app = app; }; +// TODO: rewrite this code Kanboard.Task.prototype.onPopoverOpened = function() { var self = this; - var reloadingProjectId = 0; self.renderColorPicker(); @@ -19,29 +19,6 @@ Kanboard.Task.prototype.onPopoverOpened = function() { $(dropdownId).val(currentId); } }); - - // Reload page when a destination project is changed - $(document).on("change", "select.task-reload-project-destination", function() { - if (reloadingProjectId > 0) { - $(this).val(reloadingProjectId); - } - else { - reloadingProjectId = $(this).val(); - var url = $(this).data("redirect").replace(/PROJECT_ID/g, reloadingProjectId); - - $(".loading-icon").show(); - - $.ajax({ - type: "GET", - url: url, - success: function(data, textStatus, request) { - reloadingProjectId = 0; - $(".loading-icon").hide(); - self.app.get("Popover").ajaxReload(data, request, self.app.get("Popover")); - } - }); - } - }); }; Kanboard.Task.prototype.renderColorPicker = function() { |