правим файл
vim app/views/projects/index.html.erb
вставляем туда следующий javascript
vim app/views/projects/index.html.erb
вставляем туда следующий javascript
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | < script type = "text/javascript" > $(function(){ $("#projects-index ul li .projects").hide();//скрываем подпроекты $("#projects-index ul").find("li.root").each(function(){ if($(this).find(".projects").size() > 0){ $(this).find("div.root").append('< a class = "show_hide" href = "#" > открыть/закрыть </ a >') } }); $(".show_hide").live("click", function(){ $(this).parent().parent().find(".projects").toggle(); return false; }); }); </ script > |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 | <% content_for :header_tags do %> <%= auto_discovery_link_tag( :atom , { :action => 'index' , :format => 'atom' , :key => User.current.rss_key}) %> <% end %> <div class = "contextual" > <%= link_to(l( :label_project_new ), { :controller => 'projects' , :action => 'new' }, :class => 'icon icon-add' ) + ' |' if User.current.allowed_to?( :add_project , nil , :global => true ) %> <%= link_to(l( :label_issue_view_all ), issues_path) + ' |' if User.current.allowed_to?( :view_issues , nil , :global => true ) %> <%= link_to(l( :label_overall_spent_time ), time_entries_path) + ' |' if User.current.allowed_to?( :view_time_entries , nil , :global => true ) %> <%= link_to l( :label_overall_activity ), { :controller => 'activities' , :action => 'index' , :id => nil } %> </div> <h2><%= l( :label_project_plural ) %></h2> <script type= "text/javascript" > $(function(){ $( "#projects-index ul li .projects" ).hide();//скрываем подпроекты $( "#projects-index ul" ).find( "li.root" ). each (function(){ if ($(this).find( ".projects" ).size() > 0 ){ $(this).find( "div.root" ).append( '<a class="show_hide" href="#"> открыть/закрыть </a>' ) } }); $( ".show_hide" ).live( "click" , function(){ $(this).parent().parent().find( ".projects" ).toggle(); return false ; }); }); </script> <div id= "projects-index" > <%= render_project_hierarchy( @projects ) %> </div> <% if User.current.logged? %> <p style= "text-align:right;" > <span class = "my-project" ><%= l( :label_my_projects ) %></span> </p> <% end %> <% other_formats_links do |f| %> <%= f.link_to 'Atom' , :url => { :key => User.current.rss_key} %> <% end %> <% content_for :sidebar do %> <%= form_tag({}, :method => :get ) do %> <h3><%= l( :label_project_plural ) %></h3> <label for = "closed" ><%= check_box_tag 'closed' , 1 , params[ :closed ] %> <%= l( :label_show_closed_projects ) %></label> <p><%= submit_tag l( :button_apply ), :class => 'button-small' , :name => nil %></p> <% end %> <% end %> <% html_title(l( :label_project_plural )) -%> |