4 lines
76 KiB
JavaScript
4 lines
76 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,ConflictHTTPErrorCode:409}).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;c=b.isWebCalendar?this.$webcalendars:b.isSubscription?this.$subscriptions:this.$calendars,d=_.findIndex(c,function(a,c){return"personal"==b.id||"personal"!=a.id&&a.name.localeCompare(b.name)>0}),d<0?c.push(b):c.splice(d,0,b),a.$Preferences.settings.Calendar.FoldersOrder&&a.saveFoldersOrder(_.flatMap(a.$findAll(),"id")),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(c){_.forEach(c.calendars,function(c){var d,e;d=c.isWebCalendar?b.$webcalendars:c.owner!=a.activeUser.login?b.$subscriptions:b.$calendars,e=_.find(d,function(a){return a.id==c.id}),e&&e.init(c)})})},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.saveFoldersActivation=function(b){var c={};return _.forEach(b,function(b){var d=a.$get(b);c[d.id]=d.active}),a.$$resource.post(null,"saveFoldersActivation",c)},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(){var b;return b={type:"application/octet-stream",filename:this.name+".ics"},a.$$resource.download(this.id+".ics","export",null,b)},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","$rootScope","sgSettings","sgComponent_STATUS","Preferences","User","Card","Gravatar","Resource",function(b,c,d,e,f,g,h,i,j,k,l){return angular.extend(a,{STATUS:g,$q:b,$timeout:c,$log:d,$rootScope:e,$settings:f,$User:i,$Preferences:h,$Card:j,$gravatar:k,$$resource:new l(f.activeUser("folderURL")+"Calendar",f.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:{}}),h.settings.Calendar.EventsFilterState&&(a.$queryEvents.filterpopup=h.settings.Calendar.EventsFilterState),h.settings.Calendar.TasksFilterState&&(a.$queryTasks.filterpopup=h.settings.Calendar.TasksFilterState),h.settings.Calendar.EventsSortingState&&(a.$queryEvents.sort=h.settings.Calendar.EventsSortingState[0],a.$queryEvents.asc=parseInt(h.settings.Calendar.EventsSortingState[1])),h.settings.Calendar.TasksSortingState&&(a.$queryTasks.sort=h.settings.Calendar.TasksSortingState[0],a.$queryTasks.asc=parseInt(h.settings.Calendar.TasksSortingState[1])),a.$queryTasks.show_completed=parseInt(h.settings.ShowCompletedTasks),a.$categories=h.defaults.SOGoCalendarCategoriesColors,h.defaults.SOGoTimeFormat&&(a.timeFormat=h.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){a.$refreshTimeout&&a.$timeout.cancel(a.$refreshTimeout);var c=a.$Preferences.defaults.SOGoRefreshViewCheck;if(c&&"manually"!=c){var d=angular.bind(a.$rootScope,a.$rootScope.$emit,"calendars:list");a.$refreshTimeout=a.$timeout(d,1e3*c.timeInterval())}},a.$isLoading=function(){return a.$loaded==a.STATUS.LOADING},a.$filter=function(b,c){var d,e,f=this,g=new Date,h=g.getDate(),i=g.getMonth()+1,j=g.getFullYear(),k="$query"+b.capitalize(),l={day:""+j+(i<10?"0":"")+i+(h<10?"0":"")+h},m=!1;return a.$startRefreshTimeout(b),angular.extend(this.$query,l),c&&_.forEach(_.keys(c),function(b){m|=f.$query[b]&&c[b]!=a.$query[b],"reload"==b&&c[b]?m=!0:angular.isDefined(f.$query[b])?f.$query[b]=c[b]:f[k][b]=c[b]}),d=this.$$resource.fetch(null,b+"list",angular.extend(this[k],this.$query)),m&&(e="tasks"==b?"$events":"$tasks",delete a[e],a.$log.debug("force reload of "+e)),this.$unwrapCollection(b,d)},a.$find=function(b,c,d){var e,f=[b,encodeURIComponent(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,e,f,g;return d=a.$Preferences.defaults.SOGoFirstDayOfWeek,"day"==b?(e="dayView",f=g=c):"multicolumnday"==b?(e="multicolumndayView",f=g=c):"week"==b?(e="weekView",f=c.beginOfWeek(d),g=new Date,g.setTime(f.getTime()),g.addDays(6)):"month"==b&&(e="monthView",f=c,f.setDate(1),f=f.beginOfWeek(d),g=new Date,g.setTime(c.getTime()),g.setMonth(g.getMonth()+1),g.addDays(-1),g=g.endOfWeek(d)),this.$eventsBlocks(e,f,g)},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),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"),"events"==b?(_.forEach(c[b],function(b,c){_.forEach(b.days,function(b,c){_.forEach(b.events,function(c,d){var f,g=_.zipObject(e,c);f=new a(g),b.events[d]=f})})}),d=c[b]):"tasks"==b&&_.reduce(c[b],function(b,c,d){var f,g=_.zipObject(e,c);return f=new a(g),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){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(_.filter(this.c_category,function(b){return a.$Preferences.defaults.SOGoCalendarCategoriesColors[b]}),"asCSSIdentifier")),this.$isRecurrent=angular.isDefined(b.repeat),this.repeat.days){var c=_.find(this.repeat.days,function(a){return angular.isDefined(a.occurrence)});c&&("yearly"==this.repeat.frequency&&(this.repeat.year={byday:!0}),this.repeat.month={type:"byday",occurrence:c.occurrence.toString(),day:c.day})}else this.repeat.days=[];if(this.repeat.dates?(this.repeat.frequency="custom",_.forEach(this.repeat.dates,function(b,c,d){angular.isString(b)&&(d[c]=a.$parseDate(b))})):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=a.$parseDate(this.repeat.until,{no_time:!0}))):this.repeat.end="never",this.$hasCustomRepeat=this.hasCustomRepeat(),this.isNew){var d="appointment"==this.type?"Events":"Tasks";this.classification=a.$Preferences.defaults["SOGoCalendar"+d+"DefaultClassification"].toLowerCase();var e={M:"MINUTES",H:"HOURS",D:"DAYS",W:"WEEKS"},f=/-PT?([0-9]+)([MHDW])/.exec(a.$Preferences.defaults.SOGoCalendarDefaultReminder);f&&(this.$hasAlarm=!0,this.alarm.quantity=parseInt(f[1]),this.alarm.unit=e[f[2]]),this.sendAppointmentNotifications=a.$Preferences.defaults.SOGoAppointmentSendEMailNotifications}else angular.isUndefined(b.$hasAlarm)&&(this.$hasAlarm=angular.isDefined(b.alarm));this.destinationCalendar=this.pid,this.attendees&&_.forEach(this.attendees,function(b){b.image=a.$gravatar(b.email,32)}),this.updateFreeBusy(),this.selected=!1},a.prototype.initOrganizer=function(b){var c,d=this;b&&b.isSubscription?c=a.$User.$filter(b.owner).then(function(a){var b=a[0];d.organizer={uid:b.uid,name:b.cn,email:b.c_email}}):(this.organizer={uid:a.$settings.activeUser("login"),name:a.$settings.activeUser("identification"),email:a.$settings.activeUser("email")},c=a.$q.when()),c.then(function(){d.updateFreeBusyAttendee(d.organizer)})},a.prototype.hasCustomRepeat=function(){var a=angular.isUndefined(this.occurrenceId)&&angular.isDefined(this.repeat)&&(this.repeat.interval>1||angular.isDefined(this.repeat.days)&&this.repeat.days.length>0||angular.isDefined(this.repeat.monthdays)&&this.repeat.monthdays.length>0||angular.isDefined(this.repeat.months)&&this.repeat.months.length>0||angular.isDefined(this.repeat.month)&&angular.isDefined(this.repeat.month.type)||angular.isDefined(this.repeat.dates)&&this.repeat.dates.length>0);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.showPercentComplete=function(){return"task"==this.type&&this.percentComplete>0&&"cancelled"!=this.status},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 a=this;this.freebusy=this.updateFreeBusyCoverage(),this.attendees&&(this.organizer&&this.updateFreeBusyAttendee(this.organizer),_.forEach(this.attendees,function(b){a.updateFreeBusyAttendee(b)}))},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,f;b.uid&&(d=b.uid,b.domain&&(d+="@"+b.domain),e={sday:this.start.getDayString(),eday:this.end.getDayString()},b.isMSExchange?(c=a.$$resource.userResource(),e.uid=d):c=a.$$resource.userResource(d),f=_.map(this.start.daysUpTo(this.end),function(a){return a.getDayString()}),angular.isUndefined(b.freebusy)&&(b.freebusy={}),c.fetch("freebusy.ifb","ajaxRead",e).then(function(a){_.forEach(f,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,c){var d,e,f=this;b&&((!this.attendees||c&&c.organizerCalendar)&&this.initOrganizer(c?c.organizerCalendar:void 0),b.$isList({expandable:!0})?(e=a.$Card.$find(b.container,b.c_name),e.$id().then(function(b){_.forEach(e.refs,function(b){d={name:b.c_cn,email:b.$preferredEmail(),role:"req-participant",partstat:"needs-action",uid:b.c_uid,$avatarIcon:"person"},_.find(f.attendees,function(a){return a.email==d.email})||(d.image=a.$gravatar(d.email,32),f.attendees?f.attendees.push(d):f.attendees=[d],f.updateFreeBusyAttendee(d))})})):(d={uid:b.c_uid,domain:b.c_domain,isMSExchange:b.ismsexchange,name:b.c_cn,email:b.$preferredEmail(),role:"req-participant",partstat:"needs-action",$avatarIcon:b.$avatarIcon},_.find(this.attendees,function(a){return a.email==d.email})||(d.image=a.$gravatar(d.email,32),this.attendees?this.attendees.push(d):this.attendees=[d],this.updateFreeBusyAttendee(d))))},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.$addRecurrenceDate=function(){var a=new Date;a.setMinutes(15*Math.round(a.getMinutes()/15)),angular.isUndefined(this.repeat.dates)&&(this.repeat={frequency:"custom",dates:[]}),this.repeat.dates.push(a)},a.prototype.$deleteRecurrenceDate=function(a){a>-1&&this.repeat&&this.repeat.dates&&this.repeat.dates.length>a&&this.repeat.dates.splice(a,1)},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,encodeURIComponent(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,encodeURIComponent(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&&"relative"!=this.repeat.month.day||"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?"custom"==this.repeat.frequency&&this.repeat.dates&&_.forEach(e.repeat.dates,function(a,b,c){c[b]={date:a.format(f,"%Y-%m-%d"),time:a.format(f,"%H:%M")}}):(delete e.repeat.days,"relative"==this.repeat.month.day&&(e.repeat.monthdays=[this.repeat.month.occurrence])):this.repeat.frequency&&"never"!=this.repeat.frequency&&(e.repeat={frequency:this.repeat.frequency}),e.startDate&&this.repeat.frequency&&"never"!=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,e.startDate&&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,encodeURIComponent(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,encodeURIComponent(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||"$hasAlarm"!=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.quantity>0&&a.push(this.alarm.unit.toUpperCase(),this.alarm.reference.toUpperCase()),a=a.join("_"),b=l(a),a===b&&(b=[this.alarm.quantity,l("reminder_"+this.alarm.unit.toUpperCase()),l("reminder_"+this.alarm.reference.toUpperCase())].join(" "))),b},a.prototype.copyTo=function(b){return a.$$resource.post(this.pid+"/"+encodeURIComponent(this.id),"copy",{destination:b})},a.prototype.moveTo=function(b){return a.$$resource.post(this.pid+"/"+encodeURIComponent(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,this.$onInit=function(){k(u),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,m,n,o){function p(a){a.push(g.createHotkey({key:l("hotkey_search"),description:l("Search"),callback:u})),a.push(g.createHotkey({key:l("hotkey_create_event"),description:l("Create a new event"),callback:z,args:"appointment"})),a.push(g.createHotkey({key:l("hotkey_create_task"),description:l("Create a new task"),callback:z,args:"task"})),_.forEach(a,function(a){g.registerHotkey(a)})}function q(a,b){(b&&b.reload||J.componentType!=a)&&(angular.isUndefined(n["$"+a])&&n.$filter(a),J.unselectComponents(),J.componentType=a,n.saveSelectedList(a))}function r(){_.forEach(n["$"+J.componentType],function(a){a.selected=!1}),J.mode.multiple=0}function s(){_.forEach(n["$"+J.componentType],function(a){a.selected=!0}),J.mode.multiple=n["$"+J.componentType].length}function t(a,b){b.selected=!b.selected,J.mode.multiple+=b.selected?1:-1,a.preventDefault(),a.stopPropagation()}function u(){J.mode.search=!0,h("search")}function v(){i.confirm(l("Warning"),l("Are you sure you want to delete the selected components?"),{ok:l("Delete")}).then(function(){var b=_.filter(n["$"+J.componentType],function(a){return a.selected});m.$deleteComponents(b).then(function(){J.mode.multiple=0,a.$emit("calendars:list")})})}function w(a,b){y(a,b,"appointment")}function x(a,b){y(a,b,"task")}function y(a,b,d){if(b.viewable){var e=c.when();angular.isUndefined(b.$futureComponentData)&&(b=m.$get(b.pid).$getComponent(b.id,b.occurrenceId),e=b.$futureComponentData),e.then(function(){var c="UIx"+d.capitalize()+"ViewTemplate";f.show({parent:angular.element(document.body),targetEvent:a,clickOutsideToClose:!0,escapeToClose:!0,templateUrl:c,controller:"ComponentController",controllerAs:"editor",locals:{stateComponent:b}})})}}function z(a,b,c){var d;c?(d=c,d.updateFreeBusy()):d=new n({pid:m.$defaultCalendar(),type:b});var e="UIx"+b.capitalize()+"EditorTemplate";return f.show({parent:angular.element(document.body),targetEvent:a,clickOutsideToClose:!0,escapeToClose:!0,templateUrl:e,controller:"ComponentEditorController",controllerAs:"editor",locals:{stateComponent:d}})}function A(b){function c(a,b,c,d){a.updateThisOccurrence=function(){c.$adjust(d).then(b.hide,function(a){b.cancel().then(function(){e(a,c,d)},function(){})})},a.updateAllOccurrences=function(){delete c.occurrenceId,c.$adjust(d).then(b.hide,function(a){b.cancel().then(function(){e(a,c,d)},function(){})})}}function e(b,c,d){b.status==k.ConflictHTTPErrorCode&&b.data&&b.data.message&&angular.isObject(b.data.message)&&f.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(){})}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,j,p,q,r,s;h=n.$ghost.component,i=n.$ghost.pointerHandler,h.isNew?(j=i.currentEventCoordinates,h.summary="",h.isAllDay&&(j.duration-=96),h.setDelta(15*j.duration),z(null,"appointment",h).catch().finally(function(){d(function(){n.$resetGhost()})})):(p=i.currentEventCoordinates.getDelta(i.originalEventCoordinates),q={days:p.dayNumber,start:15*p.start,duration:15*p.duration},i.originalCalendar&&0!==p.dayNumber&&(r=i.currentEventCoordinates.dayNumber,s=_.filter(m.$findAll(),{active:1}),q.destination=s[r].id,q.days=0),h.isException||!h.occurrenceId?h.$adjust(q).then(function(){a.$emit("calendars:list"),o.getAlarms()},function(a){e(a,h,q)}).finally(function(){d(function(){n.$resetGhost()})}):h.occurrenceId&&f.show({clickOutsideToClose:!0,escapeToClose:!0,locals:{component:h,params:q},template:['<md-dialog flex="50" sm-flex="80" xs-flex="90">',' <md-dialog-content class="md-dialog-content">'," <p>"+l("editRepeatingItem")+"</p>"," </md-dialog-content>"," <md-dialog-actions>",' <md-button ng-click="updateThisOccurrence()">'+l("button_thisOccurrenceOnly")+"</md-button>",' <md-button ng-click="updateAllOccurrences()">'+l("button_allOccurrences")+"</md-button>"," </md-dialog-actions>","</md-dialog>"].join(""),controller:c}).then(function(){a.$emit("calendars:list")},function(){}).finally(function(){d(function(){n.$resetGhost()})})),c.$inject=["$scope","$mdDialog","component","params"],g.$inject=["$scope","$mdDialog","component","params","conflictError"]}function B(){return n["$query"+J.componentType.capitalize()].filterpopup}function C(a){n.$filter(J.componentType,{filterpopup:a})}function D(a){return n["$query"+J.componentType.capitalize()].filterpopup==a}function E(a){n.$filter(J.componentType,{sort:a})}function F(a){return n["$query"+J.componentType.capitalize()].sort==a}function G(){m.reloadWebCalendars().finally(function(){a.$emit("calendars:list")})}function H(){J.mode.search=!1,n.$filter(J.componentType,{value:""})}var I,J=this,K=[];J.component=n,J.componentType="events",J.selectedList=0,J.selectComponentType=q,J.unselectComponents=r,J.selectAll=s,J.searchMode=u,J.toggleComponentSelection=t,J.confirmDeleteSelectedComponents=v,J.openEvent=w,J.openTask=x,J.newComponent=z,J.filterpopup=B,J.filter=C,J.filteredBy=D,J.sort=E,J.sortedBy=F,J.reload=G,J.cancelSearch=H,J.mode={search:!1,multiple:0},this.$onInit=function(){p(K),I="events","tasksListView"==j.settings.Calendar.SelectedList&&(J.selectedList=1,I="tasks"),q(I,{reload:!0}),a.$on("calendars:list",function(){n.$filter(J.componentType,{reload:!0})}),a.$on("calendar:dragend",A),b.$on("$destroy",function(){_.forEach(K,function(a){g.deregisterHotkey(a)})})}}a.$inject=["$rootScope","$scope","$q","$timeout","$state","$mdDialog","sgHotkeys","sgFocus","Dialog","Preferences","CalendarSettings","Calendar","Component","Alarm"],angular.module("SOGo.SchedulerUI").controller("CalendarListController",a)}(),function(){"use strict";function a(a,b,c,d,e,f,g,h,i,j){function k(a,b,c){return a.sortableScope.element[0]==b.element[0]}function m(){j.saveFoldersOrder(_.flatMap(j.$findAll(),"id"))}function n(){s.sortableMode=!s.sortableMode,s.filter.name=""}function o(){j.saveFoldersOrder()}function p(a){g.prompt(l("New calendar"),l("Name of the Calendar")).then(function(a){var b=new j({name:a,isEditable:!0,isRemote:!1,owner:UserLogin});b.$id().then(function(){j.$add(b)})})}function q(){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.url=c,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()}}g.prompt(l("Subscribe to a web calendar..."),l("URL of the Calendar"),{inputType:"url"}).then(function(b){j.$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 r(a){e.debug("subscribeToFolder "+a.owner+a.name),j.$subscribe(a.owner,a.name).then(function(a){f.show(f.simple().content(l("Successfully subscribed to calendar")).position("top right").hideDelay(3e3))})}var s=this;s.activeUser=h.activeUser,s.service=j,s.newCalendar=p,s.addWebCalendar=q,s.subscribeToFolder=r,s.filter={name:""},s.sortableMode=!1,s.toggleSortableMode=n,s.resetSort=o,s.sortableCalendars={scrollableContainer:"#sidenav-content",containment:"md-list",orderChanged:m,accept:k},this.$onInit=function(){s.categories=_.map(i.defaults.SOGoCalendarCategories,function(a){return{id:a.asCSSIdentifier(),name:a,color:i.defaults.SOGoCalendarCategoriesColors[a]}}),b.$watch(function(){return _.union(_.map(j.$calendars,function(a){return _.pick(a,["id","active","color"])}),_.map(j.$subscriptions,function(a){return _.pick(a,["id","active","color"])}),_.map(j.$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=j.$q.when(),f.length>0&&(e.debug(f.join(", ")+" changed"),g=j.saveFoldersActivation(f)),(f.length>0||d.length!=b.length||d.length!=c.length)&&g.then(function(){a.$emit("calendars:list")})},!0)}}a.$inject=["$rootScope","$scope","$window","$mdDialog","$log","$mdToast","Dialog","sgSettings","Preferences","Calendar"],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(){return z.component&&z.component.priority&&z.component.priority<5}function k(a){return e.$filterAll(a)}function m(a){var b=_.map(z.component.attendees,function(a){return a.name+" <"+a.email+">"});o(a,b)}function n(a,b,c){o(a,[b+" <"+c+">"])}function o(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:z.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 p(){var a="vevent"==z.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:z.component}})})}function q(){y=c.$get(z.component.pid).$getComponent(z.component.id),y.$futureComponentData.then(function(){z.component=y,p()})}function r(c){var d=c||z.component;d.$reply().then(function(){a.$emit("calendars:list"),f.getAlarms(),b.hide()})}function s(){y=c.$get(z.component.pid).$getComponent(z.component.id),y.$futureComponentData.then(function(){y.reply=z.component.reply,y.delegatedTo=z.component.delegatedTo,y.$hasAlarm=z.component.$hasAlarm,y.alarm=z.component.alarm,r(y)})}function t(){z.component.remove(!0).then(function(){a.$emit("calendars:list"),b.hide()})}function u(){z.component.remove().then(function(){a.$emit("calendars:list"),b.hide()})}function v(a){c.$$resource.post(z.component.pid+"/"+z.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 w(c){z.component.copyTo(c).then(function(){b.hide(),a.$emit("calendars:list")})}function x(c){z.component.moveTo(c).then(function(){b.hide(),a.$emit("calendars:list")})}var y,z=this;z.calendarService=c,z.service=d,z.component=h,z.close=i,z.highPriority=j,z.cardFilter=k,z.newMessageWithAllRecipients=m,z.newMessageWithRecipient=n,z.edit=p,z.editAllOccurrences=q,z.reply=r,z.replyAllOccurrences=s,z.deleteOccurrence=t,z.deleteAllOccurrences=u,z.toggleRawSource=v,z.copySelectedComponent=w,z.moveSelectedComponent=x,z.organizer=[h.organizer]}function b(a,b,c,d,e,f,g,h,i,j,k,m,n,o){function p(){var a=R.component.addAttachUrl("");f("attachUrl_"+a)}function q(){R.showRecurrenceEditor=!R.showRecurrenceEditor,R.component.$hasCustomRepeat=R.showRecurrenceEditor}function r(){R.showAttendeesEditor=!R.showAttendeesEditor}function s(){return R.component&&"monthly"==R.component.repeat.frequency&&"bymonthday"==R.component.repeat.month.type}function t(){"custom"==R.component.repeat.frequency&&(R.showRecurrenceEditor=!0)}function u(){var a=R.component.attendees&&R.component.attendees.length>0;a&&R.component.initOrganizer(i.$get(R.component.destinationCalendar))}function v(a){return k.$filterAll(a),k.$cards}function w(a){function b(a){var b=a.match(h),c=b[0],d=a.replace(new RegExp(" *<?"+c+">? *"),"");return R.showAttendeesEditor|=e,R.searchText="",new m({c_cn:_.trim(d,' "'),emails:[{value:c}]})}var c,d,e=!R.component.attendees||0===R.component.attendees.length,f=i.$get(R.component.destinationCalendar),g=e?{organizerCalendar:f}:{},h=/([\w\!\#$\%\&\'\*\+\-\/\=\?\^\`{\|\}\~]+\.)*[\w\!\#$\%\&\'\*\+\-\/\=\?\^\`{\|\}\~]+@((((([a-z0-9]{1}[a-z0-9\-]{0,62}[a-z0-9]{1})|[a-z])\.)+[a-z]{2,})|(\d{1,3}\.){3}\d{1,3}(\:\d{1,5})?)/i;if(angular.isString(a)){for(d="",c=0;c<a.length;c++)9!=a.charCodeAt(c)&&32!=a.charCodeAt(c)&&44!=a.charCodeAt(c)&&59!=a.charCodeAt(c)||!h.test(d)?d+=a.charAt(c):(R.component.addAttendee(b(d),g),d="");d&&R.component.addAttendee(b(d),g)}else R.component.addAttendee(a,g),R.showAttendeesEditor|=e}function x(a,b){R.component.deleteAttendee(a),0===R.component.attendees.length&&(R.showAttendeesEditor=!1),b.$setDirty()}function y(){if(R.component&&R.component.priority)return R.component.priority>5?l("low"):R.component.priority>4?l("normal"):l("high")}function z(a){"task"==R.component.type&&(!R.component.start&&"START"==R.component.alarm.relation||!R.component.due&&"END"==R.component.alarm.relation)?a.alarmRelation.$setValidity("alarm",!1):a.alarmRelation.$setValidity("alarm",!0)}function A(b,c){b.$valid&&R.component.$save(c).then(function(b){a.$emit("calendars:list"),n.getAlarms(),e.hide()},function(a){a.status==h.ConflictHTTPErrorCode&&_.isObject(a.data.message)?R.attendeeConflictError=a.data.message:D(b)})}function B(a){R.component.$reset(),a.$setPristine()}function C(a){B(a),R.component.isNew&&(R.component=null),e.hide()}function D(a){R.attendeeConflictError=!1,a.$setPristine(),a.$setDirty()}function E(){var a=[];return R.component.start&&R.component.end&&(a=R.component.start.daysUpTo(R.component.end)),_.map(a,function(a){return{stringWithSeparator:a.stringWithSeparator(),getDayString:a.getDayString()}})}function F(){for(var a=[],b=0;b<=23;b++)a.push(b.toString());return a}function G(a){R.component.$addStartDate(),O=new Date(R.component.start.getTime()),R.component.due||(R.component.alarm.relation="START"),z(a)}function H(a){R.component.$deleteStartDate(),R.component.due&&(R.component.alarm.relation="END"),z(a)}function I(a){R.component.$addDueDate(),Q=new Date(R.component.due.getTime()),R.component.start||(R.component.alarm.relation="END"),z(a)}function J(a){R.component.$deleteDueDate(),R.component.start&&(R.component.alarm.relation="START"),z(a)}function K(){if(R.component.start){var a;a=O.valueOf()-R.component.start.valueOf(),0!==a&&(O=new Date(R.component.start.getTime()),"appointment"===R.component.type&&(R.component.end=new Date(R.component.start.getTime()),R.component.end.addMinutes(R.component.delta),P=new Date(R.component.end.getTime())),N())}}function L(){if(R.component.end){var a=P.valueOf()-R.component.end.valueOf();0!==a&&(a=R.component.start.minutesTo(R.component.end),a<0?R.component.end=new Date(P.getTime()):(R.component.delta=a,P=new Date(R.component.end.getTime())),N())}}function M(){Q=new Date(R.component.due.getTime())}function N(){R.attendeesEditor.days=E(),R.component.updateFreeBusy()}var O,P,Q,R=this;R.service=i,R.component=o,R.categories={},R.showRecurrenceEditor=R.component.$hasCustomRepeat,R.toggleRecurrenceEditor=q,R.recurrenceMonthDaysAreRequired=s,R.showAttendeesEditor=R.component.attendees&&R.component.attendees.length,R.toggleAttendeesEditor=r,R.changeFrequency=t,R.changeCalendar=u,R.cardFilter=v,R.addAttendee=w,R.removeAttendee=x,R.addAttachUrl=p,R.priorityLevel=y,R.changeAlarmRelation=z,R.reset=B,R.cancel=C,R.edit=D,R.save=A,R.attendeeConflictError=!1,R.attendeesEditor={days:E(),hours:F()},R.addStartDate=G,R.removeStartDate=H,R.addDueDate=I,R.removeDueDate=J,R.adjustStartTime=K,R.adjustEndTime=L,R.adjustDueTime=M,R.component.start&&(O=new Date(R.component.start.getTime())),R.component.end&&(P=new Date(R.component.end.getTime())),R.component.due&&(Q=new Date(R.component.due.getTime()))}a.$inject=["$rootScope","$mdDialog","Calendar","Component","AddressBook","Alarm","Account","stateComponent"],b.$inject=["$rootScope","$scope","$log","$timeout","$mdDialog","sgFocus","User","CalendarSettings","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> <span ng-bind="'+c+'block.component.c_location"></span>'," </div>"," </div>"," </div>",' <div class="ghostStartHour" ng-if="block.startHour">{{ block.startHour }}</div>',' <div class="ghostEndHour" ng-if="block.endHour">{{ block.endHour }}</div>',"</div>"].join("")}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,0===f&&(f=10),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(a){function b(a,b){return['<div class="sg-event"',' ng-click="clickComponent({clickEvent: $event, clickComponent: component})">',' <div class="sg-category" ng-repeat="category in ::component.categories"'," ng-class=\"::('bg-category' + category)\""," ng-style=\"::{ right: ($index * 3) + 'px' }\"></div>",' <span ng-show="::component.c_priority" class="sg-priority" ng-bind="::component.c_priority"></span>'," {{ ::component.c_title }}",' <span class="icons">',' <md-icon ng-if="::component.occurrenceId" class="material-icons icon-repeat"></md-icon>',' <md-icon ng-if="::component.c_nextalarm" class="material-icons icon-alarm"></md-icon>',' <md-icon ng-if="::component.c_classification == 2" class="material-icons icon-visibility-off"></md-icon>',' <md-icon ng-if="::component.c_classification == 1" class="material-icons icon-vpn-key"></md-icon>'," </span>",' <div class="secondary" ng-if="::!component.c_isallday">',' <md-icon>access_time</md-icon> <span ng-bind="::component.starthour"></span>'," </div>",' <div class="secondary" ng-if="::component.c_location">',' <md-icon>place</md-icon> <span ng-bind="::component.c_location"></span>'," </div>","</div>"].join("")}function c(a,b,c){a.component.viewable&&b.addClass("md-clickable"),a.component.userstate&&b.addClass("sg-event--"+a.component.userstate),b.addClass("bg-folder"+a.component.pid),b.addClass("contrast-bdr-folder"+a.component.pid),0===a.component.c_isopaque&&b.addClass("sg-event--transparent"),0===a.component.c_status&&b.addClass("sg-event--cancelled")}return{restrict:"E",scope:{component:"=sgComponent",clickComponent:"&sgClick"},replace:!0,template:b,link:c}}a.$inject=["CalendarSettings"],angular.module("SOGo.SchedulerUI").directive("sgCalendarListEvent",a)}(),function(){function a(){return{restrict:"C",scope:{},bindToController:{calendar:"=sgCalendar"},template:['<md-switch ng-model="$ctrl.calendar.active"'," ng-class=\"$ctrl.calendar.getClassName('md-switch')\"",' ng-true-value="1"',' ng-false-value="0"',' aria-label="'+l("Enable")+'"></md-switch>','<p class="sg-item-name"',' ng-dblclick="$ctrl.editFolder($event)">',' <span ng-bind="$ctrl.calendar.name"></span>',' <md-icon ng-if="$ctrl.calendar.$error" class="md-warn">error</md-icon>',' <md-tooltip md-delay="1000"',' md-autohide="true"',' ng-bind="$ctrl.calendar.name"></md-tooltip>',' <span class="sg-counter-badge ng-hide"',' ng-show="calendar.activeTasks"',' ng-bind="calendar.activeTasks"></span>',"</p>",'<md-input-container class="md-flex ng-hide">',' <input class="sg-item-name" type="text"',' aria-label="'+l("Name of the Calendar")+'"',' ng-blur="$ctrl.saveFolder($event)"',' sg-enter="$ctrl.saveFolder($event)"',' sg-escape="$ctrl.revertEditing()" />',"</md-input-container>",'<md-button class="md-secondary md-icon-button" ',' as-sortable-item-handle="as-sortable-item-handle">'," <md-icon md-colors=\"::{color: 'accent-400'}\">drag_handle</md-icon>","</md-button>",'<md-icon class="md-menu sg-list-sortable-hide"',' ng-click="$ctrl.showMenu($event)"',' aria-label="'+l("Options")+'">more_vert</md-icon>'].join(""),controller:"sgCalendarListItemController",controllerAs:"$ctrl"}}function b(a,b,c,d,e,f,g,h,i,j){var k=this;this.$onInit=function(){this.editMode=!1},this.$postLink=function(){this.clickableElement=c.find("p")[0],this.nameElements=this.clickableElement.getElementsByClassName("sg-calendar-name"),this.inputContainer=c.find("md-input-container")[0],this.inputElement=c.find("input")[0],this.moreOptionsButton=_.last(c.find("md-icon")),this.updateCalendarName()},this.updateCalendarName=function(){_.forEach(this.nameElements,function(a){a.innerHTML=k.calendar.name})},this.editFolder=function(a){this.editMode=!0,this.inputElement.value=this.calendar.name,this.clickableElement.classList.add("ng-hide"),this.inputContainer.classList.remove("ng-hide"),this.inputElement.focus(),this.inputElement.select(),a&&(a.stopPropagation(),a.preventDefault())},this.saveFolder=function(a){this.inputElement.disabled||(this.calendar.name=this.inputElement.value,this.inputElement.disabled=!0,this.calendar.$rename().then(function(a){k.editMode=!1,k.inputContainer.classList.add("ng-hide"),k.clickableElement.classList.remove("ng-hide"),k.updateCalendarName()}).finally(function(){k.inputElement.disabled=!1}))},this.revertEditing=function(){this.editMode=!1,this.clickableElement.classList.remove("ng-hide"),this.inputContainer.classList.add("ng-hide"),this.inputElement.value=this.calendar.name},this.confirmDelete=function(){this.calendar.isSubscription?this.calendar.$delete().catch(function(a,b){i.alert(l('An error occured while deleting the calendar "%{0}".',k.calendar.name),l(a.error))}):i.confirm(l("Warning"),l('Are you sure you want to delete the calendar "%{0}"?',this.calendar.name),{ok:l("Delete")}).then(function(){k.calendar.$delete().catch(function(a,b){i.alert(l('An error occured while deleting the calendar "%{0}".',k.calendar.name),l(a.error))})})},this.showMenu=function(b){function c(c,e,f,g){var h=this;this.showOnly=function(){_.forEach(j.$findAll(),function(a){h.calendar.id==a.id?a.active=1:a.active=0})},this.showAll=function(){_.forEach(j.$findAll(),function(a){a.active=1})},this.showProperties=function(){function a(a,b,c){function d(a){a.$valid&&(f.calendar.$save(),c.init(f.calendar.$omit()),b.hide())}function e(){b.cancel()}var f=this;f.calendar=new j(c.$omit()),f.saveProperties=d,f.close=e,a.$watch(function(){return f.calendar.color},function(){c.color=f.calendar.color})}var b=this.calendar.color;e.show({templateUrl:this.calendar.id+"/properties",controller:a,controllerAs:"properties",clickOutsideToClose:!0,escapeToClose:!0,locals:{srcCalendar:this.calendar}}).catch(function(){h.calendar.color=b}),a.$inject=["$scope","$mdDialog","srcCalendar"]},this.showLinks=function(){function a(a,b){function c(){a.hide()}var d=this;d.calendar=b,d.close=c}e.show({parent:angular.element(document.body),clickOutsideToClose:!0,escapeToClose:!0,templateUrl:this.calendar.id+"/links",controller:a,controllerAs:"links",locals:{calendar:this.calendar}}),a.$inject=["$mdDialog","calendar"]},this.importCalendar=function(){function c(b,c,e){function g(a){var b=0===a.type.indexOf("text")||/\.(ics)$/.test(a.name);return b||d.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 f({url:ApplicationBaseURL+[e.id,"import"].join("/"),autoUpload:!0,queueLimit:1,filters:[{name:g,fn:g}],onSuccessItem:function(b,e,f,g){var h;c.hide(),0===e.imported?h=l("No event was imported."):(h=l("A total of %{0} events were imported in the calendar.",e.imported),a.$emit("calendars:list")),d.show(d.simple().content(h).position("top right").hideDelay(3e3))},onErrorItem:function(a,b,c,e){d.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()}}e.show({parent:angular.element(document.body),targetEvent:b,clickOutsideToClose:!0,escapeToClose:!0,templateUrl:"UIxCalendarImportDialog",controller:c,controllerAs:"$CalendarImportDialogController",locals:{folder:this.calendar}}),c.$inject=["scope","$mdDialog","folder"]},this.share=function(){this.calendar.$acl.$users().then(function(){e.show({templateUrl:h.calendar.id+"/UIxAclEditor",controller:"AclController",controllerAs:"acl",clickOutsideToClose:!0,escapeToClose:!0,locals:{usersWithACL:h.calendar.$acl.users,User:g,folder:h.calendar}})})}}var f=e.newPanelPosition().relativeTo(this.moreOptionsButton).addPanelPosition(e.xPosition.ALIGN_START,e.yPosition.ALIGN_TOPS),g=e.newPanelAnimation().openFrom(this.moreOptionsButton).duration(100).withAnimation(e.animation.FADE),h={attachTo:angular.element(document.body),locals:{itemCtrl:this,calendar:this.calendar,editFolder:angular.bind(this,this.editFolder),confirmDelete:angular.bind(this,this.confirmDelete)},bindToController:!0,controller:c,controllerAs:"$menuCtrl",position:f,animation:g,targetEvent:b,templateUrl:"UIxCalendarMenu",trapFocus:!0,clickOutsideToClose:!0,escapeToClose:!0,focusOnOpen:!0};e.open(h).then(function(a){a.panelEl.one("click",function(){a.close()})}),c.$inject=["mdPanelRef","$mdDialog","FileUploader","User"]}}b.$inject=["$rootScope","$scope","$element","$mdToast","$mdPanel","$mdMedia","$mdSidenav","sgConstant","Dialog","Calendar"],angular.module("SOGo.SchedulerUI").controller("sgCalendarListItemController",b).directive("sgCalendarListItem",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(){if(m=new l(d,n),"monthly"!=n){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",scope:{calendars:"=sgCalendars",calendar:"@sgCalendar",blocksType:"@sgBlocksType",day:"@sgDay",clickBlock:"&sgClick"},template:["<sg-calendar-day-table",' sg-blocks="calendars[calendar][blocksType]"',' sg-day="day"',' sg-click="clickBlock({event: clickEvent, component: clickComponent})"/>'].join("")}}angular.module("SOGo.SchedulerUI").directive("sgCalendarTable",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;h.block.length<3||(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,d,e,f;a.stopPropagation(),d=a.target.scrollHeight>a.target.clientHeight+1,d&&(e=a.target.getBoundingClientRect(),f=e.left+e.width-18,a.pageX>f)||(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(a,b,c,d,e,f){return{restrict:"CA",scope:{onDrop:"&sgOnDrop"},link:function(b,c,d,e){var f=a.$on("calendar:dragend",b.onDrop);b.$on("$destroy",f)}}}a.$inject=["$rootScope","$timeout","$mdGesture","Calendar","CalendarSettings","Component"],angular.module("SOGo.SchedulerUI").directive("sgDroppableBlock",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
|