Tag Archives: Calendar

Navigating multiple calendars in SharePoint

This topic came up over on SharePoint.StackExchange.com, and I thought I’d share here too.

You may want to setup a single page to view multiple calendars. Calendar overlay is a great way to handle this, but what if you want to see these side by side, and let the user navigate the dates in unison, so clicking Next Day will go to the next day, on each calendar.

Two Calendars on a Page

Looking at the above, clicking the day navigation will only update that one calendar web part. Not cool. How do we fix that?

Insert a Snippet App Part, and copy and paste this code into it. It’s a little raw, but it works. Class it up for your brand and site as you need.


<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<div>
<a href='#' id='newPrevDay'>Previous Day</a> &nbsp;
<a href='#' id='newNextDay'>Next Day</a>
</div>

<script type="text/javascript">
$(document).ready(function(){

ExecuteOrDelayUntilScriptLoaded(overrideButtons,"SP.UI.ApplicationPages.Calendar.js");

function overrideButtons() {
$("#newPrevDay").click(function() {
$("a[title=\"Previous Day\"]").each(function() {
eval($(this).attr("href"));
});
});

$("#newNextDay").click(function() {
$("a[title=\"Next Day\"]").each(function() {
eval($(this).attr("href"));
});
});
}
});
</script>

Once the code is in, the calendar’s buttons will be hidden and the new buttons will appear, like so:

Calendars with single navigation buttons

 

Advertisements

Calendar Overlays: Keeping events in the same window.

Previously, I shared about how to create a color coded calendar, and then taking that calendar a little further and jazzing it up with some color. One issue that has been identified with this method, and using calendar overlays in general, is the fact that the events open in a whole new window. Not cool.

I’ve toyed around with some custom JavaScript that can fix this, but haven’t found a solution, until now. Actually, until Kevin commented on my post and pointed me over to this MSDN forum thread.

After reading through the thread, I’ve compiled the follow block of code. You can throw this in the same web part that contains your CSS.

NOTE A few people have reported this doesn’t work in SharePoint 2013. I’ll find a solution. ;)

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script type="text/javascript">
// load our function to the delayed load list
_spBodyOnLoadFunctionNames.push('calendarEventLinkIntercept');

// hook into the existing SharePoint calendar load function.
function calendarEventLinkIntercept()
{
if (SP.UI.ApplicationPages.CalendarNotify.$4a)
{
var OldCalendarNotify = SP.UI.ApplicationPages.CalendarNotify.$4a;
SP.UI.ApplicationPages.CalendarNotify.$4a = function ()
{
OldCalendarNotify();
bindEventClickHandler();
}
}
if (SP.UI.ApplicationPages.CalendarNotify.$4b)
{
var OldCalendarNotify = SP.UI.ApplicationPages.CalendarNotify.$4b;
SP.UI.ApplicationPages.CalendarNotify.$4b = function ()
{
OldCalendarNotify();
bindEventClickHandler();

}
}
// future service pack change may go here!
// if (SP.UI.ApplicationPages.CalendarNotify.???)
}

function bindEventClickHandler() {
$('.ms-acal-mdiv a, .ms-acal-ddiv a, .ms-acal-sdiv a').click(function(){EditLink2(this,'WPQ2');return false;});
$('a.ms-cal-nav').attr("href", "javascript:bindEventClickHandler(); void(0);");
}
</script>

Click here to download the script.

NOTE: Update the first line to your jQuery file if you have it somewhere on your network/site already.

UPDATE: 10/22/2013 – Updated the code above to work on Week and Day views as well.

Happy SharePointing!

Customize the SharePoint Calendar Colors

I shared a post a while ago on how to create a color coded calendar in SharePoint. This is a no code (for real!) solution, and I’ve received some great feedback from it. One area I want to focus on are the colors.

Let’s go from blah

To, well, more colorful, not sure if I’d call this awesome or not (my color matching skills are lacking)

If you haven’t noticed, there are some colors which are really close to each other, and could easily be mistaken for each other. It’s rather frustrating. Also, they’re all pastels, which is nice but what if I want it to pop on the page?

You can setup a custom style sheet on your calendar page to override the colors. Unfortunately, this will not change the colors at the time you setup the calendars. To keep your colors straight, here’s the colors, and their associated values:

