Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Categories navigation changed to collapsible tree menu
- Loading branch information
Showing
11 changed files
with
92 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// Show all descendant categories of the clicked parent category | ||
function toggleDescendants(parent_id) { | ||
// Target class for the subcategories and their states (hidden or shown) | ||
target_class = '.parent-id-' + parent_id.toString(); | ||
target_class_state = $(target_class).attr("value"); | ||
// Class for the tree menu's collapse/show subcategories button | ||
button_class = "button-id-" + parent_id.toString(); | ||
|
||
if (target_class_state == "hidden") { | ||
// Show the hidden subcategories | ||
$(target_class).css("display", "block"); | ||
$(target_class).attr("value", "shown"); | ||
// Change the orientation of the collapsible menu button | ||
$("." + button_class).attr("class", "fa fa-minus-square-o " + button_class); | ||
} | ||
else if (target_class_state == "shown") { | ||
// Hide the subcategories | ||
$(target_class).css("display", "none"); | ||
$(target_class).attr("value", "hidden"); | ||
// Change the orientation of the collapsible menu button | ||
$("." + button_class).attr("class", "fa fa-plus-square-o " + button_class); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,23 @@ | ||
<div class="categories_nav"> | ||
<!-- Document upload button & modal --> | ||
<%= render partial: "documents/upload" %> | ||
|
||
<!-- Document upload button & modal --> | ||
<%= render partial: "documents/upload" %> | ||
|
||
<!-- Previous category navigation --> | ||
<%= render partial: "categories/previous_navigation" %> | ||
|
||
<div class="categories_list"> | ||
<!-- Title --> | ||
<% if @category %> | ||
<h4> <%= "#{@category.name}" %> </h4> | ||
<% else %> | ||
<h4> Browse categories </h4> | ||
<% end %> | ||
|
||
<!-- Category list --> | ||
<ul class="nav nav-stacked"> | ||
<% categories.each do |cat| %> | ||
<li> | ||
<%= link_to cat.name, category_path(cat, view_style: "grid") %> | ||
</li> | ||
<% end %> | ||
</ul> | ||
|
||
<!-- New category button and Edit categories button --> | ||
<% if !current_user.nil? and current_user.is_admin? %> | ||
<hr /> | ||
<div class="category_btn"> | ||
<%= link_to "New Category", new_category_path, :class => "category_text" %> | ||
<%= link_to "Edit Categories", manage_categories_path, :class => "category_text" %> | ||
</div> | ||
<!-- Category list --> | ||
<ul style="list-style-type: none; padding-left: 15px;" > | ||
<% categories.each do |root| %> | ||
<!-- Show root categories --> | ||
<li style="display:block-inline" value="root"> | ||
<i class="fa fa-plus-square-o button-id-<%=root.id%>" onclick="toggleDescendants(<%= root.id %>)"></i> | ||
<%= link_to root.name, category_path(root, view_style: "grid") %> | ||
</li> | ||
<!-- Subcategories are intially hidden in a tree menu --> | ||
<% root.descendants.each do |cat| %> | ||
<li class="parent-id-<%=cat.parent_id%>" style="padding-left:<%= 20 * cat.node_depth %>px; display: none" value="hidden"> | ||
<!-- only show the subcategories toggle button if this subcategory has descendants --> | ||
<% if cat.descendants.length > 0 %> | ||
<i class="fa fa-plus-square-o button-id-<%=cat.id%>" onclick="toggleDescendants(<%= cat.id %>)"></i> | ||
<% end %> | ||
<%= link_to cat.name, category_path(cat, view_style: "grid") %> | ||
</li> | ||
<% end %> | ||
</div> | ||
</div> | ||
<% end %> | ||
</ul> |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,9 @@ | ||
<%= render partial: "categories_nav", locals: {categories: @categories} %> | ||
<h3> Featured Categories </h3> | ||
<%= render partial: "featured_categories", locals: {featured: @featured} %> | ||
<hr /> | ||
<h3> Recent Documents </h3> | ||
<%= render partial: "latest_documents", locals: {latest_docs: @latest_docs} %> | ||
<% if !@featured.nil? and @featured.length > 0 %> | ||
<h3> Featured Categories </h3> | ||
<%= render partial: "featured_categories", locals: {featured: @featured} %> | ||
<% end %> | ||
<% if !@latest_docs.nil? and @latest_docs.length > 0 %> | ||
<hr /> | ||
<h3> Recent Documents </h3> | ||
<%= render partial: "latest_documents", locals: {latest_docs: @latest_docs} %> | ||
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters