Modifying the master page
- On the head tag of master page html add below lines
<!--SPM:<SharePoint:ScriptLink Name="~sitecollection/Style Library/jquery.js" runat="server"/>-->
<!--SPM:<SharePoint:ScriptLink Name="~sitecollection/Style Library/master.js" runat="server"/>-->
Modify the javascript file
- On the master.js file add the below code.
jQuery(function($) {
var jChildrens = jQuery('.ms-core-listMenu-verticalBox ul.root ul');
//Expand Active Parent node
var selectedIndex = -1;
for(var i=0; i < jChildrens.length; i++) {
jChidlren = jQuery(jChildrens[i]);
if(jChidlren.find('li.selected').length > 0) {
selectedIndex = i;
break;
}
}
jChildrens.hide();
if(selectedIndex!=-1)
{
jChildrens.eq(selectedIndex).slideDown();
}
//Parents
jQuery('.ms-core-listMenu-verticalBox ul.root > li > a').click(function (e) {
jChildren = jQuery(this).next('ul');
if(jChildren.length!=0)
{
e.preventDefault();
jChildrens.slideUp();
if (jChildren.is(':visible') == false)
{
jChildren.slideDown();
}
}
});
//Parent Click
jQuery('.ms-core-listMenu-verticalBox ul.root > li > a > span').click(function (e) {
var url = jQuery(this).parent('a').attr("href");
window.location=url;
});
});
Collapsed:
Expand: