Wednesday, May 26, 2010
Tuesday, May 4, 2010
HOW TO Display Expand/Collapse icons in a SharePoint List
Insert the following code in a Content Editor Web Part to display +/- icons to expand/collapse Items in a SharePoint List. The icons will appear in the Actions Menu in the List.
function collapseGroups() {
$("img[src='/_layouts/images/minus.gif']:visible").parent().click();
}
function expandGroups() {
$("img[src='/_layouts/images/plus.gif']:visible").parent().click();
}
$(function() {
var expandAll = "<a href='#' onClick="
+'"'+"this.href='javascript:expandGroups()'"
+'"><img title="expand all groups" style="border:none;" alt="expand all" src="/_layouts/images/collapseplus.gif"></a>';
var collapseAll = "<a href='#' onClick="+'"'
+"this.href='javascript:collapseGroups()'"
+'"><img title="collapse all groups" style="border:none;" alt="collapse all" src="/_layouts/images/collapseminus.gif"></a>';
$("td.ms-toolbar[width='99%']").append(expandAll).append(collapseAll);
});
</script>
HOW TO Display a "Printer Friendly" button on SharePoint pages
Insert the following code in a Content Editor Web Part to display a “Printer Friendly” button on SharePoint pages. When you click the button, it opens the SharePoint page in a new window. And the page will not contain the left and top nav bars. You are also presented with the list of printers that you can print to. And you can also do a Print Preview. This way you get to print only the content that you are really interested in, as opposed to the navigation menus, etc.
NOTE: In the code sample below, the jQuery file was stored in a SharePoint Doc Lib. You can also point to the Google site which hosts the jQuery file like this:
Credit:
http://web.iotap.com/Blogs/tabid/277/EntryId/82/Printer-Friendly-Page-Sharepoint-web-part.aspx
<script type="text/javascript" src="jQuery/jquery-1.3.2.min.js"></script>
<div>
<input id="printBtn" type="button" Value="Printer Friendly" alt="Print this page" style="margin-top:10px;margin-left:10px;"/>
</div>
<script>
$(document).ready(function()
{
var strlink="";
$("link[rel='stylesheet']").each(function()
{
strlink+="<link rel = 'stylesheet' href='"+$(this).attr('href')+"' type='text/css'/>";
});
$("#printBtn").click(function()
{
var htmlStr ="<html><head>"+strlink+"</head><body>"+$("#MSO_ContentTable").parent().html()+"</body></html>";
var PrintingWindow = window.open("about:blank","","toolbar,width=800,height=600,scrollbars,resizable,menubar");
PrintingWindow.document.open();
PrintingWindow.document.write(htmlStr);
PrintingWindow.document.close();
PrintingWindow.focus();
PrintingWindow.document.getElementById("printBtn").style.display="none";
PrintingWindow.print();
});
});
</script>
HOW TO Embed a Video file in a Content Editor Web Part
Insert the following code to embed a video file in a SharePoint Content Editor Web Part. Replace the ref value="" with the path to your video file.
<param name="URL" ref value="http://intranet.na.xxxx.com/sites/videos/pages/Profile.aspx?AssetID={1B89321E-E227-4FE5-978A-4D4CEF45FD7D}&DownloadFilePath=%5c%5cKFTUSOKTULAP110%5cTubeTarget1%5c2009%5c40%5c1b89321e-e227-4fe5-978a-4d4cef45fd7d%5cFile.wmv">
<param name="rate" value="1">
<param name="balance" value="0">
<param name="currentPosition" value="1">
<param name="defaultFrame" value=1>
<param name="playCount" value="1">
<param name="autoStart" value="0">
<param name="currentMarker" value="1">
<param name="invokeURLs" value="-1">
<param name="baseURL" value>
<param name="volume" value="50">
<param name="mute" value="0">
<param name="uiMode" value="mini">
<param name="stretchToFit" value="0">
<param name="windowlessVideo" value="0">
<param name="enabled" value="-1">
<param name="enableContextMenu" value="-1">
<param name="fullScreen" value="0">
<param name="SAMIStyle" value>
<param name="SAMILang" value>
<param name="SAMIFilename" value>
<param name="captioningID" value>
<param name="enableErrorDialogs" value="0">
</object>