Stupidly forgot to add the new partials to the repos.

git-svn-id: http://www.rousette.org.uk/svn/tracks-repos/trunk@166 a4c988fc-2ded-0310-b66e-134b36920a42
This commit is contained in:
bsag 2005-12-04 11:47:16 +00:00
parent 80f3fdbc77
commit 1424b12834
6 changed files with 235 additions and 1 deletions

View file

@ -0,0 +1,16 @@
<% @not_done = context.find_not_done_todos %>
<div id="c<%= context.id %>" class="context container">
<h2>
<% if collapsible -%>
<a href="#" class="container_toggle"><%= image_tag("collapse.png") %></a>
<% end -%>
<%= link_to( sanitize("#{context.name}"), { :controller => "context", :action => "show", :name => urlize(context.name) }, { :title => "Go to the #{context.name} context page" } ) %>
</h2>
<div class="items toggle_target">
<div class="empty-nd" style="display:<%= @not_done.empty? ? 'block' : 'none'%>;">
<%= render :partial => "shared/empty",
:locals => { :message => "Currently there are no uncompleted actions in this context"} %>
</div>
<%= render :partial => "todo/item", :collection => @not_done, :locals => { :project => false } %>
</div><!-- [end:items] -->
</div><!-- [end:c<%= context.id %>] -->

View file

@ -1 +0,0 @@
<p><%= message %></p>

View file

@ -0,0 +1,24 @@
<% @not_done = project.find_not_done_todos -%>
<div id="p<%= project.id %>" class="container project">
<h2>
<% if collapsible %>
<a href="#" class="container_toggle"><%= image_tag("collapse.png") %></a>
<% end %>
<%= sanitize("#{project.name}") %>
</h2>
<% if @project.description -%>
<div class="project_description"><%= sanitize(@project.description) %></div>
<% end -%>
<% if @project.done? -%>
<p class="project_completed">Project has been marked as completed</p>
<% end -%>
<div class="items toggle_target">
<div id="empty-nd" style="display:<%= @not_done.empty? ? 'block' : 'none'%>;">
<%= render :partial => "shared/empty",
:locals => { :message => "Currently there are no uncompleted actions in this project"} %>
</div>
<%= render :partial => "todo/item", :collection => @not_done, :locals => { :project => true } %>
</div><!-- [end:items] -->
</div><!-- [end:p<%= project.id %>] -->

View file

@ -0,0 +1,3 @@
<div class="message">
<p><%= message %></p>
</div>

View file

@ -0,0 +1,18 @@
<% suffix = append_descriptor ? append_descriptor : '' %>
<div class="container completed">
<h2>
<% if collapsible %>
<a href="#" class="container_toggle"><%= image_tag("collapse.png") %></a>
<% end %>
Completed actions <%= append_descriptor ? append_descriptor : '' %>
</h2>
<div id="completed" class="items toggle_target">
<div id="empty-d" style="display:<%= @done.empty? ? 'block' : 'none' %>">
<%= render :partial => "shared/empty",
:locals => { :message => "Currently there are no completed actions " + suffix } %>
</div>
<%= render :partial => "todo/item", :collection => done %>
</div>
</div><!-- [end:next_actions] -->

View file