Light Yellow, #fef8d6, Color #1
Light Green, #d0ffbc, Color #2
Orange, #feebcd, Color #3
Light Turquoise, #c8f0ff, Color #4
Pink, #ffc8e8, Color #5
Light Blue, #bee5ff, Color #6
Ice Blue, #e0e8f2, Color #7
Ice Blue, #d9dde1, Color #8
White, #f2f2f2, Color #9

See the close similarities? 1 and 3; 4 and 6; 7, 8 and 9. You only have 5 unique colors to work with.

As you create your color coded calendar, make note of the color #s you’re using, this will be important when creating the new color scheme. And since we’re talking about color schemes, I highly recommend using a comfortable color scheme. You don’t want your calendar to hurt your users. You may only want to change a few colors instead of the entire collection. There are a lot of color schemes and combos online, if you want to create your own, check out http://colorexplorer.com/. Take some time and figure out your ideal color scheme.

Now that you have your colors, let’s get started! First thing you want to do is follow my other post and make your color coded calendar, click here to open the post. Your end result should be a spread of drab pastel colors, like my first image on this post.

Okay, now that you have your color coded calendar, let’s change some colors! You don’t have to change every color in the list, or you may want to. Up to you. I’m going to change colors 3, 4, 8 and 9, and use some real colors that pop.

How? Magical CSS classes:

.ms-acal-color# {
 BACKGROUND-COLOR: #xxxxxx
}
.ms-acal-selcolor# {
 BACKGROUND-COLOR: #xxxxxx
}
.ms-acal-apanel-color# {
 BORDER-COLOR: #xxxxxx;
 BACKGROUND-COLOR: #xxxxxx;
}

The above 3 classes of styles represent one color. The first class is the color you see when the page loads, and you haven’t clicked on the item. The second is the selected color when you hover on it. The third class is the color in the legend, on the left of the calendar view.

