From 92fdef2b1ba1b77171572f0891e7d38c4cb0ab59 Mon Sep 17 00:00:00 2001 From: Reinier Balt Date: Fri, 20 Aug 2010 13:54:29 +0200 Subject: [PATCH] implement js to add and remove precedessors (dependencies) --- app/views/todos/_new_todo_form.rhtml | 10 ++++++++++ public/javascripts/application.js | 15 +++++++++++++++ public/stylesheets/standard.css | 20 +++++++++++++++++++- 3 files changed, 44 insertions(+), 1 deletion(-) diff --git a/app/views/todos/_new_todo_form.rhtml b/app/views/todos/_new_todo_form.rhtml index 1c1af12d..a870a39a 100644 --- a/app/views/todos/_new_todo_form.rhtml +++ b/app/views/todos/_new_todo_form.rhtml @@ -36,6 +36,16 @@ <%= text_field_tag "predecessor_list", nil, :size => 30, :tabindex => 8 %> + +
+ +
+ +
+ +
+ <%= source_view_tag( @source_view ) %> <%= hidden_field_tag :_tag_name, @tag_name.underscore.gsub(/\s+/,'_') if source_view_is :tag %> diff --git a/public/javascripts/application.js b/public/javascripts/application.js index 0b32a7e6..6daaffb0 100644 --- a/public/javascripts/application.js +++ b/public/javascripts/application.js @@ -87,6 +87,21 @@ var TracksForm = { submit_with_ajax_and_block_element('form#todo-form-multi-new-action', $(this)); return false; }); + + $('input[class=predecessor_add_button]').live('click', function(){ + var text = $('input[name=predecessor]').val(); + if (text.length > 0) { + $('ul#predecessor_ul').show(); + if (text.length > 35) { + text = text.substring(0,35)+"..."; + } + var html = $('ul#predecessor_ul').html(); + var new_li = "
  • "+ text + "
  • "; + $('ul#predecessor_ul').html(html + new_li); + $('input[name=predecessor]').val(''); + $('input[name=predecessor]').focus(); + } + }); } } diff --git a/public/stylesheets/standard.css b/public/stylesheets/standard.css index 55c03716..6508504f 100644 --- a/public/stylesheets/standard.css +++ b/public/stylesheets/standard.css @@ -342,10 +342,28 @@ div#input_box { #input_box ul {list-style-type: circle; font-size: 0.9em;} -.show_from_input, .due_input, .project_input, .context_input { +#input_box ul#predecessor_ul { + list-style-type: none; + color: 0; +} + +.show_from_input, .due_input, .project_input, .context_input, +.predecessor_input { float:left; } +.predecessor_add_button_box { + float:right; +} + +#input_box input.pred_remove_button { + width:1.3em; +} + +.selected_predecessors { + clear:right; +} + .box { float: left; width: 20px;