//allDaySlot Not programmed yet for splitting of events and combining of overlapping events DefaultView = function () { var self = this; var gMinStartTime; var gMaxEndTime; var gWVFirstDay; var gAllDaySlot = false; var gIsFE; var detailModalData; //Store data for use on reload delete var gModalLoaded = false; var gCalendarDivName = '#calendar' var gchkSubCalNameStart = 'chkFCSubCal_'; var gchkSubCalMain = '#chkFCSubCalMain'; var gchkFCSubCalAll = '#chkFCSubCalAll'; var ghdnSubCalendarList = '#hdnSubCalendarList'; var gGetEventDetailsURL = '/Admin/Facilities/Calendar/CalendarEventDetailsModal'; var gGetCalendarEventsURL = '/Admin/Facilities/Calendar/GetCalendarEvents'; var gDeleteUrl = '/Admin/Facilities/ReservationDelete'; var gCanBeDeletedUrl = '/Admin/Facilities/Calendar/CanBeDeleted'; var gCalendarModuleEditURL = '/Admin/Calendar.aspx?EID={0}&CID={1}'; var gIsSelectable = false; var gIsEditable = false; var gDisableDragging = false; var gDisableResizing = false; var gSelectableFunction; var gEventDropFunction; var gEventResizeFunction; var gModifyEventClickFunction; var gIsMainSubCalHidden; var gRecurrenceID = 0; var gIsRecurrenceDateModified = false; var gGetDeleteRecurrenceModalURL = '/Admin/Facilities/ReservationDelete/GetDeleteRecurrenceModal'; var gDeleteRecurrenceModalData; //Store response data var gGetRecurrenceHasExceptionsURL = '/Admin/Facilities/ReservationRecurrenceHasExceptions'; var gApproveEventURL = '/Admin/Facilities/FacilityReservationItemAction'; var gDeclineEventURL = '/Admin/Facilities/FacilityReservationItemAction'; var gDeleteEventStartDate; var DeleteRecurrenceType = { None: 0, DeleteAll: 1, DeleteFutureOnly: 2, DeleteOccurrenceOnly: 3, DeleteAllExcludeModified: 4, DeleteFutureOnlyExcludeModified: 5 }; var BulkActions = { PUBLISH: 1, UNPUBLISH: 2, SUBMIT: 4, DECLINE: 8, DELETE: 16, APPROVE: 32 }; $(document).ready(function () { $(document).click(function (e) { var shouldPropagate = self.onMouseDownFunction(e); if (!shouldPropagate) e.preventDefault(); else return true; }); gMinStartTime = document.getElementById("hdnMinStartTimeHour").value; gMaxEndTime = document.getElementById("hdnMaxEndTimeHour").value; gWVFirstDay = document.getElementById("hdnWvFirstDay").value; gIsFE = self.stringToBoolean($("#hdnIsFrontEnd").val()); gIsMainSubCalHidden = self.stringToBoolean($("#hdnFCIsMainSubCalHidden").val()); if (parseInt($("#hdnFCSubCalendarListCount").val()) > 1) { self.selectAllClick(); } $('#datepicker').datepicker({ altField: '#from', altFormat: 'mmddyyyy', showOn: 'button', buttonImage: '/Common/Images/Calendar/CalendarSelectSmall.png', buttonImageOnly: true, buttonText: 'Choose Month', onSelect: self.datePickerOnSelect }); // Click handler for the "Close" button in event details $(document).delegate('#btnFCClose', 'click', function (e) { e.preventDefault(); self.closeDetailsModal(); }); // Click handler for the "Delete Event" button in admin options $(document).delegate('#btnRemoveEvent', 'click', function (e) { e.preventDefault(); self.canBeDeleted(this); }); // Click handler for the "View Reservation Form" button in admin options $(document).delegate('#btnViewReservationForm', 'click', function (e) { e.preventDefault(); self.getSubmissionInfo(this); }); // Click handler for the "Modify Event" button in admin options $(document).delegate('#btnModifyEvent', 'click', function (e) { e.preventDefault(); if (gModifyEventClickFunction == null) { self.modifyEventClick(this); } else { gModifyEventClickFunction(this); } }); // Click handler for the "Approve" button in admin options $(document).delegate('#btnApproveEvent', 'click', function (e) { e.preventDefault(); self.approveEvent(this); }); // Click handler for the "Cancel" button in admin options $(document).delegate('#btnDeclineEvent', 'click', function (e) { e.preventDefault(); self.declineEventClick(this); }); // Click handler for the "Close" button in calendar selection dropdown $(document).delegate('#btnFCCalSelClose', 'click', function (e) { e.preventDefault(); self.showHideCalendarSelection(true); }); // Click handler for the "Open" button in calendar selection dropdown $(document).delegate('#btnFCCalSelOpen', 'click', function (e) { e.preventDefault(); //self.showHideCalendarSelection(false); not needed handled with onMousedown }); // Click handler for the "Select All" checkbox in calendar selection dropdown $(document).delegate(gchkFCSubCalAll, 'click', function () { self.selectAllClick(); }); // Click handler for the "Main Calendar" checkbox in calendar selection dropdown $(document).delegate(gchkSubCalMain, 'click', function () { self.mainSubChecked(); }); // Click handler for the "Cancel" button in Recurrence Delete Modal $(document).delegate('#btnRecurrenceRemoveEvent', 'click', function (e) { e.preventDefault(); self.deleteEvent(gDeleteRecurrenceModalData); self.closeRecurrenceDeleteModal(); }); // Click handler for the "Delete Selected" button in Recurrence Delete Modal $(document).delegate('#btnRecurrenceRemoveEventCancel', 'click', function (e) { e.preventDefault(); self.closeRecurrenceDeleteModal(); }); $("input:checkbox[name^=" + gchkSubCalNameStart + "]").click(function () { self.setCheckedSubCalendars(gchkSubCalNameStart); self.refreshCalendarEvents(); }); }); self.createCalendar = function () { var calendar = $(gCalendarDivName).fullCalendar({ ignoreTimezone: true, timeFormat: { 'month': 'h(:mm)t', //7p start time only for space reasons 'agenda': 'h:mmt{ - h:mmt}' //7:00pm - 10:30pm }, defaultView: 'agendaWeek', header: { left: 'today', center: 'prev, title,next', right: 'month,agendaWeek,agendaDay' }, titleFormat: { month: self.titleFormatMonth(), week: self.titleFormatWeek(), day: self.titleFormatDay() }, columnFormat: { month: self.columnFormatMonth(), week: self.columnFormatWeek(), day: self.columnFormatDay() }, minTime: gMinStartTime, maxTime: gMaxEndTime, allDayDefault: false, firstDay: gWVFirstDay, allDaySlot: gAllDaySlot, //Not programmed yet for splitting of events and combining of overlapping events editable: gIsEditable, //This determines if the events can be dragged and resized. Enables/disables both at the same time. To disable one use disableDragging and disableResizing. disableDragging: gDisableDragging, disableResizing: gDisableResizing, eventDrop: function (event, dayDelta, minuteDelta, allDay, revertFunc, jsEvent, ui, view) { self.eventDropHandler(event, dayDelta, minuteDelta, allDay, revertFunc, jsEvent, ui, view); }, eventResize: function (event, dayDelta, minuteDelta, revertFunc) { self.eventResizeHandler(event, dayDelta, minuteDelta, revertFunc); }, selectable: gIsSelectable, selectHelper: gIsSelectable, //When selecting shows the time range and styles instead of just highlighting events: function (start, end, callback) { //The event for filling events on the calendar self.setEvent(start, end, callback); }, eventClick: function (calEvent, jsEvent, view) { //The event called when the user clicks an event self.openDetailsModal(calEvent, jsEvent, view); }, select: function (start, end, allDay) { //The event called when the user selects a time on the calendar var view = $('#calendar').fullCalendar('getView'); allDay = $('#hdnForceAllDay').val() === 'True'; if (gSelectableFunction != null && view != null && view.name != 'month') { gSelectableFunction(start, end, allDay); } calendar.fullCalendar('unselect'); } }); }; self.isDayBeforeMonth = function () { var retval = false; if (getDateFormat().toLowerCase() == "dd/mm/yyyy") { retval = true; } return retval; }; self.titleFormatMonth = function () { return "MMMM yyyy"; // September 2012 }; self.titleFormatWeek = function () { var retVal; if (self.isDayBeforeMonth()) { retVal = "d MMMM [ yyyy]{ '—' d MMMM',' yyyy}"; // 7 September - 13 September 2012 } else { retVal = "MMMM d[ yyyy]{ '—' MMMM d',' yyyy}"; // September 7 - September 13 2012 } return retVal; }; self.titleFormatDay = function () { var retVal; if (self.isDayBeforeMonth()) { retVal = "dddd, d MMM, yyyy"; // Tuesday, 8 Sep, 2012 } else { retVal = "dddd, MMM d, yyyy"; // Tuesday, Sep 8, 2012 } return retVal; }; self.columnFormatMonth = function () { return 'ddd'; // Mon }; self.columnFormatWeek = function () { var retVal; if (self.isDayBeforeMonth()) { retVal = "ddd d/M"; // Mon 28/6 } else { retVal = "ddd M/d"; // Mon 6/28 } return retVal; }; self.columnFormatDay = function () { var retVal; if (self.isDayBeforeMonth()) { retVal = "dddd d/M"; // Monday 28/6 } else { retVal = "dddd M/d"; // Monday 6/28 } return retVal; }; self.datePickerOnSelect = function (dateText, inst) { var selDate = new Date(dateText); $(gCalendarDivName).fullCalendar('gotoDate', selDate); }; self.openDetailsModal = function (calEvent, jsEvent, view, detailsData) { if (calEvent != null && calEvent.IsClosed && !calEvent.IsMultipleEvents) { return false; } if (detailsData == null) { detailModalData = self.getEventDetailsData(calEvent); } else { detailModalData = detailsData; } openCpModal({ title: 'Details', className: 'modalEventDetails', isFrontEnd: gIsFE, autoAdjust: true, verticalCenter: true, data: detailModalData, url: gGetEventDetailsURL }); if (parseInt($("#hdnEventDetailsEventCount").val()) < 1) { self.closeDetailsModal(); } gModalLoaded = true; }; self.closeDetailsModal = function () { detailModalData = null; hideModal('modalEventDetails'); }; self.getEventDetailsData = function (calEvent) { var calIDs = self.getCheckedCalendarIds(); var data; var catID = $('#hiddenCategoryID').val() == undefined ? null : $('#hiddenCategoryID').val(); if (calEvent.id > 0) { data = { calIDs: calIDs, id: calEvent.id, isFrontEnd: gIsFE, isTimeBetweenReservations: calEvent.IsTimeBetweenReservations, categoryID: catID }; } else { data = { calIDs: calIDs, start: calEvent.start.format("MM/dd/yyyy HH:mm"), end: calEvent.end.format("MM/dd/yyyy HH:mm"), id: calEvent.id, isFrontEnd: gIsFE, isTimeBetweenReservations: false, categoryID: catID }; } if (calEvent.TimeBetweenReservationIDs != null) data.timeBetweenReservationIDs = calEvent.TimeBetweenReservationIDs; return data; }; self.getCheckedCalendarIds = function () { return document.getElementById("hdnSubCalendarList").value; }; self.genericAJAX = function (url, type, json, callBack, showLoadingMessage, async, skipErrorMessage) { if (showLoadingMessage == null) { showLoadingMessage = true; } if (async == null) { async = true; } if (skipErrorMessage == null) { skipErrorMessage = false; } var callbackResponse; $.ajax({ url: url, type: type, data: json, async: async, success: function (response) { if (response.ErrorMessage && !skipErrorMessage) alert(response.ErrorMessage); else if (response.RedirectURL) window.location.href = response.RedirectURL; else if (callBack) callbackResponse = callBack(response); }, beforeSend: function () { if (showLoadingMessage) { ajaxPostBackStart('Loading'); } }, complete: function () { if (showLoadingMessage) { ajaxPostBackEnd(); } }, error: function (xhr, textStatus, exception) { alert('Error: ' + xhr.statusText + '\nStatus: ' + xhr.status); } }); return callbackResponse; }; self.showHideDropDown = function (id, isForceHide) { var isVisible = $(id).is(':visible'); if (isVisible || isForceHide) { $(id + 'Container').css('z-index', ''); $(id).hide(); } else { $(id + 'Container').css('z-index', '10001'); $(id).show(); } }; self.showHideCalendarSelection = function (isForceHide) { if (isForceHide == null) isForceHide = false; self.showHideDropDown('#subFacilitiesPopout', isForceHide); }; self.selectAllClick = function () { self.selectAll(gchkSubCalNameStart, $(gchkFCSubCalAll).is(':checked')); self.setCheckedSubCalendars(gchkSubCalNameStart); self.refreshCalendarEvents(); }; self.selectAll = function (chkName, check) { $("input:checkbox[name^=" + chkName + "]").each(function () { $(this).attr('checked', check); }); if (!gIsMainSubCalHidden) { $(gchkSubCalMain).attr('checked', check); } }; self.setCheckedSubCalendars = function (chkName) { var arr = $("input:checkbox[name^=" + chkName + "]:checked").map(function () { return this.value; }); $(ghdnSubCalendarList).val(arr.get().join(",")); if ($(gchkSubCalMain).is(':checked')) { $(ghdnSubCalendarList).val($(ghdnSubCalendarList).val() + ',' + $(gchkSubCalMain).val()); } if ($("input:checkbox[name^=" + chkName + "]:not(:checked)").length > 0) { $(gchkFCSubCalAll).attr('checked', false); } else { if (gIsMainSubCalHidden || (!gIsMainSubCalHidden && $(gchkSubCalMain).is(':checked'))) { $(gchkFCSubCalAll).attr('checked', true); } else { $(gchkFCSubCalAll).attr('checked', false); } } }; self.getCheckedCalendarInfo = function () { var subCalendarJSON = []; //Will map to the SubCalendar Entity //Get all child calendars $("input:checkbox[name^=" + gchkSubCalNameStart + "]:checked").each(function () { var id = this.value; subCalendarJSON.push( { Id: id, IsMain: false, EventBackgroundColor: $("#hdnFCCalendarBackgroundColor_" + id).val(), EventBorderColor: $("#hdnFCCalendarBorderColor_" + id).val(), EventTextColor: $("#hdnFCCalendarTextColor_" + id).val() }); }); //Get main calendar if ($(gchkSubCalMain).is(':checked')) { var id = $(gchkSubCalMain).val(); subCalendarJSON.push( { Id: id, IsMain: true, EventBackgroundColor: $("#hdnFCCalendarBackgroundColor_" + id).val(), EventBorderColor: $("#hdnFCCalendarBorderColor_" + id).val(), EventTextColor: $("#hdnFCCalendarTextColor_" + id).val() }); } return subCalendarJSON; }; self.setEvent = function (start, end, callback) { var calView = $(gCalendarDivName).fullCalendar('getView').name; var selectedCals = { subCalendarString: JSON.stringify(self.getCheckedCalendarInfo()), start: self.convertDateToJson(start), end: self.convertDateToJson(end), calIDs: document.getElementById("hdnSubCalendarList").value, curCalView: calView, minStartHour: gMinStartTime, maxStartHour: gMaxEndTime, isFrontEnd: gIsFE, isEditable: gIsEditable }; self.genericAJAX(gGetCalendarEventsURL, 'POST', selectedCals, callback, false); }; self.unCheckMainSub = function () { $(gchkSubCalMain).attr('checked', false); }; self.mainSubChecked = function () { if (gIsMainSubCalHidden) { $(gchkSubCalMain).attr('checked', true); } else if ($(gchkSubCalMain).is(':checked')) { self.setCheckedSubCalendars(gchkSubCalNameStart); } self.refreshCalendarEvents(); }; self.seeIfDropdownShouldClose = function (event) { var evTarget = event.target; if ($('#subFacilitiesPopout').is(':hidden') || $(event.srcElement).hasClass("SubCalendarDropDown") || (evTarget != null && evTarget.parentNode.classList.contains("SubCalendarDropDown"))) { return false; } else { return true; } }; self.convertDateToJson = function (datetoConvert) { return Math.round(datetoConvert.getTime() / 1000); }; self.getEventIDFromAdminMenu = function (event) { return parseInt($(event).parents("div.popoutContainer").find("#hdnEventDetailID").val()); }; self.getEventStartDateFromAdminMenu = function (event) { return $(event).parents("div.popoutContainer").find("#hdnEventStartDate").val(); }; self.modifyEventClick = function (event) { var calEventID = parseInt($(event).parents("div.popoutContainer").find("#hdnEventDetailCalendarEventID").val()); var createdFromModuleID = parseInt($(event).parents("div.popoutContainer").find("#hdnCreatedFromModuleID").val()); if (calEventID > 0) { alert($("#hdnCalendarModuleModify").val()) } else if (createdFromModuleID > 0) { alert($("#hdnActivitiesModuleModify").val()); } else { //Check recurrence see if they are modifying the series or the occurence var recurrenceID = parseInt($(event).parents("div.popoutContainer").find("#hdnRecurrenceID").val()); var locationID = parseInt($(event).parents("div.popoutContainer").find("#hdnLocationID").val()); var isRecurrenceDateModified = self.stringToBoolean($(event).parents("div.popoutContainer").find("#hdnIsRecurrenceDateModified").val()); var modifyJson = DefaultView.modifyPrompt(isRecurrenceDateModified, recurrenceID); var eventID = self.getEventIDFromAdminMenu(event); var startDate = new Date(self.getEventStartDateFromAdminMenu(event)); var endDate = new Date($(event).parents("div.popoutContainer").find("#hdnEventEndDate").val()); var isAllDay = self.stringToBoolean($(event).parents("div.popoutContainer").find("#hdnAllDay").val()); openReservationModal(locationID, gIsFE, null, true); var dateFormat = getDateFormat(); dateFormat = dateFormat.replace("mm", "MM"); setDateTimesInModal(startDate.format(dateFormat), startDate.format("h:mm tt"), endDate.format(dateFormat), endDate.format("h:mm tt"), isAllDay); setModifyEventVariables(eventID, true, modifyJson.recurrenceID, modifyJson.isRecurrenceDateModified, modifyJson.modifySeries); $('.modalNewReservation').css('zIndex', $('.modalNewReservation').css('zIndex') + 1); //Make sure modal shows up in front of other modal } }; self.canBeDeleted = function (event) { var calEventID = parseInt($(event).parents("div.popoutContainer").find("#hdnEventDetailCalendarEventID").val()); var createdFromModuleID = parseInt($(event).parents("div.popoutContainer").find("#hdnCreatedFromModuleID").val()); var eventID = self.getEventIDFromAdminMenu(event); gDeleteEventStartDate = self.getEventStartDateFromAdminMenu(event); gRecurrenceID = parseInt($(event).parents("div.popoutContainer").find("#hdnRecurrenceID").val()); gIsRecurrenceDateModified = self.stringToBoolean($(event).parents("div.popoutContainer").find("#hdnIsRecurrenceDateModified").val()); if (eventID > 0) { if (calEventID > 0) { alert($("#hdnCalendarModuleDelete").val()); } else if (createdFromModuleID > 0) { alert($("#hdnActivitiesModuleModify").val()); } else { var data = { id: eventID }; self.genericAJAX(gCanBeDeletedUrl, 'POST', data, self.canBeDeletedSuccess, true); } } }; self.canBeDeletedSuccess = function (response) { if (response.Success) { if (self.canBeDeletedSuccessPrompt(response)) { if (self.isRecurrence()) { self.openRecurrenceDeleteModal(response); } else { self.deleteEvent(response); } } } else { if (response.Alert != undefined && response.Alert) { alert(response.Alert); } else { //Response must have came in as error message do not continue shown in ajax caller } } }; self.canBeDeletedSuccessPrompt = function (response) { var success; var deletePrompt; if (response.Confirm != undefined && response.Confirm) { deletePrompt = response.Confirm; } else if (!self.isRecurrence()) { deletePrompt = $("#hdnDeletePrompt").val(); } if (deletePrompt) { success = confirm(deletePrompt); } else { success = true; } return success; }; self.deleteEvent = function (response) { response = self.getDeleteRecurrenceType(response); var data = { id: response.ReservationID, categoryID: $('#hiddenCategoryID').val(), recurrenceID: gRecurrenceID, isRecurrenceDateModified: gIsRecurrenceDateModified, deleteRecurrenceType: response.deleteRecType, eventStartDate: gDeleteEventStartDate }; self.genericAJAX(gDeleteUrl, 'POST', data, self.eventDeleted, true); }; self.eventDeleted = function () { if (detailModalData == null) { self.refreshCalendarEvents(); self.closeDetailsModal(); } else if (detailModalData.start == null) { self.refreshCalendarEvents(); self.closeDetailsModal(); } else { self.refreshCalendarEvents(); self.refreshDetailsModal(); } }; self.openRecurrenceDeleteModal = function (response) { gDeleteRecurrenceModalData = response; openCpModal({ title: 'Delete Event Series', className: 'modalRecurrenceDelete', isFrontEnd: gIsFE, autoAdjust: true, data: null, onClose: self.closeRecurrenceDeleteModal, url: gGetDeleteRecurrenceModalURL, elementID: 'divRecurrenceDeleteModal' }); }; self.closeRecurrenceDeleteModal = function () { gDeleteRecurrenceModalData = null; hideModal('modalRecurrenceDelete'); return false; }; self.refreshDetailsModal = function () { if (detailModalData != null) { self.openDetailsModal(null, null, null, detailModalData); } }; self.getSubmissionInfo = function (event) { var eventID = self.getEventIDFromAdminMenu(event); if (eventID > 0) { var data = { id: eventID }; self.genericAJAX('/Admin/Facilities/Calendar/GetSubmissionAndFormID', 'POST', data, self.loadSubmissionForm, false); } }; self.loadSubmissionForm = function (response) { if ((response == null) || (response.NoSubmission != null && response.NoSubmission == true)) { alert($("#hdnNoSubmissionFormPrompt").val()); } else if (response.isLegacy != null && response.isLegacy.toLowerCase() == 'true') { var message = $('#hdnLegacyReservationMessage').val(); alert(message); } else { var data = { id: response.SubmissionID, formID: response.FormID, backURL: window.location.pathname + window.location.search, submissionDataDisplayType: 0 }; window.location = '/Admin/Facilities/Reservations/Edit' + '?' + $.param(data); } }; self.refreshCalendarEvents = function () { $(gCalendarDivName).fullCalendar('refetchEvents'); }; self.eventDropHandler = function (event, dayDelta, minuteDelta, allDay, revertFunc, jsEvent, ui, view) { if (event.CalendarEventID > 0) { alert($("#hdnCalendarModuleModify").val()); revertFunc(); } else if (event.CreatedFromModuleID != null && event.CreatedFromModuleID > 0) { alert($("#hdnActivitiesModuleModify").val()); revertFunc(); } else if (gEventDropFunction != null) { gEventDropFunction(event, dayDelta, minuteDelta, allDay, revertFunc, jsEvent, ui, view); } }; self.eventResizeHandler = function (event, dayDelta, minuteDelta, revertFunc) { if (event.CalendarEventID > 0) { alert($("#hdnCalendarModuleModify").val()); revertFunc(); } else if (event.CreatedFromModuleID != null && event.CreatedFromModuleID > 0) { alert($("#hdnActivitiesModuleModify").val()); revertFunc(); } else if (gEventResizeFunction != null) { gEventResizeFunction(event, dayDelta, minuteDelta, revertFunc); } }; self.stringToBoolean = function (checkString) { if (checkString.toLowerCase() === 'true') { return true; } else { return false; } }; self.onMouseDownFunction = function (event) { //If the page is already overridding the onmousedown then call this function from the parent page if ($('.popout').val() != undefined) { var target = window.event ? window.event.srcElement : event.target; if (target.id == 'popOverOpen1') { var popUpMenuId = '#popOver1_' + target.getAttribute('value'); if ($(popUpMenuId).hasClass('hidden')) { $(popUpMenuId).removeClass('hidden'); } else { $(popUpMenuId).addClass('hidden'); } return false; } else if (!$.contains($('.popout')[0], target)) { $('.popout').each(function () { if (!$(this).hasClass('hidden')) { $(this).addClass('hidden'); } }); } } if (($('#subFacilitiesPopout').val() != undefined) && ($('#btnFCCalSelOpen').val() != undefined)) { target = window.event ? window.event.srcElement : event.target; if ($.contains($('#btnFCCalSelOpen')[0], target)) { self.showHideCalendarSelection(false); } else if (!$.contains($('#subFacilitiesPopout')[0], target)) { self.showHideCalendarSelection(true); } } return true; }; self.modifyPrompt = function (isRecurrenceDateModified, recurrenceID) { var retJson = { recurrenceID: recurrenceID, isRecurrenceDateModified: isRecurrenceDateModified, modifySeries: false }; if (!isRecurrenceDateModified && recurrenceID > 0) { if (confirm($("#hdnModifyRecurrencePrompt").val())) { retJson.modifySeries = true; } else { retJson.isRecurrenceDateModified = true; } } return retJson; }; self.isRecurrence = function () { var isRec = false; if (!gIsRecurrenceDateModified && gRecurrenceID > 0) { isRec = true; } return isRec; }; self.recurrenceHasExceptions = function (recurrenceID, isRecurrenceDateModified, isModify) { var response; if (!isRecurrenceDateModified && recurrenceID > 0) { var data = { id: recurrenceID, isModify: isModify }; response = self.genericAJAX(gGetRecurrenceHasExceptionsURL, 'POST', data, self.recurrenceHasExceptionsSuccess, true, false); } else { response = {HasExceptions: false}; } return response; }; self.recurrenceHasExceptionsSuccess = function (response) { return response; }; //This function will get the recurrence type and if needed it will check to see if there are modifications to the series self.getDeleteRecurrenceType = function (response) { var deleteRecType = 0; if (self.isRecurrence()) { deleteRecType = $('input:radio[name=deleteType]:checked').val(); if (deleteRecType == DeleteRecurrenceType.DeleteAll || deleteRecType == DeleteRecurrenceType.DeleteFutureOnly) { var responseHasExc = self.recurrenceHasExceptions(gRecurrenceID, gIsRecurrenceDateModified, false); if (responseHasExc.Confirm) { if (!confirm(responseHasExc.Confirm)) { if (deleteRecType == DeleteRecurrenceType.DeleteAll) { deleteRecType = DeleteRecurrenceType.DeleteAllExcludeModified; } else if (deleteRecType == DeleteRecurrenceType.DeleteFutureOnly) { deleteRecType = DeleteRecurrenceType.DeleteFutureOnlyExcludeModified; } } } } } response.deleteRecType = deleteRecType; return response; }; self.approveEvent = function (event, adminOverride) { var data = { id: self.getEventIDFromAdminMenu(event), action: BulkActions.APPROVE, adminOverride: adminOverride == null ? false : adminOverride }; self.genericAJAX(gApproveEventURL, 'POST', data, function (response) { self.approveEventSuccess(response, event) }, false); }; self.approveEventSuccess = function (response, event) { if (response.ConfirmMessage != null) { if (confirm(response.ConfirmMessage)) { self.approveEvent(event, true); } } else { self.refreshCalendarEvents(); self.refreshDetailsModal(); } }; self.declineEventClick = function (event) { EnterComments.openCommentModal(null, null, self.declineEvent, { id: self.getEventIDFromAdminMenu(event) }); }; self.declineEvent = function (event, confirmData) { event.preventDefault(); var data = { id: confirmData.id, action: BulkActions.DECLINE, declineEmailMessage: event.data['textArea'].val() }; self.genericAJAX(gApproveEventURL, 'POST', data, self.declineEventSuccess, false); }; self.declineEventSuccess = function (response) { EnterComments.closeClick(); self.eventDeleted(); }; return { init: function () { self.createCalendar(); }, reloadDetailsModal: function () { self.refreshDetailsModal(); }, onMouseDownFunction: function (event) { self.onMouseDownFunction(event); }, setGetEventDetailsURL: function (url) { gGetEventDetailsURL = url; }, setGetCalendarEventsURL: function (url) { gGetCalendarEventsURL = url; }, setCanBeDeletedUrl: function (url) { gCanBeDeletedUrl = url; }, setDeleteUrl: function (url) { gDeleteUrl = url; }, setRecurrenceHasExceptionsURL: function (url) { gGetRecurrenceHasExceptionsURL = url; }, setRecurrenceModalUrl: function (url) { gGetDeleteRecurrenceModalURL = url; }, setDeclineEventURL: function (url) { gDeclineEventURL = url; }, setApproveEventURL: function (url) { gApproveEventURL = url; }, setSelectableFunction: function (selectableFunction) { gSelectableFunction = selectableFunction; gIsSelectable = selectableFunction != null; }, setEditableFunctions: function (eventDropFunction, eventResizeFunction) { gEventDropFunction = eventDropFunction; gEventResizeFunction = eventResizeFunction; gDisableDragging = eventDropFunction == null; gDisableResizing = eventResizeFunction == null; if (gDisableDragging && gDisableResizing) { gIsEditable = false; } else { gIsEditable = true; } }, setGetSubmissionInfoFunction: function (getSubmissionInfoFunction) { self.getSubmissionInfo = getSubmissionInfoFunction; }, setloadSubmissionForm: function (loadSubmissionFormFunction) { self.loadSubmissionForm = loadSubmissionFormFunction; }, setmodifyEventClickFunction: function (modifyEventClickFunction) { gModifyEventClickFunction = modifyEventClickFunction; }, modifyPrompt: function (isRecurrenceDateModified, recurrenceID) { return self.modifyPrompt(isRecurrenceDateModified, recurrenceID); }, recurrenceHasExceptions: function (recurrenceID, isRecurrenceDateModified, isModify) { return self.recurrenceHasExceptions(recurrenceID, isRecurrenceDateModified, isModify); } }; } ()