[Contributed by Andrew Williams] Toggling of contexts in /todo/list to collapse or expand their display via a small '+' or '-' graphic. This is independent of the shown/hidden setting for contexts, and is ideal for just hiding things on the fly to focus your view. The toggled state is stored in a cookie.

git-svn-id: http://www.rousette.org.uk/svn/tracks-repos/trunk@50 a4c988fc-2ded-0310-b66e-134b36920a42
This commit is contained in:
bsag 2005-03-28 15:18:22 +00:00
parent e0b9ba0182
commit 5fc3636f72
6 changed files with 81 additions and 6 deletions

View file

@ -19,7 +19,7 @@ var moty = ["January","February","March","April","May","June","July","August","S
</script>
</head>
<body onload="javascript:toggleAll('notes','none')">
<body onload="javascript:toggleAll('notes','none'); toggleAllImages();">
<div>
<h1>
<% if @count %>

View file

@ -1,12 +1,16 @@
<div id="display_box">
<% for @shown_place in @shown_places %>
<% @not_done = Todo.find_all("done=0 AND context_id=#{@shown_place.id}", "created ASC") %>
<% if !@not_done.empty? %>
<div class="contexts">
<h2><%= link_to( "#{@shown_place.name.capitalize}", :controller => "context", :action => "show", :name => urlize(@shown_place.name) ) %></h2>
<% for @shown_place in @shown_places %>
<% @not_done = Todo.find_all("done=0 AND context_id=#{@shown_place.id}", "created ASC") %>
<% if !@not_done.empty? %>
<div class="contexts">
<h2>
<a href="javascript:toggle('c<%=@shown_place.id%>');javascript:toggleImage('toggle_context_<%=@shown_place.id%>')">
<img src="/images/collapse.png" name="toggle_context_<%= @shown_place.id %>"/></a><%= link_to( "#{@shown_place.name.capitalize}", :controller => "context", :action => "show", :name => urlize(@shown_place.name) ) %></h2>
<div id="c<%= @shown_place.id %>">
<table class="next_actions" id="incomplete" cellspacing="2" cellpadding="0" border="0">
<%= render_collection_of_partials "not_done", @not_done %>
</table>
</div>
</div><!-- End contexts -->
<% end %>
<% end %>

View file

@ -17,6 +17,7 @@ Project wiki: <http://www.rousette.org.uk/projects/wiki/>
3. Fixed SQLite dump format in db/tracks_1.0.2_sqlite.sql (thanks, Jim)
4. Added a mini-calendar to the todo/list page. Needs some tidying up, but it provides a quick way to look up a date a few months ahead. Note that it doesn't insert the date: it's just for viewing. I modified the calendar a little bit from here: <http://www.pxl8.com/basic_calendar.html>
5. Added some XMLHTTPRequest calls to speed up checking off an item as done. It grabs the checked item and appends it immediately to a 'holding' section (where you can uncheck it again if it was a mistake, or add a closing note). When you next refresh the page, it will be added to the 'Last 5 completed items' section.
6. [Contributed by Andrew Williams] Toggling of contexts in /todo/list to collapse or expand their display via a small '+' or '-' graphic. This is independent of the shown/hidden setting for contexts, and is ideal for just hiding things on the fly to focus your view.
## Version 1.02

Binary file not shown.

After

Width:  |  Height:  |  Size: 242 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 286 B

View file

@ -9,6 +9,76 @@ function toggle(idname) {
document.getElementById(idname).style.display = (document.getElementById(idname).style.display == 'none') ? 'block' : 'none';
}
// Contributed by Andrew Williams
function toggleAllImages()
{
var cookies = document.cookie.split(';');
for(var i = 0; i < cookies.length; i++)
{
var str = cookies[i].split('=')[0];
if(str.indexOf('toggle_context_') != -1)
{
var id = str.split('_')[2];
if(getCookie(str) == 'collapsed')
{
toggle('c'+id);
toggleImage('toggle_context_'+id);
}
}
}
}
function toggle(idname)
{
document.getElementById(idname).style.display = (document.getElementById(idname).style.display == 'none') ? 'block' : 'none';
}
function toggleImage(idname)
{
if(document.images)
{
if(document[idname].src.indexOf('collapse.png') != -1)
{
document[idname].src = '/images/expand.png';
SetCookie(idname, "collapsed");
}
else
{
document[idname].src = '/images/collapse.png';
SetCookie(idname, "expanded");
}
}
}
function SetCookie (name, value) {
var argv = SetCookie.arguments;
var argc = SetCookie.arguments.length;
var expires = (argc > 2) ? argv[2] : null;
var path = (argc > 3) ? argv[3] : null;
var domain = (argc > 4) ? argv[4] : null;
var secure = (argc > 5) ? argv[5] : false;
document.cookie = name + "=" + escape (value) +
((expires == null) ? "" : ("; expires=" +
expires.toGMTString())) +
((path == null) ? "" : ("; path=" + path)) +
((domain == null) ? "" : ("; domain=" + domain)) +
((secure == true) ? "; secure" : "");
}
var bikky = document.cookie;
function getCookie(name) { // use: getCookie("name");
var index = bikky.indexOf(name + "=");
if (index == -1) return null;
index = bikky.indexOf("=", index) + 1; // first character
var endstr = bikky.indexOf(";", index);
if (endstr == -1) endstr = bikky.length; // last character
return unescape(bikky.substring(index, endstr));
}
//
// XMLHTTPRequest code from David Goodlad <http://hieraki.goodlad.ca/read/book/1>
//