Posted By

fauverism on 01/11/11


Tagged


Versions (?)

Sharepoint Left Nav Accordion sub


 / Published in: JavaScript
 

  1. // JavaScript Document
  2.  
  3. $(function(){
  4. //initialize menus
  5. var menuRows = $("[id$='QuickLaunchMenu'] > tbody > tr");
  6. var menuHd = menuRows.filter("[id]:has(+tr:not([id]))");
  7.  
  8. //set img path for when submenu is hidden
  9. var closedImg = "/_layouts/images/Menu1.gif";
  10.  
  11. //set img path for when submenu is visible
  12. var openedImg = "/_layouts/images/ptclose.gif";
  13.  
  14. var cssInit = {
  15. "background-image": "url('"+closedImg+"')",
  16. "background-repeat": "no-repeat",
  17. "background-position": "100% 50%"
  18. }
  19. var cssClosed = {"background-image": "url('"+closedImg+"')"}
  20. var cssOpen = {"background-image": "url('"+openedImg+"')"}
  21.  
  22. //hide submenus
  23. menuRows.filter(":not([id])").hide();
  24.  
  25. //apply initial inline style to menu headers
  26. menuHd.find("td:last").css(cssInit);
  27.  
  28. menuHd.click(function () {
  29. var styleElm = $(this).find("td:last")
  30. var nextTR = $(this).next("tr[id='']");
  31. if (nextTR.is(":not(':hidden')")) {
  32. nextTR.hide();
  33. styleElm.css(cssClosed);
  34. } else {
  35. nextTR.show();
  36. styleElm.css(cssOpen);
  37. }
  38. });
  39. $('a.ms-selectednav').parents('tr').eq(2).show();
  40. });

Report this snippet  

You need to login to post a comment.