{"version":3,"sources":["modules/Calendars.js"],"names":["Calendars","SearchObject","this","WhatText","WhereText","WhenIndex","CalendarDisplay","CouncilID","KeyWords","IncludeDeletedAndUnpublished","InitListingCalendar","calendarSelector","firstDate","organisationId","outletId","outletServiceId","loadingCallback","loadedCallback","includeExpiredEvents","includeEventsRunAtLocation","inDashboard","limit","additionalPath","uniqueEvents","search","oneMonthAgo","Date","setHours","setMonth","getMonth","window","CalendarSearch","UniqueEvents","SearchOutletID","SearchOrganisationID","SearchOutletServiceID","IncludeExpiredEvents","IncludeEventsRunAtLocation","editsAllowed","PageNo","PageSize","$","fullCalendar","header","left","center","right","height","startParam","endParam","nowIndicator","fixedWeekCount","defaultDate","events","url","AppSettings","ApiUrl","data","eventDataTransform","event","eventDisplayColour","DiaryTypeID","id","ID","title","EventName","start","StartsAt","end","EndsAt","allDay","IsAllDay","diaryElement","color","canEdit","CanEditOutlet","eventRender","element","template","render","replace","$template","html","removeAttr","addClass","$a","attr","DiaryUrl","InstanceUrl","append","path","$b","EventID","format","minutes","eventAfterAllRender","css","next","length","loading","isLoading","show","hide","viewRender","view","removeClass","intervalUnit","shave"],"mappings":"AAAA,IAYIA,UAZAC,aACA,WACIC,KAAKC,SAAW,GAChBD,KAAKE,UAAY,GACjBF,KAAKG,UAAY,EACjBH,KAAKI,iBAAkB,EACvBJ,KAAKK,UAAY,EACjBL,KAAKM,SAAW,GAChBN,KAAKO,8BAA+B,IAuKzCT,YAAcA,UAAY,KADfU,oBA1JV,SAA6BC,EAAkBC,EAAWC,EAAgBC,EAAUC,EAAiBC,EAAiBC,EAAgBC,EAAsBC,EAA4BC,EAAaC,EAAOC,GACxM,IAPiBC,EACbC,EAMAC,EAAc,IAAIC,KAChBN,IACFK,EAAYE,SAAS,EAAG,EAAG,EAAG,GAC9BF,EAAYG,SAASH,EAAYI,WAAa,IAElDC,OAAOC,gBAZUR,GAYmB,GAXhCC,EAAS,IAAIvB,cACV+B,aAAeT,EACtBC,EAAOf,8BAA+B,EAC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tC,OAASzC,EACdgB,EAAE9B,EAAmB,oBAAoByE,SAAS,qBAGlD3C,EAAE9B,EAAmB,oBAAoB8F,YAAY,qBAEzDhE,EAAE,kCAAkC6C,KAAK,aAAc,kBAAoBkB,EAAKE,cAChFjE,EAAE,kCAAkC6C,KAAK,aAAc,cAAgBkB,EAAKE,gBATjE,KAanBjE,EAAE,qBAAqBkE,MAAM,IAC7BlE,EAAE,aAAakE,MAAM","file":"Calendars.min.js","sourcesContent":["var SearchObject = /** @class */ (function () {\r\n function SearchObject() {\r\n this.WhatText = '';\r\n this.WhereText = '';\r\n this.WhenIndex = 5;\r\n this.CalendarDisplay = true;\r\n this.CouncilID = 0;\r\n this.KeyWords = '';\r\n this.IncludeDeletedAndUnpublished = false;\r\n }\r\n return SearchObject;\r\n}());\r\nvar Calendars;\r\n(function (Calendars) {\r\n function buildSearch(uniqueEvents) {\r\n var search = new SearchObject();\r\n search.UniqueEvents = uniqueEvents;\r\n search.IncludeDeletedAndUnpublished = false;\r\n return search;\r\n }\r\n function InitListingCalendar(calendarSelector, firstDate, organisationId, outletId, outletServiceId, loadingCallback, loadedCallback, includeExpiredEvents, includeEventsRunAtLocation, inDashboard, limit, additionalPath) {\r\n var oneMonthAgo = new Date();\r\n if (!(inDashboard || false)) {\r\n oneMonthAgo.setHours(0, 0, 0, 0);\r\n oneMonthAgo.setMonth(oneMonthAgo.getMonth() - 1);\r\n }\r\n window.CalendarSearch = buildSearch(false);\r\n // it's either organisation > 0 or outlet > 0 if both then the search is not outlet-specific\r\n // since it will also search for all outlets in the organisation\r\n if (outletId > 0) {\r\n window.CalendarSearch.SearchOutletID = outletId;\r\n }\r\n else {\r\n window.CalendarSearch.SearchOrganisationID = organisationId;\r\n }\r\n window.CalendarSearch.SearchOutletServiceID = outletServiceId;\r\n window.CalendarSearch.IncludeExpiredEvents = includeExpiredEvents;\r\n window.CalendarSearch.IncludeEventsRunAtLocation = includeEventsRunAtLocation;\r\n var editsAllowed = inDashboard || false;\r\n if ((limit || 0)) {\r\n window.CalendarSearch.PageNo = 1;\r\n window.CalendarSearch.PageSize = limit;\r\n }\r\n $(calendarSelector).fullCalendar({\r\n header: {\r\n left: \"prev,next today\",\r\n center: \"title\",\r\n right: \"month,agendaWeek,agendaDay\"\r\n },\r\n height: \"auto\",\r\n startParam: \"SearchFrom\",\r\n endParam: \"SearchTo\",\r\n nowIndicator: true,\r\n fixedWeekCount: false,\r\n defaultDate: firstDate,\r\n events: {\r\n url: window.AppSettings.ApiUrl + \"/api/v1/search/diary/GetInstanceResults\",\r\n data: function () {\r\n return window.CalendarSearch;\r\n }\r\n },\r\n eventDataTransform: function (event) {\r\n var eventDisplayColour = \"#DCDCDC\";\r\n switch (event.DiaryTypeID) {\r\n case 1:\r\n eventDisplayColour = \"#4169E1\";\r\n break;\r\n case 2:\r\n eventDisplayColour = \"#D2691E\";\r\n break;\r\n case 3:\r\n eventDisplayColour = \"#2E8B57\";\r\n break;\r\n case 4:\r\n eventDisplayColour = \"#BA55D3\";\r\n break;\r\n case 5:\r\n eventDisplayColour = \"#2D585E\";\r\n break;\r\n }\r\n return {\r\n id: event.ID,\r\n title: event.EventName,\r\n start: event.StartsAt,\r\n end: event.EndsAt,\r\n allDay: event.IsAllDay,\r\n diaryElement: event,\r\n color: eventDisplayColour,\r\n canEdit: editsAllowed && event.CanEditOutlet\r\n };\r\n },\r\n eventRender: function (event, element) {\r\n var template = $(\"#diaryResultTemplate\").render(event.diaryElement).replace(\"col-xs-6 col-sm-6 col-md-4 col-lg-3\", \"result-card-tip\");\r\n var $template = $(\"<div/>\").html(template);\r\n $(\".nofollow\", $template).removeAttr(\"rel\");\r\n template = $template.html();\r\n //element.qtip({\r\n // content: template,\r\n // position: {\r\n // target: \"mouse\",\r\n // adjust: { x: -5, y: -5 },\r\n // my: \"bottom right\",\r\n // at: \"top left\"\r\n // },\r\n // style: \"qtip-light qtip-rounded\"\r\n //});\r\n element.addClass(\"edit\");\r\n if (editsAllowed && event.canEdit) {\r\n var $a = $(\"<a>\")\r\n .addClass(\"fc-view-link\")\r\n .attr(\"href\", window.AppSettings.DiaryUrl + event.diaryElement.InstanceUrl)\r\n .attr(\"target\", \"_blank\")\r\n .html(\"<i class='fa fa-eye'></i>\");\r\n element.append($a);\r\n if (event.canEdit) {\r\n var path = additionalPath != null ? additionalPath : \"\";\r\n var $b = $(\"<a>\")\r\n .addClass(\"fc-edit-link\")\r\n .attr(\"href\", \"/Manage/Events/Edit/\" + event.diaryElement.EventID + path + \"#all\")\r\n .html(\"<i class='fa fa-edit'></i>\");\r\n element.append($b);\r\n }\r\n }\r\n else {\r\n element.attr(\"href\", window.AppSettings.DiaryUrl + event.diaryElement.InstanceUrl);\r\n element.attr(\"target\", \"_blank\");\r\n }\r\n if (event.allDay) {\r\n element.attr(\"aria-label\", \"All day event \" + event.title + \" on \" + event.start.format(\"dddd, MMMM D YYYY\"));\r\n }\r\n else {\r\n if (!event.end) {\r\n event.end = event.start;\r\n }\r\n element.attr(\"aria-label\", \"Event \" + event.title + \" on \" + event.start.format(\"dddd, MMMM D YYYY\") + \" \\n starting at \" + (event.start.minutes() === 0 ? event.start.format(\"h A\") : event.start.format(\"h m A\")) + \" \\n and finishing at \" + (event.end.minutes() === 0 ? event.end.format(\"h A\") : event.end.format(\"h m A\")));\r\n }\r\n },\r\n eventAfterAllRender: function () {\r\n $(\".council-details\").css({ \"height\": $(\".council-details\").next().height() });\r\n $(calendarSelector).attr(\"aria-label\", $(\".fc-event-container\").length + \" visible events\");\r\n },\r\n loading: function (isLoading) {\r\n if (isLoading) {\r\n $(\"#spinner\").show();\r\n if (typeof loadingCallback !== \"undefined\") {\r\n loadingCallback();\r\n }\r\n }\r\n else {\r\n $(\"#spinner\").hide();\r\n $(\".council-details\").css({ \"height\": $(\".council-details\").next().height() });\r\n if (typeof loadedCallback !== \"undefined\") {\r\n loadedCallback();\r\n }\r\n }\r\n },\r\n viewRender: function (view) {\r\n if (inDashboard || false) {\r\n return true;\r\n }\r\n if (view.start <= oneMonthAgo) {\r\n $(calendarSelector + \" .fc-prev-button\").addClass(\"fc-state-disabled\");\r\n }\r\n else {\r\n $(calendarSelector + \" .fc-prev-button\").removeClass(\"fc-state-disabled\");\r\n }\r\n $(\"#eventCalendar .fc-prev-button\").attr(\"aria-label\", \"Go to previous \" + view.intervalUnit);\r\n $(\"#eventCalendar .fc-next-button\").attr(\"aria-label\", \"Go to next \" + view.intervalUnit);\r\n return true;\r\n }\r\n });\r\n $(\".card-description\").shave(46);\r\n $(\".fc-title\").shave(20);\r\n }\r\n Calendars.InitListingCalendar = InitListingCalendar;\r\n})(Calendars || (Calendars = {}));\r\n"]}