sogo/UI/WebServerResources/js/Scheduler.services.js

2 lines
88 KiB
JavaScript
Raw Normal View History

2019-02-14 07:13:38 +01:00
!function(){"use strict";function l(e){this.component=e,this.component.attendees&&_.forEach(this.component.attendees,function(e){e.image=l.$gravatar(e.email,32)}),this.workDaysOnly=!0,this.slotStartTimeLimit=new Date,this.slotStartTimeLimit.setMinutes(0),this.slotStartTimeLimit.setHours(l.dayStartHour),this.slotEndTimeLimit=new Date,this.slotEndTimeLimit.setMinutes(0),this.slotEndTimeLimit.setHours(l.dayEndHour),this.$days=[],this.updateFreeBusyCoverage(),this.updateFreeBusy()}l.$factory=["$q","$timeout","$log","sgSettings","Preferences","User","Card","Gravatar","Resource",function(e,t,n,i,a,o,r,s,c){return angular.extend(l,{$q:e,$timeout:t,$log:n,$settings:i,$User:o,$Preferences:a,$Card:r,$gravatar:s,$$resource:new c(i.activeUser("folderURL")+"Calendar",i.activeUser())}),l.dayStartHour=parseInt(a.defaults.SOGoDayStartTime.split(":")[0]),l.dayEndHour=parseInt(a.defaults.SOGoDayEndTime.split(":")[0]),l}];try{angular.module("SOGo.SchedulerUI")}catch(e){angular.module("SOGo.SchedulerUI",["SOGo.Common"])}angular.module("SOGo.SchedulerUI").factory("Attendees",l.$factory),l.timeToQuarters=function(e){return 4*e.getHours()+Math.ceil(e.getMinutes()/15)},l.prototype.getLength=function(){return this.component.attendees?this.component.attendees.length:0},l.prototype.initOrganizer=function(e){var t,n=this;e&&e.isSubscription?t=l.$User.$filter(e.owner).then(function(e){var t=e[0];n.component.organizer={uid:t.uid,name:t.cn,email:t.c_email}}):(this.component.organizer={uid:l.$settings.activeUser("login"),name:l.$settings.activeUser("identification"),email:l.$settings.activeUser("email")},t=l.$q.when()),t.then(function(){n.updateFreeBusyAttendee(n.component.organizer)})},l.prototype.add=function(e,t){var n,i,a=this;e&&((!this.component.attendees||t&&t.organizerCalendar)&&this.initOrganizer(t?t.organizerCalendar:void 0),e.$isList({expandable:!0})?(i=l.$Card.$find(e.container,e.c_name)).$id().then(function(e){_.forEach(i.refs,function(e){n={name:e.c_cn,email:e.$preferredEmail(t?t.partial:void 0),role:"req-participant",partstat:"needs-action",uid:e.c_uid,$avatarIcon:"person"},_.find(a.component.attendees,function(e){return e.email==n.email})||(n.image=l.$gravatar(n.email,32),a.component.attendees?a.component.attendees.push(n):a.component.attendees=[n],a.updateFreeBusyAttendee(n))})}):(n={uid:e.c_uid,domain:e.c_domain,isMSExchange:e.ismsexchange,name:e.c_cn,email:e.$preferredEmail(),role:"req-participant",partstat:"needs-action",$avatarIcon:e.$avatarIcon},_.find(this.attendees,function(e){return e.email==n.email})||(n.image=l.$gravatar(n.email,32),this.component.attendees?this.component.attendees.push(n):this.component.attendees=[n],this.updateFreeBusyAttendee(n))))},l.prototype.hasAttendee=function(e){var t=_.find(this.component.attendees,function(t){return _.find(e.emails,function(e){return e.value==t.email})});return angular.isDefined(t)},l.prototype.remove=function(t){var e=_.findIndex(this.component.attendees,function(e){return e.email==t.email});this.component.attendees.splice(e,1)},l.prototype.updateFreeBusyCoverage=function(){var o,r,s,e,c={};this.component.start&&this.component.end&&(o=new Date(this.component.start.getTime()),r=new Date(this.component.end.getTime()),this.component.isAllDay?(o.setHours(l.dayStartHour),o.setMinutes(0),r.setHours(l.dayEndHour),r.setMinutes(0),s=e=0):(s=parseInt(o.getMinutes()/15+.5),e=parseInt(r.getMinutes()/15+.5)),o.setMinutes(15*s),r.setMinutes(15*e),_.forEach(o.daysUpTo(r),function(e,t){var n,i=e.getDate(),a=e.getDayString();if(a===o.getDayString())for(n=e.getHours().toString(),c[a]={},c[a][n]=[];0<s;)c[a][n].push(0),s--;else e=e.beginOfDay(),c[a]={};for(;e.getTime()<r.getTime()&&e.getDate()==i;)n=e.getHours().toString(),angular.isUndefined(c[a][n])&&(c[a][n]=[]),c[a][n].push(1),e.addMinutes(15)}),this.freebusy=c)},l.prototype.coversFreeBusy=function(e,t,n){return this.freebusy&&angular.isDefined(this.freebusy[e])&&angular.isDefined(this.freebusy[e][t])&&1==this.freebusy[e][t][n]},l.prototype.getDays=function(e){var t,n,i,a=this;return e?(t=e,(n=new Date(e.getTime())).addMinutes(this.component.de
//# sourceMappingURL=Scheduler.services.js.map