Browse files

Move flattening title links for todo_lists in to own function; regist…

…er updated handler
  • Loading branch information...
1 parent 2102272 commit 1454b5658d791ee802dc3caa6ccbb6dc757fc86f @rrrene committed Jun 26, 2012
Showing with 12 additions and 4 deletions.
  1. +12 −4 app/assets/javascripts/todo_lists.js.coffee
View
16 app/assets/javascripts/todo_lists.js.coffee
@@ -5,11 +5,19 @@
OUT.registerCreatedHandler "todo_list", (selector) ->
$(selector).find("a.new").click()
-$ ->
+# TODO: doesnot work when user clicks on "cancel" (triggers :show action, no update)
+OUT.registerUpdatedHandler "todo_list", (selector) ->
+ OUT.todo_lists.flattenTitleLinks(selector)
+
+OUT.todo_lists =
# Remove links to todo-list from todo-lists in content area
- $('.content h2 a[rel="todo-list"]').each ->
- $(this).replaceWith $(this).html()
- # TODO: doesnot work with live added data
+ flattenTitleLinks: (root = '.content') ->
+ $(root).find('h2 a[rel="todo-list"]').each ->
+ $(this).replaceWith $(this).html()
+
+$ ->
+ OUT.todo_lists.flattenTitleLinks()
+
OUT.contentItems.highlightQueryIn ".content-items .content-item-todo-list h2, .content-items .todo-title", (chain) ->
matched_lists = $(".content-items .content-item-todo-list h2 span.highlight").parents('.content-item-todo-list')

0 comments on commit 1454b56

Please sign in to comment.