diff options
author | Frederic Guillot <fred@kanboard.net> | 2015-02-14 22:53:12 -0500 |
---|---|---|
committer | Frederic Guillot <fred@kanboard.net> | 2015-02-14 22:53:12 -0500 |
commit | 627d8aaa8c7669fe2c486049d3c1fba4a7f31e74 (patch) | |
tree | 011501eab9346375162388faf91c2205113062c2 /assets/js | |
parent | 7c4bdea324d8074ffcc3fa353fcfd85ee8066634 (diff) |
Add keyboard shortcut to expand/collapse board tasks
Diffstat (limited to 'assets/js')
-rw-r--r-- | assets/js/app.js | 19 | ||||
-rw-r--r-- | assets/js/src/board.js | 22 |
2 files changed, 30 insertions, 11 deletions
diff --git a/assets/js/app.js b/assets/js/app.js index 7175ad43..7a807828 100644 --- a/assets/js/app.js +++ b/assets/js/app.js @@ -141,15 +141,16 @@ return""!=a?"visible"==document[a]:!0},SetStorageItem:function(a,c){"undefined"! c.parent().addClass("form-tab-selected");e.find(".markdown").html(a);e.css("height",f.css("height"));e.css("width",f.css("width"));d.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= $("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);$(".popover-subtask-restriction").click(Kanboard.Popover);$(".file-popover").click(Kanboard.Popover);Mousetrap.bind("ctrl+enter",function(){$("form").submit()});$(".column-tooltip").tooltip({content:function(a){return'<div class="markdown">'+ $(this).attr("title")+"</div>"}});$.datepicker.setDefaults($.datepicker.regional[$("body").data("js-lang")]);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 c(){Mousetrap.bind("n",function(){Kanboard.OpenPopover($(".task-creation-popover").attr("href"),Kanboard.InitAfterAjax)})}function b(){$(".filter-expand-link").click(function(a){a.preventDefault();f();Kanboard.SetStorageItem(d(),"expanded")});$(".filter-collapse-link").click(function(a){a.preventDefault();e();Kanboard.SetStorageItem(d(),"collapsed")});k()}function d(){return"board_stacking_"+$("#board").data("project-id")} -function e(){$(".filter-collapse").hide();$(".task-board-collapsed").show();$(".filter-expand").show();$(".task-board-expanded").hide()}function f(){$(".filter-collapse").show();$(".task-board-collapsed").hide();$(".filter-expand").hide();$(".task-board-expanded").show()}function k(){"expanded"===(Kanboard.GetStorageItem(d())||"expanded")?f():e()}function g(){$(".column").sortable({delay:300,distance:5,connectWith:".column",placeholder:"draggable-placeholder",stop:function(a,b){n(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);$(".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 p(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"),p)})});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&&(l=window.setInterval(q,1E3*b))}function m(){$("[data-task-url]").off();clearInterval(l)}function n(a,b,c,d){m();$.ajax({cache:!1,url:$("#board").attr("data-save-url"),contentType:"application/json",type:"POST",processData:!1,data:JSON.stringify({task_id:a,column_id:b,swimlane_id:d,position:c}),success:function(a){$("#board").remove();$("#main").append(a);Kanboard.InitAfterAjax();g();h();k()}})}function q(){Kanboard.IsVisible()&&$.ajax({cache:!1,url:$("#board").attr("data-check-url"),statusCode:{200:function(a){$("#board").remove(); -$("#main").append(a);Kanboard.InitAfterAjax();m();g();h();k()}}})}function h(){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,e){var k=e.getAttribute("data-owner-id"),g=e.getAttribute("data-due-date"),f=e.getAttribute("data-category-id");e.style.opacity=k!=a&&-1!=a?"0.2":"1.0";!c||""!=g&&"0"!=g||(e.style.opacity="0.2");f!=b&&-1!=b&&(e.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 r(){var a=$("#board").data("project-id");$("#form-user_id").change(h);$("#form-category_id").change(h);$("#filter-due-date").click(function(a){$(this).toggleClass("filter-on");h();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");h()}var l=null;jQuery(document).ready(function(){Kanboard.Exists("board")&&(g(),r(),b(),c())})}(); +Kanboard.Board=function(){function a(a){Kanboard.Popover(a,Kanboard.InitAfterAjax)}function c(){Mousetrap.bind("n",function(){Kanboard.OpenPopover($(".task-creation-popover").attr("href"),Kanboard.InitAfterAjax)});Mousetrap.bind("s",function(){"expanded"===(Kanboard.GetStorageItem(d())||"expanded")?(e(),Kanboard.SetStorageItem(d(),"collapsed")):(f(),Kanboard.SetStorageItem(d(),"expanded"))})}function b(){$(".filter-expand-link").click(function(a){a.preventDefault();f();Kanboard.SetStorageItem(d(), +"expanded")});$(".filter-collapse-link").click(function(a){a.preventDefault();e();Kanboard.SetStorageItem(d(),"collapsed")});k()}function d(){return"board_stacking_"+$("#board").data("project-id")}function e(){$(".filter-collapse").hide();$(".task-board-collapsed").show();$(".filter-expand").show();$(".task-board-expanded").hide()}function f(){$(".filter-collapse").show();$(".task-board-collapsed").hide();$(".filter-expand").hide();$(".task-board-expanded").show()}function k(){"expanded"===(Kanboard.GetStorageItem(d())|| +"expanded")?f():e()}function g(){$(".column").sortable({delay:300,distance:5,connectWith:".column",placeholder:"draggable-placeholder",stop:function(a,b){n(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);$(".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 p(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"),p)})});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&&(l=window.setInterval(q,1E3*b))}function m(){$("[data-task-url]").off();clearInterval(l)}function n(a,b,c,d){m();$.ajax({cache:!1,url:$("#board").attr("data-save-url"),contentType:"application/json",type:"POST",processData:!1,data:JSON.stringify({task_id:a, +column_id:b,swimlane_id:d,position:c}),success:function(a){$("#board").remove();$("#main").append(a);Kanboard.InitAfterAjax();g();h();k()}})}function q(){Kanboard.IsVisible()&&$.ajax({cache:!1,url:$("#board").attr("data-check-url"),statusCode:{200:function(a){$("#board").remove();$("#main").append(a);Kanboard.InitAfterAjax();m();g();h();k()}}})}function h(){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,e){var k=e.getAttribute("data-owner-id"),g=e.getAttribute("data-due-date"),f=e.getAttribute("data-category-id");e.style.opacity=k!=a&&-1!=a?"0.2":"1.0";!c||""!=g&&"0"!=g||(e.style.opacity="0.2");f!=b&&-1!=b&&(e.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 r(){var a=$("#board").data("project-id"); +$("#form-user_id").change(h);$("#form-category_id").change(h);$("#filter-due-date").click(function(a){$(this).toggleClass("filter-on");h();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");h()}var l= +null;jQuery(document).ready(function(){Kanboard.Exists("board")&&(g(),r(),b(),c())})}(); 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 c(a){var b=$("#user-calendar");a=b.data("check-url");var c={start:b.fullCalendar("getView").start.format(),end:b.fullCalendar("getView").end.format(),user_id:b.data("user-id")},d;for(d in c)a+="&"+d+"="+c[d];$.getJSON(a,function(a){b.fullCalendar("removeEvents");b.fullCalendar("addEventSource", a);b.fullCalendar("rerenderEvents")})}function b(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 d(){var a=Kanboard.GetStorageItem(f);if(""!==a){var a=JSON.parse(a),c;for(c in a)$("select[name="+c+"]").val(a[c])}b(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));b(a)}var f="";jQuery(document).ready(function(){if(Kanboard.Exists("calendar")){f="calendar_filters_"+$("#calendar").data("project-id");var b=$("#calendar");b.data("translations");b.fullCalendar({lang:$("body").data("js-lang"),editable:!0,eventLimit:!0,defaultView:"agendaWeek",header:{left:"prev,next today",center:"title",right:"month,agendaWeek,agendaDay"}, diff --git a/assets/js/src/board.js b/assets/js/src/board.js index 45b43794..ecf94b9c 100644 --- a/assets/js/src/board.js +++ b/assets/js/src/board.js @@ -16,6 +16,10 @@ Kanboard.Board = (function() { Kanboard.InitAfterAjax ); }); + + Mousetrap.bind("s", function() { + stack_toggle(); + }); } // Collapse/Expand tasks @@ -24,13 +28,13 @@ Kanboard.Board = (function() { $(".filter-expand-link").click(function(e) { e.preventDefault(); stack_expand(); - Kanboard.SetStorageItem(stack_key(), "expanded") + Kanboard.SetStorageItem(stack_key(), "expanded"); }); $(".filter-collapse-link").click(function(e) { e.preventDefault(); stack_collapse(); - Kanboard.SetStorageItem(stack_key(), "collapsed") + Kanboard.SetStorageItem(stack_key(), "collapsed"); }); stack_show(); @@ -60,6 +64,20 @@ Kanboard.Board = (function() { $(".task-board-expanded").show(); } + function stack_toggle() + { + var state = Kanboard.GetStorageItem(stack_key()) || "expanded"; + + if (state === "expanded") { + stack_collapse(); + Kanboard.SetStorageItem(stack_key(), "collapsed"); + } + else { + stack_expand(); + Kanboard.SetStorageItem(stack_key(), "expanded"); + } + } + function stack_show() { var state = Kanboard.GetStorageItem(stack_key()) || "expanded"; |