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