diff --git a/tracks/app/views/contexts/_context.rhtml b/tracks/app/views/contexts/_context.rhtml index 0c26b469..6191495c 100644 --- a/tracks/app/views/contexts/_context.rhtml +++ b/tracks/app/views/contexts/_context.rhtml @@ -4,18 +4,21 @@ <% if collapsible -%> <%= image_tag("collapse.png") %> <% 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 %> diff --git a/tracks/public/javascripts/todo-items.js b/tracks/public/javascripts/todo-items.js index 09ee89f9..61efefbe 100644 --- a/tracks/public/javascripts/todo-items.js +++ b/tracks/public/javascripts/todo-items.js @@ -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');