Skip to content

Commit

Permalink
Adds basic JS to allow the menu structure to be opened and closed.
Browse files Browse the repository at this point in the history
  • Loading branch information
Steve "uru" West committed Sep 11, 2015
1 parent d1bc653 commit aed8e43
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 1 deletion.
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,23 @@ the correct paths then make sure your nested set's tree config has the `title_fi
setting set to the correct column name. While SetUI does not care what this is it is
often best to use a URL friendly property, such as one generated with the slug observer.

# JavaScript

The module also includes some basic javascript to allow a slightly nicer user interaction.
To enable this you will want to symlink the files in `assets` to the appropriate asset
folders. While you can copy the files, doing so means you will manually have to update
the assets when the module is updated.

Once the JS is included in the page it will automatically collapse non-active
branches and allow branches to be opened and closed.

jQuery 1.7 or higher is required.

# Testing

Currently the module is not unit tested due to the complications of testing FuelPHP
v1 modules outside of an application.

# Acknowledgements

Triangle icon by <a href="http://www.flaticon.com/authors/elegant-themes" title="Elegant Themes">Elegant Themes</a> from <a href="http://www.flaticon.com" title="Flaticon">www.flaticon.com</a> is licensed by <a href="http://creativecommons.org/licenses/by/3.0/" title="Creative Commons BY 3.0">CC BY 3.0</a>
Binary file added assets/img/triangle.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 16 additions & 0 deletions assets/js/setui.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
$(document).ready(function(){

// Hide any children as long as the branch is not active
$('.setui-leaf')
.not('.setui-active')
.find('ul')
.hide();

// Make sure the content can be shown and hidden
$('.setui-link').on('click', function(element){
element.preventDefault();
$('#' + $(this).data('parent'))
.find('ul')
.slideToggle(200);
});
});
Binary file added assets/triangle3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions classes/Menu.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ protected function buildBranch(Model_Nestedset $node)
'name' => $node->{$nameProperty},
'branches' => $branchView,
'active' => $active,
'node' => $node,
]
);
}
Expand Down
15 changes: 14 additions & 1 deletion views/setui/leaf.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,17 @@
<li class="<?php echo ($active) ? 'active' : ''; ?>">
<li class="setui-leaf <?php echo ($active) ? 'setui-active setui-open' : ''; ?>"
id="setui_<?php echo $node->tree_id.'_'.$node->id; ?>"
>

<a href="<?php echo $url; ?>"><?php echo $name; ?></a>

<?php if (!empty($branches))
{
echo Asset::img('triangle.png', [
'class' => 'setui-link',
'data-parent' => 'setui_' . $node->tree_id . '_' . $node->id
]);
}
?>

<?php echo $branches; ?>
</li>

0 comments on commit aed8e43

Please sign in to comment.