diff options
| author | hukl <contact@smyck.org> | 2009-08-08 22:38:48 +0200 |
|---|---|---|
| committer | hukl <contact@smyck.org> | 2009-08-08 22:38:48 +0200 |
| commit | 46117a9f103e2d547be2a47724e872b3f57ce983 (patch) | |
| tree | 3360a066676ecf776f62212912abcec4965bdf27 /public/javascripts/admin_search.js | |
| parent | 4f249507da36f219b208f88e4dea5a5cd90ca254 (diff) | |
lots of new code to manage menu items - harder than expected :/
Diffstat (limited to 'public/javascripts/admin_search.js')
| -rw-r--r-- | public/javascripts/admin_search.js | 65 |
1 files changed, 64 insertions, 1 deletions
diff --git a/public/javascripts/admin_search.js b/public/javascripts/admin_search.js index 28f87a0..1e6f545 100644 --- a/public/javascripts/admin_search.js +++ b/public/javascripts/admin_search.js | |||
| @@ -45,4 +45,67 @@ admin_search = { | |||
| 45 | } | 45 | } |
| 46 | $('#search_results').slideDown(); | 46 | $('#search_results').slideDown(); |
| 47 | } | 47 | } |
| 48 | } \ No newline at end of file | 48 | }; |
| 49 | |||
| 50 | menu_items = { | ||
| 51 | |||
| 52 | initialize_search : function() { | ||
| 53 | $("#search_term").bind("keyup", function() { | ||
| 54 | if ($(this).attr("value")) { | ||
| 55 | $.ajax({ | ||
| 56 | type: "GET", | ||
| 57 | url: "/admin/menu_search", | ||
| 58 | data: "search_term=" + $(this).attr("value"), | ||
| 59 | dataType: "json", | ||
| 60 | success : function(results) { | ||
| 61 | menu_items.show_results(results); | ||
| 62 | } | ||
| 63 | }); | ||
| 64 | } | ||
| 65 | else { | ||
| 66 | $('#search_results').slideUp(); | ||
| 67 | $('#search_results').empty(); | ||
| 68 | } | ||
| 69 | }); | ||
| 70 | }, | ||
| 71 | |||
| 72 | show_results : function(results) { | ||
| 73 | $("#search_results").empty(); | ||
| 74 | for (result in results) { | ||
| 75 | var foo = $(("<a href='#'>"+ results[result].title + "</a>")); | ||
| 76 | $(foo).bind("click", function(){ | ||
| 77 | menu_items.open_title_popup(); | ||
| 78 | //menu_items.add_item_to_menu(results[result]); | ||
| 79 | return false; | ||
| 80 | }); | ||
| 81 | |||
| 82 | $("#search_results").append(foo); | ||
| 83 | |||
| 84 | } | ||
| 85 | }, | ||
| 86 | |||
| 87 | open_title_popup : function() { | ||
| 88 | popup = $("<div><form action='#'><input id='item_title' type='text' /><input id='foobar' type='submit' /></form></div>"); | ||
| 89 | $("form", popup).submit(function(){ | ||
| 90 | alert("hi"); | ||
| 91 | return false; | ||
| 92 | }); | ||
| 93 | $("body").append(popup); | ||
| 94 | }, | ||
| 95 | |||
| 96 | add_item_to_menu : function(node) { | ||
| 97 | $.ajax({ | ||
| 98 | type: "post", | ||
| 99 | url: "/menu_items/create", | ||
| 100 | data: { | ||
| 101 | "menu_item[node_id]" : node.node_id, | ||
| 102 | "menu_item[path]" : "/" + node.unique_name, | ||
| 103 | "menu_item[title]" : node.title | ||
| 104 | }, | ||
| 105 | success : function() { | ||
| 106 | alert("s"); | ||
| 107 | } | ||
| 108 | }); | ||
| 109 | } | ||
| 110 | |||
| 111 | }; \ No newline at end of file | ||
