Since I've seen so much love out there, and I know what a pain in the ass Sharepoint can be at times, I've decided to FINALLY update the javascript and CSS on here so y'all can put it to some good use!
Basically, to wrap it all in a nutshell, if you either had the old code, or read the previous articles about how to incorporate this, then the idea is still the same, but I've chopped down some of the javascript and jQuery so that it runs a lot faster and smoother. Instead of iterating through EVERY day, I've only grabbed the dates with events that are actually on the calendar. Also I got rid of the hoverIntent jQuery plugin and found out how to actually click the date on the calendar webpart without it switching the day/month view. The big messy pop up box is now underneath the calendar, and is a lot smaller as well. Enough talk lets get to it.
I tend to throw all my javascript in my "Style Libary" folder at the root and reference them in the masterpage. Make sure the above code is in your head section of your page.
Pretty easy to do. Go to Site Actions ---> View All Site Content ---> Create (this will be on top). When the fancy Silverlight box displays, under "List", choose "Calendar". I named my calendar "CorporateCalendar" (no spaces). You can change in the javascript if you would like to name yours something different. If your calendar is not on the root, no worries, we can change that in the javascript as well!
The Calendar that you just made, we need to add the calendar webpart to the page. Navigate to the page desired, edit the page, and click inside one of the "Add a webpart" sections. Inside the webpartedit ribbon, under lists and libraries, find your calendar that we created and add it to the section. Save the page then publish. How to add/remove a webpart from a page.
This CSS is branded to fit our companies' intranet look and feel. There are multiple places you will need to edit to change the colors.
/* Calendar */ .ms-acal-summary-dayrow th { display:none; } .ms-acal-month tr th:first-child { display: none; } .ms-acal-header { text-align:center; } .ms-acal-outday{ display: none; } .ms-acal-month td { text-align:center; } .ms-acal-summary-dayrow td div { color: #696158; } .ms-acal-summary-itemrow > td { display:none !important; } .ms-acal-summary-dayrow td div { background-color:#F2F1E7; border: 1px solid #F2F1E7; } .ms-acal-ctrlitem { display:none; } .ms-acal-header { width:300px; margin: 5px 10px; } .ms-acal-rootdiv { font-size:14px; color:#696158 !important; } .ms-acal-display { color:#696158; font-size:16px; } .ms-acal-month-top { color: #696158; } .ms-acal-rootdiv tr:first-child{ font-size:10px; } .ms-acal-summary-dayrow > div { height:30px; } #AsynchronousViewDefault_CalendarView table:first-child td { padding: 1px; } tr td div.ms-acal-today{ background-color: #a43a34; border-color: #a43a34 !important; text-decoration: none; color:white !important; } .ms-acal-week-top td.ms-acal-hover div, .ms-acal-summary-dayrow td.ms-acal-hover div, .ms-acal-summary-dayrow th.ms-acal-hover { text-decoration:none; background-color:#F2F1E7; border-color: #F2F1E7 !important; } #calendarDisplay { margin:10px; font-size:10px; width:96%; } #calendarClose, #calendarClose:visited{ color:#a43a34; text-decoration:none; } #calendarClose:hover { font-weight:bold; text-decoration:underline; cursor:pointer; } #calendar { width:100%; } #calendar tr:first-child td{ font-size:12px; } #calendarDisplay td { border-bottom:1px solid #696158; background-color: #F2F1E7; padding:5px 10px !important; } #calendarDisplay .leftTD { width:35%; text-align:center; } #calendarDisplay .rightTD { width:80%; }
Add this to the bottom of your page right above the ending form tag.
Close
As we can see, this is 100x smaller than the original. Ahhh the magic of jQuery!
Now this is the most important part, and it must be followed to its entirety. I will go over the details. Add this javascript just below the HTML we just added, and above the form tag on your page. Make sure you wrap it in a script tag and a $(document).ready(function () {});.
// calendar ------------------------------- // if the click event does not work, go to C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\LAYOUTS // and open the SP.UI.ApplicationPages.Calendar.debug.js file // find "$addHandler(this.$8_1.ownerDocument, 'click', this.$31_1);" and comment it out // find "$removeHandler(this.$8_1.ownerDocument, 'click', this.$31_1);" and comment it out $('#AsynchronousViewDefault_CalendarView').append($('#calendarDisplay')); $('#calendarClose').click(function () { $('#calendarDisplay').hide(); }); $('.ms-acal-header span[id$="nav_header"]').wrap(''); $('#AsynchronousViewDefault_CalendarView').on('click', '.ms-acal-summary-dayrow td', function () { $('#calendarDisplay tr').not('tr:first').remove(); $('#calendarDisplay').show(); var date = $(this).attr('date'); $('#calendar td:first').text(date); var sharepointDate = Date.parse(date).toString('yyyy-MM-dd'); var soapEnv = " \ \ \ CorporateCalendar \ \ \ \ \ \ " + sharepointDate + "\ 1500 \ \ \ "; // Call web service $.ajax({ url: "http://YOURSITE/_vti_bin/lists.asmx", type: "POST", dataType: "xml", data: soapEnv, complete: AddEventToCalendar, contentType: "text/xml; charset=\"utf-8\"" }); function AddEventToCalendar(xData, status) { //alert(xData.responseText); return false; var startTime = ""; var endTime = ""; var title = ""; var id = ""; var count = 0; $(xData.responseXML).find("z\\:row").each(function () { title = $(this).attr('ows_Title'); id = $(this).attr('ows_ID'); // get time only from "EventDate" (start) startTime = Date.parse($(this).attr("ows_EventDate").substring($(this).attr("ows_EventDate").indexOf(' '))).toString('h:mm tt'); // get time only from "EndDate" (end) endTime = Date.parse($(this).attr("ows_EndDate").substring($(this).attr("ows_EndDate").indexOf(' '))).toString('h:mm tt'); $('#calendarDisplay tr:last').after('' + startTime + ' - ' + endTime + '' + title + ''); $('#calendarDisplay tr:last').find('td').wrapInner(''); count++; }); if (count == 0) { $('#calendarDisplay tr:last').after('No Data to Display'); } } return false; });
OK, deep breath. As you can see, 10x times smaller than the original code.
I think that's it! Here's the finished product. Sorry about the picture quality I took it while remoted in to my work computer.
Clicking on the "October, 2012" will transfer the user to the calendar (big display), and clicking on the "Some Test" will transfer the user to the item. One more thing I will add, and that is I will once again update the code to accommodate changing the background color of the day box if there is an event for that day, therefore preventing the user from clicking each day to find an event. If you have any problems, feel free to email me at rscott@designandaligndevelopment.com with questions or concerns.
Anything in here will be replaced on browsers that support the canvas element