{"id":1439,"date":"2014-12-18T11:02:04","date_gmt":"2014-12-18T10:02:04","guid":{"rendered":"http:\/\/blog.kodono.info\/wordpress\/?p=1439"},"modified":"2015-11-02T16:17:39","modified_gmt":"2015-11-02T15:17:39","slug":"how-to-expand-sharepoint-2010-calendar-by-default-javascript","status":"publish","type":"post","link":"https:\/\/blog.kodono.info\/wordpress\/2014\/12\/18\/how-to-expand-sharepoint-2010-calendar-by-default-javascript\/","title":{"rendered":"How to expand Sharepoint 2010 calendar by default [JavaScript]"},"content":{"rendered":"<p>This code has been tested for Sharepoint 2010 only. It permits to expand by default (so as soon as the page is loaded) the events in the Month calendar view.<\/p>\n<p><a href=\"http:\/\/blog.kodono.info\/wordpress\/2015\/11\/02\/how-to-expand-sharepoint-2013-calendar-by-default-javascript\/\">See here a solution for Sharepoint 2013<\/a>.<\/p>\n<p>Tested with IE8 and Firefox 34. You&#8217;ll have to add the below JavaScript code into your calendar page:<\/p>\n<pre class=\"brush:javascript\">\r\n\/\/ the below function simulate a click on a link\r\nfunction fireEventClick(elem){\r\n    if(document.createEvent){                                                 \r\n      var e = document.createEvent('MouseEvents');\r\n      e.initMouseEvent('click', \/* Event type *\/\r\n      true, \/* Can bubble *\/\r\n      true, \/* Cancelable *\/\r\n      document.defaultView, \/* View *\/\r\n      1, \/* Mouse clicks *\/\r\n      0, \/* Screen x *\/\r\n      0, \/* Screen y *\/\r\n      0, \/* Client x *\/\r\n      0, \/* Client y *\/\r\n      false, \/* Ctrl *\/\r\n      false, \/* Alt *\/\r\n      false, \/* Shift *\/\r\n      false, \/* Meta *\/\r\n      0, \/* Button *\/\r\n      null); \/* Related target *\/\r\n      elem.dispatchEvent(e);                     \r\n    } else { \/\/ pour IE\r\n      elem.click();\r\n    }\r\n}\r\n\r\n\/\/ wait for all the events to be loaded\r\n_spBodyOnLoadFunctionNames.push('changeCalendarEventLinkIntercept');\r\nfunction changeCalendarEventLinkIntercept() {\r\n  var OldCalendarNotify4a = SP.UI.ApplicationPages.CalendarNotify.$4b;\r\n  SP.UI.ApplicationPages.CalendarNotify.$4b = function () {\r\n    OldCalendarNotify4a();\r\n    \/\/ here all the events are loaded so we can expand them\r\n    setTimeout(function() {\r\n      ExpandEvents(0)\r\n    }, 250)\r\n  }\r\n}\r\n\r\n\/\/ Expand the events\r\n\/\/ because Sharepoint redraw ALL the events when we click on Expand, then we need a special recurrent function\r\nfunction ExpandEvents(idx) {\r\n  var a = document.querySelectorAll('a[evtid=\"expand_collapse\"]');\r\n  if (idx &lt; a.length) {\r\n    if (a[idx].parentNode.getAttribute(\"_expand\") !== \"collapse\") fireEventClick(a[idx]);\r\n    ExpandEvents(++idx);\r\n  }\r\n}\r\nExpandEvents(0)\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>This code has been tested for Sharepoint 2010 only. It permits to expand by default (so as soon as the page is loaded) the events in the Month calendar view. See here a solution for Sharepoint 2013. Tested with IE8 and Firefox 34. You&#8217;ll have to add the below JavaScript code into your calendar page: [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_coblocks_attr":"","_coblocks_dimensions":"","_coblocks_responsive_height":"","_coblocks_accordion_ie_support":"","hide_page_title":"","footnotes":""},"categories":[13,33],"tags":[24,152,158,117],"class_list":["post-1439","post","type-post","status-publish","format-standard","hentry","category-niveau-intermediaire","category-programmation","tag-javascript","tag-niveau-intermediaire","tag-programmation","tag-sharepoint"],"_links":{"self":[{"href":"https:\/\/blog.kodono.info\/wordpress\/wp-json\/wp\/v2\/posts\/1439","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.kodono.info\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.kodono.info\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.kodono.info\/wordpress\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.kodono.info\/wordpress\/wp-json\/wp\/v2\/comments?post=1439"}],"version-history":[{"count":3,"href":"https:\/\/blog.kodono.info\/wordpress\/wp-json\/wp\/v2\/posts\/1439\/revisions"}],"predecessor-version":[{"id":1564,"href":"https:\/\/blog.kodono.info\/wordpress\/wp-json\/wp\/v2\/posts\/1439\/revisions\/1564"}],"wp:attachment":[{"href":"https:\/\/blog.kodono.info\/wordpress\/wp-json\/wp\/v2\/media?parent=1439"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.kodono.info\/wordpress\/wp-json\/wp\/v2\/categories?post=1439"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.kodono.info\/wordpress\/wp-json\/wp\/v2\/tags?post=1439"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}