UNPKG

calenstyle

Version:

CalenStyle is a Responsive Drag-and-Drop Event Calendar for Web, iOS, Android & Windows. CalenStyle is customizable plugin having multiple, clean-designed event calendar templates specially designed for web & mobile applications.

1,598 lines (1,402 loc) 219 kB
/* ----------------------------------------------------------------------------- CalenStyle - Responsive Event Calendar Version 2.0.8 Copyright (c)2017 Lajpat Shah Contributors : https://github.com/nehakadam/CalenStyle/contributors Repository : https://github.com/nehakadam/CalenStyle Homepage : https://nehakadam.github.io/CalenStyle ----------------------------------------------------------------------------- */ //"use strict"; function CalEvent(ceId, ceAllDay, ceStartDate, ceEndDate, ceType, ceTitle, ceDesc, ceUrl) { this.id = ceId; this.isAllDay = ceAllDay; this.start = ceStartDate; this.end = ceEndDate; this.type = ceType; this.title = ceTitle; this.desc = ceDesc; this.url = ceUrl; } function CalEventSeg(ceSegDayNo, ceEventId, ceEventDisplayId, ceSegId, ceSegStartDate, ceSegEndDate, ceSegLeftColumn, ceSegColumns) { this.dayNo = ceSegDayNo; this.eventId = ceEventId; this.eventDisplayId = ceEventDisplayId; this.eventSegId = ceSegId; this.eventSegStart = ceSegStartDate; this.eventSegEnd = ceSegEndDate; this.segLeftColumn = ceSegLeftColumn; this.segColumns = ceSegColumns; } // --------------------------------- Global Variables Start -------------------------------------- $.CalenStyle = $.CalenStyle || { name: "CalenStyle", version: "1.0.0", i18n: {}, // Internationalization Objects defaults: //Plugin Defaults { sectionsList: ["Header", "Calendar"], language: "", veryShortDayNames: ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"], shortDayNames: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"], fullDayNames: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"], shortMonthNames: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"], fullMonthNames: ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"], numbers: ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"], eventTooltipContent: "Default", formatDates: {}, slotTooltipContent: function(oSlotAvailability) { if(oSlotAvailability.status === "Busy") return ""; else if(oSlotAvailability.status === "Free") { if(oSlotAvailability.count === undefined || oSlotAvailability.count === null) return "<div class=cavTooltipBookNow>Book Now</div>"; else return "<div class=cavTooltipSlotCount>" + oSlotAvailability.count + " slots available</div><div class=cavTooltipBookNow>Book Now</div>"; } }, miscStrings: { today: "Today", week: "Week", allDay: "All Day", ends: "Ends", emptyEventTitle: "(No Title)", emptyGoogleCalendarEventTitle: "Busy" }, duration: "Default", durationStrings: { y: ["year ", "years "], M: ["month ", "months "], w: ["w ", "w "], d: ["d ", "d "], h: ["h ", "h "], m: ["m ", "m "], s: ["s ", "s "] }, viewsToDisplay: [ { viewName: "DetailedMonthView", viewDisplayName: "Month" }, { viewName: "WeekView", viewDisplayName: "Week" }, { viewName: "DayView", viewDisplayName: "Day" }, { viewName: "AgendaView", viewDisplayName: "Agenda" } ], visibleView: "DetailedMonthView", selectedDate: new Date(), headerComponents: { DatePickerIcon: "<span class='cContHeaderButton cContHeaderDatePickerIcon clickableLink cs-icon-Calendar'></span>", FullscreenButton: function(bIsFullscreen) { var sIconClass = (bIsFullscreen) ? "cs-icon-Contract" : "cs-icon-Expand"; return "<span class='cContHeaderButton cContHeaderFullscreen clickableLink "+ sIconClass +"'></span>"; }, PreviousButton: "<span class='cContHeaderButton cContHeaderNavButton cContHeaderPrevButton clickableLink cs-icon-Prev'></span>", NextButton: "<span class='cContHeaderButton cContHeaderNavButton cContHeaderNextButton clickableLink cs-icon-Next'></span>", TodayButton: "<span class='cContHeaderButton cContHeaderToday clickableLink'></span>", HeaderLabel: "<span class='cContHeaderLabelOuter'><span class='cContHeaderLabel'></span></span>", HeaderLabelWithDropdownMenuArrow: "<span class='cContHeaderLabelOuter clickableLink'><span class='cContHeaderLabel'></span><span class='cContHeaderButton cContHeaderDropdownMenuArrow'></span></span>", MenuSegmentedTab: "<span class='cContHeaderMenuSegmentedTab'></span>", MenuDropdownIcon: "<span class='cContHeaderButton cContHeaderMenuButton clickableLink'>&#9776;</span>" }, headerSectionsList: { left: ["DatePickerIcon", "PreviousButton", "NextButton"], center: ["HeaderLabel"], right: ["MenuSegmentedTab"] }, dropdownMenuElements: ["ViewsToDisplay"], // ["ViewsToDisplay", "DatePicker"] parentObject: null, datePickerObject: null, formatSeparatorDateTime: " ", formatSeparatorDate: "-", formatSeparatorTime: ":", is24Hour: false, inputDateTimeFormat: "dd-MM-yyyy HH:mm:ss", eventDuration: 30, // In minutes allDayEventDuration: 1, // In days timeIndicatorUpdationInterval: 15, unitTimeInterval: 30, // [5, 10, 15, 20, 30] timeLabels: "Hour", // ["Hour", "All"] inputTZOffset: "+05:30", tz: "Asia/Calcutta", // For Google Calendar outputTZOffset: "+05:30", // +05:30 weekStartDay: 1, weekNumCalculation: "US", // ["US", "Europe/ISO"] daysInCustomView: 4, daysInDayListView: 7, daysInAppointmentView: 4, agendaViewDuration: "Month", // ["Month", "Week", "CustomDays"] daysInAgendaView: 15, agendaViewTheme: "Timeline2", // ["Timeline1", "Timeline2", "Timeline3"] showDaysWithNoEventsInAgendaView: false, fixedHeightOfWeekPlannerViewCells: true, quickAgendaViewDuration: "Week", // ["Week", "CustomDays"] daysInQuickAgendaView: 5, navigateOneDayInQuickAgendaView: false, taskPlannerViewDuration: "Week", // ["Week", "CustomDays"] daysInTaskPlannerView: 5, fixedHeightOfTaskPlannerView: true, navigateOneDayInTaskPlannerView: false, transitionSpeed: 600, showTransition: false, fixedNumOfWeeksInMonthView: false, displayWeekNumInMonthView: false, actionOnDayClickInMonthView: "ModifyEventList", // ["ModifyEventList", "ChangeDate", "DisplayEventListDialog"] eventIndicatorInMonthView: "Events", // ["DayHighlight", "Events", "Custom"] eventIndicatorInDatePicker: "DayNumberBold", // ["DayNumberBold", "Dot"] eventIndicatorInDayListView: "DayHighlight", // ["DayHighlight", "Custom"] averageEventsPerDayForDayHighlightView: 5, hideExtraEvents: true, hiddenEventsIndicatorLabel: "+(count) more", hiddenEventsIndicatorAction: "ShowEventDialog", addEventsInMonthView: true, displayEventsInMonthView: true, isDragNDropInMonthView: true, isTooltipInMonthView: false, isDragNDropInDetailView: true, isResizeInDetailView: true, isTooltipInDetailView: false, isDragNDropInQuickAgendaView: true, isTooltipInQuickAgendaView: false, isDragNDropInTaskPlannerView: true, isTooltipInTaskPlannerView: false, isTooltipInAppointmentView: true, actionBarHeight: 30, filterBarPosition: "Top", // ["Top", "Bottom", "Left", "Right"] filterBarHeight: 200, filterBarWidth: 200, eventFilterCriteria: [], noneSelectedFilterAction: "SelectNone", //["SelectNone", "SelectAll"] calendarBorderColor: "FFFFFF", changeCalendarBorderColorInJS: false, // Events-specific properties extraMonthsForDataLoading: 1, deleteOldDataWhileNavigating: true, datasetModificationRule: "Default", //["Default", "ReplaceAll", "ReplaceSpecified"] changeColorBasedOn: "EventCalendar", // ["Event", "EventCalendar", "EventSource"] borderColor: "", textColor: "FFFFFF", onlyTextForNonAllDayEvents: true, eventColorsArray: ["C0392B", "D2527F", "674172", "4183D7", "336E7B", "36D7B7", "68C3A3", "E87E04", "6C7A89", "F9690E"], eventIcon: "Dot", // ["Dot", "cs-icon-Event"] hideEventIcon: { Default: false, DetailedMonthView: false, MonthView: false, WeekView: false, DayView: false, CustomView: false, QuickAgendaView: false, TaskPlannerView: false, DayEventDetailView: false, AgendaView: false, WeekPlannerView: false }, hideEventTime: { Default: false, DetailedMonthView: false, MonthView: false, WeekView: false, DayView: false, CustomView: false, QuickAgendaView: false, TaskPlannerView: false, DayEventDetailView: false, AgendaView: false, WeekPlannerView: false }, businessHoursSource: [ { day: 1, times: [{startTime: "10:00", endTime: "17:00"}] }, { day: 2, times: [ {startTime: "09:00", endTime: "13:00"}, {startTime: "14:00", endTime: "18:00"} ] }, { day: 3, times: [{startTime: "10:00", endTime: "17:00"}] }, { day: 4, times: [ {startTime: "09:00", endTime: "13:00"}, {startTime: "14:00", endTime: "18:00"} ] }, { day: 5, times: [{startTime: "10:00", endTime: "17:00"}] }, { day: 6, times: [ {startTime: "09:00", endTime: "13:00"}, {startTime: "14:00", endTime: "18:00"} ] } ], excludeNonBusinessHours: false, isNonBusinessHoursDroppable: true, isRestrictedSectionDroppable: true, eventOrTaskStatusIndicators: [ { name: "Overdue", color: "E74C3C" }, { name: "Completed", color: "27AE60" }, { name: "InProgress", color: "F1C40F" } ], calDataSource: [], datePickerCalDataSource: [ { config: { sourceCountType: "Event" } } ], adjustViewOnWindowResize: true, useHammerjsAsGestureLibrary: false, //------------------ Callback Functions Start -------------------------- initialize: null, // Custom HeaderView Callbacks modifyHeaderViewLabels: null, addEventHandlersInHeader: null, // Data Loading Callbacks dataLoadingStart: null, dataLoadingEnd: null, // Calendar Navigation Callbacks cellClicked: null, viewLoaded: null, previousButtonClicked: null, nextButtonClicked: null, todayButtonClicked: null, visibleViewChanged: null, modifyCustomView: null, // Event List related Callbacks displayEventsForPeriodInList: null, displayEventsForPeriodInListInAgendaView: null, eventListAppended: null, // Event Dialog related Callbacks displayEventListDialog: null, eventInADialogClicked: null, // Events and Appointment Time Slots related Callbacks eventRendered: null, eventsAddedInView: null, timeSlotsAddedInView: null, eventClicked: null, timeSlotClicked: null, saveChangesOnEventDrop: null, saveChangesOnEventResize: null, modifyFilterBarView: null, modifyActionBarView: null, addDaySummaryInTaskPlannerView: null //------------------ Callback Functions End -------------------------- }, tempDefaults: // Temporary Variables For Calculation Specific to CalenStyle Instance { sLoadType: "Load", iLoadCnt: 0, // iLoadCounter dLoadDt: new Date(), // LoadDate bViewLoaded: false, // bViewLoaded dHighlightDPV: [], // dArrDatesToHighlightInDatePickerView bDisFBar: false, // bDisplayFilterBar bDisMenu: false, // bDisplayViewSelectionMenu iMaxEvId: 0, // iMaxEventId iMxEvRw: 0, // iMaxEventsInRow oAEvents: [], // oArrEvents oASmEvSeg: [], // oArrSmallEventSegments oAADEvSeg: [], // oArrAllDayEventSegments oASrcCnt: [], // oArrSourceCount oAResSec: [], // oArrRestrictedSection oASltAvail: [], // oArrSlotAvailability oAECalendar: [], // oArrEventCalendar oAEvTaskStatus: [], bEvTskStatus: false, oSURLParams: [], iDocHtPrev: 0, // iDocumentHeightPrevious iUTmMS: 0, // iUnitTimeMS iUTmSlt: 0, // iUnitTimeSlots dVSDt: new Date(), // dViewStartDate dVEDt: new Date(), // dViewEndDate dVDSDt: new Date(), // dViewToDisplayStartDate dVDEDt: new Date(), // dViewToDisplayEndDate dCMDt: new Date(), // dCurrentMonthDate dPMDt: new Date(), // dPreviousMonthDate dNMDt: new Date(), // dNextMonthDate dPLSDt: new Date(), // dPrevLoadStartDate dPLEDt: new Date(), // dPrevLoadEndDate dNLSDt: new Date(), // dNextLoadStartDate dNLEDt: new Date(), // dNextLoadEndDate dDrgSDt: null, // dViewStartDate dDrgEDt: null, // dViewEndDate dAVDt: [], // dArrViewDates dAVDDt: [], // dArrViewDisplayDates iNoVDay: 0, // iNumberOfViewDays iNoVDayDis: 0, // iNumberOfViewDaysToDisplay iSelDay: 0, bAWkRw: [], // bArrWeekRow bADVCur: [], // bArrDVCurrent sADVInfo: [], // bArrDVInfo iBsDays: 0, // iBusinessDaysForWeek bABsDays: [], // bArrBusinessDaysForWeek oBsHours: {"start": "", "end": ""}, // oBusinessHours bChkDroppable: false, iWkInMonth: 6, // iNumberOfWeeksInMonth bDVResEv: false, // bDVResizingEvent bDVDrgEv: false, // bDVDraggingEvent bEvLgPresd: false, // bEventLongPressed bUrlClk: false, // bUrlClicked oEvEdt: null, // oEventBeingEdited oDVEdtgEv: null, // oDVEditingEvent bDVScrlg: false, // bDVScrolling fDVDayWth: 0, // bDVDaysWidth fADVDayLftPos: [], // fArrDVDaysLeftPos fAHrTpPos: [], // fArrHourTopPos bCMVDisEvLst: false, // bCMVDisplayEventList bDisABar: false, // bDisplayActionBar oAEvFltrCnt: [], // oArrEventFilterCount iCalHeight: 0, // iCalendarHeight bDyClDLV: false // bDayClickedInDayListView }, extra: // Common Temporary Variables { iCalenStyleObjCount: 0, iBorderOverhead: 1, iEventHeightOverhead: 4, iScrollbarWidth: 0, dToday: new Date(), iMS: { m: 6E4, h: 36E5, d: 864E5, w: 6048E5 }, sArrInputDateTimeFormats: ["DateObject", "UnixTimestamp", "ISO8601", "ISO8601Compact", "dd-MM-yyyy hh:mm:ss AA", "dd-MM-yyyy HH:mm:ss", "MM-dd-yyyy hh:mm:ss AA", "MM-dd-yyyy HH:mm:ss", "yyyy-MM-dd hh:mm:ss AA", "yyyy-MM-dd HH:mm:ss"], sArrViewsTypes: ["DetailedMonthView", "MonthView", "WeekView", "DayView", "AgendaView", "WeekPlannerView", "QuickAgendaView", "TaskPlannerView", "CustomView", "DayEventListView", "DayEventDetailView", "AppointmentView", "DatePicker"], bTouchDevice: ("ontouchstart" in document.documentElement ? true : false), sClickHandler: ("ontouchstart" in document.documentElement ? "click" : "click"), sClickHandlerButtons: ("ontouchstart" in document.documentElement ? "touchstart" : "click"), oArrCalenStyle: [], iEventHeights: { DetailedMonthView: 18, WeekView: 18, DayView: 18, CustomView: 18, DayEventDetailView: 18, QuickAgendaView: 18 }, oEventClass: { DetailedMonthView: "cdmvEvent", WeekView: "cdvEventAllDay", DayView: "cdvEventAllDay", CustomView: "cdvEventAllDay", DayEventDetailView: "cdvEventAllDay", QuickAgendaView: "cqavEvent" } } }; $.cf = { isValid: function(sValue) { return (sValue !== undefined && sValue !== null && sValue !== ""); }, compareStrings: function(sString1, sString2) { var to = this; if(sString1 !== null && sString1 !== undefined && sString2 !== null && sString2 !== undefined) { if(typeof sString1 === "string" && typeof sString2 === "string") { if(sString1.toLocaleLowerCase() === sString2.toLocaleLowerCase()) return true; } return false; } else { if((sString1 === null && sString2 === null) || (sString1 === undefined && sString2 === undefined)) return true; else return false; } }, getTimestamp: function() { return (new Date()).getTime(); }, getRGBAString: function(sHexcode, fAlpha) { var iRed = 0, iGreen = 0, iBlue = 0, sArrRGBA = sHexcode.match(/rgba\((\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3}),\s*(\d*(?:\.\d+)?)/i), sArrRGB = sHexcode.match(/rgb\((\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3})/i); if($.cf.isValid(sArrRGBA) && sArrRGBA.length > 0) { iRed = sArrRGBA[0]; iGreen = sArrRGBA[1]; iBlue = sArrRGBA[2]; } else if($.cf.isValid(sArrRGB) && sArrRGB.length > 0) { iRed = sArrRGB[0]; iGreen = sArrRGB[1]; iBlue = sArrRGB[2]; } else { sHexcode = (sHexcode.charAt(0) === "#") ? sHexcode.substring(1,7) : sHexcode; sHexcode = sHexcode.match(/([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})/)[0]; if(sHexcode.length === 3) { iRed = sHexcode.substring(0, 1); iRed = iRed + iRed; iRed = parseInt(iRed, 16); iGreen = sHexcode.substring(1, 2); iGreen = iGreen + iGreen; iGreen = parseInt(iGreen, 16); iBlue = sHexcode.substring(2, 3); iBlue = iBlue + iBlue; iBlue = parseInt(iBlue, 16); } else if(sHexcode.length === 6) { iRed = parseInt(sHexcode.substring(0,2), 16); iGreen = parseInt(sHexcode.substring(2,4), 16); iBlue = parseInt(sHexcode.substring(4,6), 16); } } return "rgba(" + iRed + ", " + iGreen + ", " + iBlue + ", " + fAlpha +")"; }, addHashToHexcode: function(sHexcode) { if($.cf.isValid(sHexcode)) { var sArrRGBA = sHexcode.match(/(rgba)/i), sArrHexHash = sHexcode.match(/(#+([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3}))/), sArrHex = sHexcode.match(/([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})/); if($.cf.isValid(sArrRGBA) && sArrRGBA.length > 0) return sHexcode; else if($.cf.isValid(sArrHexHash) && sArrHexHash.length > 0) return sArrHexHash[0]; else if($.cf.isValid(sArrHex) && sArrHex.length > 0) return "#" + sArrHex[0]; else return "#000000"; } else return sHexcode; }, getSizeValue: function($oElem, sCSSProp) { var sValue = $oElem.css(sCSSProp), iValue, iPerc, iParentValue; if(sValue !== undefined && sValue !== null && sValue !== "") { if(sValue.indexOf("px") !== -1) iValue = parseInt(sValue.replace("px", "")); else if(sValue.indexOf("%") !== -1) { iPerc = parseInt(sValue.replace("%", "")); iParentValue = $oElem.closest().width(); iValue = (iPerc % 100 * iParentValue); } if(iValue <= 0) return false; else return iValue; } else return false; } }; // --------------------------------- Global Variables End -------------------------------------- (function(factory) { if(typeof define === 'function' && define.amd) { // AMD. Register as an anonymous module. define(['jquery'], factory); } else if(typeof exports === 'object') { // Node/CommonJS module.exports = factory(require('jquery')); } else { // Browser globals factory(jQuery); } } (function ($) { $.fn.CalenStyle = function(options) { var oCalenStyle = $(this).data(), sArrDataKeys = Object.keys(oCalenStyle), iKey, sKey; if(options === null || options === undefined) { if(sArrDataKeys.length > 0) { for(iKey in sArrDataKeys) { sKey = sArrDataKeys[iKey]; if(sKey.search("plugin_CalenStyle_") !== -1) { return oCalenStyle[sKey]; } } } else { console.log("No CalenStyle Object Defined For This Element"); } } else if(typeof options === "string") { if($.cf.isValid(oCalenStyle)) { if(options === "destroy") { if(sArrDataKeys.length > 0) { for(iKey in sArrDataKeys) { sKey = sArrDataKeys[iKey]; if(sKey.search("plugin_CalenStyle_") !== -1) { $(this).children().remove(); $(".cElemDatePickerBg").remove(); $(this).removeData(); $(this).unbind(); $(this).removeClass("elem-CalenStyle"); $(document).unbind($.CalenStyle.extra.sClickHandler+".CalenStyle"); $(document).unbind($.CalenStyle.extra.sClickHandler+".CalenStyleDialog"); $(document).unbind($.CalenStyle.extra.sClickHandler+".MonthPicker"); $(document).unbind($.CalenStyle.extra.sClickHandler+".YearPicker"); oCalenStyle = oCalenStyle[sKey]; $(window).unbind("resize." + oCalenStyle.tv.pluginId); $(window).unbind("resize.CSDP." + oCalenStyle.tv.pluginId); var oArrTempCalenStyle = []; for(var iTempIndex = 0; iTempIndex < $.CalenStyle.extra.oArrCalenStyle.length; iTempIndex++) { var oThisCalenStyle = $.CalenStyle.extra.oArrCalenStyle[iTempIndex]; if(oThisCalenStyle.tv.pluginId !== oCalenStyle.tv.pluginId && oThisCalenStyle.tv.pluginId !== oCalenStyle.setting.datePickerObject.tv.pluginId) oArrTempCalenStyle.push(oThisCalenStyle); } $.CalenStyle.extra.oArrCalenStyle = oArrTempCalenStyle; console.log("Destroyed CalenStyle Object"); console.log(oCalenStyle); break; } } } else { console.log("No CalenStyle Object Defined For This Element"); } } } } else { return this.each(function() { $.CalenStyle.extra.iCalenStyleObjCount++; if(!$.data(this, "plugin_CalenStyle_" + $.CalenStyle.extra.iCalenStyleObjCount)) { oCalenStyle = new CalenStyle(this, options); $.data(this, "plugin_CalenStyle_" + $.CalenStyle.extra.iCalenStyleObjCount, oCalenStyle); oCalenStyle.loadView(); console.log("Calendar Object "); console.log(oCalenStyle); } else { if(sArrDataKeys.length > 0) { for(iKey in sArrDataKeys) { sKey = sArrDataKeys[iKey]; if(sKey.search("plugin_CalenStyle_") !== -1) { return oCalenStyle[sKey]; } } } else { console.log("No CalenStyle Object Defined For This Element"); } } }); } }; })); function CalenStyle(element, options) { var to = this; to.elem = element; var sLang = ($.cf.isValid(options.language)) ? options.language : $.CalenStyle.defaults.language; to.setting = $.extend({}, $.CalenStyle.defaults, options, $.CalenStyle.i18n[sLang]); to.tv = $.extend({}, $.CalenStyle.tempDefaults); to.tv.pluginId = $.CalenStyle.extra.iCalenStyleObjCount; to.tv.iUTmMS = to.setting.unitTimeInterval * $.CalenStyle.extra.iMS.m; to.tv.iUTmSlt = (60 / to.setting.unitTimeInterval); to.tv.iCalHeight = $(to.elem).height(); if(to.setting.initialize) to.setting.initialize.call(to); $.CalenStyle.extra.dToday = to._getCurrentDate(); if(to.compareDates(to.setting.selectedDate, new Date()) === 0) to.setting.selectedDate = new Date($.CalenStyle.extra.dToday); to.tv.dLoadDt = new Date($.CalenStyle.extra.dToday); to.tv.dVSDt = new Date($.CalenStyle.extra.dToday); to.tv.dVEDt = new Date($.CalenStyle.extra.dToday); to.tv.dVDSDt = new Date($.CalenStyle.extra.dToday); to.tv.dVDEDt = new Date($.CalenStyle.extra.dToday); to.tv.dCMDt = new Date($.CalenStyle.extra.dToday); to.tv.dPMDt = new Date($.CalenStyle.extra.dToday); to.tv.dNMDt = new Date($.CalenStyle.extra.dToday); to.tv.dPLSDt = new Date($.CalenStyle.extra.dToday); to.tv.dPLEDt = new Date($.CalenStyle.extra.dToday); to.tv.dNLSDt = new Date($.CalenStyle.extra.dToday); to.tv.dNLEDt = new Date($.CalenStyle.extra.dToday); $.CalenStyle.extra.oArrCalenStyle.push(to); to._setHeightForEvents(); } /*! -------------------------------------- Common Functions Start -------------------------------------- */ CalenStyle.prototype = { // Public Method modifyCalenStyleObject: function(oTemp) { var to = this; to = oTemp; }, // Public Method setLanguage: function(sTempLang, bLoadData) { var to = this; to.setting.language = sTempLang; to.setting = $.extend({}, to.setting, $.CalenStyle.i18n[sTempLang]); for(var iTempIndex = 0; iTempIndex < to.setting.viewsToDisplay.length; iTempIndex++) { to.setting.viewsToDisplay[iTempIndex].viewDisplayName = to.setting.viewDisplayNames[to.setting.viewsToDisplay[iTempIndex].viewName]; } to.setting.datePickerObject.setting = $.extend({}, to.setting.datePickerObject.setting, $.CalenStyle.i18n[sTempLang]); if(bLoadData) to.reloadData(); else { to.refreshView(); to.setting.datePickerObject.refreshView(); } return to; }, // Public Method changeOutputTimezone: function(sTZ, sTZD, bLoadData) { var to = this; var iTempIndex; var sPrevTZ = to.setting.tz, sPrevTZD = to.setting.outputTZOffset; to.setting.tz = sTZ; to.setting.outputTZOffset = sTZD; if(bLoadData || (to.tv.bGCData && sPrevTZ !== sTZ)) to.reloadData(); else if(sPrevTZD !== sTZD) { for(iTempIndex = 0; iTempIndex < to.tv.oAEvents.length; iTempIndex++) { var oEvent = to.tv.oAEvents[iTempIndex]; if(!oEvent.isAllDay) { oEvent.start = to.normalizeDateTimeWithOffset(oEvent.start, sPrevTZD, sTZD); oEvent.end = to.normalizeDateTimeWithOffset(oEvent.end, sPrevTZD, sTZD); } } for(iTempIndex = 0; iTempIndex < to.tv.oAResSec.length; iTempIndex++) { var oRestrictedSection = to.tv.oAResSec[iTempIndex]; if(!oRestrictedSection.isAllDay) { oRestrictedSection.start = to.normalizeDateTimeWithOffset(oRestrictedSection.start, sPrevTZD, sTZD); oRestrictedSection.end = to.normalizeDateTimeWithOffset(oRestrictedSection.end, sPrevTZD, sTZD); } } for(iTempIndex = 0; iTempIndex < to.tv.oASltAvail.length; iTempIndex++) { var oSlot = to.tv.oASltAvail[iTempIndex]; if(!oSlot.isAllDay) { oSlot.start = to.normalizeDateTimeWithOffset(oSlot.start, sPrevTZD, sTZD); oSlot.end = to.normalizeDateTimeWithOffset(oSlot.end, sPrevTZD, sTZD); } } to.refreshView(); } }, addRemoveLoaderIndicators: function(bAdd, sLoaderIndicatorClass) { var to = this; if($.cf.compareStrings(to.setting.visibleView, "DetailedMonthView") || $.cf.compareStrings(to.setting.visibleView, "MonthView") || $.cf.compareStrings(to.setting.visibleView, "DatePicker")) { if(bAdd) $(to.elem).find(".cmvMonthTableMain tbody").addClass(sLoaderIndicatorClass); else $(to.elem).find(".cmvMonthTableMain tbody").removeClass(sLoaderIndicatorClass); } else if($.cf.compareStrings(to.setting.visibleView, "WeekView") || $.cf.compareStrings(to.setting.visibleView, "DayView") || $.cf.compareStrings(to.setting.visibleView, "CustomView")) { if(bAdd) $(to.elem).find(".cdvDetailTableMain tbody").addClass(sLoaderIndicatorClass); else $(to.elem).find(".cdvDetailTableMain tbody").removeClass(sLoaderIndicatorClass); } else if($.cf.compareStrings(to.setting.visibleView, "DayEventDetailView")) { if(bAdd) { $(to.elem).find(".cdvDetailTableMain tbody").addClass(sLoaderIndicatorClass); $(to.elem).find(".cdlvDaysTableMain tbody").addClass(sLoaderIndicatorClass); } else { $(to.elem).find(".cdvDetailTableMain tbody").removeClass(sLoaderIndicatorClass); $(to.elem).find(".cdlvDaysTableMain tbody").removeClass(sLoaderIndicatorClass); } } else if($.cf.compareStrings(to.setting.visibleView, "DayEventListView")) { if(bAdd) $(to.elem).find(".cdlvDaysTableMain tbody").addClass(sLoaderIndicatorClass); else $(to.elem).find(".cdlvDaysTableMain tbody").removeClass(sLoaderIndicatorClass); } else if($.cf.compareStrings(to.setting.visibleView, "QuickAgendaView")) { if(bAdd) $(to.elem).find(".cqavTableMain tbody").addClass(sLoaderIndicatorClass); else $(to.elem).find(".cqavTableMain tbody").removeClass(sLoaderIndicatorClass); } else if($.cf.compareStrings(to.setting.visibleView, "TaskPlannerView")) { if(bAdd) $(to.elem).find(".ctpvTableMain tbody").addClass(sLoaderIndicatorClass); else $(to.elem).find(".ctpvTableMain tbody").removeClass(sLoaderIndicatorClass); } else if($.cf.compareStrings(to.setting.visibleView, "AppointmentView")) { if(bAdd) $(to.elem).find(".cavTableMain").addClass(sLoaderIndicatorClass); else $(to.elem).find(".cavTableMain").removeClass(sLoaderIndicatorClass); } else if($.cf.compareStrings(to.setting.visibleView, "AgendaView")) { if(bAdd) $(to.elem).find(".cListOuterCont").addClass(sLoaderIndicatorClass); else $(to.elem).find(".cListOuterCont").removeClass(sLoaderIndicatorClass); } else if($.cf.compareStrings(to.setting.visibleView, "WeekPlannerView")) { if(bAdd) $(to.elem).find(".cwpvTableOuterCont").addClass(sLoaderIndicatorClass); else $(to.elem).find(".cwpvTableOuterCont").removeClass(sLoaderIndicatorClass); } }, addRemoveViewLoader: function(bAdd, sViewLoaderClass) { var to = this; if(bAdd) { if(sViewLoaderClass === "cViewLoaderBg") $(to.elem).parent().append("<div class='"+sViewLoaderClass+"'><div class='cViewLoaderBody'></div></div>"); else if(sViewLoaderClass === "cEventLoaderBg") $(to.elem).parent().append("<div class='"+sViewLoaderClass+"'><div class='cEventLoaderIcon'></div></div>"); $(".cContHeaderMenuDropdownBg").css({"background": "rgba(0, 0, 0, 0)"}); var $oThisElem = $(to.elem), iMainLeftMargin = $.cf.getSizeValue($oThisElem, "margin-left"), iMainTopMargin = $.cf.getSizeValue($oThisElem, "margin-top"), iMainContLeft = $oThisElem.position().left + iMainLeftMargin, iMainContTop = $oThisElem.position().top + iMainTopMargin, iMainContMaxWidth = $.cf.getSizeValue($oThisElem, "max-width"), iMainContMinWidth = $.cf.getSizeValue($oThisElem, "min-width"), iMainContWidth = $oThisElem.width(), iMainContHeight = $oThisElem.height(); iMainContWidth = (iMainContMaxWidth && iMainContWidth > iMainContMaxWidth) ? iMainContMaxWidth : iMainContWidth; iMainContWidth = (iMainContMinWidth && iMainContWidth < iMainContMinWidth) ? iMainContMinWidth : iMainContWidth; $("."+sViewLoaderClass).css({"left": iMainContLeft, "top": iMainContTop, "width": iMainContWidth, "height": iMainContHeight}); if(sViewLoaderClass === "cViewLoaderBg") { var iHeaderHeight = $(to.elem).find(".cContHeader").height(), iViewLoaderBodyHeight = iMainContHeight - iHeaderHeight, iViewLoaderBodyTop = iHeaderHeight; $(".cViewLoaderBody").css({"height": iViewLoaderBodyHeight, "margin-top": iViewLoaderBodyTop}); } $("."+sViewLoaderClass).on("click touchstart touchmove", function(e) { e.stopPropagation(); }); } else { $("."+sViewLoaderClass).remove(); } }, __setHoverClass: function($oElem, sClass) { $oElem.on("touchstart", function(e) { $oElem.addClass(sClass); }); $oElem.on("touchend", function(e) { $oElem.removeClass(sClass); }); }, _callCommonEvents: function() { var to = this; to._hideDatePicker(); to._collapseSubmenu(); }, _resetSourceFetch: function() { var to = this; for(var iSourceIndex = 0; iSourceIndex < to.setting.calDataSource.length; iSourceIndex++) { var oSource = to.setting.calDataSource[iSourceIndex]; oSource.fetched = false; } }, // Public Method reloadData: function(oSourceURLParams) { var to = this; to.tv.sLoadType = "Load"; to.tv.dLoadDt = new Date(to.setting.selectedDate); to.tv.oSURLParams = to.__parseJson(oSourceURLParams) || []; to._resetSourceFetch(); to.__reloadCurrentView(true, true); }, _setDisplayTimeLabelsArray: function() { var to = this; var sTimeToDisplay = "Array", iTempIndex; if($.cf.compareStrings(to.setting.timeLabels, "Hour") || $.cf.compareStrings(to.setting.timeLabels, "All")) sTimeToDisplay = to.setting.timeLabels; else if($.isArray(to.setting.timeLabels)) { if(to.setting.timeLabels.length === to.tv.iUTmSlt) { sTimeToDisplay = "No"; for(iTempIndex = 0; iTempIndex < to.tv.iUTmSlt; iTempIndex++) { if(! $.cf.compareStrings(typeof to.setting.timeLabels[iTempIndex], "boolean")) { sTimeToDisplay = "Array"; break; } } } } if(!$.cf.compareStrings(sTimeToDisplay, "No")) { to.setting.timeLabels = []; for(iTempIndex = 0; iTempIndex < to.tv.iUTmSlt; iTempIndex++) { if($.cf.compareStrings(sTimeToDisplay, "Hour") || $.cf.compareStrings(sTimeToDisplay, "Array")) { if(iTempIndex === 0) to.setting.timeLabels.push(true); else to.setting.timeLabels.push(false); } else if($.cf.compareStrings(sTimeToDisplay, "All")) to.setting.timeLabels.push(true); } } }, _getRestrictedSectionForCurrentView: function(dThisDate) { var to = this; var dArrTempResSec = [], iTempIndex; for(iTempIndex = 0; iTempIndex < to.tv.oAResSec.length; iTempIndex++) { var dTempResSec = to.tv.oAResSec[iTempIndex], bCompStartDates = (to.compareDates(new Date(dTempResSec.start), dThisDate) <= 0) ? true : false, bCompEndDates = (to.compareDates(new Date(dTempResSec.end), dThisDate) >= 0) ? true : false; if(bCompStartDates && bCompEndDates) dArrTempResSec.push(dTempResSec); } // ----------------------- Restricted Section Array Sorting Start ------------------------------ var iNumOfTimes = dArrTempResSec.length; if(iNumOfTimes > 1) { for(iTempIndex = 0; iTempIndex < (iNumOfTimes - 1); iTempIndex++) { var dArrTempTimes1 = dArrTempResSec[iTempIndex]; var dArrTempTimes2 = dArrTempResSec[(iTempIndex + 1)]; if(to.compareDateTimes(new Date(dArrTempTimes1[0]), new Date(dArrTempTimes2[0])) === 0) { dArrTempResSec[iTempIndex] = dArrTempTimes2; dArrTempResSec[(iTempIndex + 1)] = dArrTempTimes1; } } } // ----------------------- Restricted Section Array Sorting End ------------------------------ return dArrTempResSec; }, _getBusinessDaysForWeek: function() { var to = this; var iTempIndex, iTempIndex1; to.setting.businessHoursSource = to.__parseJson(to.setting.businessHoursSource); to.tv.iBsDays = 0; to.tv.bABsDays = [false, false, false, false, false, false, false]; for(iTempIndex = 0; iTempIndex < to.setting.businessHoursSource.length; iTempIndex++) { var oTempBusinessHours = to.setting.businessHoursSource[iTempIndex], oTempBusinessHourTimes = oTempBusinessHours.times; if($.cf.isValid(oTempBusinessHours.day)) to.tv.bABsDays[oTempBusinessHours.day] = true; if($.cf.isValid(oTempBusinessHours.days)) { for(iTempIndex1 = 0; iTempIndex1 < oTempBusinessHours.days.length; iTempIndex1++) { to.tv.bABsDays[oTempBusinessHours.days[iTempIndex1]] = true; } } for(var iTimeIndex = 0; iTimeIndex < oTempBusinessHourTimes.length; iTimeIndex++) { var oTempBusinessHourTime = oTempBusinessHourTimes[iTimeIndex]; if(!$.cf.isValid(to.tv.oBsHours.start)) to.tv.oBsHours.start = oTempBusinessHourTime.startTime; else { if(to._compareHours(oTempBusinessHourTime.startTime, to.tv.oBsHours.start) < 0) to.tv.oBsHours.start = oTempBusinessHourTime.startTime; } if(!$.cf.isValid(to.tv.oBsHours.end)) to.tv.oBsHours.end = oTempBusinessHourTime.endTime; else { if(to._compareHours(oTempBusinessHourTime.endTime, to.tv.oBsHours.end) > 0) to.tv.oBsHours.end = oTempBusinessHourTime.endTime; } } } to.tv.oBsHours.startTime = to._getHourAndMinuteFromString(to.tv.oBsHours.start); to.tv.oBsHours.endTime = to._getHourAndMinuteFromString(to.tv.oBsHours.end); var iStartTimeRem = ((to.tv.oBsHours.startTime[0] * 60 + to.tv.oBsHours.startTime[1]) % to.setting.unitTimeInterval), iEndTimeRem = ((to.tv.oBsHours.endTime[0] * 60 + to.tv.oBsHours.endTime[1]) % to.setting.unitTimeInterval); if(iStartTimeRem !== 0) { to.tv.oBsHours.startTime[1] = to.tv.oBsHours.startTime[1] + iStartTimeRem; to.tv.oBsHours.start = to.tv.oBsHours.startTime[0] + ":" + to.tv.oBsHours.startTime[1]; } if(iEndTimeRem !== 0) { to.tv.oBsHours.endTime[1] = to.tv.oBsHours.endTime[1] + iEndTimeRem; to.tv.oBsHours.end = to.tv.oBsHours.endTime[0] + ":" + to.tv.oBsHours.endTime[1]; } for(iTempIndex = 0; iTempIndex < to.tv.bABsDays.length; iTempIndex++) { if(to.tv.bABsDays[iTempIndex]) to.tv.iBsDays++; } }, _compareHours: function(sDate1, sDate2) { var to = this; var sArrDate1 = to._getHourAndMinuteFromString(sDate1), sArrDate2 = to._getHourAndMinuteFromString(sDate2), dDate1 = new Date(), dDate2 = new Date(); dDate1.setHours(parseInt(sArrDate1[0])); dDate1.setMinutes(parseInt(sArrDate1[1])); dDate2.setHours(parseInt(sArrDate2[0])); dDate2.setMinutes(parseInt(sArrDate2[1])); return to.compareDateTimes(dDate1, dDate2); }, _getBusinessHoursForCurrentView: function(dThisDate) { var to = this; var iTempIndex, oThisDate = to.getDateInFormat({"date": dThisDate}, "object", false, true), oArrTempBusinessHours = []; for(iTempIndex = 0; iTempIndex < to.setting.businessHoursSource.length; iTempIndex++) { var oTempBusinessHours = to.setting.businessHoursSource[iTempIndex], bDayMatched = $.cf.isValid(oTempBusinessHours.day) && (oThisDate.D === parseInt(oTempBusinessHours.day)) || $.cf.isValid(oTempBusinessHours.days) && (oTempBusinessHours.days.indexOf(oThisDate.D) !== -1); if(bDayMatched) { for(var iTimesIndex = 0; iTimesIndex < oTempBusinessHours.times.length; iTimesIndex++) { var sArrTempTime = oTempBusinessHours.times[iTimesIndex], iArrStartTimes = to._getHourAndMinuteFromString(sArrTempTime.startTime), iArrEndTimes = to._getHourAndMinuteFromString(sArrTempTime.endTime), dStartDate = to.setDateInFormat({"iDate": {d: oThisDate.d, M: oThisDate.M, y: oThisDate.y, H: parseInt(iArrStartTimes[0]), m: parseInt(iArrStartTimes[1]), s: 0}}, ""), dEndDate = to.setDateInFormat({"iDate": {d: oThisDate.d, M: oThisDate.M, y: oThisDate.y, H: parseInt(iArrEndTimes[0]), m: parseInt(iArrEndTimes[1]), s: 0}}, ""); if(to.compareDateTimes(dStartDate, dEndDate) < 0) oArrTempBusinessHours.push([dStartDate, dEndDate]); } break; } } // ------------------------ Sorting BusinessHours Start ---------------------------------- var iNumOfTimes = oArrTempBusinessHours.length; if(iNumOfTimes > 1) { for(iTempIndex = 0; iTempIndex < (iNumOfTimes - 1); iTempIndex++) { var dArrTemp1 = oArrTempBusinessHours[iTempIndex], dArrTemp2 = oArrTempBusinessHours[(iTempIndex + 1)]; if(to.compareDateTimes(dArrTemp1[0], dArrTemp2[0]) !== 0) { oArrTempBusinessHours[iTempIndex] = dArrTemp2; oArrTempBusinessHours[(iTempIndex + 1)] = dArrTemp1; } } } // ------------------------ Sorting BusinessHours End ---------------------------------- return oArrTempBusinessHours; }, _getHourAndMinuteFromString: function(sTempStartTime) { var to = this; var sArrTimes = sTempStartTime.split(" "), iArrTimes = sArrTimes[0].split(to.setting.formatSeparatorTime), iHours = iArrTimes[0], iMinutes = iArrTimes[1]; if(sArrTimes.length > 1) { if($.cf.compareStrings(sArrTimes[1], "AM") && iHours === 12) iHours = 0; if($.cf.compareStrings(sArrTimes[1], "PM") && iHours < 12) iHours = iHours + 12; } return [iHours, iMinutes]; }, _checkAllowDroppable: function() { var to = this; to.tv.bChkDroppable = false; if(!to.setting.isNonBusinessHoursDroppable && !to.setting.isNonBusinessHoursDroppable) to.tv.bChkDroppable = true; var iTempIndex, bIsDraggable = to.setting.isDragNDropInMonthView || to.setting.isDragNDropInDetailView || to.setting.isDragNDropInQuickAgendaView || to.setting.isDragNDropInTaskPlannerView; if(!to.tv.bChkDroppable && to.tv.oAResSec.length > 0 && bIsDraggable) { for(iTempIndex = 0; iTempIndex < to.tv.oAResSec.length; iTempIndex++) { var oResSec = to.tv.oAResSec[iTempIndex]; if($.cf.isValid(oResSec.isDroppable) && oResSec.isDroppable) { to.tv.bChkDroppable = true; break; } } } }, _findWhetherEventEnteredNonDroppableZone: function(dEventStartDate, dEventEndDate, bIsAllDay, iEventDays, sDroppableId) { var to = this; var bEventEntered = false, sArrDroppableId = $.cf.isValid(sDroppableId) ? sDroppableId.split(",") : []; if($.cf.isValid(dEventStartDate) && $.cf.isValid(dEventEndDate) && iEventDays > 0) { var iMaxTimeSlots = 24 * to.tv.iUTmSlt, iDateIndex, iSlotsIndex, iTempIndex, bArrEvSlots, iEventSlots, iDayIndex, iDroppableIndex, iDroppableIndex1, iDroppableIndex2; iEventSlots = Math.round((dEventEndDate.getTime() - dEventStartDate.getTime()) / to.tv.iUTmMS); iEventSlots = (iEventSlots === 0) ? 1 : iEventSlots; sDroppableId = $.cf.isValid(sDroppableId) ? sDroppableId : ""; var dThisTempDate = to._normalizeDateTime(dEventStartDate, "START", "T"), iThisTempDate = dThisTempDate.getTime(); for(iDateIndex = 0; iDateIndex < iEventDays; iDateIndex++) { if(to.tv.bABsDays[dThisTempDate.getDay()] || !to.setting.excludeNonBusinessHours) { for(iDayIndex = 0; iDayIndex < to.tv.dAVDt.length; iDayIndex++) { if(to.tv.dAVDt[iDayIndex].getDay() === dThisTempDate.getDay()) break; } // ---------------------- Set Array Of Event TimeSlots Start ------------------- bArrEvSlots = []; for(var iHoursIndex = 0; iHoursIndex < 24; iHoursIndex++) { for(iSlotsIndex = 0; iSlotsIndex < to.tv.iUTmSlt; iSlotsIndex++) bArrEvSlots.push(0); } bArrEvSlots.push(0); // For All Day // ---------------------- Set Array Of Event TimeSlots End ---------------------- var dArrTempResSec = to._getRestrictedSectionForCurrentView(dThisTempDate), oArrTempBusinessHours = to._getBusinessHoursForCurrentView(dThisTempDate), bAllowedInResSec = false, bNotAllowedInResSec = false; // --------------- Set RestrictedSection Date Array Indicator Start --------------------------------- if(dArrTempResSec.length > 0) { bEventEntered = false; for(iTempIndex = 0; iTempIndex < dArrTempResSec.length; iTempIndex++) { var dArrResSec = dArrTempResSec[iTempIndex], dResSecStart = new Date(dArrResSec.start), dResSecEnd = new Date(dArrResSec.end), bResSecAllDay = $.cf.isValid(dArrResSec.isAllDay) ? dArrResSec.isAllDay : false, sResSecDroppableId = $.cf.isValid(dArrResSec.droppableId) ? dArrResSec.droppableId : "", bResSecIsDroppable = $.cf.isValid(dArrResSec.isDroppable) ? dArrResSec.isDroppable : to.setting.isRestrictedSectionDroppable, sArrAllowedDroppables = $.cf.isValid(dArrResSec.allowedDroppables) ? dArrResSec.allowedDroppables : [], iCompResSecSDT = to.compareDateTimes(dResSecStart, dEventStartDate), iCompResSecEDT = to.compareDateTimes(dResSecEnd, dEventEndDate), iCompResSecSEDT = to.compareDateTimes(dResSecStart, dEventEndDate), iCompResSecESDT = to.compareDateTimes(dResSecEnd, dEventStartDate), bCompStart = (to.compareDates(dThisTempDate, dResSecStart) === 0), bCompEnd = (to.compareDates(dThisTempDate, dResSecEnd) === 0), iResSecSlots = 0; if(!bCompStart) dResSecStart = to._normalizeDateTime(dThisTempDate, "START", "T"); if(!bCompEnd) dResSecEnd = to._normalizeDateTime(dThisTempDate, "END", "T"); iResSecSlots = Math.round((dResSecEnd.getTime() - dResSecStart.getTime()) / to.tv.iUTmMS); iResSecSlots = (iResSecSlots === 0) ? 1 : (iResSecSlots > iMaxTimeSlots) ? iMaxTimeSlots : iResSecSlots; if(bIsAllDay || iEventSlots >= iMaxTimeSlots) { if((bIsAllDay && bResSecAllDay) || (iCompResSecSDT === 0 && iCompResSecEDT === 0)) return true; } else if(iCompResSecSDT <= 0 && iCompResSecEDT >= 0) { if(!bResSecIsDroppable) bNotAllowedInResSec = true; // return true; if(! (iCompResSecSDT > 0 && iCompResSecEDT > 0 && iCompResSecSEDT < 0) || (iCompResSecSDT < 0 && iCompResSecEDT < 0 && iCompResSecESDT > 0) ) { if(!bResSecIsDroppable) bNotAllowedInResSec = true; // return true; else { var bAllowAll = false; if(sArrAllowedDroppables.length === 0) bAllowedInResSec = true; else { for(iDroppableIndex = 0; iDroppableIndex < sArrAllowedDroppables.length; iDroppableIndex++) { if($.cf.compareStrings(sArrAllowedDroppables[iDroppableIndex], "All")) { bAllowAll = true; bAllowedInResSec = true; break; } } if(!bAllowAll) { if($.cf.isValid(sDroppableId)) { if(sArrDroppableId.length === 1 && sDroppableId === sResSecDroppableId) bAllowedInResSec = true; else { for(iDroppableIndex1 = 0; iDroppableIndex1 < sArrDroppableId.length; iDroppableIndex1++) { var sTempDroppableId = sArrDroppableId[iDroppableIndex1]; if(sTempDroppableId !== sResSecDroppableId) { var bAllowed = false; for(iDroppableIndex2 = 0; iDroppableIndex2 < sArrAllowedDroppables.length; iDroppableIndex2++) { if($.cf.compareStrings(sArrAllowedDroppables[iDroppableIndex2], sTempDroppableId)) { bAllowed = true; bAllowedInResSec = true; break; } } if(!bAllowed) bNotAllowedInResSec = true; // return true; } else bAllowedInResSec = true; } } } else bNotAllowedInResSec = true; // return true; } } } } } else if( (iCompResSecSDT >= 0 && iCompResSecEDT >= 0 && iCompResSecSEDT < 0) || (iCompResSecSDT <= 0 && iCompResSecEDT <= 0 && iCompResSecESDT > 0) ) { //if(!bResSecIsDroppable || (bResSecIsDroppable && sResSecDroppableId !== sDroppableId)) // return true; bNotAllowedInResSec = true; // return true; } } if(bAllowedInResSec) return false; if(bNotAllowedInResSec) return true; if($.cf.isValid(sDroppableId)) return true; } // --------------- Set RestrictedSection Date Array Indicator End ----------------------------------- // ---------------------- Set Available Date Array Indicator Start -------------------------- if(oArrTempBusinessHours.length > 0 && !to.setting.isNonBusinessHoursDroppable) { bEventEntered = true; for(iTempIndex = 0; iTempIndex < oArrTempBusinessHours.length; iTempIndex++) { var dArrTempAvailable = oArrTempBusinessHours[iTempIndex], dTempAvailableStart = new Date(dArrTempAvailable[0]), dTempAvailableEnd = new Date(dArrTempAvailable[1]), iCompAvSDT = to.compareDateTimes(dTempAvailableStart, dEventStartDate), iCompAvEDT = to.compareDateTimes(dTempAvailableEnd, dEventEndDate); if(bIsAllDay) { if(!to.tv.bABsDays[dThisTempDate.getDay()]) return true; else bEventEntered = false; } if(iCompAvSDT <= 0 && iCompAvEDT >= 0) bEventEntered = false && bEventEntered; else bEventEntered = true && bEventEntered; } if(bEventEntered) return true; } else { if(!to.setting.isNonBusinessHoursDroppable) return true; } // ----------------------- Set Available Date Array Indicator End --------------------------- } //else // console.log("Non Business Day"); iThisTempDate += $.CalenStyle.extra.iMS.d; dThisTempDate = new Date(iThisTempDate); } } return bEventEntered; }, //--------------------------------- View Related Functions Start ---------------------------------- // Public Method modifySettings: function(oOptions) { var to = this; var iTempPluginObjCount = to.tv.pluginId; to.setting = $.extend({}, $.CalenStyle.defaults, oOptions); to.tv = $.extend({}, $.CalenStyle.tempDefaults); to.tv.pluginId = iTempPluginObjCount; to.tv.iUTmMS = to.setting.unitTimeInterval * $.CalenStyle.extra.iMS.m; to.tv.iUTmSlt = (60 / to.setting.unitTimeInterval); }, // Public Method loadView: function() { var to = this; if(!$(to.elem).hasClass("cElemDatePicker")) $(to.elem).addClass("elem-CalenStyle"); $(to.elem).html("<div class='calendarCont'></div>"); if(to.setting.viewsToDisplay.length > 1) { for(var iTempIndex1 = 0; iTempIndex1 < to.setting.viewsToDisplay.length; iTempIndex1++) { var oViewToDisplay = to.setting.viewsToDisplay[iTempIndex1], sViewName = oViewToDisplay.viewName || ""; if($.cf.compareStrings(sViewName, to.setting.visibleView)) to.tv.bDisMenu = true; } } to.tv.dLoadDt = to.setDateInFormat({"date": to.setting.selectedDate}, "START"); to.tv.bViewLoaded = false; to._getBusinessDaysForWeek(); to._checkAllowDroppable(); to._setDisplayTimeLabelsArray(); to._resetSourceFetch(); var sUA = navigator.userAgent, sBRClass = "br-other"; if(/(ipod|iphone|ipad)/i.test(sUA)) sBRClass = "br-ios"; else if (/opera|opr/i.test(sUA)) sBRClass = "br-opera"; else if (/msie|trident/i.test(sUA)) sBRClass = "br-ie"; else if (/chrome.+? edge/i.test(sUA)) sBRClass = "br-ie"; else if (/chrome|crios|crmo/i.test(sUA)) sBRClass = "br-chrome"; else if (/firefox|iceweasel/i.test(sUA)) sBRClass = "br-firefox"; else if (/safari/i.test(sUA)) sBRClass = "br-safari"; $("body").addClass(sBRClass); var iScrollbarWidth; if(!$.CalenStyle.extra.bTouchDevice) { var isWebKit = 'WebkitAppearance' in document.documentElement.style; if(isWebKit) iScrollbarWidth = 5; else { var eDiv = document.createElement('div'); eDiv.innerHTML = "<div style='width:50px;height:50px;position:absolute;left:-50px;top:-50px;overflow:auto;'><div style='width:1px;height:100px;'></div></div>"; eDiv = eDiv.firstChild; document.body.appendChild(eDiv); var iWidth = eDiv.offsetWidth - eDiv.clientWidth; document.body.removeChild(eDiv); iScrollbarWidth = iWidth; } $(".calendarCont").addClass("calendarContWeb"); } else { iScrollbarWidth = 2; $(".calendarCont").addClass("calendarContMobile"); } $.CalenStyle.extra.iScrollbarWidth = iScrollbarWidth; to.setCurrentView(to.setting.visibleView, true); }, // Public Method setCurrentView: function(sThisView, bLoadData) { var to = this; to.setting.visibleView = sThisView; var $oCalendarCont = $(to.elem).find(".calendarCont"); $oCalendarCont.removeClass("cmvCalendarCont cdvCalendarCont cdlvCalendarCont cagvCalendarCont cagvTimeline1 cagvTimeline2 cagvTimeline3 cavCalendarCont