fix #727. Adds a check to prevent expand/collapse while a previous expand/collaps is still animating

git-svn-id: http://www.rousette.org.uk/svn/tracks-repos/trunk@869 a4c988fc-2ded-0310-b66e-134b36920a42
This commit is contained in:
lrbalt 2008-06-05 19:47:20 +00:00
parent 549d5e7a97
commit 32b54383ee
2 changed files with 19 additions and 14 deletions

View file

@ -4,18 +4,21 @@
<% if collapsible -%>
<a href="#" class="container_toggle" id="toggle_c<%= context.id %>"><%= image_tag("collapse.png") %></a>
<% apply_behavior '.container_toggle:click', :prevent_default => true do |page|
page << "containerElem = this.up('.container')
toggleTarget = containerElem.down('.toggle_target')
if (Element.visible(toggleTarget))
{
todoItems.collapseNextActionListing(this, toggleTarget);
todoItems.contextCollapseCookieManager.setCookie(todoItems.buildCookieName(containerElem), true)
}
else
{
todoItems.expandNextActionListing(this, toggleTarget);
todoItems.contextCollapseCookieManager.clearCookie(todoItems.buildCookieName(containerElem))
}
page << " /* only handle the click if a previous click had finished its animation */
if (todoItems.lastEffect == null || todoItems.lastEffect.state!='running') {
containerElem = this.up('.container')
toggleTarget = containerElem.down('.toggle_target')
if (Element.visible(toggleTarget))
{
todoItems.collapseNextActionListing(this, toggleTarget);
todoItems.contextCollapseCookieManager.setCookie(todoItems.buildCookieName(containerElem), true)
}
else
{
todoItems.expandNextActionListing(this, toggleTarget);
todoItems.contextCollapseCookieManager.clearCookie(todoItems.buildCookieName(containerElem))
}
}
"
end
%>

View file

@ -12,6 +12,8 @@ ToDoItems = Class.create();
ToDoItems.prototype = {
initialize: function()
{
/* keep track of last effect so you can check if the animation has finised */
this.lastEffect= null;
this.initialized = true;
this.contextCollapseCookieManager = new CookieManager();
this.toggleItemsMap = {};
@ -112,7 +114,7 @@ ToDoItems.prototype = {
}
else
{
Effect.BlindDown(itemsElem, { duration: 0.4 });
this.lastEffect = Effect.BlindDown(itemsElem, { duration: 0.4 });
}
toggleElem.setAttribute('title', 'Collapse');
imgElem = this.findToggleImgElem(toggleElem);
@ -133,7 +135,7 @@ ToDoItems.prototype = {
},
collapseNextActionListing: function(toggleElem, itemsElem)
{
Effect.BlindUp(itemsElem, { duration: 0.4});
this.lastEffect = Effect.BlindUp(itemsElem, { duration: 0.4});
toggleElem.setAttribute('title', 'Expand');
imgElem = this.findToggleImgElem(toggleElem);
imgElem.src = imgElem.src.replace('collapse','expand');