1. Click on the Edit page Under "Site Actions".
2.Add Content Editor Web part any Zone.
3.Click on the Web part. "Click here to add content"
4.Click On "Edit Html Source" on the Ribbon.
5.Add following code.
<script type="text/javascript">
// Add the Web Part Titles here to have them opened by default
var wpsToSkip = ['Tasks','sandbox'];
function wpExpander() {
var theTDs = document.getElementsByTagName("TD");
for (var t=0;t<theTDs.length;t++) {
var id = theTDs[t].id;
if (id.match("WebPartTitleWPQ")) {
id = id.substr(id.indexOf("WPQ"));
var title = (theTDs[t].innerText || theTDs[t].textContent).replace(/[\n\r]/,'');
var strImg = "<img style='margin:6px 5px 0px 2px;cursor:hand;float:left;' ";
if (wpsToSkip.join().match(title)) {
strImg += "onClick='showHide(\""+id+"\",this)' src='/_layouts/images/minus.gif'>";
} else {
strImg += "onClick='showHide(\""+id+"\",this)' src='/_layouts/images/plus.gif'>";
document.getElementById("WebPart"+id).style.display = "none";
}
theTDs[t].innerHTML = strImg + theTDs[t].innerHTML;
}
}
}
function showHide(i,o) {
var wp = document.getElementById("WebPart"+i);
wp.style.display = (wp.style.display=="") ? "none" : "";
o.src = (o.src.match(/plus.gif/)) ? "/_layouts/images/minus.gif" : "/_layouts/images/plus.gif";
}
_spBodyOnLoadFunctionNames.push("wpExpander()");
</script>
6.Make this Web part as Hidden.
7.Save and Close the web part.
or
As usual, put this code into a Content Editor Web Part at the bottom of the page.
No comments:
Post a Comment