2 lines
76 KiB
JavaScript
2 lines
76 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,a,o,i,r,s){return angular.extend(c,{$q:e,$timeout:t,$log:n,$$resource:new o(a.activeUser("folderURL")+"Calendar",a.activeUser()),$Preferences:i,$Component:r,$$Acl:s,activeUser:a.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 a=this;if(e)this.$calendars=[],this.$subscriptions=[],this.$webcalendars=[],angular.forEach(e,function(e,t){var n=new c(e);n.isWebCalendar?a.$webcalendars.push(n):n.isSubscription?a.$subscriptions.push(n):a.$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 a=this;c.$$resource.fetch("calendarslist").then(function(e){_.forEach(e.calendars,function(t){var e,n;e=t.isWebCalendar?a.$webcalendars:t.owner!=c.activeUser.login?a.$subscriptions:a.$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 a=c.$q.defer();return _.find(this.$webcalendars,function(e){return e.urls.webCalendarURL==n})?a.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),a.resolve()},function(e){401==e.status?a.resolve(t):a.reject()})},a.reject),a.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=this.$omit())},c.prototype.$id=function(){return this.id?c.$q.when(this.id):this.$futureCalendarData.then(function(e){return e.id})},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;return c.$$resource.save(this.id,this.$omit()).then(function(e){return t.$shadowData=t.$omit(),e},function(e){return c.$log.error(JSON.stringify(e,void 0,2)),t.$reset(),e})},c.prototype.setCredentials=function(e,t){var n=this,a=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),a.resolve()},function(e){401==e.status?a.reject(l("Wrong username or password")):a.reject(e.statusText)})},a.reject),a.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]=e)}),n}}(),function(){"use strict";function p(e){if("function"!=typeof e.then){if(this.init(e),this.pid&&!this.id){var t=p.$$resource.newguid(this.pid);this.$unwrap(t),this.isNew=!0}}else this.$unwrap(e)}p.$factory=["$q","$timeout","$log","$rootScope","sgSettings","sgComponent_STATUS","Preferences","User","Card","Gravatar","Resource",function(e,t,n,a,o,i,r,s,c,l,d){return angular.extend(p,{STATUS:i,$q:e,$timeout:t,$log:n,$rootScope:a,$settings:o,$User:s,$Preferences:r,$Card:c,$gravatar:l,$$resource:new d(o.activeUser("folderURL")+"Calendar",o.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&&(p.$queryEvents.filterpopup=r.settings.Calendar.EventsFilterState),r.settings.Calendar.TasksFilterState&&(p.$queryTasks.filterpopup=r.settings.Calendar.TasksFilterState),r.settings.Calendar.EventsSortingState&&(p.$queryEvents.sort=r.settings.Calendar.EventsSortingState[0],p.$queryEvents.asc=parseInt(r.settings.Calendar.EventsSortingState[1])),r.settings.Calendar.TasksSortingState&&(p.$queryTasks.sort=r.settings.Calendar.TasksSortingState[0],p.$queryTasks.asc=parseInt(r.settings.Calendar.TasksSortingState[1])),p.$queryTasks.show_completed=parseInt(r.settings.ShowCompletedTasks),p.$categories=r.defaults.SOGoCalendarCategoriesColors,r.defaults.SOGoTimeFormat&&(p.timeFormat=r.defaults.SOGoTimeFormat),p}];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",p.$factory),p.$selectedCount=function(){var e;return e=0,p.$events&&(e+=_.filter(p.$events,function(e){return e.selected}).length),p.$tasks&&(e+=_.filter(p.$tasks,function(e){return e.selected}).length),e},p.$startRefreshTimeout=function(e){p.$refreshTimeout&&p.$timeout.cancel(p.$refreshTimeout);var t=p.$Preferences.defaults.SOGoRefreshViewCheck;if(t&&"manually"!=t){var n=angular.bind(p.$rootScope,p.$rootScope.$emit,"calendars:list");p.$refreshTimeout=p.$timeout(n,1e3*t.timeInterval())}},p.$isLoading=function(){return p.$loaded==p.STATUS.LOADING},p.$filter=function(e,t){var n,a,o=this,i=new Date,r=i.getDate(),s=i.getMonth()+1,c=i.getFullYear(),l="$query"+e.capitalize(),d={day:c+(s<10?"0":"")+s+(r<10?"0":"")+r},u=!1;return p.$startRefreshTimeout(e),angular.extend(this.$query,d),t&&_.forEach(_.keys(t),function(e){u|=o.$query[e]&&t[e]!=p.$query[e],"reload"==e&&t[e]?u=!0:angular.isDefined(o.$query[e])?o.$query[e]=t[e]:o[l][e]=t[e]}),n=this.$$resource.fetch(null,e+"list",angular.extend(this[l],this.$query)),u&&(delete p[a="tasks"==e?"$events":"$tasks"],p.$log.debug("force reload of "+a)),this.$unwrapCollection(e,n)},p.$find=function(e,t,n){var a=[e,encodeURIComponent(t)];return n&&a.push(n),new p(this.$$resource.fetch(a.join("/"),"view"))},p.filterCategories=function(e){var t=new RegExp(e,"i");return _.filter(_.keys(p.$categories),function(e){return-1!=e.search(t)})},p.saveSelectedList=function(e){return this.$$resource.post(null,"saveSelectedList",{list:e+"ListView"})},p.$eventsBlocksForView=function(e,t){var n,a,o,i;return n=p.$Preferences.defaults.SOGoFirstDayOfWeek,"day"==e?(a="dayView",o=i=t):"multicolumnday"==e?(a="multicolumndayView",o=i=t):"week"==e?(a="weekView",o=t.beginOfWeek(n),(i=new Date).setTime(o.getTime()),i.addDays(6)):"month"==e&&(a="monthView",(o=t).setDate(1),o=o.beginOfWeek(n),(i=new Date).setTime(t.getTime()),i.setMonth(i.getMonth()+1),i.addDays(-1),i=i.endOfWeek(n)),this.$eventsBlocks(a,o,i)},p.$eventsBlocks=function(e,t,n){var a,c,l,d=[],u=[],o=p.$q.defer();return a={view:e.toLowerCase(),sd:t.getDayString(),ed:n.getDayString()},this.$$resource.fetch(null,"eventsblocks",a).then(function(e){var r,s;r=function(e,t,n){var a,o=_.zipObject(this.eventsFields,t),i=new Date(1e3*o.c_startdate);return o.hour=i.getHourString(),o.blocks=[],a=new p(o),e.push(a),e},s=function(e){this[e.nbr].blocks.push(e),e.component=this[e.nbr],e.isFirst=1==this[e.nbr].blocks.length},p.$views=[],p.$timeout(function(){_.forEach(e,function(e,t){var n,a=[],o={},i={};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),a),_.forEach(_.flatten(e.blocks),_.bind(s,a)),_.forEach(_.flatten(e.allDayBlocks),_.bind(s,a)),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];o[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];i[d[c]]=e.allDayBlocks[c]}p.$log.debug("blocks ready ("+_.flatten(e.blocks).length+")"),p.$log.debug("all day blocks ready ("+_.flatten(e.allDayBlocks).length+")"),n={blocks:o,allDayBlocks:i},e.id&&e.calendarName&&(n.id=e.id,n.calendarName=e.calendarName),p.$views.push(n)}),o.resolve(p.$views)})},o.reject),o.promise},p.$unwrapCollection=function(t,e){var n=[];return p.$loaded=p.STATUS.DELAYED_LOADING,p.$timeout(function(){p.$loaded!=p.STATUS.LOADED&&(p.$loaded=p.STATUS.LOADING)},p.STATUS.DELAYED_MS),e.then(function(e){return p.$timeout(function(){var o=_.invokeMap(e.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(e[t],function(e,t){_.forEach(e.days,function(a,e){_.forEach(a.events,function(e,t){var n;n=new p(_.zipObject(o,e)),a.events[t]=n})})}),n=e[t]):"tasks"==t&&_.reduce(e[t],function(e,t,n){var a;return a=new p(_.zipObject(o,t)),e.push(a),e},n),p.$log.debug("list of "+t+" ready ("+n.length+")"),p["$"+t]=n,p.$loaded=p.STATUS.LOADED,n})})},p.$resetGhost=function(){this.$ghost.pointerHandler=null,this.$ghost.component=null,this.$ghost.startHour=null,this.$ghost.endHour=null},p.$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))},p.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=p.$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=p.$parseDate(this.endDate),this.delta=this.start.minutesTo(this.end)):"appointment"==this.type&&this.setDelta(this.delta),this.dueDate&&(this.due=p.$parseDate(this.dueDate)),this.completedDate?this.completed=p.$parseDate(this.completedDate):"task"==this.type&&(this.completed=new Date),this.c_category&&(this.categories=_.invokeMap(_.filter(this.c_category,function(e){return p.$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]=p.$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=p.$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=p.$Preferences.defaults["SOGoCalendar"+n+"DefaultClassification"].toLowerCase();var a=/-PT?([0-9]+)([MHDW])/.exec(p.$Preferences.defaults.SOGoCalendarDefaultReminder);a&&(this.$hasAlarm=!0,this.alarm.quantity=parseInt(a[1]),this.alarm.unit={M:"MINUTES",H:"HOURS",D:"DAYS",W:"WEEKS"}[a[2]]),this.sendAppointmentNotifications=p.$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=p.$gravatar(e.email,32)}),this.updateFreeBusy(),this.selected=!1},p.prototype.initOrganizer=function(e){var t,n=this;e&&e.isSubscription?t=p.$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:p.$settings.activeUser("login"),name:p.$settings.activeUser("identification"),email:p.$settings.activeUser("email")},t=p.$q.when()),t.then(function(){n.updateFreeBusyAttendee(n.organizer)})},p.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)},p.prototype.isEditable=function(){return!this.occurrenceId&&!this.isReadOnly},p.prototype.isEditableOccurrence=function(){return this.occurrenceId&&!this.isReadOnly},p.prototype.isInvitation=function(){return!this.occurrenceId&&this.userHasRSVP},p.prototype.isInvitationOccurrence=function(){return this.occurrenceId&&this.userHasRSVP},p.prototype.showPercentComplete=function(){return"task"==this.type&&0<this.percentComplete&&"cancelled"!=this.status},p.prototype.enablePercentComplete=function(){return"task"==this.type&&"not-specified"!=this.status&&"cancelled"!=this.status},p.prototype.coversFreeBusy=function(e,t,n){return angular.isDefined(this.freebusy[e])&&angular.isDefined(this.freebusy[e][t])&&1==this.freebusy[e][t][n]},p.prototype.updateFreeBusyCoverage=function(){var i=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,a=e.getDate(),o=e.getDayString();if(o==i.start.getDayString())for(n=e.getHours().toString(),r[o]={},r[o][n]=[];0<s;)r[o][n].push(0),s--;else e=e.beginOfDay(),r[o]={};for(;e.getTime()<i.end.getTime()&&e.getDate()==a;)n=e.getHours().toString(),angular.isUndefined(r[o][n])&&(r[o][n]=[]),r[o][n].push(1),e.addMinutes(15)}),r}},p.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)}))},p.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)},p.prototype.updateFreeBusyAttendee=function(o){var e,t,n,i;o.uid&&(t=o.uid,o.domain&&(t+="@"+o.domain),n={sday:this.start.getDayString(),eday:this.end.getDayString()},o.isMSExchange?(e=p.$$resource.userResource(),n.uid=t):e=p.$$resource.userResource(t),i=_.map(this.start.daysUpTo(this.end),function(e){return e.getDayString()}),angular.isUndefined(o.freebusy)&&(o.freebusy={}),e.fetch("freebusy.ifb","ajaxRead",n).then(function(a){_.forEach(i,function(e){var t;angular.isUndefined(o.freebusy[e])&&(o.freebusy[e]={}),angular.isUndefined(a[e])&&(a[e]={});for(var n=0;n<=23;n++)t=n.toString(),a[e][t]?o.freebusy[e][t]=[a[e][t][0],a[e][t][15],a[e][t][30],a[e][t][45]]:o.freebusy[e][t]=[0,0,0,0]})}))},p.prototype.getClassName=function(e){return angular.isUndefined(e)&&(e="fg"),e+"-folder"+(this.destinationCalendar||this.c_folder||this.pid)},p.prototype.addAttendee=function(e,t){var n,a,o=this;e&&((!this.attendees||t&&t.organizerCalendar)&&this.initOrganizer(t?t.organizerCalendar:void 0),e.$isList({expandable:!0})?(a=p.$Card.$find(e.container,e.c_name)).$id().then(function(e){_.forEach(a.refs,function(e){n={name:e.c_cn,email:e.$preferredEmail(),role:"req-participant",partstat:"needs-action",uid:e.c_uid,$avatarIcon:"person"},_.find(o.attendees,function(e){return e.email==n.email})||(n.image=p.$gravatar(n.email,32),o.attendees?o.attendees.push(n):o.attendees=[n],o.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=p.$gravatar(n.email,32),this.attendees?this.attendees.push(n):this.attendees=[n],this.updateFreeBusyAttendee(n))))},p.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)},p.prototype.deleteAttendee=function(t){var e=_.findIndex(this.attendees,function(e){return e.email==t.email});this.attendees.splice(e,1)},p.prototype.canRemindAttendeesByEmail=function(){return"email"==this.alarm.action&&!this.isReadOnly&&this.attendees&&0<this.attendees.length},p.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},p.prototype.deleteAttachUrl=function(e){-1<e&&this.attachUrls.length>e&&this.attachUrls.splice(e,1)},p.prototype.$addDueDate=function(){this.due=new Date,this.due.setMinutes(15*Math.round(this.due.getMinutes()/15)),this.dueDate=this.due.toISOString()},p.prototype.$deleteDueDate=function(){delete this.due,delete this.dueDate},p.prototype.$addStartDate=function(){this.start=new Date,this.start.setMinutes(15*Math.round(this.start.getMinutes()/15))},p.prototype.$deleteStartDate=function(){delete this.start,delete this.startDate},p.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)},p.prototype.$deleteRecurrenceDate=function(e){-1<e&&this.repeat&&this.repeat.dates&&this.repeat.dates.length>e&&this.repeat.dates.splice(e,1)},p.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()},p.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:{}},p.$$resource.save(n.join("/"),e,{action:"rsvpAppointment"}).then(function(e){return t.$shadowData=t.$omit(),e})},p.prototype.$adjust=function(e){var t=[this.pid,encodeURIComponent(this.id)];return _.every(_.values(e),function(e){return 0===e})?p.$q.when():(this.occurrenceId&&t.push(this.occurrenceId),p.$log.debug("adjust "+t.join("/")+" "+JSON.stringify(e)),p.$$resource.save(t.join("/"),e,{action:"adjust"}))},p.prototype.$save=function(e){var t,n,a,o,i=this;return a=this.$omit(),o=p.$Preferences.$mdDateLocaleProvider,a.startDate=a.start?a.start.format(o,"%Y-%m-%d"):"",a.startTime=a.start?a.start.format(o,"%H:%M"):"",a.endDate=a.end?a.end.format(o,"%Y-%m-%d"):"",a.endTime=a.end?a.end.format(o,"%H:%M"):"",a.dueDate=a.due?a.due.format(o,"%Y-%m-%d"):"",a.dueTime=a.due?a.due.format(o,"%H:%M"):"",a.completedDate=a.completed?a.completed.format(o,"%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 a.repeat.monthdays,a.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(a.repeat.dates,function(e,t,n){n[t]={date:e.format(o,"%Y-%m-%d"),time:e.format(o,"%H:%M")}}):(delete a.repeat.days,"relative"==this.repeat.month.day&&(a.repeat.monthdays=[this.repeat.month.occurrence])):this.repeat.frequency&&"never"!=this.repeat.frequency&&(a.repeat={frequency:this.repeat.frequency}),a.startDate&&this.repeat.frequency&&"never"!=this.repeat.frequency?"until"==this.repeat.end&&this.repeat.until?a.repeat.until=this.repeat.until.stringWithSeparator("-"):"count"==this.repeat.end&&this.repeat.count?a.repeat.count=this.repeat.count:(delete a.repeat.until,delete a.repeat.count):delete a.repeat,"not-specified"==this.status?delete a.status:"completed"!=this.status&&delete a.completedDate,a.startDate&&this.$hasAlarm?!this.alarm.action||"email"!=this.alarm.action||this.attendees&&0<this.attendees.length||(a.alarm.attendees=0,a.alarm.organizer=1):a.alarm={},n=[this.pid,encodeURIComponent(this.id)],this.isNew&&(t={action:"saveAs"+this.type.capitalize()}),this.occurrenceId&&n.push(this.occurrenceId),angular.extend(a,e),p.$$resource.save(n.join("/"),a,t).then(function(e){return i.$shadowData=i.$omit(),e})},p.prototype.remove=function(e){var t=[this.pid,encodeURIComponent(this.id)];return e&&this.occurrenceId&&t.push(this.occurrenceId),p.$$resource.remove(t.join("/"))},p.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,p.$log.error(t.error)})},p.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},p.prototype.repeatDescription=function(){var e=null;return this.repeat&&(e=l("repeat_"+this.repeat.frequency.toUpperCase())),e},p.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},p.prototype.copyTo=function(e){return p.$$resource.post(this.pid+"/"+encodeURIComponent(this.id),"copy",{destination:e})},p.prototype.moveTo=function(e){return p.$$resource.post(this.pid+"/"+encodeURIComponent(this.id),"move",{destination:e})},p.prototype.toString=function(){return"[Component "+this.id+"]"}}(),function(){"use strict";function v(t,n,a,o,i,r,e,s,c){var d,u=this,p=[];function h(e,t){var n;"week"==o.view?n=u.selectedDate.beginOfWeek(s.defaults.SOGoFirstDayOfWeek).addDays(7*t):"month"==o.view?((n=u.selectedDate).setDate(1),n.setMonth(n.getMonth()+t)):n=u.selectedDate.addDays(t),g(e,n)}function m(e){"month"==o.view?(e.setDate(1),e.setHours(12),e.$dateFormat="%B %Y"):"week"==o.view?(e.setTime(e.beginOfWeek(s.defaults.SOGoFirstDayOfWeek).getTime()),e.$dateFormat=l("Week %d").replace("%d","%U")):e.$dateFormat="%A"}function f(){e.$eventsBlocksForView(o.view,o.day.asDate()).then(function(e){var n,t,a;for(n=0;n<e.length;n++)a=e[n],u.views[n]?(_.forEach(a.allDayBlocks,function(e,t){u.views[n].allDayBlocks[t]=e}),_.forEach(a.blocks,function(e,t){u.views[n].blocks[t]=e})):u.views[n]=a,a.id&&(u.views[n].calendar=new r({id:a.id,name:a.calendarName}));for(t=u.views.length;n<=t;t--)u.views.splice(t,1)})}function g(e,t){var n=t?t.getDayString():angular.element(e.currentTarget).attr("date");t&&m(t),a.go("calendars.view",{day:n})}function y(e,t){a.go("calendars.view",{view:t})}angular.isUndefined(v.expandedAllDays)&&(v.expandedAllDays=!1),u.selectedDate=o.day.asDate(),u.expandedAllDays=v.expandedAllDays,u.toggleAllDays=function(){v.expandedAllDays=!v.expandedAllDays,u.expandedAllDays=v.expandedAllDays},u.views=c,u.changeDate=g,u.changeView=y,this.$onInit=function(){var e;(e=p).push(i.createHotkey({key:l("hotkey_today"),description:l("Today"),callback:g,args:new Date})),e.push(i.createHotkey({key:l("hotkey_dayview"),description:l("Day"),callback:y,args:"day"})),e.push(i.createHotkey({key:l("hotkey_weekview"),description:l("Week"),callback:y,args:"week"})),e.push(i.createHotkey({key:l("hotkey_monthview"),description:l("Month"),callback:y,args:"month"})),e.push(i.createHotkey({key:l("hotkey_multicolumndayview"),description:l("Multicolumn Day View"),callback:y,args:"multicolumnday"})),e.push(i.createHotkey({key:"left",description:l("Move backward"),callback:h,args:-1})),e.push(i.createHotkey({key:"right",description:l("Move forward"),callback:h,args:1})),_.forEach(e,function(e){i.registerHotkey(e)}),m(u.selectedDate),d=n.$on("calendars:list",f),t.$on("$destroy",function(){d(),_.forEach(p,function(e){i.deregisterHotkey(e)})})}}v.$inject=["$scope","$rootScope","$state","$stateParams","sgHotkeys","Calendar","Component","Preferences","stateEventsBlocks"],angular.module("SOGo.SchedulerUI").controller("CalendarController",v)}(),function(){"use strict";function e(p,t,o,h,e,m,n,a,i,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,a("search")}function b(t,n,a){if(n.viewable){var e=o.when();angular.isUndefined(n.$futureComponentData)&&(e=(n=g.$get(n.pid).$getComponent(n.id,n.occurrenceId)).$futureComponentData),e.then(function(){var e="UIx"+a.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 k(e,t,n){var a;n?(a=n).updateFreeBusy():a=new y({pid:g.$defaultCalendar(),type:t});var o="UIx"+t.capitalize()+"EditorTemplate";return m.show({parent:angular.element(document.body),targetEvent:e,clickOutsideToClose:!0,escapeToClose:!0,templateUrl:o,controller:"ComponentEditorController",controllerAs:"editor",locals:{stateComponent:a}})}function D(e){var t,n,a,o,i,r,s;function c(e,t,n,a){e.updateThisOccurrence=function(){n.$adjust(a).then(t.hide,function(e){t.cancel().then(function(){d(e,n,a)},function(){})})},e.updateAllOccurrences=function(){delete n.occurrenceId,n.$adjust(a).then(t.hide,function(e){t.cancel().then(function(){d(e,n,a)},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(){p.$emit("calendars:list")},function(){})}function u(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)}}t=y.$ghost.component,n=y.$ghost.pointerHandler,t.isNew?(a=n.currentEventCoordinates,t.summary="",t.isAllDay&&(a.duration-=96),t.setDelta(15*a.duration),k(null,"appointment",t).catch().finally(function(){h(function(){y.$resetGhost()})})):(o=n.currentEventCoordinates.getDelta(n.originalEventCoordinates),i={days:o.dayNumber,start:15*o.start,duration:15*o.duration},n.originalCalendar&&0!==o.dayNumber&&(r=n.currentEventCoordinates.dayNumber,s=_.filter(g.$findAll(),{active:1}),i.destination=s[r].id,i.days=0),t.isException||!t.occurrenceId?t.$adjust(i).then(function(){p.$emit("calendars:list"),v.getAlarms()},function(e){d(e,t,i)}).finally(function(){h(function(){y.$resetGhost()})}):t.occurrenceId&&m.show({clickOutsideToClose:!0,escapeToClose:!0,locals:{component:t,params:i},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(){p.$emit("calendars:list")},function(){}).finally(function(){h(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(){i.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,p.$emit("calendars:list")})})},d.openEvent=function(e,t){b(e,t,"appointment")},d.openTask=function(e,t){b(e,t,"task")},d.newComponent=k,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(){g.reloadWebCalendars().finally(function(){p.$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:k,args:"appointment"})),e.push(n.createHotkey({key:l("hotkey_create_task"),description:l("Create a new task"),callback:k,args:"task"})),_.forEach(e,function(e){n.registerHotkey(e)}),s="events","tasksListView"==r.settings.Calendar.SelectedList&&(d.selectedList=1,s="tasks"),$(s,{reload:!0}),p.$on("calendars:list",function(){y.$filter(d.componentType,{reload:!0})}),p.$on("calendar:dragend",D),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(i,e,t,a,r,n,o,s,c,d){var u=this;u.activeUser=s.activeUser,u.service=d,u.newCalendar=function(e){o.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(){function n(e,n,t,a){var o=this,i=t.split("/"),r=i[2];o.title=l("Please identify yourself to %{0}").formatted(r),o.url=t,o.authenticate=function(t){!t.$valid&&t.$error.required||a.setCredentials(o.username,o.password).then(function(e){n.hide()},function(e){t.password.$setValidity("credentials",!1)})},o.cancel=function(){n.cancel()}}o.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)&&a.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,a,o;t=_.intersectionBy(e,n,"id"),a=_.map(_.filter(t,function(e){var t=_.find(n,{id:e.id});return!_.isEqual(e,t)}),"id"),o=d.$q.when(),0<a.length&&(r.debug(a.join(", ")+" changed"),o=d.saveFoldersActivation(a)),(0<a.length||t.length!=e.length||t.length!=n.length)&&o.then(function(){i.$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,e,n,a,i,r,s){var c,d=this;function u(n,a){r.$findAll().then(function(e){var t=_.find(e,function(e){if(0===e.id)return e});t.$getMailboxes().then(function(e){t.$newMessage().then(function(e){angular.extend(e.editable,{to:a,subject:d.component.summary}),o.show({parent:angular.element(document.body),targetEvent:n,clickOutsideToClose:!1,escapeToClose:!1,templateUrl:"../Mail/UIxMailEditor",controller:"MessageEditorController",controllerAs:"editor",locals:{stateAccount:t,stateMessage:e}})})})}),n.preventDefault(),n.stopPropagation()}function p(){var t="vevent"==d.component.component?"Appointment":"Task";o.hide().then(function(){var e="UIx"+t+"EditorTemplate";o.show({parent:angular.element(document.body),clickOutsideToClose:!0,escapeToClose:!0,templateUrl:e,controller:"ComponentEditorController",controllerAs:"editor",locals:{stateComponent:d.component}})})}function h(e){(e||d.component).$reply().then(function(){t.$emit("calendars:list"),i.getAlarms(),o.hide()})}d.calendarService=e,d.service=n,d.component=s,d.close=function(){o.hide()},d.highPriority=function(){return d.component&&d.component.priority&&d.component.priority<5},d.cardFilter=function(e){return a.$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=e.$get(d.component.pid).$getComponent(d.component.id)).$futureComponentData.then(function(){d.component=c,p()})},d.reply=h,d.replyAllOccurrences=function(){(c=e.$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(){t.$emit("calendars:list"),o.hide()})},d.deleteAllOccurrences=function(){d.component.remove().then(function(){t.$emit("calendars:list"),o.hide()})},d.toggleRawSource=function(n){e.$$resource.post(d.component.pid+"/"+d.component.id,"raw").then(function(e){function t(e,t,n){e.data=n,e.close=function(){t.hide()}}o.hide(),o.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"]})},d.copySelectedComponent=function(e){d.component.copyTo(e).then(function(){o.hide(),t.$emit("calendars:list")})},d.moveSelectedComponent=function(e){d.component.moveTo(e).then(function(){o.hide(),t.$emit("calendars:list")})},d.organizer=[s.organizer]}function t(n,e,t,a,o,i,r,s,c,d,u,p,h,m){var f,g,y=this;function v(e){"task"==y.component.type&&y.component.$hasAlarm&&(!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 k(){y.attendeesEditor.days=b(),y.component.updateFreeBusy()}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&&0<y.component.attendees.length&&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,o=!y.component.attendees||0===y.component.attendees.length,a=c.$get(y.component.destinationCalendar),i=o?{organizerCalendar:a}:{},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],a=e.replace(new RegExp(" *<?"+n+">? *"),"");return y.showAttendeesEditor|=o,y.searchText="",new p({c_cn:_.trim(a,' "'),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|=o},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 5<y.component.priority?l("low"):4<y.component.priority?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";v(e)},y.reset=$,y.cancel=function(e){$(e),y.component.isNew&&(y.component=null);o.hide()},y.edit=C,y.save=function(t,e){v(t),t.$valid&&y.component.$save(e).then(function(e){n.$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())),k())}},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())),k())}},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())}e.$inject=["$rootScope","$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(a,o){this.day=a.day,this.dayNumber=a.dayNumber,this.dayString=a.dayString,this.calendarData=function(){var t,e,n;return a.calendar?(t=a.calendar,n=_.filter(o.$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 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")))}}}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,p,h;n=l[0],d=t[0],u=t[1],p=-1,l.addClass("sg-event--ghost md-whiteframe-3dp ng-hide");var a=r.$on("calendar:dragstart",function(){var e,t,n;c.block=s.$ghost,(t=d.calendarData())&&(p=t.index,e=t.pid,h=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)}),o=r.$on("calendar:drag",function(){var e,t,n,a,o,i,r,s;if(e=!1,g.$view&&g.$view.type==u.type){if(t="multiday-allday"===u.type,n=c.block.component.c_isallday,a=c.block.pointerHandler.currentEventCoordinates.dayNumber,o=c.block.pointerHandler.currentEventCoordinates.start,r=c.block.pointerHandler.currentEventCoordinates.duration,s=f.EventDragDayLength-o,angular.isUndefined(r))return;for(s<(i=r)&&(i=s),-1<a&&(p<0&&a==d.dayNumber||a==p&&(h==p||!c.block.component.isException))&&(e=!0,t||(n||(c.block.startHour=m(o)),g.$view.quarterHeight?(l.css("top",o*g.$view.quarterHeight+"px"),l.css("height",i*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-=i,a++;!e&&r&&a<=d.dayNumber;)(i=r)>f.EventDragDayLength&&(i=f.EventDragDayLength),-1<a&&a==d.dayNumber&&(e=!0,t||(l.css("top",g.$view.topOffset+"px"),g.$view.quarterHeight&&l.css("height",i*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-=i,a++,o=0;r||(t?l.addClass("sg-event--ghost--last"):n||(c.block.endHour=m((o+i)%f.EventDragDayLength)))}e?l.removeClass("ng-hide"):l.addClass("ng-hide")}),i=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,a;return t=15*e,(n=Math.floor(t/60))<10&&(n="0"+n),(a=t%60)<10&&(a="0"+a),n+":"+a}c.$on("$destroy",function(){a(),o(),i()})}}}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,o,a,i,c,d,u){var p=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=p.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"),"touchend"==e.srcEvent.type?n(function(){p.inputElement.focus(),p.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){p.editMode=!1,p.inputContainer.classList.add("ng-hide"),p.clickableElement.classList.remove("ng-hide"),p.updateCalendarName()}).finally(function(){p.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}".',p.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(){p.calendar.$delete().catch(function(e,t){d.alert(l('An error occured while deleting the calendar "%{0}".',p.calendar.name),l(e.error))})})},this.showMenu=function(i){var e=o.newPanelPosition().relativeTo(this.moreOptionsButton).addPanelPosition(o.xPosition.ALIGN_START,o.yPosition.ALIGN_TOPS),t=o.newPanelAnimation().openFrom(this.moreOptionsButton).duration(100).withAnimation(o.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:a,controllerAs:"$menuCtrl",position:e,animation:t,targetEvent:i,templateUrl:"UIxCalendarMenu",trapFocus:!0,clickOutsideToClose:!0,escapeToClose:!0,focusOnOpen:!0};function a(e,n,a,t){var o=this;this.showOnly=function(){_.forEach(u.$findAll(),function(e){o.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 a=this;a.calendar=new u(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})}n.show({templateUrl:this.calendar.id+"/properties",controller:t,controllerAs:"properties",clickOutsideToClose:!0,escapeToClose:!0,locals:{srcCalendar:this.calendar}}).catch(function(){o.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,i,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 a({url:ApplicationBaseURL+[t.id,"import"].join("/"),autoUpload:!0,queueLimit:1,filters:[{name:n,fn:n}],onSuccessItem:function(e,t,n,a){var o;i.hide(),0===t.imported?o=l("No event was imported."):(o=l("A total of %{0} events were imported in the calendar.",t.imported),r.$emit("calendars:list")),s.show(s.simple().content(o).position("top right").hideDelay(3e3))},onErrorItem:function(e,t,n,a){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(){i.hide()}}n.show({parent:angular.element(document.body),targetEvent:i,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:o.calendar.id+"/UIxAclEditor",controller:"AclController",controllerAs:"acl",clickOutsideToClose:!0,escapeToClose:!0,locals:{usersWithACL:o.calendar.$acl.users,User:t,folder:o.calendar}})})}}o.open(n).then(function(e){(p.panel=e).panelEl.one("click",function(){e.close()})}),a.$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,p,h){return{restrict:"A",scope:{type:"@sgCalendarScrollView"},controller:a,link:function(e,a,t,o){var i,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)}i=null,r=e.type,n="multicolumndayview"==a.attr("sg-view"),o.isMultiColumn=n,d(function(){var e,t,n;i=new s(a,r),"monthly"!=r&&h.defaults.SOGoDayStartTime&&(e=h.defaults.SOGoDayStartTime.split(":"),t=document.getElementById("hour"+parseInt(e[0])),n=parseInt(e[1])*i.quarterHeight,i.element.scrollTop=t.offsetTop+n);o.quarterHeight=i.quarterHeight}),e.$on("$destroy",function(){i&&i.$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,a,o,i,r,s;return n=t=a=o=0,0<(i=this.element.getElementsByClassName("day")).length&&(n=(r=i[0].getBoundingClientRect()).height,t=r.width,a=r.left-e,0<(s=i[0].getElementsByClassName("sg-calendar-tile-header")).length&&(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 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,a,o,i;e=p.$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,(a=t.y-this.scrollStep)<0?(a<(o=-this.element.scrollTop)&&(a=o),this.element.scrollTop+=a):0<(i=(a=t.y+this.scrollStep)-this.element.clientHeight)&&(this.element.scrollTop+=i)))}}}}}function a(e){this.type=e.type}e.$inject=["$rootScope","$window","$document","$q","$timeout","$mdGesture","Calendar","Component","Preferences"],a.$inject=["$scope"],angular.module("SOGo.SchedulerUI").directive("sgCalendarScrollView",e)}(),function(){"use strict";angular.module("SOGo.SchedulerUI").directive("sgCalendarTable",function(){return{restrict:"E",scope:{calendars:"=sgCalendars",calendar:"@sgCalendar",blocksType:"@sgBlocksType",day:"@sgDay",clickBlock:"&sgClick"},template:["<sg-calendar-day-table",' sg-blocks="calendars[calendar][blocksType]"',' sg-day="day"',' sg-click="clickBlock({event: clickEvent, component: clickComponent})"/>'].join("")}})}(),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,a,f,g,y,c,v){return{restrict:"CA",require:"^sgCalendarDay",link:function(u,p,e,h){if(u.block){if(!u.block.component.editable||u.block.userState)return void p.removeClass("sg-draggable-calendar-block");!function(){var e,t,n,a,o,i,r,s,c,l;if(u.block.length<3)return;e=u.block.component,t=u.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"===p[0].parentNode.tagName?(a&&(r=angular.element('<div class="dragGrip-left"></div>').append(i),p.append(r)),o&&(s=angular.element('<div class="dragGrip-right"></div>').append(i.clone()),p.append(s))):(a&&(c=angular.element('<div class="dragGrip-top"></div>').append(i),p.append(c)),o&&(l=angular.element('<div class="dragGrip-bottom"></div>').append(i.clone()),p.append(l)))}()}function t(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",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",i))}function i(e){var t=v.$ghost.pointerHandler;a(function(){t.updateFromEvent(e)})}function r(e){var t,n;t=u.block,n=v.$ghost.pointerHandler,angular.element(document).off("mousemove",i),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}p.on("mousedown",t),u.$on("$destroy",function(){p.off("mousedown",t),p.off("mousemove",i)}),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 a=-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=a<0?0:n-a-1,a=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 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)%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,a,o,i,r,s,c,d;a=p.hasClass("clickableHourCell"),o="SG-CALENDAR-MONTH-DAY"==p[0].parentNode.tagName||p.hasClass("clickableDayCell"),d=h.calendarData(),u.block&&u.block.component?t=u.block:(i=h.dayString.parseDate(g.$mdDateLocaleProvider,"%Y-%m-%e"),r={type:"appointment",pid:d?d.pid:y.$defaultCalendar(),summary:l("New Event"),startDate:i,isAllDay:a?0:1},s=new v(r),(t={component:s,dayNumber:h.dayNumber,length:0}).component.blocks=[t]);n="multiday",o?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),a=n.days*c.EventDragDayLength+n.y;f.debug("quarters delta "+a),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+a,this.currentEventCoordinates.duration=this.originalEventCoordinates.duration):"change-start"==this.dragMode?0<(e=this.originalEventCoordinates.duration-a)?(this.currentEventCoordinates.start=this.originalEventCoordinates.start+a,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+a)?(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,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-c.EventDragHorizontalOffset)/a);var i=c.EventDragDayLength-1;n.y<0?n.y=0:n.y>i&&(n.y=i)}return n},getEventMultiDayAllDayViewCoordinates:function(e,t){var n,a=this.getContainerBasedCoordinates(e,t);if(a){n=new d;var o=e.dayWidth,i=e.daysOffset;n.x=Math.floor((a.x-i)/o);var r=0,s=y.$view.maxX;if("move-event"!=this.dragMode){var c=h.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,a=this.getContainerBasedCoordinates(e,t);if(a){n=new d;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)}}}}}e.$inject=["$rootScope","$timeout","$log","Preferences","Calendar","CalendarSettings","Component"],angular.module("SOGo.SchedulerUI").directive("sgDraggableCalendarBlock",e)}(),function(){"use strict";function e(i,e,t,n,a,o){return{restrict:"CA",scope:{onDrop:"&sgOnDrop"},link:function(e,t,n,a){var o=i.$on("calendar:dragend",e.onDrop);e.$on("$destroy",o)}}}e.$inject=["$rootScope","$timeout","$mdGesture","Calendar","CalendarSettings","Component"],angular.module("SOGo.SchedulerUI").directive("sgDroppableBlock",e)}(),function(){"use strict";function e(c,l,d){var u,p=this,h=l.controller("sgCalendarScrollView");c.nowDay=null,c.lineElement=null,c.updateLine=function(e){var t=new Date,n=t.getDayString(),a=t.getHours(),o=4*c.quarterHeight,i=t.getMinutes(),r=c.quarterHeight/15,s=parseInt(a*o+i*r-1);(e||n!=c.nowDay)&&(c.lineElement&&c.lineElement.remove(),c.lineElement=function(t,e){var n=angular.element("<sg-now-line>");h.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(p,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,a){function o(){return e.find("sg-calendar-day")}var i=n.$watch(function(){return a.quarterHeight},function(e){if(e){i(),n.quarterHeight=e;var t=n.$watch(o,function(e){e.length&&(t(),n.days=e,n.updateLine())})}})},controller:e}})}();
|
|
//# sourceMappingURL=Scheduler.services.js.map
|