Thursday, April 5, 2012

Sharepoint Quick Launch expand/collapse by JQuery


Follow the below mentioned steps to make the Quick Launch expand/collapse:

1. Edit the Sharepoint site Master page ( Right click on Master page --> Send To --> Download a copy)

 2. Copy the below mentioned script code to the master page under the <body> tag:

 <script type="text/javascript" src="http://www.google.com/jsapi"></script>  
 <script type="text/javascript">  
  // Load jQuery  
  google.load("jquery", "1.2.6");  
 </script>  
 <script type="text/javascript">  
 $(function(){  
 //initialize menus  
   var menuRows = $("[id$='QuickLaunchMenu'] > tbody > tr");  
   var menuHd = menuRows.filter("[id!='']:has(+tr[id=''])");  
   //set img path for when submenu is hidden  
   var closedImg = "/_layouts/images/plus.gif";  
   //set img path for when submenu is visible  
   var openedImg = "/_layouts/images/minus.gif";  
   var cssInit = {  
     "background-image": "url('"+closedImg+"')",  
     "background-repeat": "no-repeat",  
     "background-position": "100% 50%"  
   }  
   var cssClosed = {"background-image": "url('"+closedImg+"')"}  
   var cssOpen = {"background-image": "url('"+openedImg+"')"}  
   //hide submenus  
   menuRows.filter("[id='']").hide();  
   //apply initial inline style to menu headers  
   menuHd.find("td:last").css(cssInit);  
   menuHd.click(function () {   
     var styleElm = $(this).find("td:last")  
     var nextTR = $(this).next("tr[id='']");  
     if (nextTR.is(':visible')) {  
       nextTR.hide();  
       styleElm.css(cssClosed);  
     } else {  
       nextTR.show();  
       styleElm.css(cssOpen);  
     }  
   });  
 });  
 </script>  

3. Upload the master page, checkin and approve it.
4. Now the quick launch on the Sharepoint site will be collapsed.

Feel free to let me know if you face any issue. 

Wednesday, April 4, 2012

Edit Sharepoint Breadcrumb by JQuery/Javascript



Folks,

You can follow the below mention steps to edit the Sharepoint Breadcrumb.
  • Create a new master page ("defaultNew.master").
  • Insert the jquery code: 
  • <script type="text/javascript" src="https://www.google.com/jsapi"></script>
    <script type="text/javascript">
      // Load jQuery
      google.load("jquery", "1.2.6");
    </script>
    <script type="text/javascript">
    $(document).ready(function(){ 
                    $('a[class="ms-sitemapdirectional"]').each(function(i)
                                    {
              $(this).attr('href', $(this).attr('href').replace('Wiki%20Pages/Forms/AllPages.aspx', 'Wiki%20Pages/Home.aspx'));
                                          $(this).attr('href', $(this).attr('href').replace('/Forms/AllPages.aspx', ''));
                                    });
    });
    </script>
  • Upload the "defaultNew.master" to the masterpage gallery of root site.
  • Set the "defaultNew.master"  as the System Master Page of site.
Note: I am replacing the URL in the breadcrumb list, you can modify in other ways as well.


Feel free to let me know if you face any issue.

Sharepoint Utility - Get all admin users on Sharepoint Site