You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

53 lines
2.2 KiB

  1. jQuery.fn.initMenu = function () {
  2. return this.each(function () {
  3. var theMenu = $(this).get(0);
  4. $('.acitem', this).hide();
  5. $('li.expand > .acitem', this).show();
  6. $('li.expand > .acitem', this).prev().addClass('active');
  7. $('li a', this).click(
  8. function (e) {
  9. e.stopImmediatePropagation();
  10. var theElement = $(this).next();
  11. var parent = this.parentNode.parentNode;
  12. if ($(parent).hasClass('noaccordion')) {
  13. if (theElement[0] === undefined) {
  14. window.location.href = this.href;
  15. }
  16. $(theElement).slideToggle('normal', function () {
  17. if ($(this).is(':visible')) {
  18. $(this).prev().addClass('active');
  19. }
  20. else {
  21. $(this).prev().removeClass('active');
  22. }
  23. });
  24. return false;
  25. }
  26. else {
  27. if (theElement.hasClass('acitem') && theElement.is(':visible')) {
  28. if ($(parent).hasClass('collapsible')) {
  29. $('.acitem:visible', parent).first().slideUp('normal',
  30. function () {
  31. $(this).prev().removeClass('active');
  32. }
  33. );
  34. return false;
  35. }
  36. return false;
  37. }
  38. if (theElement.hasClass('acitem') && !theElement.is(':visible')) {
  39. $('.acitem:visible', parent).first().slideUp('normal', function () {
  40. $(this).prev().removeClass('active');
  41. });
  42. theElement.slideDown('normal', function () {
  43. $(this).prev().addClass('active');
  44. });
  45. return false;
  46. }
  47. }
  48. }
  49. );
  50. });
  51. };
  52. $(document).ready(function () { $('.menu').initMenu(); });