/*! Originally based on the tinynav.js library found at http://tinynav.viljamis.com by @viljamis */
(function ($, window, i) {
$.fn.tinyNav = function (options) {
// Default settings
var settings = $.extend({
'active' : 'selected', // String: Set the "active" class
'header' : false, // Boolean: Show header instead of the active item
'indent' : '--', // String: Set this to empty to disable identing
'depth_count' : 3 // Integer: depth to stop counting
}, options);
return this.each(function () {
// Used for namespacing
i++;
var $nav = $(this),
// Namespacing
namespace = 'tinynav',
namespace_i = namespace + i,
l_namespace_i = '.l_' + namespace_i,
$select = $('').addClass(namespace + ' ' + namespace_i);
if ($nav.is('ul,ol')) {
if (settings.header) {
$select.append(
$('').text(Drupal.t('Navigation'))
);
}
// Build options
var options = '';
$nav
.addClass('l_' + namespace_i)
.find('a')
.each(function () {
var indent = '';
// indent once for each parent this has
var parent_count = $(this).parents("ul,ol").length;
// apply indenting if found
for (var i=1; i' +
indent + $(this).text() +
'';
}
});
// Append options into a select
$select.append(options);
// Select the active item
$select
.find(':eq(' + (settings.header + $(l_namespace_i + ' li')
.index($(l_namespace_i + ' .' + settings.active)) + ')'))
.attr('selected', true);
// Change window location
$select.change(function () {
if ($(this).val() != '-null-') {
window.location.href = $(this).val();
}
});
// Inject select
$(l_namespace_i).after($select);
}
});
};
})(jQuery, this, 0);;
(function ($) {
Drupal.behaviors.tinynav = {
attach: function (context, settings) {
// make sure we don't try to access an undefined array
settings.tinynav = settings.tinynav || {
selector: '#zone-menu .region-menu ul.menu',
media_query: 'all and (max-width:780px)',
header: false,
active: 'active-trail'
}
// Add the class to the selectors so we can access it later
$(settings.tinynav.selector).addClass('tinyjs');
// Build the Settings array
var tinyNavSettings = {
header: settings.tinynav.header
};
if (settings.tinynav.active) {
tinyNavSettings.active = settings.tinynav.active;
}
// Tinynav (<-- new verb) them all
$('.tinyjs').tinyNav(tinyNavSettings);
// Add a wrapper to the select element
$('select.tinynav').wrap('');
},
weight: 99
};
})(jQuery);
;