From 067df75e9860274c0631a0c8c599502290957440 Mon Sep 17 00:00:00 2001 From: popsch Date: Sat, 10 Sep 2011 01:49:44 +0800 Subject: [PATCH] toggle notes patch from Christian Frank --- app/views/layouts/standard.html.erb | 4 +++- config/locales/en.yml | 2 ++ public/javascripts/application.js | 18 ++++++++++++++++++ 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/app/views/layouts/standard.html.erb b/app/views/layouts/standard.html.erb index da6e6818..86409650 100644 --- a/app/views/layouts/standard.html.erb +++ b/app/views/layouts/standard.html.erb @@ -48,7 +48,9 @@ diff --git a/config/locales/en.yml b/config/locales/en.yml index 475d3710..12fc2049 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -2,6 +2,8 @@ en: layouts: toggle_notes: Toggle notes + toggle_contexts: "Toggle collapsed contexts" + toggle_contexts_title: "Make collapsed contexts (in)visible" next_actions_rss_feed: RSS feed of next actions toggle_notes_title: Toggle all notes mobile_navigation: diff --git a/public/javascripts/application.js b/public/javascripts/application.js index 1a81579f..887b9f47 100644 --- a/public/javascripts/application.js +++ b/public/javascripts/application.js @@ -305,6 +305,19 @@ var TracksPages = { $(".todo_notes").toggle(); }); + + /* Poor man's perspectives, allows to hide any context that is collapsed */ + $("#toggle-contexts-nav").click(function () { + /* Need to keep a single toggle across all contexts */ + $(this).toggleClass("context_visibility"); + if ($(this).hasClass("context_visibility")) { + $(".context_collapsed").hide(); /* Hide all collapsed contexts together*/ + } + else { + $(".context_collapsed").show(); + } + }); + /* fade flashes and alerts in automatically */ $(".alert").fadeOut(8000); } @@ -354,12 +367,16 @@ var TodoItemsContainer = { $(this).find('img').attr('src', imgSrc.replace('collapse', 'expand')); $.cookie(TodoItemsContainer.buildCookieName(this.parentNode.parentNode), true); toggle_target.slideUp(500); + // set parent class to 'context_collapsed' so we can hide/unhide all collapsed contexts + toggle_target.parent().addClass("context_collapsed"); } else { // show it imgSrc = $(this).find('img').attr('src'); $(this).find('img').attr('src', imgSrc.replace('expand', 'collapse')); $.cookie(TodoItemsContainer.buildCookieName(this.parentNode.parentNode), null); toggle_target.slideDown(500); + // remove class 'context_collapsed' from parent class + toggle_target.parent().removeClass("context_collapsed"); } return false; }); @@ -370,6 +387,7 @@ var TodoItemsContainer = { if (imgSrc) { $(this).find('.container_toggle img').attr('src', imgSrc.replace('collapse', 'expand')); $(this).find('.toggle_target').hide(); + $(this).find('.toggle_target').parent().addClass("context_collapsed"); } } });