Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Added the ability to define maximum display depth #73

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions tinynav.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
'active' : 'selected', // String: Set the "active" class
'header' : '', // String: Specify text for "header" and show header instead of the active item
'indent' : '- ', // String: Specify text for indenting sub-items
'label' : '' // String: sets the <label> text for the <select> (if not set, no label will be added)
'label' : '', // String: sets the <label> text for the <select> (if not set, no label will be added)
'depth' : 6 // Int: Define a maximum display depth
}, options);

return this.each(function () {
Expand Down Expand Up @@ -37,12 +38,15 @@
.addClass('l_' + namespace_i)
.find('a')
.each(function () {
options += '<option value="' + $(this).attr('href') + '">';
var j;
for (j = 0; j < $(this).parents('ul, ol').length - 1; j++) {
options += settings.indent;
var depth = $(this).parents('ul, ol').length;
if (depth - 1 < settings.depth) {
options += '<option value="' + $(this).attr('href') + '">';
var j;
for (j = 0; j < depth - 1; j++) {
options += settings.indent;
}
options += $(this).text() + '</option>';
}
options += $(this).text() + '</option>';
});

// Append options into a select
Expand Down
3 changes: 1 addition & 2 deletions tinynav.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.