×"+e.text+"
";n.calendarEvents.push({title:"Poll: "+t,start:moment(e.postDate).toDate(),calendarEventObject:null,toolTipTitle:"Poll Added",fullDescription:i,allDay:!1})}),l.resolve()},function(){n.isLoadingPolls=!1,l.resolve()})):l.resolve(),this.$q.all([s.promise,r.promise,l.promise])},d.prototype.getAssociationEvents=function(e,t,i,n){var o=this;if(this.onlyRefreshCalendarEvents)return this.onlyRefreshCalendarEvents=void 0,void n(this.calendarEvents);this.calendarEvents=[],this.getAllEvents(e,t).then(function(){n(o.calendarEvents)})},d.prototype.getCalendarEvents=function(e,t,i,n){var o=this;this.isLoadingCalendarEvents=!0;var a=e.format(d.DateFormat),s=t.format(d.DateFormat);this.$http.get("/api/CalendarEvent?startDate="+a+"&endDate="+s).then(function(e){var r=[];o.isLoadingCalendarEvents=!1,_.each(e.data,function(e){var t,i=moment.utc(e.eventDateUtc),n=i.format(d.TimeFormat)==d.NoTime;if(n)e.timeOnly="",e.dateOnly=new Date(i.year(),i.month(),i.date()),t=new Date(i.year(),i.month(),i.date());else{var o=moment.utc(e.eventDateUtc).local();e.timeOnly=o.format(d.TimeFormat),e.dateOnly=o.clone().startOf("day").toDate(),t=o.toDate()}var a=e.title;a&&10"+e.title+"
";r.push({title:a,start:t,toolTipTitle:"Event",fullDescription:s,calendarEventObject:e,allDay:n})}),n(r)},function(){o.isLoadingCalendarEvents=!1})},d.prototype.onResidentClicked=function(e){if(!e.hasEmail)return alert("That user cannot be included because they do not have an email address on file."),void(e.isAssociated=!1);_.contains(this.editEvent.associatedUserIds,e.userId)?this.editEvent.associatedUserIds=_.without(this.editEvent.associatedUserIds,e.userId):this.editEvent.associatedUserIds.push(e.userId)},d.prototype.isDateInPast=function(e){var t=moment(e),i=moment();return t.isBefore(i,"day")||t.isSame(i,"day")},d.prototype.onShouldSendChange=function(){this.editEvent.shouldSendNotification&&this.isDateInPast(this.editEvent.dateOnly)?this.editEvent.shouldSendNotification=!1:this.editEvent.notificationEmailDaysBefore||(this.editEvent.notificationEmailDaysBefore=1)},d.prototype.onChangeEmailDaysBefore=function(){var e=moment(this.editEvent.dateOnly).subtract(this.editEvent.notificationEmailDaysBefore,"day"),t=moment();this.showBadNotificationDateWarning=e.isBefore(t,"day")||e.isSame(t,"day"),this.showBadNotificationDateWarning&&(this.maxDaysBack=moment(this.editEvent.dateOnly).diff(t,"day"),this.editEvent.notificationEmailDaysBefore=this.maxDaysBack,this.$timeout(function(){this.showBadNotificationDateWarning=!1},1e4))},d.prototype.expandCalendarEventModel=function(){this.showExpandedCalendarEventModel=!0,this.hookUpWysiwyg()},d.prototype.hookUpWysiwyg=function(){var t=this;this.$timeout(function(){a.HtmlUtil2.initTinyMce("tiny-mce-editor",200,{menubar:!1}).then(function(e){t.tinyMceEditor=e,t.editEvent&&t.editEvent.description?t.tinyMceEditor.setContent(t.editEvent.description):t.tinyMceEditor.setContent("")})},100)},d.prototype.setEditEvent=function(e,t){var i=this;this.showExpandedCalendarEventModel=t||!1,this.editEvent=e,this.showBadNotificationDateWarning=!1,this.editEvent&&(this.residents&&(this.residents.forEach(function(e){return e.isAssociated=!1}),this.editEvent.associatedUserIds&&this.residents.filter(function(e){return-1!==i.editEvent.associatedUserIds.indexOf(e.userId)}).forEach(function(e){return e.isAssociated=!0})),this.editEvent.associatedGroupShortNames?this.associatedGroups.forEach(function(e){e.isAssociated=-1!==i.editEvent.associatedGroupShortNames.indexOf(e.groupShortName)}):this.associatedGroups.forEach(function(e){return e.isAssociated=!1}),this.editEvent.associatedGroupShortNames=this.associatedGroups.filter(function(e){return e.isAssociated}).map(function(e){return e.groupShortName}),this.editEvent.shouldSendNotification=null!==this.editEvent.notificationEmailDaysBefore,setTimeout(function(){$("#calendar-event-title").focus()},10),this.showExpandedCalendarEventModel&&this.hookUpWysiwyg())},d.prototype.deleteCalendarEvent=function(e){var t=this;confirm("Are you sure you want to remove this event?")&&(this.isLoadingCalendarEvents=!0,this.$http.delete("/api/CalendarEvent?eventId="+e).then(function(){t.isLoadingCalendarEvents=!1,t.editEvent=null,t.onlyRefreshCalendarEvents=!0,$("#log-calendar").fullCalendar("refetchEvents")},function(){t.isLoadingCalendarEvents=!1,alert("Failed to delete the calendar event.")}))},d.prototype.getDaysBeforeValue=function(){var e=null;return null!==this.editEvent.notificationEmailDaysBefore&&void 0!==this.editEvent.notificationEmailDaysBefore&&("string"==typeof this.editEvent.notificationEmailDaysBefore?(e=parseInt(this.editEvent.notificationEmailDaysBefore),isNaN(e)&&(e=null)):"number"==typeof this.editEvent.notificationEmailDaysBefore&&(e=this.editEvent.notificationEmailDaysBefore)),null!==e&&e<0&&(e=null),e},d.prototype.saveCalendarEvent=function(){var i=this;if(a.HtmlUtil2.isValidString(this.editEvent.title)){if(this.tinyMceEditor&&(this.editEvent.description=this.tinyMceEditor.getContent()),this.editEvent.shouldSendNotification)if(null===this.getDaysBeforeValue())return void alert("Please enter a valid number for the 'days before' email send date");if(this.residents){var e=_.filter(this.residents,function(e){return e.isAssociated});this.editEvent.associatedUserIds=_.map(e,function(e){return e.userId})}var t,n="";"string"==typeof this.editEvent.timeOnly&&1"+e.title+"
";n.push({title:t,start:e.date.substring(0,10),toolTipTitle:"Event",fullDescription:i,calendarEventObject:e})}),o(n)},function(){s.isLoadingCalendarEvents=!1})}}]};$(document).ready(function(){$(".EditableEntry").editable("<%= Request.Url %>",{id:"EditEntryId",type:"textarea",cancel:"Cancel",submit:"Ok"}),$("#log-calendar").fullCalendar(n)}),s.onResidentClicked=function(e){_.contains(s.editEvent.associatedUserIds,e)?s.editEvent.associatedUserIds=_.without(s.editEvent.associatedUserIds,e):s.editEvent.associatedUserIds.push(e)},s.isUserAssociated=function(e){return!(!s.editEvent||!s.editEvent.associatedUserIds)&&_.contains(s.editEvent.associatedUserIds,e)},s.expandCalendarEventModel=function(){s.showExpandedCalendarEventModel=!0},s.setEditEvent=function(e,t){s.showExpandedCalendarEventModel=t||!1,(s.editEvent=e)&&setTimeout(function(){$("#calendar-event-title").focus()},10)},s.deleteCalendarEvent=function(e){confirm("Are you sure you want to remove this calendar event?")&&(s.isLoadingCalendarEvents=!0,r.delete("/api/CalendarEvent?eventId="+e).then(function(){s.isLoadingCalendarEvents=!1,s.editEvent=null,s.onlyRefreshCalendarEvents=!0,$("#log-calendar").fullCalendar("refetchEvents")},function(){s.isLoadingCalendarEvents=!1,alert("Failed to delete the calendar event.")}))},s.saveCalendarEvent=function(){var e,t="";t="string"==typeof s.editEvent.timeOnly&&1
×"+e.text+"
";n.calendarEvents.push({title:"Poll: "+t,start:moment(e.postDate).toDate(),calendarEventObject:null,toolTipTitle:"Poll Added",fullDescription:i,allDay:!1})}),l.resolve()},function(){n.isLoadingPolls=!1,l.resolve()})):l.resolve(),this.$q.all([s.promise,r.promise,l.promise])},d.prototype.getAssociationEvents=function(e,t,i,n){var o=this;if(this.onlyRefreshCalendarEvents)return this.onlyRefreshCalendarEvents=void 0,void n(this.calendarEvents);this.calendarEvents=[],this.getAllEvents(e,t).then(function(){n(o.calendarEvents)})},d.prototype.getCalendarEvents=function(e,t,i,n){var o=this;this.isLoadingCalendarEvents=!0;var a=e.format(d.DateFormat),s=t.format(d.DateFormat);this.$http.get("/api/CalendarEvent?startDate="+a+"&endDate="+s).then(function(e){var r=[];o.isLoadingCalendarEvents=!1,_.each(e.data,function(e){var t,i=moment.utc(e.eventDateUtc),n=i.format(d.TimeFormat)==d.NoTime;if(n)e.timeOnly="",e.dateOnly=new Date(i.year(),i.month(),i.date()),t=new Date(i.year(),i.month(),i.date());else{var o=moment.utc(e.eventDateUtc).local();e.timeOnly=o.format(d.TimeFormat),e.dateOnly=o.clone().startOf("day").toDate(),t=o.toDate()}var a=e.title;a&&10"+e.title+"
";r.push({title:a,start:t,toolTipTitle:"Event",fullDescription:s,calendarEventObject:e,allDay:n})}),n(r)},function(){o.isLoadingCalendarEvents=!1})},d.prototype.onResidentClicked=function(e){if(!e.hasEmail)return alert("That user cannot be included because they do not have an email address on file."),void(e.isAssociated=!1);_.contains(this.editEvent.associatedUserIds,e.userId)?this.editEvent.associatedUserIds=_.without(this.editEvent.associatedUserIds,e.userId):this.editEvent.associatedUserIds.push(e.userId)},d.prototype.isDateInPast=function(e){var t=moment(e),i=moment();return t.isBefore(i,"day")||t.isSame(i,"day")},d.prototype.onShouldSendChange=function(){this.editEvent.shouldSendNotification&&this.isDateInPast(this.editEvent.dateOnly)?this.editEvent.shouldSendNotification=!1:this.editEvent.notificationEmailDaysBefore||(this.editEvent.notificationEmailDaysBefore=1)},d.prototype.onChangeEmailDaysBefore=function(){var e=moment(this.editEvent.dateOnly).subtract(this.editEvent.notificationEmailDaysBefore,"day"),t=moment();this.showBadNotificationDateWarning=e.isBefore(t,"day")||e.isSame(t,"day"),this.showBadNotificationDateWarning&&(this.maxDaysBack=moment(this.editEvent.dateOnly).diff(t,"day"),this.editEvent.notificationEmailDaysBefore=this.maxDaysBack,this.$timeout(function(){this.showBadNotificationDateWarning=!1},1e4))},d.prototype.expandCalendarEventModel=function(){this.showExpandedCalendarEventModel=!0,this.hookUpWysiwyg()},d.prototype.hookUpWysiwyg=function(){var t=this;this.$timeout(function(){a.HtmlUtil2.initTinyMce("tiny-mce-editor",200,{menubar:!1}).then(function(e){t.tinyMceEditor=e,t.editEvent&&t.editEvent.description?t.tinyMceEditor.setContent(t.editEvent.description):t.tinyMceEditor.setContent("")})},100)},d.prototype.setEditEvent=function(e,t){var i=this;this.showExpandedCalendarEventModel=t||!1,this.editEvent=e,this.showBadNotificationDateWarning=!1,this.editEvent&&(this.residents&&(this.residents.forEach(function(e){return e.isAssociated=!1}),this.editEvent.associatedUserIds&&this.residents.filter(function(e){return-1!==i.editEvent.associatedUserIds.indexOf(e.userId)}).forEach(function(e){return e.isAssociated=!0})),this.editEvent.associatedGroupShortNames?this.associatedGroups.forEach(function(e){e.isAssociated=-1!==i.editEvent.associatedGroupShortNames.indexOf(e.groupShortName)}):this.associatedGroups.forEach(function(e){return e.isAssociated=!1}),this.editEvent.associatedGroupShortNames=this.associatedGroups.filter(function(e){return e.isAssociated}).map(function(e){return e.groupShortName}),this.editEvent.shouldSendNotification=null!==this.editEvent.notificationEmailDaysBefore,setTimeout(function(){$("#calendar-event-title").focus()},10),this.showExpandedCalendarEventModel&&this.hookUpWysiwyg())},d.prototype.deleteCalendarEvent=function(e){var t=this;confirm("Are you sure you want to remove this event?")&&(this.isLoadingCalendarEvents=!0,this.$http.delete("/api/CalendarEvent?eventId="+e).then(function(){t.isLoadingCalendarEvents=!1,t.editEvent=null,t.onlyRefreshCalendarEvents=!0,$("#log-calendar").fullCalendar("refetchEvents")},function(){t.isLoadingCalendarEvents=!1,alert("Failed to delete the calendar event.")}))},d.prototype.getDaysBeforeValue=function(){var e=null;return null!==this.editEvent.notificationEmailDaysBefore&&void 0!==this.editEvent.notificationEmailDaysBefore&&("string"==typeof this.editEvent.notificationEmailDaysBefore?(e=parseInt(this.editEvent.notificationEmailDaysBefore),isNaN(e)&&(e=null)):"number"==typeof this.editEvent.notificationEmailDaysBefore&&(e=this.editEvent.notificationEmailDaysBefore)),null!==e&&e<0&&(e=null),e},d.prototype.saveCalendarEvent=function(){var i=this;if(a.HtmlUtil2.isValidString(this.editEvent.title)){if(this.tinyMceEditor&&(this.editEvent.description=this.tinyMceEditor.getContent()),this.editEvent.shouldSendNotification)if(null===this.getDaysBeforeValue())return void alert("Please enter a valid number for the 'days before' email send date");if(this.residents){var e=_.filter(this.residents,function(e){return e.isAssociated});this.editEvent.associatedUserIds=_.map(e,function(e){return e.userId})}var t,n="";"string"==typeof this.editEvent.timeOnly&&1"+e.title+"
";n.push({title:t,start:e.date.substring(0,10),toolTipTitle:"Event",fullDescription:i,calendarEventObject:e})}),o(n)},function(){s.isLoadingCalendarEvents=!1})}}]};$(document).ready(function(){$(".EditableEntry").editable("<%= Request.Url %>",{id:"EditEntryId",type:"textarea",cancel:"Cancel",submit:"Ok"}),$("#log-calendar").fullCalendar(n)}),s.onResidentClicked=function(e){_.contains(s.editEvent.associatedUserIds,e)?s.editEvent.associatedUserIds=_.without(s.editEvent.associatedUserIds,e):s.editEvent.associatedUserIds.push(e)},s.isUserAssociated=function(e){return!(!s.editEvent||!s.editEvent.associatedUserIds)&&_.contains(s.editEvent.associatedUserIds,e)},s.expandCalendarEventModel=function(){s.showExpandedCalendarEventModel=!0},s.setEditEvent=function(e,t){s.showExpandedCalendarEventModel=t||!1,(s.editEvent=e)&&setTimeout(function(){$("#calendar-event-title").focus()},10)},s.deleteCalendarEvent=function(e){confirm("Are you sure you want to remove this calendar event?")&&(s.isLoadingCalendarEvents=!0,r.delete("/api/CalendarEvent?eventId="+e).then(function(){s.isLoadingCalendarEvents=!1,s.editEvent=null,s.onlyRefreshCalendarEvents=!0,$("#log-calendar").fullCalendar("refetchEvents")},function(){s.isLoadingCalendarEvents=!1,alert("Failed to delete the calendar event.")}))},s.saveCalendarEvent=function(){var e,t="";t="string"==typeof s.editEvent.timeOnly&&1