Draft text index tree navigator
This commit is contained in:
@@ -56,6 +56,7 @@
|
|||||||
//= require legislation_allegations
|
//= require legislation_allegations
|
||||||
//= require legislation_annotatable
|
//= require legislation_annotatable
|
||||||
//= require watch_form_changes
|
//= require watch_form_changes
|
||||||
|
//= require tree_navigator
|
||||||
//= require custom
|
//= require custom
|
||||||
|
|
||||||
var initialize_modules = function() {
|
var initialize_modules = function() {
|
||||||
@@ -87,6 +88,7 @@ var initialize_modules = function() {
|
|||||||
if ( $(".legislation-annotatable").length )
|
if ( $(".legislation-annotatable").length )
|
||||||
App.LegislationAnnotatable.initialize();
|
App.LegislationAnnotatable.initialize();
|
||||||
App.WatchFormChanges.initialize();
|
App.WatchFormChanges.initialize();
|
||||||
|
App.TreeNavigator.initialize();
|
||||||
};
|
};
|
||||||
|
|
||||||
$(function(){
|
$(function(){
|
||||||
|
|||||||
32
app/assets/javascripts/tree_navigator.js.coffee
Normal file
32
app/assets/javascripts/tree_navigator.js.coffee
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
App.TreeNavigator =
|
||||||
|
closeNodes: (nodes) ->
|
||||||
|
children = nodes.children('ul')
|
||||||
|
|
||||||
|
if(children.length == 0)
|
||||||
|
return
|
||||||
|
|
||||||
|
children.each ->
|
||||||
|
link = $(this).prev('a')
|
||||||
|
$('<span class="closed"></span>').insertBefore(link)
|
||||||
|
$(this).hide()
|
||||||
|
App.TreeNavigator.closeNodes($(this).children())
|
||||||
|
|
||||||
|
initialize: ->
|
||||||
|
elem = $('[data-tree-navigator]')
|
||||||
|
if(elem.length == 0)
|
||||||
|
return
|
||||||
|
|
||||||
|
ul = elem.find('ul:eq(0)')
|
||||||
|
if(ul.length && ul.children().length)
|
||||||
|
App.TreeNavigator.closeNodes(ul.children())
|
||||||
|
|
||||||
|
$('[data-tree-navigator] span').on
|
||||||
|
click: (e) ->
|
||||||
|
elem = $(this)
|
||||||
|
if(elem.hasClass('open'))
|
||||||
|
elem.removeClass('open').addClass('closed')
|
||||||
|
elem.siblings('ul').hide()
|
||||||
|
else if(elem.hasClass('closed'))
|
||||||
|
elem.removeClass('closed').addClass('open')
|
||||||
|
elem.siblings('ul').show()
|
||||||
|
|
||||||
@@ -40,7 +40,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div data-sticky-container>
|
<div data-sticky-container>
|
||||||
<div data-sticky data-anchor="sticky-panel" class="draft-index sticky">
|
<div data-sticky data-anchor="sticky-panel" class="draft-index sticky" data-tree-navigator>
|
||||||
<%= @draft_version.toc_html.html_safe %>
|
<%= @draft_version.toc_html.html_safe %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user