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