diff --git a/app/assets/javascripts/folder.coffee b/app/assets/javascripts/folder.coffee index 24f83d1..23f56c3 100644 --- a/app/assets/javascripts/folder.coffee +++ b/app/assets/javascripts/folder.coffee @@ -1,3 +1,11 @@ # Place all the behaviors and hooks related to the matching controller here. # All this logic will automatically be available in application.js. # You can use CoffeeScript in this file: http://coffeescript.org/ + +$ -> + $('.tree_menu').delegate ".toggleable_folder", "click", -> + target = $(this) + if target.hasClass('glyphicon-plus') + target.removeClass('glyphicon-plus').addClass('glyphicon-minus') + else if target.hasClass('glyphicon-minus') + target.addClass('glyphicon-plus').removeClass('glyphicon-minus') \ No newline at end of file diff --git a/app/assets/stylesheets/application.css.scss b/app/assets/stylesheets/application.css.scss index 639fc45..fb2523b 100644 --- a/app/assets/stylesheets/application.css.scss +++ b/app/assets/stylesheets/application.css.scss @@ -23,4 +23,29 @@ body{ .nested_folders { margin-left: 30px; -} \ No newline at end of file +} + +.list-group { + ul { + list-style-type: none; + .glyphicon { + cursor: pointer; + } + a { + color: black; + text-decoration: none; + span:hover { + text-decoration: underline; + } + }; + }; + li > ul { + list-style-type: none; + }; + .glyphicon-minus ~ ul { + display: block; + } + .glyphicon-plus ~ ul { + display: none; + }; +}; \ No newline at end of file diff --git a/app/assets/stylesheets/folders.css.scss b/app/assets/stylesheets/folders.css.scss index bd31bb2..798676a 100644 --- a/app/assets/stylesheets/folders.css.scss +++ b/app/assets/stylesheets/folders.css.scss @@ -1,4 +1,3 @@ // Place all the styles related to the folder controller here. // They will automatically be included in application.css. -// You can use Sass (SCSS) here: http://sass-lang.com/ - +// You can use Sass (SCSS) here: http://sass-lang.com/ \ No newline at end of file diff --git a/app/views/shared/_menu.html.slim b/app/views/shared/_menu.html.slim new file mode 100644 index 0000000..b468fcd --- /dev/null +++ b/app/views/shared/_menu.html.slim @@ -0,0 +1,6 @@ +.tree_menu + .panel + .panel-heading + h4 Folders + .list-group + = render 'shared/tree', :folders => Folder.roots.order("created_at asc") \ No newline at end of file diff --git a/app/views/shared/_tree.html.slim b/app/views/shared/_tree.html.slim new file mode 100644 index 0000000..05150d8 --- /dev/null +++ b/app/views/shared/_tree.html.slim @@ -0,0 +1,11 @@ +ul + - folders.each do |folder| + li + - if folder.has_children? + span.glyphicon.toggleable_folder class=(@folder && @folder.ancestor_ids.include?(folder.id) ? 'glyphicon-minus' : "glyphicon-plus" ) + - else + span.glyphicon + '  + = link_to "#{content_tag(:span, "", :class => 'glyphicon glyphicon-folder-close')} #{content_tag(:span, folder.name)}".html_safe, folder_path(folder) + - if folder.has_children? + = render 'shared/tree', :folders => folder.children.order("created_at asc") \ No newline at end of file diff --git a/app/views/static_pages/landing.html.slim b/app/views/static_pages/landing.html.slim index 5054d0c..af0dda0 100644 --- a/app/views/static_pages/landing.html.slim +++ b/app/views/static_pages/landing.html.slim @@ -1 +1,7 @@ -h1= @greeting \ No newline at end of file +h1= @greeting + += render "shared/menu" + +/folder +/= nested_folders Folder.all.arrange(:order => :created_at) +