Assalamualaikum and hello,

Today I’m finished to find a way how to customize Sharepoint 2007’s Calendar using jQuery. I’m customize it because I want to show lightbox popup when anonymous user click any item in calendar list.

As you know, many Sharepoint function is restricted, and if we want to make a new function, we can tweak it using javascript.

 

For example, this picture show that, if user click the link in any item in calendar, the popup of required form will appear because this link will open page DispForm.aspx. Page DispForm.aspx cannot publish, so anonymous user cannot view it.

Solution:
Using jQuery to change the URL link at all item in calendar.

To show lightbox popup, we can use

<a onclick="javascript:DoAction('anyPage.aspx')" href="#">lightbox</a>

function DoAction(link)
{
   $.fancybox.open({
	href : link,
	type : 'iframe',
	padding : 5
   });
}

or you can use any other method to call lightbox popup.

After that, use this jQuery code to change attribute of calendar.

//function to detect the url and change to popup function
$(document).ready(function() {
   $("table[id^='CalViewTable']").find("a[href*='DispForm.aspx']").each(function() {
       var originalUrl = $(this).attr("href");
       var getId = originalUrl.replace("DispForm.aspx", "");
       $(this).attr("href", "#");
       $(this).attr("onclick", "javascript:DoAction('anyPage.aspx"+getId+"')");
   });
});

after change the attribute, automatically when you refresh the page, it will replace DispForm.aspx with # and add attribute onclick.

Result:
Now, anonymous user can view without any required form anymore.

Using jQuery, you’re freely to change with your own coding! Have a nice coding! =)

Related Posts with Thumbnails