summaryrefslogtreecommitdiff
path: root/assets/js
diff options
context:
space:
mode:
Diffstat (limited to 'assets/js')
-rw-r--r--assets/js/app.js25
-rw-r--r--assets/js/src/dashboard.js52
2 files changed, 66 insertions, 11 deletions
diff --git a/assets/js/app.js b/assets/js/app.js
index 3417949b..deec24a0 100644
--- a/assets/js/app.js
+++ b/assets/js/app.js
@@ -133,25 +133,28 @@ unbind:function(a,b){return m.bind(a,function(){},b)},trigger:function(a,b){if(q
b[c[e].seq]=1,x(c[e].callback,d,c[e].combo,c[e].seq)):g||x(c[e].callback,d,c[e].combo);c="keypress"==d.type&&I;d.type!=u||w(a)||c||t(b);I=g&&"keydown"==d.type}};J.Mousetrap=m;"function"===typeof define&&define.amd&&define(m)})(window,document);
var Kanboard=function(){return{Exists:function(a){return document.getElementById(a)?!0:!1},Popover:function(a,d){a.preventDefault();a.stopPropagation();var c=a.target.getAttribute("href");c||(c=a.target.getAttribute("data-href"));c&&Kanboard.OpenPopover(c,d)},OpenPopover:function(a,d){$.get(a,function(a){$("body").append('<div id="popover-container"><div id="popover-content">'+a+"</div></div>");$("#popover-container").click(function(){$(this).remove()});$("#popover-content").click(function(a){a.stopPropagation()});
$(".close-popover").click(function(a){a.preventDefault();$("#popover-container").remove()});Mousetrap.bind("esc",function(){$("#popover-container").remove()});d&&d()})},IsVisible:function(){var a="";"undefined"!==typeof document.hidden?a="visibilityState":"undefined"!==typeof document.mozHidden?a="mozVisibilityState":"undefined"!==typeof document.msHidden?a="msVisibilityState":"undefined"!==typeof document.webkitHidden&&(a="webkitVisibilityState");return""!=a?"visible"==document[a]:!0},SetStorageItem:function(a,
-d){"undefined"!==typeof Storage&&localStorage.setItem(a,d)},GetStorageItem:function(a){return"undefined"!==typeof Storage?localStorage.getItem(a):""},MarkdownPreview:function(a){a.preventDefault();var d=$(this),c=$(this).closest("ul"),f=$(".write-area"),e=$(".preview-area"),g=$("textarea");$.ajax({url:"?controller=app&action=preview",contentType:"application/json",type:"POST",processData:!1,dataType:"html",data:JSON.stringify({text:g.val()})}).done(function(a){c.find("li").removeClass("form-tab-selected");
-d.parent().addClass("form-tab-selected");e.find(".markdown").html(a);e.css("height",g.css("height"));e.css("width",g.css("width"));f.hide();e.show()})},MarkdownWriter:function(a){a.preventDefault();$(this).closest("ul").find("li").removeClass("form-tab-selected");$(this).parent().addClass("form-tab-selected");$(".write-area").show();$(".preview-area").hide()},CheckSession:function(){$(".form-login").length||$.ajax({cache:!1,url:$("body").data("status-url"),statusCode:{401:function(a){window.location=
+d){"undefined"!==typeof Storage&&localStorage.setItem(a,d)},GetStorageItem:function(a){return"undefined"!==typeof Storage?localStorage.getItem(a):""},MarkdownPreview:function(a){a.preventDefault();var d=$(this),c=$(this).closest("ul"),e=$(".write-area"),f=$(".preview-area"),g=$("textarea");$.ajax({url:"?controller=app&action=preview",contentType:"application/json",type:"POST",processData:!1,dataType:"html",data:JSON.stringify({text:g.val()})}).done(function(a){c.find("li").removeClass("form-tab-selected");
+d.parent().addClass("form-tab-selected");f.find(".markdown").html(a);f.css("height",g.css("height"));f.css("width",g.css("width"));e.hide();f.show()})},MarkdownWriter:function(a){a.preventDefault();$(this).closest("ul").find("li").removeClass("form-tab-selected");$(this).parent().addClass("form-tab-selected");$(".write-area").show();$(".preview-area").hide()},CheckSession:function(){$(".form-login").length||$.ajax({cache:!1,url:$("body").data("status-url"),statusCode:{401:function(a){window.location=
$("body").data("login-url")}}})},Init:function(){$("#board-selector").chosen({width:180});$("#board-selector").change(function(){window.location=$(this).attr("data-board-url").replace(/PROJECT_ID/g,$(this).val())});window.setInterval(Kanboard.CheckSession,6E4);Mousetrap.bind("ctrl+enter",function(){$("form").submit()});$(".popover-subtask-restriction").click(Kanboard.Popover);Kanboard.InitAfterAjax()},InitAfterAjax:function(){$(".form-date").datepicker({showOtherMonths:!0,selectOtherMonths:!0,dateFormat:"yy-mm-dd",
constrainInput:!1});$("#markdown-preview").click(Kanboard.MarkdownPreview);$("#markdown-write").click(Kanboard.MarkdownWriter);$(".auto-select").focus(function(){$(this).select()});$(".dropit-submenu").hide();$(".dropdown").not(".dropit").dropit()}}}();
-Kanboard.Board=function(){function a(a){Kanboard.Popover(a,Kanboard.InitAfterAjax)}function d(){Mousetrap.bind("n",function(){Kanboard.OpenPopover($(".task-creation-popover").attr("href"),Kanboard.InitAfterAjax)})}function c(){$(".column").sortable({delay:300,distance:5,connectWith:".column",placeholder:"draggable-placeholder",stop:function(a,b){e(b.item.attr("data-task-id"),b.item.parent().attr("data-column-id"),b.item.index()+1,b.item.parent().attr("data-swimlane-id"))}});$(".assignee-popover").click(a);
+Kanboard.Board=function(){function a(a){Kanboard.Popover(a,Kanboard.InitAfterAjax)}function d(){Mousetrap.bind("n",function(){Kanboard.OpenPopover($(".task-creation-popover").attr("href"),Kanboard.InitAfterAjax)})}function c(){$(".column").sortable({delay:300,distance:5,connectWith:".column",placeholder:"draggable-placeholder",stop:function(a,b){f(b.item.attr("data-task-id"),b.item.parent().attr("data-column-id"),b.item.index()+1,b.item.parent().attr("data-swimlane-id"))}});$(".assignee-popover").click(a);
$(".category-popover").click(a);$(".task-edit-popover").click(a);$(".task-creation-popover").click(a);$(".task-description-popover").click(a);$(".column-tooltip").tooltip({content:function(a){return $(this).attr("title")}});$(".task-board-tooltip").tooltip({track:!1,position:{my:"left-20 top",at:"center bottom+9",using:function(a,b){$(this).css(a);var c=b.target.left+b.target.width/2-b.element.left-20;$("<div>").addClass("tooltip-arrow").addClass(b.vertical).addClass(0==c?"align-left":"align-right").appendTo(this)}},
content:function(a){if(a=$(this).attr("data-href")){var b=this;$.get(a,function k(a){$(".ui-tooltip-content:visible").html(a);a=$(".ui-tooltip:visible");a.css({top:"",left:""});a.children(".tooltip-arrow").remove();var c=$(b).tooltip("option","position");c.of=$(b);a.position(c);$("#tooltip-subtasks a").click(function(a){a.preventDefault();a.stopPropagation();$(this).hasClass("popover-subtask-restriction")?(Kanboard.OpenPopover($(this).attr("href")),$(b).tooltip("close")):$.get($(this).attr("href"),
k)})});return'<i class="fa fa-refresh fa-spin fa-2x"></i>'}}}).on("mouseenter",function(){var a=this;$(this).tooltip("open");$(".ui-tooltip").on("mouseleave",function(){$(a).tooltip("close")})}).on("mouseleave focusout",function(a){a.stopImmediatePropagation();var b=this;setTimeout(function(){$(".ui-tooltip:hover").length||$(b).tooltip("close")},100)});$("[data-task-url]").each(function(){$(this).click(function(){window.location=$(this).attr("data-task-url")})});var b=parseInt($("#board").attr("data-check-interval"));
-0<b&&(h=window.setInterval(g,1E3*b))}function f(){$("[data-task-url]").off();clearInterval(h)}function e(a,d,g,e){f();$.ajax({cache:!1,url:$("#board").attr("data-save-url"),contentType:"application/json",type:"POST",processData:!1,data:JSON.stringify({task_id:a,column_id:d,swimlane_id:e,position:g}),success:function(a){$("#board").remove();$("#main").append(a);Kanboard.InitAfterAjax();c();b()}})}function g(){Kanboard.IsVisible()&&$.ajax({cache:!1,url:$("#board").attr("data-check-url"),statusCode:{200:function(a){$("#board").remove();
-$("#main").append(a);Kanboard.InitAfterAjax();f();c();b()}}})}function b(){var a=$("#form-user_id").val(),b=$("#form-category_id").val(),c=$("#filter-due-date").hasClass("filter-on"),d=$("#board").data("project-id");$("[data-task-id]").each(function(d,g){var e=g.getAttribute("data-owner-id"),f=g.getAttribute("data-due-date"),h=g.getAttribute("data-category-id");g.style.opacity=e!=a&&-1!=a?"0.2":"1.0";!c||""!=f&&"0"!=f||(g.style.opacity="0.2");h!=b&&-1!=b&&(g.style.opacity="0.2")});Kanboard.SetStorageItem("board_filter_"+
+0<b&&(h=window.setInterval(g,1E3*b))}function e(){$("[data-task-url]").off();clearInterval(h)}function f(a,d,g,f){e();$.ajax({cache:!1,url:$("#board").attr("data-save-url"),contentType:"application/json",type:"POST",processData:!1,data:JSON.stringify({task_id:a,column_id:d,swimlane_id:f,position:g}),success:function(a){$("#board").remove();$("#main").append(a);Kanboard.InitAfterAjax();c();b()}})}function g(){Kanboard.IsVisible()&&$.ajax({cache:!1,url:$("#board").attr("data-check-url"),statusCode:{200:function(a){$("#board").remove();
+$("#main").append(a);Kanboard.InitAfterAjax();e();c();b()}}})}function b(){var a=$("#form-user_id").val(),b=$("#form-category_id").val(),c=$("#filter-due-date").hasClass("filter-on"),d=$("#board").data("project-id");$("[data-task-id]").each(function(d,g){var e=g.getAttribute("data-owner-id"),f=g.getAttribute("data-due-date"),h=g.getAttribute("data-category-id");g.style.opacity=e!=a&&-1!=a?"0.2":"1.0";!c||""!=f&&"0"!=f||(g.style.opacity="0.2");h!=b&&-1!=b&&(g.style.opacity="0.2")});Kanboard.SetStorageItem("board_filter_"+
d+"_form-user_id",a);Kanboard.SetStorageItem("board_filter_"+d+"_form-category_id",b);Kanboard.SetStorageItem("board_filter_"+d+"_filter-due-date",~~c)}function l(){var a=$("#board").data("project-id");$("#form-user_id").change(b);$("#form-category_id").change(b);$("#filter-due-date").click(function(a){$(this).toggleClass("filter-on");b();a.preventDefault()});$("#form-user_id").val(Kanboard.GetStorageItem("board_filter_"+a+"_form-user_id")||-1);$("#form-category_id").val(Kanboard.GetStorageItem("board_filter_"+
a+"_form-category_id")||-1);+Kanboard.GetStorageItem("board_filter_"+a+"_filter-due-date")?$("#filter-due-date").addClass("filter-on"):$("#filter-due-date").removeClass("filter-on");b()}var h=null;return{Init:function(){c();l();d()}}}();
Kanboard.Calendar=function(){function a(a){$.ajax({cache:!1,url:$("#calendar").data("save-url"),contentType:"application/json",type:"POST",processData:!1,data:JSON.stringify({task_id:a.id,date_due:a.start.format()})})}function d(a){var b=$("#calendar"),c=b.data("check-url"),d={start:b.fullCalendar("getView").start.format(),end:b.fullCalendar("getView").end.format()};jQuery.extend(d,a);for(var e in d)c+="&"+e+"="+d[e];$.getJSON(c,function(a){b.fullCalendar("removeEvents");b.fullCalendar("addEventSource",
-a);b.fullCalendar("rerenderEvents")})}function c(){var a=Kanboard.GetStorageItem(e);if("undefined"!==a&&""!==a){var a=JSON.parse(a),b;for(b in a)$("select[name="+b+"]").val(a[b])}d(a||{});$(".calendar-filter").change(f)}function f(){var a={};$(".calendar-filter").each(function(b,c){a[$(this).attr("name")]=$(this).val()});Kanboard.SetStorageItem(e,JSON.stringify(a));d(a)}var e="";return{Init:function(){e="calendar_filters_"+$("#calendar").data("project-id");var d=$("#calendar"),b=d.data("translations");
+a);b.fullCalendar("rerenderEvents")})}function c(){var a=Kanboard.GetStorageItem(f);if("undefined"!==a&&""!==a){var a=JSON.parse(a),b;for(b in a)$("select[name="+b+"]").val(a[b])}d(a||{});$(".calendar-filter").change(e)}function e(){var a={};$(".calendar-filter").each(function(b,c){a[$(this).attr("name")]=$(this).val()});Kanboard.SetStorageItem(f,JSON.stringify(a));d(a)}var f="";return{Init:function(){f="calendar_filters_"+$("#calendar").data("project-id");var d=$("#calendar"),b=d.data("translations");
d.fullCalendar({editable:!0,eventLimit:!0,header:{left:"prev,next today",center:"title",right:""},viewRender:c,eventDrop:a,monthNames:[b.January,b.February,b.March,b.April,b.May,b.June,b.July,b.August,b.September,b.October,b.November,b.December],monthNamesShort:[b.Jan,b.Feb,b.Mar,b.Apr,b.May,b.Jun,b.Jul,b.Aug,b.Sep,b.Oct,b.Nov,b.Dec],buttonText:{today:b.Today},dayNames:[b.Sunday,b.Monday,b.Tuesday,b.Wednesday,b.Thursday,b.Friday,b.Saturday],dayNamesShort:[b.Sun,b.Mon,b.Tue,b.Wed,b.Thu,b.Fri,b.Sat]});
c()}}}();Kanboard.Task=function(){return{Init:function(){$(".file-popover").click(Kanboard.Popover)}}}();Kanboard.Analytic=function(){return{Init:function(){Kanboard.Exists("analytic-task-repartition")?Kanboard.Analytic.TaskRepartition.Init():Kanboard.Exists("analytic-user-repartition")?Kanboard.Analytic.UserRepartition.Init():Kanboard.Exists("analytic-cfd")&&Kanboard.Analytic.CFD.Init()}}}();
-Kanboard.Analytic.CFD=function(){return{Init:function(){jQuery.getJSON($("#chart").attr("data-url"),function(a){var d=a.labels,c=a.columns,f=a.metrics;a=[];for(var e=0;e<f.length;e++){var g={};g[d.column]=f[e].column_title;g[d.day]=f[e].day;g[d.total]=f[e].total;a.push(g)}f=dimple.newSvg("#chart","100%",380);a=new dimple.chart(f,a);a.addCategoryAxis("x",d.day).addOrderRule("Date");a.addMeasureAxis("y",d.total);a.addSeries(d.column,dimple.plot.area).addOrderRule(c.reverse());a.addLegend(10,10,500,
-30,"left");a.draw()})}}}();Kanboard.Analytic.TaskRepartition=function(){return{Init:function(){jQuery.getJSON($("#chart").attr("data-url"),function(a){var d=a.labels,c=a.metrics;a=[];for(var f=0;f<c.length;f++){var e={};e[d.nb_tasks]=c[f].nb_tasks;e[d.column_title]=c[f].column_title;a.push(e)}c=dimple.newSvg("#chart","100%",350);a=new dimple.chart(c,a);a.addMeasureAxis("p",d.nb_tasks);a.addSeries(d.column_title,dimple.plot.pie).innerRadius="50%";a.addLegend(0,0,100,"100%","left");a.draw()})}}}();
-Kanboard.Analytic.UserRepartition=function(){return{Init:function(){jQuery.getJSON($("#chart").attr("data-url"),function(a){var d=a.labels,c=a.metrics;a=[];for(var f=0;f<c.length;f++){var e={};e[d.nb_tasks]=c[f].nb_tasks;e[d.user]=c[f].user;a.push(e)}c=dimple.newSvg("#chart","100%",350);a=new dimple.chart(c,a);a.addMeasureAxis("p",d.nb_tasks);a.addSeries(d.user,dimple.plot.pie).innerRadius="50%";a.addLegend(0,0,100,"100%","left");a.draw()})}}}();
+Kanboard.Analytic.CFD=function(){return{Init:function(){jQuery.getJSON($("#chart").attr("data-url"),function(a){var d=a.labels,c=a.columns,e=a.metrics;a=[];for(var f=0;f<e.length;f++){var g={};g[d.column]=e[f].column_title;g[d.day]=e[f].day;g[d.total]=e[f].total;a.push(g)}e=dimple.newSvg("#chart","100%",380);a=new dimple.chart(e,a);a.addCategoryAxis("x",d.day).addOrderRule("Date");a.addMeasureAxis("y",d.total);a.addSeries(d.column,dimple.plot.area).addOrderRule(c.reverse());a.addLegend(10,10,500,
+30,"left");a.draw()})}}}();Kanboard.Analytic.TaskRepartition=function(){return{Init:function(){jQuery.getJSON($("#chart").attr("data-url"),function(a){var d=a.labels,c=a.metrics;a=[];for(var e=0;e<c.length;e++){var f={};f[d.nb_tasks]=c[e].nb_tasks;f[d.column_title]=c[e].column_title;a.push(f)}c=dimple.newSvg("#chart","100%",350);a=new dimple.chart(c,a);a.addMeasureAxis("p",d.nb_tasks);a.addSeries(d.column_title,dimple.plot.pie).innerRadius="50%";a.addLegend(0,0,100,"100%","left");a.draw()})}}}();
+Kanboard.Analytic.UserRepartition=function(){return{Init:function(){jQuery.getJSON($("#chart").attr("data-url"),function(a){var d=a.labels,c=a.metrics;a=[];for(var e=0;e<c.length;e++){var f={};f[d.nb_tasks]=c[e].nb_tasks;f[d.user]=c[e].user;a.push(f)}c=dimple.newSvg("#chart","100%",350);a=new dimple.chart(c,a);a.addMeasureAxis("p",d.nb_tasks);a.addSeries(d.user,dimple.plot.pie).innerRadius="50%";a.addLegend(0,0,100,"100%","left");a.draw()})}}}();
Kanboard.Swimlane=function(){function a(a){$(".swimlane-row-"+a).css("display","none");$(".show-icon-swimlane-"+a).css("display","inline");$(".hide-icon-swimlane-"+a).css("display","none")}function d(){var a="hidden_swimlanes_"+$("#board").data("project-id");return JSON.parse(Kanboard.GetStorageItem(a))||[]}jQuery(document).ajaxComplete(function(){d().map(function(c){a(c)})});jQuery(document).ready(function(){d().map(function(c){a(c)})});jQuery(document).on("click",".board-swimlane-toggle",function(c){c.preventDefault();
-c=$(this).data("swimlane-id");if(-1<d().indexOf(c)){var f="hidden_swimlanes_"+$("#board").data("project-id"),e=JSON.parse(Kanboard.GetStorageItem(f))||[],g=e.indexOf(c);-1<g&&e.splice(g,1);Kanboard.SetStorageItem(f,JSON.stringify(e));$(".swimlane-row-"+c).css("display","table-row");$(".show-icon-swimlane-"+c).css("display","none");$(".hide-icon-swimlane-"+c).css("display","inline")}else f="hidden_swimlanes_"+$("#board").data("project-id"),e=JSON.parse(Kanboard.GetStorageItem(f))||[],e.push(c),Kanboard.SetStorageItem(f,
-JSON.stringify(e)),a(c)})}();jQuery(document).ready(function(){Kanboard.Init();Kanboard.Exists("board")?Kanboard.Board.Init():Kanboard.Exists("calendar")?Kanboard.Calendar.Init():Kanboard.Exists("task-section")?Kanboard.Task.Init():Kanboard.Exists("analytic-section")&&Kanboard.Analytic.Init()});
+c=$(this).data("swimlane-id");if(-1<d().indexOf(c)){var e="hidden_swimlanes_"+$("#board").data("project-id"),f=JSON.parse(Kanboard.GetStorageItem(e))||[],g=f.indexOf(c);-1<g&&f.splice(g,1);Kanboard.SetStorageItem(e,JSON.stringify(f));$(".swimlane-row-"+c).css("display","table-row");$(".show-icon-swimlane-"+c).css("display","none");$(".hide-icon-swimlane-"+c).css("display","inline")}else e="hidden_swimlanes_"+$("#board").data("project-id"),f=JSON.parse(Kanboard.GetStorageItem(e))||[],f.push(c),Kanboard.SetStorageItem(e,
+JSON.stringify(f)),a(c)})}();
+Kanboard.Dashboard=function(){function a(){0<$(".dashboard-right-column > div:visible").size()?$(".dashboard-left-column").removeClass("dashboard-single-column"):$(".dashboard-left-column").addClass("dashboard-single-column");0<$(".dashboard-left-column > div:visible").size()?$(".dashboard-right-column").removeClass("dashboard-single-column"):$(".dashboard-right-column").addClass("dashboard-single-column")}jQuery(document).ready(function(){var d=Kanboard.GetStorageItem("dashboard_view");if(d){var d=
+JSON.parse(d),c;for(c in d)$("#dashboard-"+c).toggle(d[c]);a()}});jQuery(document).on("click",".dashboard-toggle",function(d){d.preventDefault();$("#dashboard-"+$(this).data("toggle")).toggle();a();d=["projects","tasks","subtasks","activities"];for(var c={},e=0;e<d.length;e++)c[d[e]]=$("#dashboard-"+d[e]).is(":visible");Kanboard.SetStorageItem("dashboard_view",JSON.stringify(c))})}();
+jQuery(document).ready(function(){Kanboard.Init();Kanboard.Exists("board")?Kanboard.Board.Init():Kanboard.Exists("calendar")?Kanboard.Calendar.Init():Kanboard.Exists("task-section")?Kanboard.Task.Init():Kanboard.Exists("analytic-section")&&Kanboard.Analytic.Init()});
diff --git a/assets/js/src/dashboard.js b/assets/js/src/dashboard.js
new file mode 100644
index 00000000..98cc3a51
--- /dev/null
+++ b/assets/js/src/dashboard.js
@@ -0,0 +1,52 @@
+Kanboard.Dashboard = (function() {
+
+ jQuery(document).ready(function() {
+
+ var state = Kanboard.GetStorageItem("dashboard_view");
+
+ if (state) {
+
+ var sections = JSON.parse(state);
+
+ for (var section in sections) {
+ $("#dashboard-" + section).toggle(sections[section]);
+ }
+
+ hideColumns();
+ }
+ });
+
+ jQuery(document).on('click', ".dashboard-toggle", function(e) {
+ e.preventDefault();
+
+ $("#dashboard-" + $(this).data("toggle")).toggle();
+ hideColumns();
+
+ var sections = ["projects", "tasks", "subtasks", "activities"];
+ var state = {};
+
+ for (var i = 0; i < sections.length; i++) {
+ state[sections[i]] = $("#dashboard-" + sections[i]).is(":visible");
+ }
+
+ Kanboard.SetStorageItem("dashboard_view", JSON.stringify(state));
+ });
+
+ function hideColumns()
+ {
+ if ($(".dashboard-right-column > div:visible").size() > 0) {
+ $(".dashboard-left-column").removeClass("dashboard-single-column");
+ }
+ else {
+ $(".dashboard-left-column").addClass("dashboard-single-column");
+ }
+
+ if ($(".dashboard-left-column > div:visible").size() > 0) {
+ $(".dashboard-right-column").removeClass("dashboard-single-column");
+ }
+ else {
+ $(".dashboard-right-column").addClass("dashboard-single-column");
+ }
+ }
+
+})(); \ No newline at end of file