See at the end of the class name, before the {, is a #. This is just a place holder, you’ll want to swap this out with the color above you want to change. For example, if you want to change color 4, you’d update your CSS like:

.ms-acal-color4, .ms-acal-selcolor4, and .ms-acal-apanel-color4

You can copy and paste the CSS as many times as you need, for numbers 1 through 9. Within each section you’ll see BACKGROUND-COLOR: #xxxxxx, and in the last CSS you’ll see BORDER-COLOR :#xxxxxx as well. This is where your new color scheme comes into play.

I’m going  use this neat color scheme I quickly found:

Any scheme you find you’ll want to find the HTML, hexidecimal, or CSS value, for your colors (naming varies depending on the site you get it from). It’ll be a 6 character code, usually starting with #. Take the above CSS classes and create your new CSS classes using the colors your picked for your previously made calendar, and specify your own color palette. Here’s what mine will look like:

.ms-acal-color3{
 BACKGROUND-COLOR: #C0362C
}

.ms-acal-selcolor3{
 BACKGROUND-COLOR: #C0362C
}

.ms-acal-apanel-color3{
 BORDER-COLOR: #C3B7AC; BACKGROUND-COLOR: #C0362C;
}

.ms-acal-color4{
 BACKGROUND-COLOR: #816C5B
}

.ms-acal-selcolor4{
 BACKGROUND-COLOR: #816C5B
}

.ms-acal-apanel-color4{
 BORDER-COLOR: #C3B7AC; BACKGROUND-COLOR: #816C5B;
}

.ms-acal-color8{
 BACKGROUND-COLOR: #668D3C
}

.ms-acal-selcolor8{
 BACKGROUND-COLOR: #668D3C
}

.ms-acal-apanel-color8{
 BORDER-COLOR: #C3B7AC; BACKGROUND-COLOR: #668D3C;
}

.ms-acal-color9{
 BACKGROUND-COLOR: #007996
}

.ms-acal-selcolor9{
 BACKGROUND-COLOR: #007996
}

.ms-acal-apanel-color9{
 BORDER-COLOR: #C3B7AC; BACKGROUND-COLOR: #007996;
}

For the border color, I decided to go with a grey. Once you have your CSS together, let’s get it into SharePoint!

Browse to your color coded calendar.

  • Click Site Actions, then Edit Page. This will switch the page into edit mode.
  • Click Add a Web Part above the calendar.
  • Select Forms in the Categories from the top left, then select HTML Form Web part. Click Add
  • Hover over the web part and click on the web part menu, on the right
  • The task pane will appear on the far right. Click Source Editor.
  • Delete what’s in there now, and then type in:
    <style type="text/css">
  • Paste in your CSS.
  • Type in at the bottom of the page
    </style>
  • You should see something similar to
  • Click Save.
  • You’ll see your new colors appear!!
  • My text is hard to read. Fortunately from here I can use the full arsenal of CSS and change font colors, sizes, spacing, etc.
  • To change the font color, add the following for each color number you want to change (#ffffff is white, you could use any color you want here as well.)
    .ms-acal-color3 div, .ms-acal-color3 div a, .ms-acal-apanel-color3 SPAN {color: #ffffff !important}
  • Click OK in the task pane to close it. Click Stop Editing in the ribbon to stop page editing.

And here we have it!


You can also modify the default light green item by adding these CSS classes. However, if you do, make sure to put it at the top of your CSS text, also, in my case here, any colors not using a new color scheme, like my pink PTO, will be changed to whatever color you put here.

.ms-acal-item {
 BORDER: #xxxxxx; BACKGROUND-COLOR: #xxxxxx
}
.ms-acal-default-hover {
 BORDER: #xxxxxx; BACKGROUND-COLOR: #xxxxxx
}
.ms-acal-apanel-item {
 BORDER: #xxxxxx; BACKGROUND-COLOR: #xxxxxx
}

And if you want to change the default font color:

.ms-acal-item div, .ms-acal-item div a, .ms-acal-apanel-item SPAN
{ color: #xxxxxx !important}

Happy SharePointing!

Color code your SharePoint calendar

A nice new feature in SharePoint 2010 is the ability to roll up multiple calendars into one, and color code them. In previous versions of SharePoint, this was something that was only doable with third-party products or some serious jQuery.

Consider the following scenario. The sales department of Contoso has a single calendar they use to track and manage their events, like trade shows, client meetings, follow up calls, department meetings, etc. They have it all in one calendar, but it’s a mess, and hard to see important events.

Boring SharePoint Calendar View

Instead, they would like to view each category of event in its own color. Like this:

Color coded SharePoint calendar

This is simple to do with a single calendar, there’s just a little leg work up front.

Before we begin: one down side to this is that it’s not easily replicable. Once you create your calendar, you cannot copy or move it to another location. You’ll need to recreate it again in your new location. So start with your calendar view or web part you want to use.

One more note: it has been discovered that once you’re using the calendar overlay, clicking on an event will open a new window to view the event. It will not use the modal dialog box. I’m betting this is a “feature” since the overlay could technically pull from calendars from other lists and sites. I’ll see if I can figure a way around that. ;)

To make this pretty calendar, we need to make a view for each color set we want. By making each view, we can overlay each view over the calendar and then select a color for each. Creating each view will require the filter data to be in the appointment in some manner. Ideally a choice field has been added with options to choose from, but if your users were typing in “Tradeshow” or “Meeting” in the Title field, we can filter on that as well.

First thing we do is modify the default view. Chances are your current default view is Calendar, which includes all items. This will be our base for our colorful masterpiece. This default view will automatically assume the green color. Go head and modify this view to weed out anything you don’t want using a unique color (i.e. set the filter where category is equal to blank, as long as the users specify a category it shouldn’t show up in this view).

Now create a view for each color set.

Quick steps to create a view

  • In the ribbon, click the Calendar tab, then click Create View
  • On the bottom half of the page, select existing view Calendar
  • Name it accordingly.
  • Scroll down to the Filter and specify your filter
  • Click OK

Continue these same steps to create each view. At the end, you should have a few views. Check out each view and ensure you’re seeing unique values in each. If you see the same value in more than one, it will appear more than once (in each color) in your color coded calendar.

Once your views are made, go to your site home page and browse to your calendar page. This will ensure we’re on the default page that your users will also access.

Now let’s bring it all together

  • In the ribbon, click the Calendar tab
  • Click Calendars Overlay
  • Click New Calendar
  • Name it, preferably the same name as your view
  • Select your color
  • Ensure the correct URL is specified and click Resolve
  • Select your Calendar list
  • Select your View
  • Check Always Show
  • Click OK

Do this for each view and then click OK to return.

Now you have a pretty color coded calendar! You’ll also see a legend on the left, which helps define the colors for your users.

Color code SharePoint legend

Don’t forget your missing appointments! Make sure your views are including all of your appointments. In my example, if the Category field isn’t required, users can create appointments without specifying a category. This would cause appointments to go missing in our new view. To resolve this, create another view which includes a filter to include all but the above items.

Want to change up the colors? Check out my other post: https://davidlozzi.com/2012/06/20/customize-the-sharepoint-calendar-colors/.

Happy SharePointing!