2 lines
75 KiB
JavaScript
2 lines
75 KiB
JavaScript
!function(){"use strict";function e(t){if(this.init(t),this.name&&!this.id){var n=e.$$resource.create("createFolder",this.name);this.$unwrap(n)}}e.$factory=["$q","$timeout","$log","sgSettings","Resource","Preferences","Component","Acl",function(t,n,a,o,i,r,s,c){return angular.extend(e,{$q:t,$timeout:n,$log:a,$$resource:new i(o.activeUser("folderURL")+"Calendar",o.activeUser()),$Preferences:r,$Component:s,$$Acl:c,activeUser:o.activeUser(),$view:null}),e}];try{angular.module("SOGo.SchedulerUI")}catch(e){angular.module("SOGo.SchedulerUI",["SOGo.Common"])}angular.module("SOGo.SchedulerUI").value("CalendarSettings",{EventDragDayLength:96,EventDragHorizontalOffset:3,ConflictHTTPErrorCode:409}).factory("Calendar",e.$factory),e.$defaultCalendar=function(){var t;return"first"==e.$Preferences.defaults.SOGoDefaultCalendar&&(t=_.find(e.$findAll(null,!0),function(e){return e.active}))?t.id:"personal"},e.$add=function(t){var n,a;n=t.isWebCalendar?this.$webcalendars:t.isSubscription?this.$subscriptions:this.$calendars,(a=_.findIndex(n,function(e,n){return"personal"==t.id||"personal"!=e.id&&e.name.localeCompare(t.name)>0}))<0?n.push(t):n.splice(a,0,t),e.$Preferences.settings.Calendar.FoldersOrder&&e.saveFoldersOrder(_.flatMap(e.$findAll(),"id")),e.$reloadAll()},e.$findAll=function(t,n){var a=this;if(t)this.$calendars=[],this.$subscriptions=[],this.$webcalendars=[],angular.forEach(t,function(t,n){var o=new e(t);o.isWebCalendar?a.$webcalendars.push(o):o.isSubscription?a.$subscriptions.push(o):a.$calendars.push(o)});else if(angular.isUndefined(this.$calendars))return this.$calendars=[],this.$subscriptions=[],this.$webcalendars=[],e.$$resource.fetch("calendarslist").then(function(t){return e.$findAll(t.calendars,n)});return n?_.union(this.$calendars,_.filter(this.$subscriptions,function(e){return e.isOwned||e.acls.objectCreator})):_.union(this.$calendars,this.$subscriptions,this.$webcalendars)},e.$reloadAll=function(){var t=this;e.$$resource.fetch("calendarslist").then(function(n){_.forEach(n.calendars,function(n){var a,o;a=n.isWebCalendar?t.$webcalendars:n.owner!=e.activeUser.login?t.$subscriptions:t.$calendars,(o=_.find(a,function(e){return e.id==n.id}))&&o.init(n)})})},e.$get=function(t){var n;return(n=_.find(e.$calendars,function(e){return e.id==t}))||(n=_.find(e.$subscriptions,function(e){return e.id==t})),n||(n=_.find(e.$webcalendars,function(e){return e.id==t})),n},e.$getIndex=function(t){var n;return(n=_.indexOf(_.map(e.$calendars,"id"),t))<0&&(n=_.indexOf(_.map(e.$subscriptions,"id"),t)),n<0&&(n=_.indexOf(_.map(e.$webcalendars,"id"),t)),n},e.$subscribe=function(t,n){var a=this;return e.$$resource.userResource(t).fetch(n,"subscribe").then(function(t){var n=new e(angular.extend({active:1},t));return _.find(a.$subscriptions,function(e){return e.id==t.id})||e.$add(n),n})},e.$addWebCalendar=function(t){var n=e.$q.defer();return _.find(this.$webcalendars,function(e){return e.urls.webCalendarURL==t})?n.reject():e.$$resource.post(null,"addWebCalendar",{url:t}).then(function(a){angular.extend(a,{isWebCalendar:!0,isEditable:!0,isRemote:!1,owner:e.activeUser.login,urls:{webCalendarURL:t}});var o=new e(a);e.$$resource.fetch(o.id,"reload").then(function(t){e.$log.debug(JSON.stringify(t,void 0,2)),e.$add(o),n.resolve()},function(e){401==e.status?n.resolve(o):n.reject()})},n.reject),n.promise},e.reloadWebCalendars=function(){var t=[];return _.forEach(this.$webcalendars,function(n){var a=e.$$resource.fetch(n.id,"reload");a.then(function(e){n.$error=!1},function(e){n.$error=l(e.statusText)}),t.push(a)}),e.$q.all(t)},e.$deleteComponents=function(t){var n={},a=[];return _.forEach(t,function(e){angular.isDefined(n[e.pid])||(n[e.pid]=[]),n[e.pid].push(e.id)}),_.forEach(n,function(t,n){a.push(e.$$resource.post(n,"batchDelete",{uids:t}))}),e.$q.all(a)},e.saveFoldersActivation=function(t){var n={};return _.forEach(t,function(t){var a=e.$get(t);n[a.id]=a.active}),e.$$resource.post(null,"saveFoldersActivation",n)},e.saveFoldersOrder=function(t){return this.$$resource.post(null,"saveFoldersOrder",{folders:t}).then(function(){if(e.$Preferences.settings.Calendar.FoldersOrder=t,!t)return e.$$resource.fetch("calendarslist").then(function(t){return e.$findAll(t.calendars)})})},e.prototype.init=function(t){this.color=this.color||"#AAAAAA",this.active=1,angular.extend(this,t),this.id&&(this.$acl=new e.$$Acl("Calendar/"+this.id)),this.isOwned=e.activeUser.isSuperUser||this.owner==e.activeUser.login,this.isSubscription=!this.isRemote&&this.owner!=e.activeUser.login,angular.isUndefined(this.$shadowData)&&(this.$shadowData=this.$omit())},e.prototype.$id=function(){return this.id?e.$q.when(this.id):this.$futureCalendarData.then(function(e){return e.id})},e.prototype.getClassName=function(e){return angular.isUndefined(e)&&(e="fg"),e+"-folder"+this.id},e.prototype.$rename=function(){var t,n,a=this;return this.name==this.$shadowData.name?e.$q.when():(n=this.isWebCalendar?e.$webcalendars:this.isSubscription?e.$subscriptions:e.$calendars,(t=_.indexOf(_.map(n,"id"),this.id))>-1?this.$save().then(function(){n.splice(t,1),e.$add(a)}):e.$q.reject())},e.prototype.$delete=function(){var t,n,a=this;return this.isSubscription?(n=e.$$resource.fetch(this.id,"unsubscribe"),t=e.$subscriptions):(n=e.$$resource.remove(this.id),t=this.isWebCalendar?e.$webcalendars:e.$calendars),n.then(function(){var e=_.indexOf(_.map(t,"id"),a.id);t.splice(e,1)})},e.prototype.$reset=function(){var e=this;angular.forEach(this,function(t,n){"constructor"!=n&&"$"!=n[0]&&delete e[n]}),angular.extend(this,this.$shadowData),this.$shadowData=this.$omit()},e.prototype.$save=function(){var t=this;return e.$$resource.save(this.id,this.$omit()).then(function(e){return t.$shadowData=t.$omit(),e},function(n){return e.$log.error(JSON.stringify(n,void 0,2)),t.$reset(),n})},e.prototype.setCredentials=function(t,n){var a=this,o=e.$q.defer();return e.$$resource.post(this.id,"set-credentials",{username:t,password:n}).then(function(){e.$$resource.fetch(a.id,"reload").then(function(t){e.$add(a),o.resolve()},function(e){401==e.status?o.reject(l("Wrong username or password")):o.reject(e.statusText)})},o.reject),o.promise},e.prototype.export=function(){var t;return t={type:"application/octet-stream",filename:this.name+".ics"},e.$$resource.download(this.id+".ics","export",null,t)},e.prototype.$setActivation=function(){return e.$$resource.fetch(this.id,(this.active?"":"de")+"activateFolder")},e.prototype.$getComponent=function(t,n){return e.$Component.$find(this.id,t,n)},e.prototype.$unwrap=function(t){var n=this;this.$futureCalendarData=t.then(function(t){return e.$timeout(function(){return n.init(t),n})},function(t){n.isError=!0,angular.isObject(t)&&e.$timeout(function(){angular.extend(n,t)})})},e.prototype.$omit=function(){var e={};return angular.forEach(this,function(t,n){"constructor"!=n&&"$"!=n[0]&&(e[n]=t)}),e}}(),function(){"use strict";function e(t){if("function"!=typeof t.then){if(this.init(t),this.pid&&!this.id){var n=e.$$resource.newguid(this.pid);this.$unwrap(n),this.isNew=!0}}else this.$unwrap(t)}e.$factory=["$q","$timeout","$log","$rootScope","sgSettings","sgComponent_STATUS","Preferences","User","Card","Gravatar","Resource",function(t,n,a,o,i,r,s,c,l,d,u){return angular.extend(e,{STATUS:r,$q:t,$timeout:n,$log:a,$rootScope:o,$settings:i,$User:c,$Preferences:s,$Card:l,$gravatar:d,$$resource:new u(i.activeUser("folderURL")+"Calendar",i.activeUser()),timeFormat:"%H:%M",$query:{value:"",search:"title_Category_Location"},$queryEvents:{sort:"start",asc:1,filterpopup:"view_next7"},$queryTasks:{sort:"status",asc:1,filterpopup:"view_incomplete"},$refreshTimeout:null,$ghost:{}}),s.settings.Calendar.EventsFilterState&&(e.$queryEvents.filterpopup=s.settings.Calendar.EventsFilterState),s.settings.Calendar.TasksFilterState&&(e.$queryTasks.filterpopup=s.settings.Calendar.TasksFilterState),s.settings.Calendar.EventsSortingState&&(e.$queryEvents.sort=s.settings.Calendar.EventsSortingState[0],e.$queryEvents.asc=parseInt(s.settings.Calendar.EventsSortingState[1])),s.settings.Calendar.TasksSortingState&&(e.$queryTasks.sort=s.settings.Calendar.TasksSortingState[0],e.$queryTasks.asc=parseInt(s.settings.Calendar.TasksSortingState[1])),e.$queryTasks.show_completed=parseInt(s.settings.ShowCompletedTasks),e.$categories=s.defaults.SOGoCalendarCategoriesColors,s.defaults.SOGoTimeFormat&&(e.timeFormat=s.defaults.SOGoTimeFormat),e}];try{angular.module("SOGo.SchedulerUI")}catch(e){angular.module("SOGo.SchedulerUI",["SOGo.Common"])}angular.module("SOGo.SchedulerUI").constant("sgComponent_STATUS",{NOT_LOADED:0,DELAYED_LOADING:1,LOADING:2,LOADED:3,DELAYED_MS:300}).factory("Component",e.$factory),e.$selectedCount=function(){var t;return t=0,e.$events&&(t+=_.filter(e.$events,function(e){return e.selected}).length),e.$tasks&&(t+=_.filter(e.$tasks,function(e){return e.selected}).length),t},e.$startRefreshTimeout=function(t){e.$refreshTimeout&&e.$timeout.cancel(e.$refreshTimeout);var n=e.$Preferences.defaults.SOGoRefreshViewCheck;if(n&&"manually"!=n){var a=angular.bind(e.$rootScope,e.$rootScope.$emit,"calendars:list");e.$refreshTimeout=e.$timeout(a,1e3*n.timeInterval())}},e.$isLoading=function(){return e.$loaded==e.STATUS.LOADING},e.$filter=function(t,n){var a,o,i=this,r=new Date,s=r.getDate(),c=r.getMonth()+1,l=r.getFullYear(),d="$query"+t.capitalize(),u={day:l+(c<10?"0":"")+c+(s<10?"0":"")+s},p=!1;return e.$startRefreshTimeout(t),angular.extend(this.$query,u),n&&_.forEach(_.keys(n),function(t){p|=i.$query[t]&&n[t]!=e.$query[t],"reload"==t&&n[t]?p=!0:angular.isDefined(i.$query[t])?i.$query[t]=n[t]:i[d][t]=n[t]}),a=this.$$resource.fetch(null,t+"list",angular.extend(this[d],this.$query)),p&&(delete e[o="tasks"==t?"$events":"$tasks"],e.$log.debug("force reload of "+o)),this.$unwrapCollection(t,a)},e.$find=function(t,n,a){var o=[t,encodeURIComponent(n)];return a&&o.push(a),new e(this.$$resource.fetch(o.join("/"),"view"))},e.filterCategories=function(t){var n=new RegExp(t,"i");return _.filter(_.keys(e.$categories),function(e){return-1!=e.search(n)})},e.saveSelectedList=function(e){return this.$$resource.post(null,"saveSelectedList",{list:e+"ListView"})},e.$eventsBlocksForView=function(t,n){var a,o,i,r;return a=e.$Preferences.defaults.SOGoFirstDayOfWeek,"day"==t?(o="dayView",i=r=n):"multicolumnday"==t?(o="multicolumndayView",i=r=n):"week"==t?(o="weekView",i=n.beginOfWeek(a),(r=new Date).setTime(i.getTime()),r.addDays(6)):"month"==t&&(o="monthView",(i=n).setDate(1),i=i.beginOfWeek(a),(r=new Date).setTime(n.getTime()),r.setMonth(r.getMonth()+1),r.addDays(-1),r=r.endOfWeek(a)),this.$eventsBlocks(o,i,r)},e.$eventsBlocks=function(t,n,a){var o,i,r,s=[],c=[],l=e.$q.defer();return o={view:t.toLowerCase(),sd:n.getDayString(),ed:a.getDayString()},this.$$resource.fetch(null,"eventsblocks",o).then(function(t){var n,a;n=function(t,n,a){var o,i=_.zipObject(this.eventsFields,n),r=new Date(1e3*i.c_startdate);return i.hour=r.getHourString(),i.blocks=[],o=new e(i),t.push(o),t},a=function(e){this[e.nbr].blocks.push(e),e.component=this[e.nbr],e.isFirst=1==this[e.nbr].blocks.length},e.$views=[],e.$timeout(function(){_.forEach(t,function(t,o){var l,d=[],u={},p={};for(t.eventsFields.splice(_.indexOf(t.eventsFields,"c_folder"),1,"pid"),t.eventsFields.splice(_.indexOf(t.eventsFields,"c_name"),1,"id"),t.eventsFields.splice(_.indexOf(t.eventsFields,"c_recurrence_id"),1,"occurrenceId"),t.eventsFields.splice(_.indexOf(t.eventsFields,"c_title"),1,"summary"),_.reduce(t.events,_.bind(n,t),d),_.forEach(_.flatten(t.blocks),_.bind(a,d)),_.forEach(_.flatten(t.allDayBlocks),_.bind(a,d)),0===s.length&&(s=_.flatMap(t.days,"date"),c=_.flatMap(t.days,"number")),i=0;i<t.blocks.length;i++){for(r=0;r<t.blocks[i].length;r++)t.blocks[i][r].dayIndex=i+o*t.blocks.length,t.blocks[i][r].dayNumber=c[i];u[s[i]]=t.blocks[i]}for(i=0;i<t.allDayBlocks.length;i++){for(r=0;r<t.allDayBlocks[i].length;r++)t.allDayBlocks[i][r].dayIndex=i+o*t.allDayBlocks.length,t.allDayBlocks[i][r].dayNumber=c[i];p[s[i]]=t.allDayBlocks[i]}e.$log.debug("blocks ready ("+_.flatten(t.blocks).length+")"),e.$log.debug("all day blocks ready ("+_.flatten(t.allDayBlocks).length+")"),l={blocks:u,allDayBlocks:p},t.id&&t.calendarName&&(l.id=t.id,l.calendarName=t.calendarName),e.$views.push(l)}),l.resolve(e.$views)})},l.reject),l.promise},e.$unwrapCollection=function(t,n){var a=[];return e.$loaded=e.STATUS.DELAYED_LOADING,e.$timeout(function(){e.$loaded!=e.STATUS.LOADED&&(e.$loaded=e.STATUS.LOADING)},e.STATUS.DELAYED_MS),n.then(function(n){return e.$timeout(function(){var o=_.invokeMap(n.fields,"toLowerCase");return o.splice(_.indexOf(o,"c_folder"),1,"pid"),o.splice(_.indexOf(o,"c_name"),1,"id"),o.splice(_.indexOf(o,"c_recurrence_id"),1,"occurrenceId"),"events"==t?(_.forEach(n[t],function(t,n){_.forEach(t.days,function(t,n){_.forEach(t.events,function(n,a){var i;i=new e(_.zipObject(o,n)),t.events[a]=i})})}),a=n[t]):"tasks"==t&&_.reduce(n[t],function(t,n,a){var i;return i=new e(_.zipObject(o,n)),t.push(i),t},a),e.$log.debug("list of "+t+" ready ("+a.length+")"),e["$"+t]=a,e.$loaded=e.STATUS.LOADED,a})})},e.$resetGhost=function(){this.$ghost.pointerHandler=null,this.$ghost.component=null,this.$ghost.startHour=null,this.$ghost.endHour=null},e.$parseDate=function(e,t){var n,a;return n=e.substring(0,10).split("-"),t&&t.no_time?new Date(parseInt(n[0]),parseInt(n[1])-1,parseInt(n[2])):(a=e.substring(11,16).split(":"),new Date(parseInt(n[0]),parseInt(n[1])-1,parseInt(n[2]),parseInt(a[0]),parseInt(a[1]),0,0))},e.prototype.init=function(t){if(this.categories=[],this.repeat={},this.alarm={action:"display",quantity:5,unit:"MINUTES",reference:"BEFORE",relation:"START"},this.status="not-specified",this.delta=60,angular.extend(this,t),"vevent"==this.component?this.type="appointment":"vtodo"==this.component&&(this.type="task"),this.startDate?angular.isString(this.startDate)?this.start=e.$parseDate(this.startDate):this.start=this.startDate:"appointment"==this.type&&(this.start=new Date,this.start.setMinutes(15*Math.round(this.start.getMinutes()/15))),this.endDate?(this.end=e.$parseDate(this.endDate),this.delta=this.start.minutesTo(this.end)):"appointment"==this.type&&this.setDelta(this.delta),this.dueDate&&(this.due=e.$parseDate(this.dueDate)),this.completedDate?this.completed=e.$parseDate(this.completedDate):"task"==this.type&&(this.completed=new Date),this.c_category&&(this.categories=_.invokeMap(_.filter(this.c_category,function(t){return e.$Preferences.defaults.SOGoCalendarCategoriesColors[t]}),"asCSSIdentifier")),this.$isRecurrent=angular.isDefined(t.repeat),this.repeat.days){var n=_.find(this.repeat.days,function(e){return angular.isDefined(e.occurrence)});n&&("yearly"==this.repeat.frequency&&(this.repeat.year={byday:!0}),this.repeat.month={type:"byday",occurrence:n.occurrence.toString(),day:n.day})}else this.repeat.days=[];if(this.repeat.dates?(this.repeat.frequency="custom",_.forEach(this.repeat.dates,function(t,n,a){angular.isString(t)&&(a[n]=e.$parseDate(t))})):angular.isUndefined(this.repeat.frequency)&&(this.repeat.frequency="never"),angular.isUndefined(this.repeat.interval)&&(this.repeat.interval=1),angular.isUndefined(this.repeat.monthdays)?this.repeat.monthdays=[]:this.repeat.monthdays.length>0&&(this.repeat.month={type:"bymonthday"}),angular.isUndefined(this.repeat.month)&&(this.repeat.month={}),angular.isUndefined(this.repeat.month.occurrence)&&angular.extend(this.repeat.month,{occurrence:"1",day:"SU"}),angular.isUndefined(this.repeat.months)&&(this.repeat.months=[]),angular.isUndefined(this.repeat.year)&&(this.repeat.year={}),this.repeat.count?this.repeat.end="count":this.repeat.until?(this.repeat.end="until",angular.isString(this.repeat.until)&&(this.repeat.until=e.$parseDate(this.repeat.until,{no_time:!0}))):this.repeat.end="never",this.$hasCustomRepeat=this.hasCustomRepeat(),this.isNew){var a="appointment"==this.type?"Events":"Tasks";this.classification=e.$Preferences.defaults["SOGoCalendar"+a+"DefaultClassification"].toLowerCase();var o=/-PT?([0-9]+)([MHDW])/.exec(e.$Preferences.defaults.SOGoCalendarDefaultReminder);o&&(this.$hasAlarm=!0,this.alarm.quantity=parseInt(o[1]),this.alarm.unit={M:"MINUTES",H:"HOURS",D:"DAYS",W:"WEEKS"}[o[2]]),this.sendAppointmentNotifications=e.$Preferences.defaults.SOGoAppointmentSendEMailNotifications}else angular.isUndefined(t.$hasAlarm)&&(this.$hasAlarm=angular.isDefined(t.alarm));this.destinationCalendar=this.pid,this.attendees&&_.forEach(this.attendees,function(t){t.image=e.$gravatar(t.email,32)}),this.updateFreeBusy(),this.selected=!1},e.prototype.initOrganizer=function(t){var n,a=this;t&&t.isSubscription?n=e.$User.$filter(t.owner).then(function(e){var t=e[0];a.organizer={uid:t.uid,name:t.cn,email:t.c_email}}):(this.organizer={uid:e.$settings.activeUser("login"),name:e.$settings.activeUser("identification"),email:e.$settings.activeUser("email")},n=e.$q.when()),n.then(function(){a.updateFreeBusyAttendee(a.organizer)})},e.prototype.hasCustomRepeat=function(){return angular.isUndefined(this.occurrenceId)&&angular.isDefined(this.repeat)&&(this.repeat.interval>1||angular.isDefined(this.repeat.days)&&this.repeat.days.length>0||angular.isDefined(this.repeat.monthdays)&&this.repeat.monthdays.length>0||angular.isDefined(this.repeat.months)&&this.repeat.months.length>0||angular.isDefined(this.repeat.month)&&angular.isDefined(this.repeat.month.type)||angular.isDefined(this.repeat.dates)&&this.repeat.dates.length>0)},e.prototype.isEditable=function(){return!this.occurrenceId&&!this.isReadOnly},e.prototype.isEditableOccurrence=function(){return this.occurrenceId&&!this.isReadOnly},e.prototype.isInvitation=function(){return!this.occurrenceId&&this.userHasRSVP},e.prototype.isInvitationOccurrence=function(){return this.occurrenceId&&this.userHasRSVP},e.prototype.showPercentComplete=function(){return"task"==this.type&&this.percentComplete>0&&"cancelled"!=this.status},e.prototype.enablePercentComplete=function(){return"task"==this.type&&"not-specified"!=this.status&&"cancelled"!=this.status},e.prototype.coversFreeBusy=function(e,t,n){return angular.isDefined(this.freebusy[e])&&angular.isDefined(this.freebusy[e][t])&&1==this.freebusy[e][t][n]},e.prototype.updateFreeBusyCoverage=function(){var e=this,t={};if(this.start&&this.end){var n=new Date(this.start.getTime()),a=new Date(this.end.getTime()),o=parseInt(n.getMinutes()/15+.5),i=parseInt(a.getMinutes()/15+.5);return n.setMinutes(15*o),a.setMinutes(15*i),_.forEach(n.daysUpTo(a),function(n,a){var i,r=n.getDate(),s=n.getDayString();if(s==e.start.getDayString())for(i=n.getHours().toString(),t[s]={},t[s][i]=[];o>0;)t[s][i].push(0),o--;else n=n.beginOfDay(),t[s]={};for(;n.getTime()<e.end.getTime()&&n.getDate()==r;)i=n.getHours().toString(),angular.isUndefined(t[s][i])&&(t[s][i]=[]),t[s][i].push(1),n.addMinutes(15)}),t}},e.prototype.updateFreeBusy=function(){var e=this;this.freebusy=this.updateFreeBusyCoverage(),this.attendees&&(this.organizer&&this.updateFreeBusyAttendee(this.organizer),_.forEach(this.attendees,function(t){e.updateFreeBusyAttendee(t)}))},e.prototype.setDelta=function(e){this.delta=e,this.end=new Date(this.start.getTime()),this.end.setMinutes(15*Math.round(this.end.getMinutes()/15)),this.end.addMinutes(this.delta)},e.prototype.updateFreeBusyAttendee=function(t){var n,a,o,i;t.uid&&(a=t.uid,t.domain&&(a+="@"+t.domain),o={sday:this.start.getDayString(),eday:this.end.getDayString()},t.isMSExchange?(n=e.$$resource.userResource(),o.uid=a):n=e.$$resource.userResource(a),i=_.map(this.start.daysUpTo(this.end),function(e){return e.getDayString()}),angular.isUndefined(t.freebusy)&&(t.freebusy={}),n.fetch("freebusy.ifb","ajaxRead",o).then(function(e){_.forEach(i,function(n){var a;angular.isUndefined(t.freebusy[n])&&(t.freebusy[n]={}),angular.isUndefined(e[n])&&(e[n]={});for(var o=0;o<=23;o++)a=o.toString(),e[n][a]?t.freebusy[n][a]=[e[n][a][0],e[n][a][15],e[n][a][30],e[n][a][45]]:t.freebusy[n][a]=[0,0,0,0]})}))},e.prototype.getClassName=function(e){return angular.isUndefined(e)&&(e="fg"),e+"-folder"+(this.destinationCalendar||this.c_folder||this.pid)},e.prototype.addAttendee=function(t,n){var a,o,i=this;t&&((!this.attendees||n&&n.organizerCalendar)&&this.initOrganizer(n?n.organizerCalendar:void 0),t.$isList({expandable:!0})?(o=e.$Card.$find(t.container,t.c_name)).$id().then(function(t){_.forEach(o.refs,function(t){a={name:t.c_cn,email:t.$preferredEmail(),role:"req-participant",partstat:"needs-action",uid:t.c_uid,$avatarIcon:"person"},_.find(i.attendees,function(e){return e.email==a.email})||(a.image=e.$gravatar(a.email,32),i.attendees?i.attendees.push(a):i.attendees=[a],i.updateFreeBusyAttendee(a))})}):(a={uid:t.c_uid,domain:t.c_domain,isMSExchange:t.ismsexchange,name:t.c_cn,email:t.$preferredEmail(),role:"req-participant",partstat:"needs-action",$avatarIcon:t.$avatarIcon},_.find(this.attendees,function(e){return e.email==a.email})||(a.image=e.$gravatar(a.email,32),this.attendees?this.attendees.push(a):this.attendees=[a],this.updateFreeBusyAttendee(a))))},e.prototype.hasAttendee=function(e){var t=_.find(this.attendees,function(t){return _.find(e.emails,function(e){return e.value==t.email})});return angular.isDefined(t)},e.prototype.deleteAttendee=function(e){var t=_.findIndex(this.attendees,function(t){return t.email==e.email});this.attendees.splice(t,1)},e.prototype.canRemindAttendeesByEmail=function(){return"email"==this.alarm.action&&!this.isReadOnly&&this.attendees&&this.attendees.length>0},e.prototype.addAttachUrl=function(e){if(angular.isUndefined(this.attachUrls))this.attachUrls=[{value:e}];else{for(var t=0;t<this.attachUrls.length&&this.attachUrls[t].value!=e;t++);t==this.attachUrls.length&&this.attachUrls.push({value:e})}return this.attachUrls.length-1},e.prototype.deleteAttachUrl=function(e){e>-1&&this.attachUrls.length>e&&this.attachUrls.splice(e,1)},e.prototype.$addDueDate=function(){this.due=new Date,this.due.setMinutes(15*Math.round(this.due.getMinutes()/15)),this.dueDate=this.due.toISOString()},e.prototype.$deleteDueDate=function(){delete this.due,delete this.dueDate},e.prototype.$addStartDate=function(){this.start=new Date,this.start.setMinutes(15*Math.round(this.start.getMinutes()/15))},e.prototype.$deleteStartDate=function(){delete this.start,delete this.startDate},e.prototype.$addRecurrenceDate=function(){var e=new Date;e.setMinutes(15*Math.round(e.getMinutes()/15)),angular.isUndefined(this.repeat.dates)&&(this.repeat={frequency:"custom",dates:[]}),this.repeat.dates.push(e)},e.prototype.$deleteRecurrenceDate=function(e){e>-1&&this.repeat&&this.repeat.dates&&this.repeat.dates.length>e&&this.repeat.dates.splice(e,1)},e.prototype.$reset=function(){var e=this;angular.forEach(this,function(t,n){"constructor"!=n&&"$"!=n[0]&&delete e[n]}),this.init(this.$shadowData),this.$shadowData=this.$omit()},e.prototype.$reply=function(){var t,n=this,a=[this.pid,encodeURIComponent(this.id)];return this.occurrenceId&&a.push(this.occurrenceId),t={reply:this.reply,delegatedTo:this.delegatedTo,alarm:this.$hasAlarm?this.alarm:{}},e.$$resource.save(a.join("/"),t,{action:"rsvpAppointment"}).then(function(e){return n.$shadowData=n.$omit(),e})},e.prototype.$adjust=function(t){var n=[this.pid,encodeURIComponent(this.id)];return _.every(_.values(t),function(e){return 0===e})?e.$q.when():(this.occurrenceId&&n.push(this.occurrenceId),e.$log.debug("adjust "+n.join("/")+" "+JSON.stringify(t)),e.$$resource.save(n.join("/"),t,{action:"adjust"}))},e.prototype.$save=function(t){var n,a,o,i,r=this;return o=this.$omit(),i=e.$Preferences.$mdDateLocaleProvider,o.startDate=o.start?o.start.format(i,"%Y-%m-%d"):"",o.startTime=o.start?o.start.format(i,"%H:%M"):"",o.endDate=o.end?o.end.format(i,"%Y-%m-%d"):"",o.endTime=o.end?o.end.format(i,"%H:%M"):"",o.dueDate=o.due?o.due.format(i,"%Y-%m-%d"):"",o.dueTime=o.due?o.due.format(i,"%H:%M"):"",o.completedDate=o.completed?o.completed.format(i,"%Y-%m-%d"):"",this.hasCustomRepeat()?"monthly"==this.repeat.frequency&&this.repeat.month.type&&"byday"==this.repeat.month.type&&"relative"!=this.repeat.month.day||"yearly"==this.repeat.frequency&&this.repeat.year.byday?(delete o.repeat.monthdays,o.repeat.days=[{day:this.repeat.month.day,occurrence:this.repeat.month.occurrence.toString()}]):"monthly"!=this.repeat.frequency&&"yearly"!=this.repeat.frequency||!this.repeat.month.type?"custom"==this.repeat.frequency&&this.repeat.dates&&_.forEach(o.repeat.dates,function(e,t,n){n[t]={date:e.format(i,"%Y-%m-%d"),time:e.format(i,"%H:%M")}}):(delete o.repeat.days,"relative"==this.repeat.month.day&&(o.repeat.monthdays=[this.repeat.month.occurrence])):this.repeat.frequency&&"never"!=this.repeat.frequency&&(o.repeat={frequency:this.repeat.frequency}),o.startDate&&this.repeat.frequency&&"never"!=this.repeat.frequency?"until"==this.repeat.end&&this.repeat.until?o.repeat.until=this.repeat.until.stringWithSeparator("-"):"count"==this.repeat.end&&this.repeat.count?o.repeat.count=this.repeat.count:(delete o.repeat.until,delete o.repeat.count):delete o.repeat,"not-specified"==this.status?delete o.status:"completed"!=this.status&&delete o.completedDate,o.startDate&&this.$hasAlarm?!this.alarm.action||"email"!=this.alarm.action||this.attendees&&this.attendees.length>0||(o.alarm.attendees=0,o.alarm.organizer=1):o.alarm={},a=[this.pid,encodeURIComponent(this.id)],this.isNew&&(n={action:"saveAs"+this.type.capitalize()}),this.occurrenceId&&a.push(this.occurrenceId),angular.extend(o,t),e.$$resource.save(a.join("/"),o,n).then(function(e){return r.$shadowData=r.$omit(),e})},e.prototype.remove=function(t){var n=[this.pid,encodeURIComponent(this.id)];return t&&this.occurrenceId&&n.push(this.occurrenceId),e.$$resource.remove(n.join("/"))},e.prototype.$unwrap=function(t){var n=this;this.$futureComponentData=t,this.$futureComponentData.then(function(e){n.init(e),n.$shadowData=n.$omit()},function(t){angular.extend(n,t),n.isError=!0,e.$log.error(n.error)})},e.prototype.$omit=function(){var e={};return angular.forEach(this,function(t,n){"constructor"==n||"$hasAlarm"!=n&&"$"==n[0]||"blocks"==n||(e[n]=angular.copy(t))}),e},e.prototype.repeatDescription=function(){var e=null;return this.repeat&&(e=l("repeat_"+this.repeat.frequency.toUpperCase())),e},e.prototype.alarmDescription=function(){var e,t=null;return this.alarm&&(e=["reminder",this.alarm.quantity],this.alarm.quantity>0&&e.push(this.alarm.unit.toUpperCase(),this.alarm.reference.toUpperCase()),(e=e.join("_"))===(t=l(e))&&(t=[this.alarm.quantity,l("reminder_"+this.alarm.unit.toUpperCase()),l("reminder_"+this.alarm.reference.toUpperCase())].join(" "))),t},e.prototype.copyTo=function(t){return e.$$resource.post(this.pid+"/"+encodeURIComponent(this.id),"copy",{destination:t})},e.prototype.moveTo=function(t){return e.$$resource.post(this.pid+"/"+encodeURIComponent(this.id),"move",{destination:t})},e.prototype.toString=function(){return"[Component "+this.id+"]"}}(),function(){"use strict";e.$inject=["$scope","$rootScope","$state","$stateParams","sgHotkeys","Calendar","Component","Preferences","stateEventsBlocks"];function e(t,n,a,o,i,r,s,c,d){var u,p=this,h=[];angular.isUndefined(e.expandedAllDays)&&(e.expandedAllDays=!1),p.selectedDate=o.day.asDate(),p.expandedAllDays=e.expandedAllDays,p.toggleAllDays=function(){e.expandedAllDays=!e.expandedAllDays,p.expandedAllDays=e.expandedAllDays},p.views=d,p.changeDate=y,p.changeView=v,this.$onInit=function(){(e=h).push(i.createHotkey({key:l("hotkey_today"),description:l("Today"),callback:y,args:new Date})),e.push(i.createHotkey({key:l("hotkey_dayview"),description:l("Day"),callback:v,args:"day"})),e.push(i.createHotkey({key:l("hotkey_weekview"),description:l("Week"),callback:v,args:"week"})),e.push(i.createHotkey({key:l("hotkey_monthview"),description:l("Month"),callback:v,args:"month"})),e.push(i.createHotkey({key:l("hotkey_multicolumndayview"),description:l("Multicolumn Day View"),callback:v,args:"multicolumnday"})),e.push(i.createHotkey({key:"left",description:l("Move backward"),callback:m,args:-1})),e.push(i.createHotkey({key:"right",description:l("Move forward"),callback:m,args:1})),_.forEach(e,function(e){i.registerHotkey(e)});var e;f(p.selectedDate),u=n.$on("calendars:list",g),t.$on("$destroy",function(){u(),_.forEach(h,function(e){i.deregisterHotkey(e)})})};function m(e,t){var n;"week"==o.view?n=p.selectedDate.beginOfWeek(c.defaults.SOGoFirstDayOfWeek).addDays(7*t):"month"==o.view?((n=p.selectedDate).setDate(1),n.setMonth(n.getMonth()+t)):n=p.selectedDate.addDays(t),y(e,n)}function f(e){"month"==o.view?(e.setDate(1),e.setHours(12),e.$dateFormat="%B %Y"):"week"==o.view?(e.setTime(e.beginOfWeek(c.defaults.SOGoFirstDayOfWeek).getTime()),e.$dateFormat=l("Week %d").replace("%d","%U")):e.$dateFormat="%A"}function g(){s.$eventsBlocksForView(o.view,o.day.asDate()).then(function(e){var t,n,a;for(t=0;t<e.length;t++)a=e[t],p.views[t]?(_.forEach(a.allDayBlocks,function(e,n){p.views[t].allDayBlocks[n]=e}),_.forEach(a.blocks,function(e,n){p.views[t].blocks[n]=e})):p.views[t]=a,a.id&&(p.views[t].calendar=new r({id:a.id,name:a.calendarName}));for(n=p.views.length;n>=t;n--)p.views.splice(n,1)})}function y(e,t){var n=t?t.getDayString():angular.element(e.currentTarget).attr("date");t&&f(t),a.go("calendars.view",{day:n})}function v(e,t){a.go("calendars.view",{view:t})}}angular.module("SOGo.SchedulerUI").controller("CalendarController",e)}(),function(){"use strict";e.$inject=["$rootScope","$scope","$q","$timeout","$state","$mdDialog","sgHotkeys","sgFocus","Dialog","Preferences","CalendarSettings","Calendar","Component","Alarm"];function e(e,t,n,a,o,i,r,s,c,d,u,p,h,m){var f,g=this,y=[];g.component=h,g.componentType="events",g.selectedList=0,g.selectComponentType=v,g.unselectComponents=function(){_.forEach(h["$"+g.componentType],function(e){e.selected=!1}),g.mode.multiple=0},g.selectAll=function(){_.forEach(h["$"+g.componentType],function(e){e.selected=!0}),g.mode.multiple=h["$"+g.componentType].length},g.searchMode=$,g.toggleComponentSelection=function(e,t){t.selected=!t.selected,g.mode.multiple+=t.selected?1:-1,e.preventDefault(),e.stopPropagation()},g.confirmDeleteSelectedComponents=function(){c.confirm(l("Warning"),l("Are you sure you want to delete the selected components?"),{ok:l("Delete")}).then(function(){var t=_.filter(h["$"+g.componentType],function(e){return e.selected});p.$deleteComponents(t).then(function(){g.mode.multiple=0,e.$emit("calendars:list")})})},g.openEvent=function(e,t){C(e,t,"appointment")},g.openTask=function(e,t){C(e,t,"task")},g.newComponent=b,g.filterpopup=function(){return h["$query"+g.componentType.capitalize()].filterpopup},g.filter=function(e){h.$filter(g.componentType,{filterpopup:e})},g.filteredBy=function(e){return h["$query"+g.componentType.capitalize()].filterpopup==e},g.sort=function(e){h.$filter(g.componentType,{sort:e})},g.sortedBy=function(e){return h["$query"+g.componentType.capitalize()].sort==e},g.reload=function(){p.reloadWebCalendars().finally(function(){e.$emit("calendars:list")})},g.cancelSearch=function(){g.mode.search=!1,h.$filter(g.componentType,{value:""})},g.mode={search:!1,multiple:0},this.$onInit=function(){(n=y).push(r.createHotkey({key:l("hotkey_search"),description:l("Search"),callback:$})),n.push(r.createHotkey({key:l("hotkey_create_event"),description:l("Create a new event"),callback:b,args:"appointment"})),n.push(r.createHotkey({key:l("hotkey_create_task"),description:l("Create a new task"),callback:b,args:"task"})),_.forEach(n,function(e){r.registerHotkey(e)});var n;f="events","tasksListView"==d.settings.Calendar.SelectedList&&(g.selectedList=1,f="tasks"),v(f,{reload:!0}),e.$on("calendars:list",function(){h.$filter(g.componentType,{reload:!0})}),e.$on("calendar:dragend",D),t.$on("$destroy",function(){_.forEach(y,function(e){r.deregisterHotkey(e)})})};function v(e,t){(t&&t.reload||g.componentType!=e)&&(angular.isUndefined(h["$"+e])&&h.$filter(e),g.unselectComponents(),g.componentType=e,h.saveSelectedList(e))}function $(){g.mode.search=!0,s("search")}function C(e,t,a){if(t.viewable){var o=n.when();angular.isUndefined(t.$futureComponentData)&&(o=(t=p.$get(t.pid).$getComponent(t.id,t.occurrenceId)).$futureComponentData),o.then(function(){var n="UIx"+a.capitalize()+"ViewTemplate";i.show({parent:angular.element(document.body),targetEvent:e,clickOutsideToClose:!0,escapeToClose:!0,templateUrl:n,controller:"ComponentController",controllerAs:"editor",locals:{stateComponent:t}})})}}function b(e,t,n){var a;n?(a=n).updateFreeBusy():a=new h({pid:p.$defaultCalendar(),type:t});var o="UIx"+t.capitalize()+"EditorTemplate";return i.show({parent:angular.element(document.body),targetEvent:e,clickOutsideToClose:!0,escapeToClose:!0,templateUrl:o,controller:"ComponentEditorController",controllerAs:"editor",locals:{stateComponent:a}})}function D(t){var n,o,r,s,c,d,f;n=h.$ghost.component,o=h.$ghost.pointerHandler,n.isNew?(r=o.currentEventCoordinates,n.summary="",n.isAllDay&&(r.duration-=96),n.setDelta(15*r.duration),b(null,"appointment",n).catch().finally(function(){a(function(){h.$resetGhost()})})):(s=o.currentEventCoordinates.getDelta(o.originalEventCoordinates),c={days:s.dayNumber,start:15*s.start,duration:15*s.duration},o.originalCalendar&&0!==s.dayNumber&&(d=o.currentEventCoordinates.dayNumber,f=_.filter(p.$findAll(),{active:1}),c.destination=f[d].id,c.days=0),n.isException||!n.occurrenceId?n.$adjust(c).then(function(){e.$emit("calendars:list"),m.getAlarms()},function(e){y(e,n,c)}).finally(function(){a(function(){h.$resetGhost()})}):n.occurrenceId&&i.show({clickOutsideToClose:!0,escapeToClose:!0,locals:{component:n,params:c},template:['<md-dialog flex="50" sm-flex="80" xs-flex="90">',' <md-dialog-content class="md-dialog-content">'," <p>"+l("editRepeatingItem")+"</p>"," </md-dialog-content>"," <md-dialog-actions>",' <md-button ng-click="updateThisOccurrence()">'+l("button_thisOccurrenceOnly")+"</md-button>",' <md-button ng-click="updateAllOccurrences()">'+l("button_allOccurrences")+"</md-button>"," </md-dialog-actions>","</md-dialog>"].join(""),controller:g}).then(function(){e.$emit("calendars:list")},function(){}).finally(function(){a(function(){h.$resetGhost()})})),g.$inject=["$scope","$mdDialog","component","params"];function g(e,t,n,a){e.updateThisOccurrence=function(){n.$adjust(a).then(t.hide,function(e){t.cancel().then(function(){y(e,n,a)},function(){})})},e.updateAllOccurrences=function(){delete n.occurrenceId,n.$adjust(a).then(t.hide,function(e){t.cancel().then(function(){y(e,n,a)},function(){})})}}function y(t,n,a){t.status==u.ConflictHTTPErrorCode&&t.data&&t.data.message&&angular.isObject(t.data.message)&&i.show({parent:angular.element(document.body),clickOutsideToClose:!1,escapeToClose:!1,templateUrl:"UIxAttendeeConflictDialog",controller:v,controllerAs:"$AttendeeConflictDialogController",locals:{component:n,params:a,conflictError:t.data.message}}).then(function(){e.$emit("calendars:list")},function(){})}v.$inject=["$scope","$mdDialog","component","params","conflictError"];function v(e,t,n,a,o){this.conflictError=o,this.cancel=t.cancel,this.save=function(){n.$adjust(angular.extend({ignoreConflicts:!0},a)).then(t.hide)}}}}angular.module("SOGo.SchedulerUI").controller("CalendarListController",e)}(),function(){"use strict";e.$inject=["$rootScope","$scope","$window","$mdDialog","$log","$mdToast","Dialog","sgSettings","Preferences","Calendar"];function e(e,t,n,a,o,i,r,s,c,d){var u=this;u.activeUser=s.activeUser,u.service=d,u.newCalendar=function(e){r.prompt(l("New calendar"),l("Name of the Calendar")).then(function(e){var t=new d({name:e,isEditable:!0,isRemote:!1,owner:UserLogin});t.$id().then(function(){d.$add(t)})})},u.addWebCalendar=function(){r.prompt(l("Subscribe to a web calendar..."),l("URL of the Calendar"),{inputType:"url"}).then(function(t){d.$addWebCalendar(t).then(function(n){angular.isObject(n)&&a.show({parent:angular.element(document.body),clickOutsideToClose:!0,escapeToClose:!0,templateUrl:"UIxWebCalendarAuthDialog",controller:e,controllerAs:"$WebCalendarAuthDialogController",locals:{url:t,calendar:n}})})}),e.$inject=["scope","$mdDialog","url","calendar"];function e(e,t,n,a){var o=this,i=n.split("/"),r=i[2];o.title=l("Please identify yourself to %{0}").formatted(r),o.url=n,o.authenticate=function(e){!e.$valid&&e.$error.required||a.setCredentials(o.username,o.password).then(function(e){t.hide()},function(t){e.password.$setValidity("credentials",!1)})},o.cancel=function(){t.cancel()}}},u.subscribeToFolder=function(e){o.debug("subscribeToFolder "+e.owner+e.name),d.$subscribe(e.owner,e.name).then(function(e){i.show(i.simple().content(l("Successfully subscribed to calendar")).position("top right").hideDelay(3e3))})},u.filter={name:""},u.sortableMode=!1,u.toggleSortableMode=function(){u.sortableMode=!u.sortableMode,u.filter.name=""},u.resetSort=function(){d.saveFoldersOrder()},u.sortableCalendars={scrollableContainer:"#sidenav-content",containment:"md-list",orderChanged:function(){d.saveFoldersOrder(_.flatMap(d.$findAll(),"id"))},accept:function(e,t,n){return e.sortableScope.element[0]==t.element[0]}},this.$onInit=function(){u.categories=_.map(c.defaults.SOGoCalendarCategories,function(e){return{id:e.asCSSIdentifier(),name:e,color:c.defaults.SOGoCalendarCategoriesColors[e]}}),t.$watch(function(){return _.union(_.map(d.$calendars,function(e){return _.pick(e,["id","active","color"])}),_.map(d.$subscriptions,function(e){return _.pick(e,["id","active","color"])}),_.map(d.$webcalendars,function(e){return _.pick(e,["id","active","color"])}))},function(t,n){var a,i,r;a=_.intersectionBy(t,n,"id"),i=_.map(_.filter(a,function(e){var t=_.find(n,{id:e.id});return!_.isEqual(e,t)}),"id"),r=d.$q.when(),i.length>0&&(o.debug(i.join(", ")+" changed"),r=d.saveFoldersActivation(i)),(i.length>0||a.length!=t.length||a.length!=n.length)&&r.then(function(){e.$emit("calendars:list")})},!0)}}angular.module("SOGo.SchedulerUI").controller("CalendarsController",e)}(),function(){"use strict";e.$inject=["$rootScope","$mdDialog","Calendar","Component","AddressBook","Alarm","Account","stateComponent"];function e(e,t,n,a,o,i,r,s){var c,d=this;d.calendarService=n,d.service=a,d.component=s,d.close=function(){t.hide()},d.highPriority=function(){return d.component&&d.component.priority&&d.component.priority<5},d.cardFilter=function(e){return o.$filterAll(e)},d.newMessageWithAllRecipients=function(e){var t=_.map(d.component.attendees,function(e){return e.name+" <"+e.email+">"});u(e,t)},d.newMessageWithRecipient=function(e,t,n){u(e,[t+" <"+n+">"])},d.edit=p,d.editAllOccurrences=function(){(c=n.$get(d.component.pid).$getComponent(d.component.id)).$futureComponentData.then(function(){d.component=c,p()})},d.reply=h,d.replyAllOccurrences=function(){(c=n.$get(d.component.pid).$getComponent(d.component.id)).$futureComponentData.then(function(){c.reply=d.component.reply,c.delegatedTo=d.component.delegatedTo,c.$hasAlarm=d.component.$hasAlarm,c.alarm=d.component.alarm,h(c)})},d.deleteOccurrence=function(){d.component.remove(!0).then(function(){e.$emit("calendars:list"),t.hide()})},d.deleteAllOccurrences=function(){d.component.remove().then(function(){e.$emit("calendars:list"),t.hide()})},d.toggleRawSource=function(e){n.$$resource.post(d.component.pid+"/"+d.component.id,"raw").then(function(n){t.hide(),t.show({parent:angular.element(document.body),targetEvent:e,clickOutsideToClose:!0,escapeToClose:!0,template:['<md-dialog flex="40" flex-sm="80" flex-xs="100" aria-label="'+l("View Raw Source")+'">',' <md-dialog-content class="md-dialog-content">',' <pre ng-bind-html="data"></pre>'," </md-dialog-content>"," <md-dialog-actions>",' <md-button ng-click="close()">'+l("Close")+"</md-button>"," </md-dialog-actions>","</md-dialog>"].join(""),controller:a,locals:{data:n}}),a.$inject=["scope","$mdDialog","data"];function a(e,t,n){e.data=n,e.close=function(){t.hide()}}})},d.copySelectedComponent=function(n){d.component.copyTo(n).then(function(){t.hide(),e.$emit("calendars:list")})},d.moveSelectedComponent=function(n){d.component.moveTo(n).then(function(){t.hide(),e.$emit("calendars:list")})},d.organizer=[s.organizer];function u(e,n){r.$findAll().then(function(a){var o=_.find(a,function(e){if(0===e.id)return e});o.$getMailboxes().then(function(a){o.$newMessage().then(function(a){angular.extend(a.editable,{to:n,subject:d.component.summary}),t.show({parent:angular.element(document.body),targetEvent:e,clickOutsideToClose:!1,escapeToClose:!1,templateUrl:"../Mail/UIxMailEditor",controller:"MessageEditorController",controllerAs:"editor",locals:{stateAccount:o,stateMessage:a}})})})}),e.preventDefault(),e.stopPropagation()}function p(){var e="vevent"==d.component.component?"Appointment":"Task";t.hide().then(function(){var n="UIx"+e+"EditorTemplate";t.show({parent:angular.element(document.body),clickOutsideToClose:!0,escapeToClose:!0,templateUrl:n,controller:"ComponentEditorController",controllerAs:"editor",locals:{stateComponent:d.component}})})}function h(n){(n||d.component).$reply().then(function(){e.$emit("calendars:list"),i.getAlarms(),t.hide()})}}t.$inject=["$rootScope","$scope","$log","$timeout","$mdDialog","sgFocus","User","CalendarSettings","Calendar","Component","AddressBook","Card","Alarm","stateComponent"];function t(e,t,n,a,o,i,r,s,c,d,u,p,h,m){var f,g,y=this;y.service=c,y.component=m,y.categories={},y.showRecurrenceEditor=y.component.$hasCustomRepeat,y.toggleRecurrenceEditor=function(){y.showRecurrenceEditor=!y.showRecurrenceEditor,y.component.$hasCustomRepeat=y.showRecurrenceEditor},y.recurrenceMonthDaysAreRequired=function(){return y.component&&"monthly"==y.component.repeat.frequency&&"bymonthday"==y.component.repeat.month.type},y.showAttendeesEditor=y.component.attendees&&y.component.attendees.length,y.toggleAttendeesEditor=function(){y.showAttendeesEditor=!y.showAttendeesEditor},y.changeFrequency=function(){"custom"==y.component.repeat.frequency&&(y.showRecurrenceEditor=!0)},y.changeCalendar=function(){y.component.attendees&&y.component.attendees.length>0&&y.component.initOrganizer(c.$get(y.component.destinationCalendar))},y.cardFilter=function(e){return u.$filterAll(e),u.$cards},y.addAttendee=function(e){var t,n,a=!y.component.attendees||0===y.component.attendees.length,o=c.$get(y.component.destinationCalendar),i=a?{organizerCalendar:o}:{},r=/([\w\!\#$\%\&\'\*\+\-\/\=\?\^\`{\|\}\~]+\.)*[\w\!\#$\%\&\'\*\+\-\/\=\?\^\`{\|\}\~]+@((((([a-z0-9]{1}[a-z0-9\-]{0,62}[a-z0-9]{1})|[a-z])\.)+[a-z]{2,})|(\d{1,3}\.){3}\d{1,3}(\:\d{1,5})?)/i;function s(e){var t=e.match(r),n=t[0],o=e.replace(new RegExp(" *<?"+n+">? *"),"");return y.showAttendeesEditor|=a,y.searchText="",new p({c_cn:_.trim(o,' "'),emails:[{value:n}]})}if(angular.isString(e)){for(n="",t=0;t<e.length;t++)9!=e.charCodeAt(t)&&32!=e.charCodeAt(t)&&44!=e.charCodeAt(t)&&59!=e.charCodeAt(t)||!r.test(n)?n+=e.charAt(t):(y.component.addAttendee(s(n),i),n="");n&&y.component.addAttendee(s(n),i)}else y.component.addAttendee(e,i),y.showAttendeesEditor|=a},y.removeAttendee=function(e,t){y.component.deleteAttendee(e),0===y.component.attendees.length&&(y.showAttendeesEditor=!1);t.$setDirty()},y.addAttachUrl=function(){var e=y.component.addAttachUrl("");i("attachUrl_"+e)},y.priorityLevel=function(){if(y.component&&y.component.priority)return y.component.priority>5?l("low"):y.component.priority>4?l("normal"):l("high")},y.changeAlarmRelation=v,y.onAlarmChange=function(e){if("task"!==y.component.type)return;y.component.start||"START"!=y.component.alarm.relation?y.component.due||"END"!=y.component.alarm.relation||(y.component.alarm.relation="START"):y.component.alarm.relation="END"},y.reset=$,y.cancel=function(e){$(e),y.component.isNew&&(y.component=null);o.hide()},y.edit=C,y.save=function(t,n){v(t),t.$valid&&y.component.$save(n).then(function(t){e.$emit("calendars:list"),h.getAlarms(),o.hide()},function(e){e.status==s.ConflictHTTPErrorCode&&_.isObject(e.data.message)?y.attendeeConflictError=e.data.message:C(t)})},y.attendeeConflictError=!1,y.attendeesEditor={days:b(),hours:function(){for(var e=[],t=0;t<=23;t++)e.push(t.toString());return e}()},y.addStartDate=function(e){y.component.$addStartDate(),f=new Date(y.component.start.getTime()),y.component.due||(y.component.alarm.relation="START");v(e)},y.removeStartDate=function(e){y.component.$deleteStartDate(),y.component.due&&(y.component.alarm.relation="END");v(e)},y.addDueDate=function(e){y.component.$addDueDate(),new Date(y.component.due.getTime()),y.component.start||(y.component.alarm.relation="END");v(e)},y.removeDueDate=function(e){y.component.$deleteDueDate(),y.component.start&&(y.component.alarm.relation="START");v(e)},y.adjustStartTime=function(){if(y.component.start){0!==f.valueOf()-y.component.start.valueOf()&&(f=new Date(y.component.start.getTime()),"appointment"===y.component.type&&(y.component.end=new Date(y.component.start.getTime()),y.component.end.addMinutes(y.component.delta),g=new Date(y.component.end.getTime())),D())}},y.adjustEndTime=function(){if(y.component.end){var e=g.valueOf()-y.component.end.valueOf();0!==e&&((e=y.component.start.minutesTo(y.component.end))<0?y.component.end=new Date(g.getTime()):(y.component.delta=e,g=new Date(y.component.end.getTime())),D())}},y.adjustDueTime=function(){new Date(y.component.due.getTime())},y.component.start&&(f=new Date(y.component.start.getTime())),y.component.end&&(g=new Date(y.component.end.getTime())),y.component.due&&new Date(y.component.due.getTime());function v(e){"task"==y.component.type&&(!y.component.start&&"START"==y.component.alarm.relation||!y.component.due&&"END"==y.component.alarm.relation)?e.alarmRelation.$setValidity("alarm",!1):e.alarmRelation.$setValidity("alarm",!0)}function $(e){y.component.$reset(),e.$setPristine()}function C(e){y.attendeeConflictError=!1,e.$setPristine(),e.$setDirty()}function b(){var e=[];return y.component.start&&y.component.end&&(e=y.component.start.daysUpTo(y.component.end)),_.map(e,function(e){return{stringWithSeparator:e.stringWithSeparator(),getDayString:e.getDayString()}})}function D(){y.attendeesEditor.days=b(),y.component.updateFreeBusy()}}angular.module("SOGo.SchedulerUI").controller("ComponentController",e).controller("ComponentEditorController",t)}(),function(){"use strict";e.$inject=["$scope","Calendar"];function e(e,t){this.day=e.day,this.dayNumber=e.dayNumber,this.dayString=e.dayString,this.calendarData=function(){var n,a,o;return e.calendar?(n=e.calendar,o=_.filter(t.$findAll(),{active:1}),a=_.findIndex(o,function(e){return e.id==n}),{pid:n,index:a}):null}}angular.module("SOGo.SchedulerUI").directive("sgCalendarDay",function(){return{restrict:"E",scope:{day:"@sgDay",dayNumber:"@sgDayNumber",dayString:"@sgDayString",calendar:"@sgCalendar"},controller:e}})}(),function(){"use strict";e.$inject=["CalendarSettings"];function e(e){return{restrict:"E",scope:{block:"=sgBlock",clickBlock:"&sgClick"},replace:!0,template:function(e,t){var n=_.has(t,"sgCalendarGhost")?"":"::";return['<div class="sg-event"'," ng-class=\"{'sg-event--dragging': block.dragging}\">",' <div class="eventInside"',' ng-click="clickBlock({clickEvent: $event, clickComponent: block.component})">',' <div class="sg-category" ng-repeat="category in '+n+'block.component.categories"',' ng-class="'+n+"('bg-category' + category)\"",' ng-style="'+n+"{ right: ($index * 3) + 'px' }\"></div>",' <div class="text">',' <span ng-show="'+n+'block.component.c_priority" class="sg-priority">{{'+n+"block.component.c_priority}}</span>"," {{ "+n+"block.component.summary }}",' <span class="icons">',' <md-icon ng-if="'+n+'block.component.occurrenceId" class="material-icons icon-repeat"></md-icon>',' <md-icon ng-if="'+n+'block.component.c_nextalarm" class="material-icons icon-alarm"></md-icon>',' <md-icon ng-if="'+n+'block.component.c_classification == 2" class="material-icons icon-visibility-off"></md-icon>',' <md-icon ng-if="'+n+'block.component.c_classification == 1" class="material-icons icon-vpn-key"></md-icon>'," </span>",' <div class="secondary" ng-if="'+n+'block.component.c_location">',' <md-icon>place</md-icon> <span ng-bind="'+n+'block.component.c_location"></span>'," </div>"," </div>"," </div>",' <div class="ghostStartHour" ng-if="block.startHour">{{ block.startHour }}</div>',' <div class="ghostEndHour" ng-if="block.endHour">{{ block.endHour }}</div>',"</div>"].join("")},link:function(e,t,n){var a,o,i;_.has(n,"sgCalendarGhost")||(a=100/e.block.siblings,o=e.block.position*a,0===(i=100-(e.block.position+1)*a)&&(i=10),t.css("left",o+"%"),t.css("right",i+"%"),e.block.component&&e.block.component.c_isallday||(t.addClass("starts"+e.block.start),t.addClass("lasts"+e.block.length)),e.block.userState&&t.addClass("sg-event--"+e.block.userState),e.block.component&&(t.addClass("bg-folder"+e.block.component.pid),t.addClass("contrast-bdr-folder"+e.block.component.pid),0===e.block.component.c_isopaque&&t.addClass("sg-event--transparent"),0===e.block.component.c_status&&t.addClass("sg-event--cancelled")))}}}angular.module("SOGo.SchedulerUI").directive("sgCalendarDayBlock",e)}(),function(){"use strict";angular.module("SOGo.SchedulerUI").directive("sgCalendarDayTable",function(){return{restrict:"E",scope:{blocks:"=sgBlocks",day:"@sgDay",clickBlock:"&sgClick"},template:["<sg-calendar-day-block",' class="sg-draggable-calendar-block"',' ng-repeat="block in blocks[day]"',' sg-block="block"',' sg-click="clickBlock({event: clickEvent, component: clickComponent})"/>'].join("")}})}(),function(){"use strict";e.$inject=["$rootScope","$timeout","CalendarSettings","Calendar","Component"];function e(e,t,n,a,o){return{restrict:"A",require:["^sgCalendarDay","^sgCalendarScrollView"],link:function(t,i,r,s){var c,l,d,u,p;c=i[0],l=s[0],d=s[1],u=-1,i.addClass("sg-event--ghost md-whiteframe-3dp ng-hide");var h=e.$on("calendar:dragstart",function(){var e,n,a;t.block=o.$ghost,(n=l.calendarData())&&(u=n.index,e=n.pid,p=t.block.pointerHandler.originalCalendar.index);e||(e=t.block.component.pid);(a=t.block.component.blocks[0].userState)&&i.addClass("sg-event--"+a);i.addClass("bg-folder"+e)}),m=e.$on("calendar:drag",function(){var e,o,r,s,c,h,m,f;if(e=!1,a.$view&&a.$view.type==d.type){if(o="multiday-allday"===d.type,r=t.block.component.c_isallday,s=t.block.pointerHandler.currentEventCoordinates.dayNumber,c=t.block.pointerHandler.currentEventCoordinates.start,m=t.block.pointerHandler.currentEventCoordinates.duration,f=n.EventDragDayLength-c,angular.isUndefined(m))return;for((h=m)>f&&(h=f),s>-1&&(u<0&&s==l.dayNumber||s==u&&(p==u||!t.block.component.isException))&&(e=!0,o||(r||(t.block.startHour=($=c,g($))),a.$view.quarterHeight?(i.css("top",c*a.$view.quarterHeight+"px"),i.css("height",h*a.$view.quarterHeight+"px")):i.css("top",a.$view.topOffset+"px")),i.removeClass("fg-folder"+t.block.component.pid),i.removeClass("sg-event--ghost--last"),i.addClass("sg-event--ghost--first"),t.block.isFirst=!0),m-=h,s++;!e&&m&&s<=l.dayNumber;)(h=m)>n.EventDragDayLength&&(h=n.EventDragDayLength),s>-1&&s==l.dayNumber&&(e=!0,o||(i.css("top",a.$view.topOffset+"px"),a.$view.quarterHeight&&i.css("height",h*a.$view.quarterHeight+"px")),i.removeClass("sg-event--ghost--first"),i.removeClass("sg-event--ghost--last"),i.addClass("fg-folder"+t.block.component.pid)),m-=h,s++,c=0;m||(o?i.addClass("sg-event--ghost--last"):r||(t.block.endHour=(y=c,v=h,g((y+v)%n.EventDragDayLength))))}var y,v;var $;e?i.removeClass("ng-hide"):i.addClass("ng-hide")}),f=e.$on("calendar:dragend",function(){_.forEachRight(c.classList,function(e){/^bg-folder/.test(e)&&i.removeClass(e)}),i.addClass("ng-hide")});t.$on("$destroy",function(){h(),m(),f()});function g(e){var t,n,a;return t=15*e,(n=Math.floor(t/60))<10&&(n="0"+n),(a=t%60)<10&&(a="0"+a),n+":"+a}}}}angular.module("SOGo.SchedulerUI").directive("sgCalendarGhost",e)}(),function(){"use strict";e.$inject=["CalendarSettings"];function e(e){return{restrict:"E",scope:{component:"=sgComponent",clickComponent:"&sgClick"},replace:!0,template:function(e,t){return['<div class="sg-event"',' ng-click="clickComponent({clickEvent: $event, clickComponent: component})">',' <div class="sg-category" ng-repeat="category in ::component.categories"'," ng-class=\"::('bg-category' + category)\""," ng-style=\"::{ right: ($index * 3) + 'px' }\"></div>",' <span ng-show="::component.c_priority" class="sg-priority" ng-bind="::component.c_priority"></span>'," {{ ::component.c_title }}",' <span class="icons">',' <md-icon ng-if="::component.occurrenceId" class="material-icons icon-repeat"></md-icon>',' <md-icon ng-if="::component.c_nextalarm" class="material-icons icon-alarm"></md-icon>',' <md-icon ng-if="::component.c_classification == 2" class="material-icons icon-visibility-off"></md-icon>',' <md-icon ng-if="::component.c_classification == 1" class="material-icons icon-vpn-key"></md-icon>'," </span>",' <div class="secondary" ng-if="::!component.c_isallday">',' <md-icon>access_time</md-icon> <span ng-bind="::component.starthour"></span>'," </div>",' <div class="secondary" ng-if="::component.c_location">',' <md-icon>place</md-icon> <span ng-bind="::component.c_location"></span>'," </div>","</div>"].join("")},link:function(e,t,n){e.component.viewable&&t.addClass("md-clickable");e.component.userstate&&t.addClass("sg-event--"+e.component.userstate);t.addClass("bg-folder"+e.component.pid),t.addClass("contrast-bdr-folder"+e.component.pid),0===e.component.c_isopaque&&t.addClass("sg-event--transparent");0===e.component.c_status&&t.addClass("sg-event--cancelled")}}}angular.module("SOGo.SchedulerUI").directive("sgCalendarListEvent",e)}(),function(){e.$inject=["$rootScope","$scope","$element","$mdToast","$mdPanel","$mdMedia","$mdSidenav","sgConstant","Dialog","Calendar"];function e(e,t,n,a,o,i,r,s,c,d){var u=this;this.$onInit=function(){this.editMode=!1},this.$postLink=function(){this.clickableElement=n.find("p")[0],this.nameElements=this.clickableElement.getElementsByClassName("sg-calendar-name"),this.inputContainer=n.find("md-input-container")[0],this.inputElement=n.find("input")[0],this.moreOptionsButton=_.last(n.find("md-icon")),this.updateCalendarName()},this.updateCalendarName=function(){_.forEach(this.nameElements,function(e){e.innerHTML=u.calendar.name})},this.editFolder=function(e){this.editMode=!0,this.inputElement.value=this.calendar.name,this.clickableElement.classList.add("ng-hide"),this.inputContainer.classList.remove("ng-hide"),this.inputElement.focus(),this.inputElement.select(),e&&(e.stopPropagation(),e.preventDefault())},this.saveFolder=function(e){this.inputElement.disabled||(this.calendar.name=this.inputElement.value,this.inputElement.disabled=!0,this.calendar.$rename().then(function(e){u.editMode=!1,u.inputContainer.classList.add("ng-hide"),u.clickableElement.classList.remove("ng-hide"),u.updateCalendarName()}).finally(function(){u.inputElement.disabled=!1}))},this.revertEditing=function(){this.editMode=!1,this.clickableElement.classList.remove("ng-hide"),this.inputContainer.classList.add("ng-hide"),this.inputElement.value=this.calendar.name},this.confirmDelete=function(){this.calendar.isSubscription?this.calendar.$delete().catch(function(e,t){c.alert(l('An error occured while deleting the calendar "%{0}".',u.calendar.name),l(e.error))}):c.confirm(l("Warning"),l('Are you sure you want to delete the calendar "%{0}"?',this.calendar.name),{ok:l("Delete")}).then(function(){u.calendar.$delete().catch(function(e,t){c.alert(l('An error occured while deleting the calendar "%{0}".',u.calendar.name),l(e.error))})})},this.showMenu=function(t){var n=o.newPanelPosition().relativeTo(this.moreOptionsButton).addPanelPosition(o.xPosition.ALIGN_START,o.yPosition.ALIGN_TOPS),i=o.newPanelAnimation().openFrom(this.moreOptionsButton).duration(100).withAnimation(o.animation.FADE),r={attachTo:angular.element(document.body),locals:{itemCtrl:this,calendar:this.calendar,editFolder:angular.bind(this,this.editFolder),confirmDelete:angular.bind(this,this.confirmDelete)},bindToController:!0,controller:s,controllerAs:"$menuCtrl",position:n,animation:i,targetEvent:t,templateUrl:"UIxCalendarMenu",trapFocus:!0,clickOutsideToClose:!0,escapeToClose:!0,focusOnOpen:!0};o.open(r).then(function(e){e.panelEl.one("click",function(){e.close()})}),s.$inject=["mdPanelRef","$mdDialog","FileUploader","User"];function s(n,o,i,r){var s=this;this.showOnly=function(){_.forEach(d.$findAll(),function(e){s.calendar.id==e.id?e.active=1:e.active=0})},this.showAll=function(){_.forEach(d.$findAll(),function(e){e.active=1})},this.showProperties=function(){var e=this.calendar.color;o.show({templateUrl:this.calendar.id+"/properties",controller:t,controllerAs:"properties",clickOutsideToClose:!0,escapeToClose:!0,locals:{srcCalendar:this.calendar}}).catch(function(){s.calendar.color=e}),t.$inject=["$scope","$mdDialog","srcCalendar"];function t(e,t,n){var a=this;a.calendar=new d(n.$omit()),a.saveProperties=function(e){e.$valid&&(a.calendar.$save(),n.init(a.calendar.$omit()),t.hide())},a.close=function(){t.cancel()},e.$watch(function(){return a.calendar.color},function(){n.color=a.calendar.color})}},this.showLinks=function(){o.show({parent:angular.element(document.body),clickOutsideToClose:!0,escapeToClose:!0,templateUrl:this.calendar.id+"/links",controller:e,controllerAs:"links",locals:{calendar:this.calendar}}),e.$inject=["$mdDialog","calendar"];function e(e,t){this.calendar=t,this.close=function(){e.hide()}}},this.importCalendar=function(){o.show({parent:angular.element(document.body),targetEvent:t,clickOutsideToClose:!0,escapeToClose:!0,templateUrl:"UIxCalendarImportDialog",controller:n,controllerAs:"$CalendarImportDialogController",locals:{folder:this.calendar}}),n.$inject=["scope","$mdDialog","folder"];function n(t,n,o){this.uploader=new i({url:ApplicationBaseURL+[o.id,"import"].join("/"),autoUpload:!0,queueLimit:1,filters:[{name:r,fn:r}],onSuccessItem:function(t,o,i,r){var s;n.hide(),0===o.imported?s=l("No event was imported."):(s=l("A total of %{0} events were imported in the calendar.",o.imported),e.$emit("calendars:list")),a.show(a.simple().content(s).position("top right").hideDelay(3e3))},onErrorItem:function(e,t,n,o){a.show({template:["<md-toast>",' <div class="md-toast-content">',' <md-icon class="md-warn md-hue-1">error_outline</md-icon>'," <span>"+l("An error occurred while importing calendar.")+"</span>"," </div>","</md-toast>"].join(""),position:"top right",hideDelay:3e3})}}),this.close=function(){n.hide()};function r(e){var t=0===e.type.indexOf("text")||/\.(ics)$/.test(e.name);return t||a.show({template:["<md-toast>",' <div class="md-toast-content">',' <md-icon class="md-warn md-hue-1">error_outline</md-icon>'," <span>"+l("Select an iCalendar file (.ics).")+"</span>"," </div>","</md-toast>"].join(""),position:"top right",hideDelay:3e3}),t}}},this.share=function(){this.calendar.$acl.$users().then(function(){o.show({templateUrl:s.calendar.id+"/UIxAclEditor",controller:"AclController",controllerAs:"acl",clickOutsideToClose:!0,escapeToClose:!0,locals:{usersWithACL:s.calendar.$acl.users,User:r,folder:s.calendar}})})}}}}angular.module("SOGo.SchedulerUI").controller("sgCalendarListItemController",e).directive("sgCalendarListItem",function(){return{restrict:"C",scope:{},bindToController:{calendar:"=sgCalendar"},template:['<md-switch ng-model="$ctrl.calendar.active"'," ng-class=\"$ctrl.calendar.getClassName('md-switch')\"",' ng-true-value="1"',' ng-false-value="0"',' aria-label="'+l("Enable")+'"></md-switch>','<p class="sg-item-name"',' ng-dblclick="$ctrl.editFolder($event)">',' <span ng-bind="$ctrl.calendar.name"></span>',' <md-icon ng-if="$ctrl.calendar.$error" class="md-warn">error</md-icon>',' <md-tooltip md-delay="1000"',' md-autohide="true"',' ng-bind="$ctrl.calendar.name"></md-tooltip>',' <span class="sg-counter-badge ng-hide"',' ng-show="calendar.activeTasks"',' ng-bind="calendar.activeTasks"></span>',"</p>",'<md-input-container class="md-flex ng-hide">',' <input class="sg-item-name" type="text"',' aria-label="'+l("Name of the Calendar")+'"',' ng-blur="$ctrl.saveFolder($event)"',' sg-enter="$ctrl.saveFolder($event)"',' sg-escape="$ctrl.revertEditing()" />',"</md-input-container>",'<md-button class="md-secondary md-icon-button" ',' as-sortable-item-handle="as-sortable-item-handle">'," <md-icon md-colors=\"::{color: 'accent-400'}\">drag_handle</md-icon>","</md-button>",'<md-icon class="md-menu sg-list-sortable-hide"',' ng-click="$ctrl.showMenu($event)"',' aria-label="'+l("Options")+'">more_vert</md-icon>'].join(""),controller:"sgCalendarListItemController",controllerAs:"$ctrl"}})}(),function(){"use strict";angular.module("SOGo.SchedulerUI").directive("sgCalendarMonthDay",function(){return{restrict:"E",scope:{blocks:"=sgBlocks",day:"@sgDay",clickBlock:"&sgClick"},template:["<sg-calendar-month-event",' class="sg-draggable-calendar-block"',' ng-repeat="block in blocks[day]"',' sg-block="block"',' sg-click="clickBlock({event: clickEvent, component: clickComponent})"/>'].join("")}})}(),function(){"use strict";angular.module("SOGo.SchedulerUI").directive("sgCalendarMonthEvent",function(){return{restrict:"E",scope:{block:"=sgBlock",clickBlock:"&sgClick"},replace:!0,template:function(e,t){var n=_.has(t,"sgCalendarGhost")?"":"::";return['<div class="sg-event"'," ng-class=\"{'sg-event--dragging': block.dragging}\"",' ng-click="clickBlock({clickEvent: $event, clickComponent: block.component})">',' <div class="sg-category" ng-repeat="category in '+n+'block.component.categories"',' ng-class="'+n+"('bg-category' + category)\"",' ng-style="'+n+"{ right: ($index * 3) + 'px' }\"></div>",' <span class="secondary" ng-if="'+n+'(!block.component.c_isallday && block.isFirst)">{{ '+n+"block.component.startHour }}</span>",' <span ng-show="'+n+'block.component.c_priority" class="sg-priority">{{'+n+"block.component.c_priority}}</span>"," {{ "+n+"block.component.summary }}",' <span class="icons">',' <md-icon ng-if="'+n+'block.component.occurrenceId" class="material-icons icon-repeat"></md-icon>',' <md-icon ng-if="'+n+'block.component.c_nextalarm" class="material-icons icon-alarm"></md-icon>',' <md-icon ng-if="'+n+'block.component.c_classification == 2" class="material-icons icon-visibility-off"></md-icon>',' <md-icon ng-if="'+n+'block.component.c_classification == 1" class="material-icons icon-vpn-key"></md-icon>'," </span>","</div>"].join("")},link:function(e,t,n){_.has(n,"sgCalendarGhost")||(e.block.userState&&t.addClass("sg-event--"+e.block.userState),e.block.component&&(t.addClass("bg-folder"+e.block.component.pid),0===e.block.component.c_isopaque&&t.addClass("sg-event--transparent"),0===e.block.component.c_status&&t.addClass("sg-event--cancelled")))}}})}(),function(){"use strict";e.$inject=["$rootScope","$window","$document","$q","$timeout","$mdGesture","Calendar","Component","Preferences"];function e(e,n,a,o,i,r,s,c,l){return{restrict:"A",scope:{type:"@sgCalendarScrollView"},controller:t,link:function(t,a,o,r){var d,u,p=!1;d=null,u=t.type,p="multicolumndayview"==a.attr("sg-view"),r.isMultiColumn=p,i(function(){if(d=new h(a,u),"monthly"!=u){var e,t,n;l.defaults.SOGoDayStartTime&&(e=l.defaults.SOGoDayStartTime.split(":"),t=document.getElementById("hour"+parseInt(e[0])),n=parseInt(e[1])*d.quarterHeight,d.element.scrollTop=t.offsetTop+n)}r.quarterHeight=d.quarterHeight}),t.$on("$destroy",function(){d&&d.$destroy()});function h(t,a){this.$element=t,this.element=t[0],this.type=a,this.quarterHeight=this.getQuarterHeight(),this.scrollStep=6*this.quarterHeight,this.dayNumbers=this.getDayNumbers(),this.maxX=this.getMaxColumns(),this.deregisterDragStart=e.$on("calendar:dragstart",angular.bind(this,this.onDragStart)),this.deregisterDragStop=e.$on("calendar:dragend",angular.bind(this,this.onDragEnd)),this.bindedUpdateCoordinates=angular.bind(this,this.updateCoordinates),this.bindedUpdateFromPointerHandler=angular.bind(this,this.updateFromPointerHandler),this.updateCoordinates(),angular.element(n).on("resize",this.bindedUpdateCoordinates)}h.prototype={$destroy:function(){this.deregisterDragStart(),this.deregisterDragStop(),this.$element.off("mousemove",this.bindedUpdateFromPointerHandler),angular.element(n).off("resize",this.bindedUpdateCoordinates)},onDragStart:function(){this.$element.on("mousemove",this.bindedUpdateFromPointerHandler),this.updateCoordinates(),this.updateFromPointerHandler()},onDragEnd:function(){this.$element.off("mousemove",this.bindedUpdateFromPointerHandler),s.$view=null},getQuarterHeight:function(){var e,t,n=null;return e=document.getElementById("hour0"),t=document.getElementById("hour23"),e&&t&&(n=(t.offsetTop-e.offsetTop)/92),n},getDayDimensions:function(e){var t,n,a,o,i,r,s;return n=t=a=o=0,(i=this.element.getElementsByClassName("day")).length>0&&(n=(r=i[0].getBoundingClientRect()).height,t=r.width,a=r.left-e,(s=i[0].getElementsByClassName("sg-calendar-tile-header")).length>0&&(o=s[0].clientHeight)),{height:n,width:t,offset:{left:a,top:o}}},getDayNumbers:function(){var e;return e=this.element.getElementsByTagName("sg-calendar-day"),_.map(e,function(e,t){return p?t:parseInt(e.attributes["sg-day-number"].value)})},getMaxColumns:function(){var e,t=0;return"monthly"==this.type?(e=this.element.getElementsByTagName("md-grid-list")[0],t=parseInt(e.attributes["md-cols"].value)-1):t=this.element.getElementsByClassName("day").length-1,t},updateCoordinates:function(){var e,t;e=this.element.getBoundingClientRect(),t=this.getDayDimensions(e.left),angular.extend(this,{coordinates:{x:e.left,y:e.top},dayHeight:t.height,dayWidth:t.width,daysOffset:t.offset.left,topOffset:t.offset.top})},updateFromPointerHandler:function(){var e,t,n,a,o,i;e=c.$ghost.pointerHandler,this.coordinates&&e&&(t=e.getContainerBasedCoordinates(this))&&(s.$view=this,n=(new Date).getTime(),(!this.lastScroll||n>this.lastScroll+100)&&(this.lastScroll=n,(a=t.y-this.scrollStep)<0?(a<(o=-this.element.scrollTop)&&(a=o),this.element.scrollTop+=a):(i=(a=t.y+this.scrollStep)-this.element.clientHeight)>0&&(this.element.scrollTop+=i)))}}}}}t.$inject=["$scope"];function t(e){this.type=e.type}angular.module("SOGo.SchedulerUI").directive("sgCalendarScrollView",e)}(),function(){"use strict";angular.module("SOGo.SchedulerUI").directive("sgCategoryStylesheet",function(){return{restrict:"E",require:"ngModel",scope:{ngModel:"="},replace:!0,template:['<style type="text/css">'," .bg-category{{ ngModel.id }} {"," background-color: {{ ngModel.color }} !important;"," }"," .bdr-category{{ ngModel.id }} {"," border-color: {{ ngModel.color }} !important;"," }","</style>"].join("")}})}(),function(){"use strict";e.$inject=["$rootScope","$timeout","$log","Preferences","Calendar","CalendarSettings","Component"];function e(e,t,n,a,o,i,r){return{restrict:"CA",require:"^sgCalendarDay",link:function(s,c,d,u){if(s.block){if(!s.block.component.editable||s.block.userState)return void c.removeClass("sg-draggable-calendar-block");!function(){var e,t,n,a,o,i,r,l,d,u;if(s.block.length<3)return;e=s.block.component,t=s.block.dayIndex,n=_.findIndex(e.blocks,["dayIndex",t]),a=0===n,o=n===e.blocks.length-1,(i=angular.element('<div class="dragGrip"></div>')).addClass("bdr-folder"+e.pid),e.c_isallday||"SG-CALENDAR-MONTH-DAY"===c[0].parentNode.tagName?(a&&(r=angular.element('<div class="dragGrip-left"></div>').append(i),c.append(r)),o&&(l=angular.element('<div class="dragGrip-right"></div>').append(i.clone()),c.append(l))):(a&&(d=angular.element('<div class="dragGrip-top"></div>').append(i),c.append(d)),o&&(u=angular.element('<div class="dragGrip-bottom"></div>').append(i.clone()),c.append(u)))}()}c.on("mousedown",p),s.$on("$destroy",function(){c.off("mousedown",p),c.off("mousemove",h)});function p(e){var t,n,a,o;e.stopPropagation(),e.target.scrollHeight>e.target.clientHeight+1&&(a=e.target.getBoundingClientRect(),o=a.left+a.width-18,e.pageX>o)||(t="move-event",s.block&&s.block.component?"dragGrip-top"==e.target.className||"dragGrip-left"==e.target.className?t="change-start":"dragGrip-bottom"!=e.target.className&&"dragGrip-right"!=e.target.className||(t="change-end"):t="change-end",(n=new y(t)).initFromEvent(e),r.$ghost.pointerHandler=n,angular.element(document).one("mouseup",m),angular.element(document).on("mousemove",h))}function h(e){var n=r.$ghost.pointerHandler;t(function(){n.updateFromEvent(e)})}function m(t){var n,a;n=s.block,a=r.$ghost.pointerHandler,angular.element(document).off("mousemove",h),a.dragHasStarted&&(e.$emit("calendar:dragend"),a.dragHasStarted=!1),n&&n.component&&_.forEach(n.component.blocks,function(e){e.dragging=!1})}function f(){}f.prototype={x:-1,y:-1,getDelta:function(e){var t=new f;return t.x=this.x-e.x,t.y=this.y-e.y,o.$view&&(t.days=o.$view.dayNumbers[this.x]-o.$view.dayNumbers[e.x]),t},getDistance:function(e){var t=this.getDelta(e);return Math.sqrt(t.x*t.x+t.y*t.y)},clone:function(){var e=new f;return e.x=this.x,e.y=this.y,e}};function g(e){this.setEventType(e)}g.prototype={dayNumber:-1,weekDay:-1,start:-1,duration:-1,eventType:null,setEventType:function(e){this.eventType=e},initFromBlock:function(e){var t=-1;"monthly"===this.eventType?(this.start=0,this.duration=e.component.blocks.length*i.EventDragDayLength):(this.start=e.component.blocks[0].start,this.duration=_.sumBy(e.component.blocks,function(e){var n,a;return a=e.dayNumber,n=t<0?0:a-t-1,t=a,e.length+n*i.EventDragDayLength}))},initFromCalendar:function(e){this.dayNumber=e},getDelta:function(e){var t=new g;return t.dayNumber=this.dayNumber-e.dayNumber,t.start=this.start-e.start,t.duration=this.duration-e.duration,t},_quartersToHM:function(e){var t=15*e,n=Math.floor(t/60);n<10&&(n="0"+n);var a=t%60;return a<10&&(a="0"+a),n+":"+a},getStartTime:function(){return this._quartersToHM(this.start)},getEndTime:function(){var e=(this.start+this.duration)%i.EventDragDayLength;return this._quartersToHM(e)},clone:function(){var e=new g;return e.dayNumber=this.dayNumber,e.start=this.start,e.duration=this.duration,e}};function y(e){this.dragMode=e}y.prototype={originalCoordinates:null,currentCoordinates:null,originalViewCoordinates:null,currentViewCoordinates:null,originalEventCoordinates:null,currentEventCoordinates:null,originalCalendar:null,dragHasStarted:!1,getEventViewCoordinates:null,initFromBlock:function(e){this.currentEventCoordinates=new g(this.eventType),this.originalEventCoordinates=new g(this.eventType),this.originalEventCoordinates.initFromBlock(e)},initFromEvent:function(e){this.currentCoordinates=new f,this.updateFromEvent(e),this.originalCoordinates=this.currentCoordinates.clone()},initFromCalendar:function(e){this.originalCalendar=e,this.currentEventCoordinates.initFromCalendar(e.index),this.originalEventCoordinates.initFromCalendar(e.index)},updateFromEvent:function(t){if(this.currentCoordinates.x=t.pageX,this.currentCoordinates.y=t.pageY,this.dragHasStarted&&o.$view){var i=this.getEventViewCoordinates(o.$view);this.originalViewCoordinates||(this.originalViewCoordinates=this.getEventViewCoordinates(o.$view,this.originalCoordinates),r.$ghost.component.isNew&&(this.setTimeFromQuarters(r.$ghost.component.start,this.originalViewCoordinates.y),n.debug("new event start date "+r.$ghost.component.start))),this.currentViewCoordinates&&i&&i.x==this.currentViewCoordinates.x&&i.y==this.currentViewCoordinates.y||(this.currentViewCoordinates=i,this.originalViewCoordinates&&(i||(this.currentViewCoordinates=this.originalViewCoordinates.clone()),this.updateEventCoordinates()))}else if(this.originalCoordinates&&this.currentCoordinates&&!this.dragHasStarted){var d=this.getDistance();d>3&&(this.dragHasStarted=!0,function(t){var i,d,p,h,m,f,g,y,v;p=c.hasClass("clickableHourCell"),h="SG-CALENDAR-MONTH-DAY"==c[0].parentNode.tagName||c.hasClass("clickableDayCell"),v=u.calendarData(),s.block&&s.block.component?i=s.block:(m=u.dayString.parseDate(a.$mdDateLocaleProvider,"%Y-%m-%e"),f={type:"appointment",pid:v?v.pid:o.$defaultCalendar(),summary:l("New Event"),startDate:m,isAllDay:p?0:1},g=new r(f),(i={component:g,dayNumber:u.dayNumber,length:0}).component.blocks=[i]);d="multiday",h?d="monthly":i.component.c_isallday&&(d="multiday-allday");_.forEach(i.component.blocks,function(e){e.dragging=!0}),(y=r.$ghost.pointerHandler).prepareWithEventType(d),y.initFromBlock(i),v&&y.initFromCalendar(v);r.$ghost.component=i.component,n.debug("emit calendar:dragstart "+d),e.$emit("calendar:dragstart")}())}},updateEventCoordinates:function(){var t,a=this.currentViewCoordinates.getDelta(this.originalViewCoordinates),r=a.days*i.EventDragDayLength+a.y;n.debug("quarters delta "+r),angular.isUndefined(this.originalEventCoordinates.start)?(this.originalEventCoordinates.dayNumber=o.$view.dayNumbers[this.originalViewCoordinates.x],this.originalEventCoordinates.start=this.originalViewCoordinates.y):this.originalEventCoordinates.dayNumber<0&&(this.originalEventCoordinates.dayNumber=o.$view.dayNumbers[s.block.component.blocks[0].dayIndex]),this.currentEventCoordinates.dayNumber=this.originalEventCoordinates.dayNumber,"move-event"==this.dragMode?(this.currentEventCoordinates.start=this.originalEventCoordinates.start+r,this.currentEventCoordinates.duration=this.originalEventCoordinates.duration):"change-start"==this.dragMode?(t=this.originalEventCoordinates.duration-r)>0?(this.currentEventCoordinates.start=this.originalEventCoordinates.start+r,this.currentEventCoordinates.duration=t):t<0&&(this.currentEventCoordinates.start=this.originalEventCoordinates.start+this.originalEventCoordinates.duration,this.currentEventCoordinates.duration=-t):"change-end"==this.dragMode&&((t=this.originalEventCoordinates.duration+r)>0?(this.currentEventCoordinates.start=this.originalEventCoordinates.start,this.currentEventCoordinates.duration=t):t<0&&(this.currentEventCoordinates.start=this.originalEventCoordinates.start+t,this.currentEventCoordinates.duration=-t));var c;this.currentEventCoordinates.start<0?(c=Math.ceil(-this.currentEventCoordinates.start/i.EventDragDayLength),this.currentEventCoordinates.start+=c*i.EventDragDayLength,this.currentEventCoordinates.dayNumber-=c):this.currentEventCoordinates.start>=i.EventDragDayLength&&(c=Math.floor(this.currentEventCoordinates.start/i.EventDragDayLength),this.currentEventCoordinates.start-=c*i.EventDragDayLength,this.currentEventCoordinates.dayNumber+=c),n.debug("event coordinates "+JSON.stringify(this.currentEventCoordinates)),e.$emit("calendar:drag")},getContainerBasedCoordinates:function(e,t){var n=t||this.currentCoordinates,a=n.getDelta(e.coordinates),o=e.element;return(a.x<e.daysOffset||a.x>o.clientWidth||a.y<0||a.y>o.clientHeight)&&(a=null),a},prepareWithEventType:function(e){var t={multiday:this.getEventMultiDayViewCoordinates,"multiday-allday":this.getEventMultiDayAllDayViewCoordinates,monthly:this.getEventMonthlyViewCoordinates,unknown:null},n=t[e];this.eventType=e,this.getEventViewCoordinates=n},getEventMultiDayViewCoordinates:function(e,t){var n=this.getEventMultiDayAllDayViewCoordinates(e,t);if(n){var a=e.quarterHeight,o=this.getContainerBasedCoordinates(e,t);o.y+=e.element.scrollTop,n.y=Math.floor((o.y-i.EventDragHorizontalOffset)/a);var r=i.EventDragDayLength-1;n.y<0?n.y=0:n.y>r&&(n.y=r)}return n},getEventMultiDayAllDayViewCoordinates:function(e,t){var n,a=this.getContainerBasedCoordinates(e,t);if(a){n=new f;var i=e.dayWidth,r=e.daysOffset;n.x=Math.floor((a.x-r)/i);var s=0,c=o.$view.maxX;if("move-event"!=this.dragMode){var l=u.calendarData();l&&(s=c=l.index)}n.x<s?n.x=s:n.x>c&&(n.x=c),n.y=0}else n=null;return n},getEventMonthlyViewCoordinates:function(e,t){var n,a=this.getContainerBasedCoordinates(e,t);if(a){n=new f;var o=e.maxX,i=e.dayWidth,r=e.daysOffset,s=e.dayHeight,c=Math.floor((a.y-0)/s);c<0&&(c=0),n.x=Math.floor((a.x-r)/i),n.x<0?n.x=0:n.x>o&&(n.x=o),n.x+=(o+1)*c,n.y=0}else n=null;return n},getDistance:function(){return this.currentCoordinates.getDistance(this.originalCoordinates)},setTimeFromQuarters:function(e,t){var n,a;n=Math.floor(t/4),a=t%4*15,e.setHours(n,a)}}}}}angular.module("SOGo.SchedulerUI").directive("sgDraggableCalendarBlock",e)}(),function(){"use strict";e.$inject=["$scope","$element","$timeout"];function e(e,t,n){var a,o=this,i=t.controller("sgCalendarScrollView");e.nowDay=null,e.lineElement=null,e.updateLine=function(r){var s=new Date,c=s.getDayString(),l=s.getHours(),d=4*e.quarterHeight,u=s.getMinutes(),p=e.quarterHeight/15,h=parseInt(l*d+u*p-1);(r||c!=e.nowDay)&&(e.lineElement&&e.lineElement.remove(),e.lineElement=function(e,n){var a=angular.element("<sg-now-line>");i.isMultiColumn?n&&n[0].attributes["sg-day"].value==e&&t.append(a):_.forEach(n,function(t){t.attributes["sg-day"].value==e&&angular.element(t).find("div").eq(0).append(a)});return a}(c,e.days),e.nowDay=c);e.lineElement&&(e.lineElement.css("top",h+"px"),a=n(angular.bind(o,e.updateLine),6e4))},e.$on("$destroy",function(){a&&n.cancel(a)})}angular.module("SOGo.SchedulerUI").directive("sgNowLine",function(){return{restrict:"C",require:"^^sgCalendarScrollView",link:function(e,t,n,a){function o(){return t.find("sg-calendar-day")}var i=e.$watch(function(){return a.quarterHeight},function(t){if(t){i(),e.quarterHeight=t;var n=e.$watch(o,function(t){t.length&&(n(),e.days=t,e.updateLine())})}})},controller:e}})}();
|
|
//# sourceMappingURL=Scheduler.services.js.map
|