Id="Ribbon.WikiPageTab.CustomGroup"
Location="CommandUI.Ribbon">
Location="Ribbon.WikiPageTab.Groups._children">
Id="Ribbon.WikiPageTab.CustomGroup"
Sequence="55"
Description="Custom Group"
Title="Custom"
Command="EnableCustomGroup"
Template="Ribbon.Templates.Flexible2">
Id="Ribbon.WikiPageTab.CustomGroup.Print"
Command="CustomGroupPrint"
Image32by32="/_layouts/IMAGES/print32x32.gif"
LabelText="Print"
TemplateAlias="o2"
Sequence="15" />
Location="Ribbon.WikiPageTab.Scaling._children">
Id="Ribbon.WikiPageTab.Scaling.CustomGroup.MaxSize"
Sequence="15"
GroupId="Ribbon.WikiPageTab.CustomGroup"
Size="LargeLarge" />
Command="EnableCustomGroup"
CommandAction="javascript:return true;" />
Command="CustomGroupPrint"
CommandAction="javascript:
function PrintWebPart()
{
var bolWebPartFound = false;
var TopMomTableElement = getElementEndsWithId('TopID');
var TableClassName = 'ms-listviewtable';
if(TopMomTableElement!=null)
{
// remove input tags
var inputTags = document.getElementsByTagName('INPUT');
var t = inputTags.length;
for (var i = 0; i < t; i++) {
inputTags[0].parentNode.removeChild(inputTags[0]);
}
var allTableTags=document.getElementsByTagName('TABLE');
var TableListHTML = '';
for (i=0; i < allTableTags.length; i++)
{
if (allTableTags[i].className==TableClassName)
{
TableListHTML = allTableTags[i].outerHTML;
}
}
var currentTime = new Date();
var month = currentTime.getMonth() + 1;
var day = currentTime.getDate();
var year = currentTime.getFullYear();
var dateString = day + '/' + month + '/' + year ;
var CSSSTYLE = '<style type=\'text/css\'>' +
'table.top { border:1px solid black; border-spacing: 0px;border-collapse:collapse;} td.top { border: 1px solid black; border-spacing:0px; font:100% arial,sans-serif; } ' +
'td.ms-vb2, td.ms-vb-user, .ms-vb-title, th.ms-vh2, th.ms-vh { border:1px solid black; border-spacing: 0px; font:90% arial,sans-serif; } ' +
' img {display: none} .s4-ctx {display: none} </style>';
var PrintingWindow = window.open('','PrintWebPart', 'width=800,height=600,scrollbars,resizable,menubar');
PrintingWindow.document.open();
PrintingWindow.document.write('<html><head> ' + CSSSTYLE + '</head><body>\n\n' + '<B> Printed Date: ' + dateString + '</B><BR/>' + TopMomTableElement.outerHTML + '<br/>' + TableListHTML +'</body></html>');
}
}
function getElementEndsWithId( endID )
{
var children = document.body.getElementsByTagName('TABLE');
var child;
var length = children.length;
for (var i = 0; i < length; i++)
{
child = children[i];
if(child.id.indexOf(endID)!=-1)
{
return child;
}
}
return null;
}
PrintWebPart();" />
Monday, 30 January 2012
CustomActions with Javascript
Labels:
JavaScript/JQuery
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment