From 3dbc39113ea136904d5a9c83c0a459b817b026a9 Mon Sep 17 00:00:00 2001 From: lukemelia Date: Tue, 13 Feb 2007 06:48:45 +0000 Subject: [PATCH] Fixes #439 (Can't toggle contexts on todo index page). Not sure I quite understand why this was broken, but we should be able to migrate a lot of code out of todo-items.js over time. git-svn-id: http://www.rousette.org.uk/svn/tracks-repos/trunk@439 a4c988fc-2ded-0310-b66e-134b36920a42 --- tracks/app/views/contexts/_context.rhtml | 16 ++++++++++++++++ tracks/public/javascripts/todo-items.js | 4 +--- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/tracks/app/views/contexts/_context.rhtml b/tracks/app/views/contexts/_context.rhtml index 82a377e5..62014a76 100644 --- a/tracks/app/views/contexts/_context.rhtml +++ b/tracks/app/views/contexts/_context.rhtml @@ -3,6 +3,22 @@

<% 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)) + } + " + end + %> <% end -%> <% if source_view_is :context %> <%= in_place_editor_field :context, :name, {}, { :url => url_for(:controller => 'context', :action => 'update', :id => context.id, :field => 'name', :wants_render => false) } %> diff --git a/tracks/public/javascripts/todo-items.js b/tracks/public/javascripts/todo-items.js index 12e0d92f..09ee89f9 100644 --- a/tracks/public/javascripts/todo-items.js +++ b/tracks/public/javascripts/todo-items.js @@ -30,10 +30,8 @@ ToDoItems.prototype = { this.toggleContainerMap[toggleElem.id] = containerElem; this.toggleItemsMap[toggleElem.id] = itemsElem; this.containerItemsMap[containerElem.id] = itemsElem; - Event.observe(this.containerToggles[i], 'click', containerTogglesClick); - this.containerToggles[i].onclick = function() {return false;}; //workaround for Event.stop problem with Safari 2.0.3. See http://particletree.com/notebook/eventstop/ } - this.setNextActionListingTogglesToCookiedState(); + this.setNextActionListingTogglesToCookiedState(); }, setNextActionListingTogglesToCookiedState: function() {