@ -0,0 +1,174 @@
/*
* ToDo Items
*
* Requires the prototype.js library
*
* Use the following markup to include the library:
* <script type="text/javascript" src="todo-items.js"></script>
*/
addEvent(window, "load", addNextActionListingToggles);
addEvent(window, "load", addAjaxToDoItemCheckmarkHandling);
function addNextActionListingToggles()
{
var toggleElems = document.getElementsByClassName('container_toggle');
for(var i = 0; i < toggleElems.length; i++)
{
addEvent(toggleElems[i], "click", toggleNextActionListing);
}
}
function addAjaxToDoItemCheckmarkHandling()
{
var itemCheckboxes = document.getElementsByClassName('item-checkbox');
for(var i = 0; i < itemCheckboxes.length; i++)
{
addEvent(itemCheckboxes[i], "click", toggleTodoItemChecked);
}
}
function addOneAjaxToDoItemCheckmarkHandling(elem)
{
addEvent(document.getElementsByClassName('item-checkbox',elem)[0], "click", toggleTodoItemChecked);
}
function hideContainerIfEmpty(containerElemId)
{
if (document.getElementsByClassName('item-container',$(containerElemId)).length == 0)
{
new Effect.Fade(containerElemId)
}
}
function getMarkUndoneTargetElem()
{
return document.getElementsByClassName('container')[0];
}
function ensureVisibleWithEffectAppear(elemId)
{
if ($(elemId).style.display == 'none')
{
new Effect.Appear(elemId,{duration:0.4});
}
}
function toggleTodoItemChecked()
{
var itemContainerElem = findNearestParentByClassName(this, 'item-container');
var itemContainerElemId = itemContainerElem.getAttribute('id');
var checkboxForm = this.form;
var markingAsDone = this.checked;
var targetElemId = markingAsDone ? 'completed' : getMarkUndoneTargetElem().getAttribute('id');
new Ajax.Updater(
targetElemId,
checkboxForm.action,
{
asynchronous:true,
evalScripts:true,
insertion:markingAsDone ? Insertion.Top : Insertion.Bottom,
onLoading:function(request){ Form.disable(checkboxForm); ensureVisibleWithEffectAppear(targetElemId); },
onSuccess:function(request){ fadeAndRemoveItem(itemContainerElemId); },
onComplete:function(request){ new Effect.Highlight(itemContainerElemId,{}); addOneAjaxToDoItemCheckmarkHandling($(itemContainerElemId)); hideContainerIfEmpty('new_actions'); },
parameters:Form.serialize(checkboxForm)
});
return false;
}
function fadeAndRemoveItem(itemContainerElemId)
{
var fadingElemId = itemContainerElemId + '-fading';
$(itemContainerElemId).setAttribute('id',fadingElemId);
Element.removeClassName($(fadingElemId),'item-container');
new Effect.Fade(fadingElemId,{afterFinish:function(effect) { Element.remove(fadingElemId); }, duration:0.4});
}
function toggleNextActionListing()
{
var itemsElem = findItemsElem(this);
if (Element.visible(itemsElem))
Effect.BlindUp(itemsElem, { duration: 0.4});
else
Effect.BlindDown(itemsElem, { duration: 0.4 });
this.setAttribute('title', (this.style.display == 'none') ? 'Expand' : 'Collapse');
var childImgElems = this.getElementsByTagName('img');
for(var i = 0; i < childImgElems.length; i++)
{
if (childImgElems[i].src.indexOf('collapse.png') != -1)
{
childImgElems[i].src = childImgElems[i].src.replace('collapse','expand');
childImgElems[i].setAttribute('title','Expand');
//SetCookie(idname, "collapsed");
}
else if (childImgElems[i].src.indexOf('expand.png') != -1)
{
childImgElems[i].src = childImgElems[i].src.replace('expand','collapse');
childImgElems[i].setAttribute('title','Collapse');
//SetCookie(idname, "expanded");
}
}
return false;
}
function findNearestParentByClassName(elem, parentClassName)
{
var parentElem = elem.parentNode;
while(parentElem)
{
if (Element.hasClassName(parentElem, parentClassName))
{
return parentElem;
}
parentElem = parentElem.parentNode;
}
return null;
}
function findItemsElem(toggleElem)
{
var containerElem = findNearestParentByClassName(toggleElem, "container");
if (containerElem)
return document.getElementsByClassName('toggle_target',containerElem)[0];
else
return null;
}
// This is a cross-browser function for event addition.
function addEvent(obj, evType, fn)
{
if (obj.addEventListener)
{
obj.addEventListener(evType, fn, false);
return true;
}
else if (obj.attachEvent)
{
var r = obj.attachEvent("on" + evType, fn);
return r;
}
else
{
alert("Event handler could not be attached");
return false;
}
}
function removeEvent(obj, evType, fn)
{
if (obj.removeEventListener)
{
obj.removeEventListener(evType, fn, false);
return true;
}
else if (obj.detachEvent)
{
var r = obj.detachEvent("on"+evType, fn);
return r;
}
else
{
alert("Handler could not be removed");
}
}