You don't get to work with Google, because it is outside of the Microsoft environment. Oh, Microsoft. Your stores are lolariously ripped off of Apple's, your products are ripped from Google's, but the trick with iteration is that you are supposed to make things better, not worse. Unironically using Bing for a search engine is not the way to go. Just make your shitty office software marginally less shitty, bitches.
![]() |
This is two storefronts down from the Apple Store in Yorkdale Mall. No photos my left tit. |
Google does calendars really well, and your peers are mass-tunnelling out of the building to access their far superior services. Therefore, they have an idea of how to colour their calendars. They are asking you to make coloured calendars in Sharepoint, too.
Okay! Sharepoint supports this out of the box, but, per usual, ass-backwards. They support this by allowing you to include different calendar lists into one calendar view, with each calendar listed separately. Those calendar lists can live anywhere on your site and be rolled up by default, and - just like any other list - only people who have permissions to see their contents will be able to see the calendars. This works pretty well.
The available default colours alternate between boring and horrible, but that's so normal you probably don't notice. The trick is that your departments do not want multiple calendars, or to list their events across more than one list. They want one list, and they want it to be pretty.
Colouring A Calendar
You're going to need web parts for this. And jQuery. And a vague comprehension, however thin, of the term "event handler." Have you added jQuery to your masterpages yet? No? Go do that.
Here is your script:
- Add as many Case Sensitive Sniffer Words and Colour Classes as you like to the above script.
- Open your CSS and add those classes to your custom CSS for the site.
- Save the above into a text file.
- Upload the text file to your Style Library, under View All Site Contents, Style Library.
- Get the link for where the thing lives. It is almost certainly
http://[YOUR STUPID SERVER:PORT]/Style%20Library/yourScript.txt - Load up a page displaying a calendar that needs colours
- This can be a Calendar Page, or any other page you've stuck a Calendar web part into.
- Edit the page the calendar is on by dropping down Site Actions > Edit This Page.
- Click the Add A Web Part button
- Load, from Media and Content, a Content Editor.
- On the Content Editor, click the dropdown arrow, and select "Edit Web Part"
- Set the Content Link to where your script for that calendar lives.
- Save it.
- Provided you've set your sniffer words correctly, your calendar is now coloured and displaying all events for a given day by default.
Event Handler Issues, This Is Important
SP.UI.ApplicationPages.CalendarNotify.$4b is your event handler, by default. The name of this event handler tends to change unexpectedly! It is a surprise every time. If your calendar colour isn't working at all, and jQuery is loaded, it is time to find out if it's changed to SP.UI.ApplicationPages.CalendarNotify.$5c or some shit. It did that on me once and took eight hours to find the problem.
In earlier variants, the appropriate handler name is SP.UI.ApplicationPages.CalendarNotify.$3a.
In earlier variants, the appropriate handler name is SP.UI.ApplicationPages.CalendarNotify.$3a.
Calendar Expansion
Google can hide it because Google's calendars work right and work easily and weren't designed backwards. You will have people requesting this instantly. Don't want it? Take out function expandCalendar(){(miscellaneous code)}.
Colouring and How It Works
It would be super nice to have this script be case-insensitive, but for now, you load one line of sniffer for every variant you're looking for. The jQuery then searches the loaded events for the sniffer words. So:
$('div[title*="THING"]').addClass('calendarColor1');
$('div[title*="Thing"]').addClass('calendarColor1');
$('div[title*="thing"]').addClass('calendarColor1');
$('div[title*="thInG"]').addClass('calendarColor1');
All set the CSS class calendarColor1 to things with the word Thing somewhere in the visible event information.
Why yes, this is slow and inefficient, thanks for asking, but please recall that Sharepoint gives exactly no fucks about bandwidth already, so it doesn't noticeably damage performance at all.
Add as many spelling variants and colours as you like. One of mine, with a particularly ham-handed intern, has six variants. It eventually got easier than actually managing the calendar.
Other Calendar Fun
I've also added a sniffer for the word "Deleted" which sets a class of "hidden" to that event, because the people who actually use these calendars are legend. The sort of legend that involves a hook stuck on a car door. Tell you what, we can go camping some time and trade the stories by the light of burning IT support requests.
No comments:
Post a Comment