diff options
| -rw-r--r-- | app/views/events/new.html.erb | 89 | ||||
| -rw-r--r-- | public/javascripts/admin_interface.js | 4 | ||||
| -rw-r--r-- | public/javascripts/admin_search.js | 59 |
3 files changed, 112 insertions, 40 deletions
diff --git a/app/views/events/new.html.erb b/app/views/events/new.html.erb index 4e1ef53..b20fe48 100644 --- a/app/views/events/new.html.erb +++ b/app/views/events/new.html.erb | |||
| @@ -1,47 +1,56 @@ | |||
| 1 | <h1>New event</h1> | 1 | <h1>New event</h1> |
| 2 | 2 | ||
| 3 | <%= link_to 'Back', safe_return_to(params[:return_to] || events_path) %> | ||
| 4 | |||
| 3 | <%= form_for(@event) do |f| %> | 5 | <%= form_for(@event) do |f| %> |
| 4 | <%= form_error_messages(f) %> | 6 | <%= form_error_messages(f) %> |
| 5 | 7 | ||
| 6 | <p> | 8 | <div id="page_editor"> |
| 7 | <%= f.label :start_time %><br /> | 9 | <div id="content"> |
| 8 | <%= f.datetime_select :start_time %> | 10 | <div class="node_description">Node</div> |
| 9 | </p> | 11 | <div class="node_content"> |
| 10 | <p> | 12 | <%= text_field_tag :event_node_search_term %> |
| 11 | <%= f.label :end_time %><br /> | 13 | <div id="search_results"></div> |
| 12 | <%= f.datetime_select :end_time %> | 14 | <%= f.hidden_field :node_id %> |
| 13 | </p> | 15 | <span class="field_hint">Optional — search and pick a node to associate this event with a page.</span> |
| 14 | <p> | 16 | </div> |
| 15 | <%= f.label :rrule %><br /> | 17 | |
| 16 | <%= f.text_field :rrule %> | 18 | <div class="node_description">Start time</div> |
| 17 | </p> | 19 | <div class="node_content"><%= f.datetime_select :start_time %></div> |
| 18 | <p> | 20 | |
| 19 | <%= f.label :tag_list, "Tags" %><br /> | 21 | <div class="node_description">End time</div> |
| 20 | <%= f.text_field :tag_list %> | 22 | <div class="node_content"><%= f.datetime_select :end_time %></div> |
| 21 | </p> | 23 | |
| 22 | <p> | 24 | <div class="node_description">Rrule</div> |
| 23 | <%= f.label :allday %><br /> | 25 | <div class="node_content"><%= f.text_field :rrule %></div> |
| 24 | <%= f.check_box :allday %> | 26 | |
| 25 | </p> | 27 | <div class="node_description">Title</div> |
| 26 | <p> | 28 | <div class="node_content"> |
| 27 | <%= f.label :url %><br /> | 29 | <%= f.text_field :title %> |
| 28 | <%= f.text_field :url %> | 30 | <span id="event_title_hint" class="field_hint">Optional — if left blank, the associated node's title is used.</span> |
| 29 | </p> | 31 | </div> |
| 30 | <p> | 32 | |
| 31 | <%= f.label :latitude %><br /> | 33 | <div class="node_description">Tags</div> |
| 32 | <%= f.text_field :latitude %> | 34 | <div class="node_content"><%= f.text_field :tag_list %></div> |
| 33 | </p> | 35 | |
| 34 | <p> | 36 | <div class="node_description">Allday</div> |
| 35 | <%= f.label :longitude %><br /> | 37 | <div class="node_content"><%= f.check_box :allday %></div> |
| 36 | <%= f.text_field :longitude %> | 38 | |
| 37 | </p> | 39 | <div class="node_description">Url</div> |
| 38 | <p> | 40 | <div class="node_content"><%= f.text_field :url %></div> |
| 39 | <%= f.hidden_field :node_id %> | 41 | |
| 40 | <%= hidden_field_tag :return_to, params[:return_to] %> | 42 | <div class="node_description">Latitude</div> |
| 41 | </p> | 43 | <div class="node_content"><%= f.text_field :latitude %></div> |
| 42 | <p> | 44 | |
| 43 | <%= f.submit 'Create' %> | 45 | <div class="node_description">Longitude</div> |
| 44 | </p> | 46 | <div class="node_content"><%= f.text_field :longitude %></div> |
| 47 | |||
| 48 | <div class="node_description"></div> | ||
| 49 | <div class="node_content"><%= hidden_field_tag :return_to, params[:return_to] %></div> | ||
| 50 | |||
| 51 | <div class="node_description"></div> | ||
| 52 | <div class="node_content"><%= f.submit 'Create' %></div> | ||
| 53 | </div> | ||
| 54 | </div> | ||
| 45 | <% end %> | 55 | <% end %> |
| 46 | 56 | ||
| 47 | <%= link_to 'Back', safe_return_to(params[:return_to] || events_path) %> | ||
diff --git a/public/javascripts/admin_interface.js b/public/javascripts/admin_interface.js index 4107ce8..8ca5b5e 100644 --- a/public/javascripts/admin_interface.js +++ b/public/javascripts/admin_interface.js | |||
| @@ -51,6 +51,10 @@ $(document).ready(function () { | |||
| 51 | move_to_search.initialize_search(); | 51 | move_to_search.initialize_search(); |
| 52 | } | 52 | } |
| 53 | 53 | ||
| 54 | if ($("#event_node_search_term").length != 0) { | ||
| 55 | event_search.initialize_search(); | ||
| 56 | } | ||
| 57 | |||
| 54 | if ($("#rrule_builder").length != 0) { | 58 | if ($("#rrule_builder").length != 0) { |
| 55 | rrule_builder.initialize(); | 59 | rrule_builder.initialize(); |
| 56 | } | 60 | } |
diff --git a/public/javascripts/admin_search.js b/public/javascripts/admin_search.js index 6ef9087..5be5d57 100644 --- a/public/javascripts/admin_search.js +++ b/public/javascripts/admin_search.js | |||
| @@ -283,3 +283,62 @@ move_to_search = { | |||
| 283 | return barf; | 283 | return barf; |
| 284 | } | 284 | } |
| 285 | } | 285 | } |
| 286 | |||
| 287 | event_search = { | ||
| 288 | initialize_search : function() { | ||
| 289 | $("#event_node_search_term").bind("input", function() { | ||
| 290 | if ($(this).val()) { | ||
| 291 | $.ajax({ | ||
| 292 | type: "GET", | ||
| 293 | url: ADMIN_MENU_SEARCH_URL, | ||
| 294 | data: "search_term=" + $(this).val(), | ||
| 295 | dataType: "json", | ||
| 296 | success : function(results) { | ||
| 297 | event_search.show_results(results); | ||
| 298 | } | ||
| 299 | }); | ||
| 300 | } | ||
| 301 | else { | ||
| 302 | $('#search_results').slideUp(); | ||
| 303 | $('#search_results').empty(); | ||
| 304 | } | ||
| 305 | }); | ||
| 306 | }, | ||
| 307 | |||
| 308 | show_results : function(results) { | ||
| 309 | $("#search_results").empty(); | ||
| 310 | var found = false; | ||
| 311 | for (result in results) { | ||
| 312 | var link = $(( | ||
| 313 | "<p><a href='#'>" + results[result].title + | ||
| 314 | "<span class='result_path'>" + results[result].unique_name + "</span>" + | ||
| 315 | "</a></p>")); | ||
| 316 | |||
| 317 | $(link).bind("click", event_search.link_closure(results[result])); | ||
| 318 | |||
| 319 | $("#search_results").append(link); | ||
| 320 | found = true; | ||
| 321 | } | ||
| 322 | if (found) | ||
| 323 | $('#search_results').slideDown(); | ||
| 324 | else | ||
| 325 | $('#search_results').slideUp(); | ||
| 326 | }, | ||
| 327 | |||
| 328 | link_closure : function(node) { | ||
| 329 | var barf = function(){ | ||
| 330 | $("#event_node_search_term").val(node.title); | ||
| 331 | $("#event_node_id").val(node.node_id); | ||
| 332 | $('#search_results').slideUp(); | ||
| 333 | $('#search_results').empty(); | ||
| 334 | |||
| 335 | var title_field = $("#event_title"); | ||
| 336 | if (title_field.val() === "") { | ||
| 337 | $("#event_title_hint").text("Using \"" + node.title + "\" from the associated node."); | ||
| 338 | } | ||
| 339 | |||
| 340 | return false; | ||
| 341 | } | ||
| 342 | return barf; | ||
| 343 | } | ||
| 344 | }; | ||
