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