sidebar.js 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. jQuery.expr[':'].Contains = function(a, i, m) {
  2. return jQuery(a).text().toUpperCase().indexOf(m[3].toUpperCase()) >= 0;
  3. };
  4. $(function() {
  5. $("#sidebar-nav").accordion({
  6. autoHeight: false,
  7. navigation: true,
  8. collapsible: true
  9. }).accordion("activate", false)
  10. .find('a.link').unbind('click').click(
  11. function(ev) {
  12. ev.cancelBubble = true; // IE
  13. if (ev.stopPropagation) {
  14. ev.stopPropagation(); // the rest
  15. }
  16. return true;
  17. }).prev().prev().remove();
  18. $("#sidebar-nav>h3").click(function() {
  19. if ($(this).attr('initialized') == 'true') return;
  20. $(this).next().find(".sidebar-nav-tree").treeview({
  21. collapsed: true,
  22. persist: "cookie"
  23. });
  24. $(this).attr('initialized', true);
  25. });
  26. });
  27. function tree_search(input) {
  28. treeview = $(input).parent().parent().next();
  29. // Expand all items
  30. treeview.find('.expandable-hitarea').click();
  31. // make all items visible again
  32. treeview.find('li:hidden').show();
  33. // hide all items that do not match the given search criteria
  34. if ($(input).val()) {
  35. treeview.find('li').not(':has(a:Contains(' + $(input).val() + '))').hide();
  36. }
  37. }