Showing posts with label Publishing. Show all posts
Showing posts with label Publishing. Show all posts

Thursday, November 1, 2012

SharePoint calendars: color coding, hover effects, etc.



Two months ago, I introduced a method to display html in list views. The purpose of this post is to extend it to calendar views.
To learn more about the method itself, please refer to the post from September 1st. And of course, I recommend that you read the whole series about the “HTML calculated column“. You may find the following posts particularly useful:
- some simple but useful examples to get started
- a troubleshooting section
- how to apply the method to the DispForm.aspx page (as this is the page your calendar items will link to)
The script
You can use this module alone, or combined with the ones for list views. The scripts are very similar, but I had to make some adjustments to deal with the specificities of ”a” tags.
view plaincopy to clipboardprint?

<script type="text/javascript">  

// 

// Text to HTML - Calendar views 

// Questions and comments: Christophe@PathToSharePoint.com 

// 

var theAs = document.getElementsByTagName("a");  

var i=0;  

var AContent = "";  

while (i < theAs.length)  

{  

try 

{  

AContent = theAs[i].innerText || theAs[i].textContent;  

if ((AContent.indexOf("<DIV") >= 0) && (AContent.indexOf("</DIV>") >= 0)) {  

var tempDIV = document.createElement ("DIV");  

tempDIV.style.cursor = "pointer";  

tempDIV.innerHTML = AContent;  

theAs[i].innerHTML = "";  

theAs[i].appendChild(tempDIV);  

}  

}  

catch(err){}  

i=i+1;  

}  

</script> 

<script type="text/javascript">
//
// Text to HTML - Calendar views
// Questions and comments: Christophe@PathToSharePoint.com
//
var theAs = document.getElementsByTagName("a");
var i=0;
var AContent = "";
while (i < theAs.length)
{
try
{
AContent = theAs[i].innerText || theAs[i].textContent;
if ((AContent.indexOf("<DIV") >= 0) && (AContent.indexOf("</DIV>") >= 0)) {
var tempDIV = document.createElement ("DIV");
tempDIV.style.cursor = "pointer";
tempDIV.innerHTML = AContent;
theAs[i].innerHTML = "";
theAs[i].appendChild(tempDIV);
}
}
catch(err){}
i=i+1;
}
</script>
A simple example
For my example (see above screenshot), I have chosen a variation of this post,  as I wanted a printable calendar. For each task, the color depends on the % complete. Here is the formula for the calculated column:
view plaincopy to clipboardprint?

="<DIV style='position:relative;'><DIV style='font-size:0px; border-top: 14px solid "&CHOOSE(INT([%]*10)+1,"red","red","OrangeRed","OrangeRed","DarkOrange","Orange","Gold","yellow","GreenYellow","LawnGreen","Lime")&";width:100%;'> </DIV><DIV style='position:absolute; top:0px;'>"&TEXT([%],"0%")&"</DIV></DIV>" 

="<DIV style='position:relative;'><DIV style='font-size:0px; border-top: 14px solid "&CHOOSE(INT([%]*10)+1,"red","red","OrangeRed","OrangeRed","DarkOrange","Orange","Gold","yellow","GreenYellow","LawnGreen","Lime")&";width:100%;'> </DIV><DIV style='position:absolute; top:0px;'>"&TEXT([%],"0%")&"</DIV></DIV>"
Most of the examples I have already published for list views will also apply to calendar views. I have already shared a couple screenshots here.
My demo site also features a US holiday calendar with hover effects based on this method.
Important notes
- if you combine the scripts for list views and calendar views, you’ll need to put the script for calendar views first.
- During my tests, I have uncovered several issues with SharePoint calendars. I am keeping an ongoing list here.
- As the method is based on calculated columns, it has some limitations (see here for more details). For example you cannot include a lookup field in a formula.
- In SharePoint calendar views, items are displayed as hyperlinks to the display form (DispForm.aspx). The hyperlink will take precedence over hyperlinks you include in your formula.
- for short events (30 min or less), SharePoint provides limited space in the day and week views. Take this into account in your design.
Special thanks to Peter and Greg who sent me a detailed report of their tests to validate the script.
The next step will be to apply the method to preview panes.

Wednesday, January 4, 2012

Addons, Plugins and WebParts that Rock for SharePoint - Part 1

Hi there

I am going to be bringing you lots of addons, plugins and webparts that have made my life REALLY easy when deploying solutions for my clients.

I have spent 6 years working with and designing solutions for hundreds of clients and I have had my fair share of crappy webparts and promises that don't work.

So this is a chance for you to learn from my mistakes.

In this post I have got the first list of webparts that are pretty cool.


Document Previewer

Vizit is a fantastic Thumbnail preview tool for Document Libraries. If you need road warriors to be able to quick see a word document or an engineer to preview a CAD file in the browser then this is the tool you need.

Publishing to Sharepoint

You can utilise 3 solutions I have used before. 
Spring solutions put out a product and Microsoft do with Live Writer. The Microsoft product is free.
http://www.ispringsolutions.com/articles/publishing_content_directly_to_sharepoint.html

Squeezing Info

Here are some great Tab and Accordian webparts for squeezing more info onto pages.
http://www.amrein.com/apps/page.asp?Q=5808 - Tabs and Accordians

Playing Media Files in the Browser

Here is an Audio player for your media document Libraries
http://www.amrein.com/apps/page.asp?Q=5756 - Audio Player

Getting Social with Sharepoint

http://www.newsgator.com/products/social-sites-for-sharepoint-2010.aspx - Social Site Setup