!function(){"use strict";function d(e){this.component=e,this.component.attendees&&_.forEach(this.component.attendees,function(e){e.image=d.$gravatar(e.email,32)}),this.workDaysOnly=!0,this.slotStartTimeLimit=new Date,this.slotStartTimeLimit.setMinutes(0),this.slotStartTimeLimit.setHours(d.dayStartHour),this.slotEndTimeLimit=new Date,this.slotEndTimeLimit.setMinutes(0),this.slotEndTimeLimit.setHours(d.dayEndHour),this.$days=[],this.$futureFreebusyData={},this.updateFreeBusyCoverage(),this.updateFreeBusy(),0==this.$days.length&&this.getDays()}d.$factory=["$q","$timeout","$log","sgSettings","Attendees_ROLES","Preferences","User","Card","Gravatar","Resource",function(e,t,n,i,a,o,r,s,c,l){return angular.extend(d,{$q:e,$timeout:t,$log:n,$settings:i,$User:r,$Preferences:o,$Card:s,$gravatar:c,$$resource:new l(i.activeUser("folderURL")+"Calendar",i.activeUser()),ROLES:a}),d.dayStartHour=parseInt(o.defaults.SOGoDayStartTime.split(":")[0]),d.dayEndHour=parseInt(o.defaults.SOGoDayEndTime.split(":")[0]),d}];try{angular.module("SOGo.SchedulerUI")}catch(e){angular.module("SOGo.SchedulerUI",["SOGo.Common"])}angular.module("SOGo.SchedulerUI").constant("Attendees_ROLES",{REQ_PARTICIPANT:"req-participant",OPT_PARTICIPANT:"opt-participant",NON_PARTICIPANT:"non-participant",CHAIR:"chair"}).factory("Attendees",d.$factory),d.timeToQuarters=function(e){return 4*e.getHours()+Math.ceil(e.getMinutes()/15)},d.prototype.getLength=function(){return this.component.attendees?this.component.attendees.length:0},d.prototype.initOrganizer=function(e){var t=this,e=e&&e.isSubscription?d.$User.$filter(e.owner).then(function(e){e=e[0];t.component.organizer={uid:e.uid,name:e.cn,email:e.c_email}}):(this.component.organizer||(this.component.organizer={uid:d.$settings.activeUser("login"),name:d.$settings.activeUser("identification"),email:d.$settings.activeUser("email")}),d.$q.when());e.then(function(){t.updateFreeBusyAttendee(t.component.organizer)})},d.prototype.add=function(e,t){var n,i,a=this,o=d.$q.when();return e&&((!this.component.attendees||t&&t.organizerCalendar)&&this.initOrganizer(t?t.organizerCalendar:null),e.$isList({expandable:!0})?o=(i=d.$Card.$find(e.container,e.c_name)).$id().then(function(e){_.forEach(i.refs,function(e){n={name:e.c_cn,email:e.$preferredEmail(t?t.partial:null),role:d.ROLES.REQ_PARTICIPANT,partstat:"needs-action",uid:e.c_uid,$avatarIcon:"person"},_.find(a.component.attendees,function(e){return e.email==n.email})||(n.image=d.$gravatar(n.email,32),a.component.attendees?a.component.attendees.push(n):a.component.attendees=[n],a.updateFreeBusyAttendee(n))})}):(n={uid:e.c_uid,domain:e.c_domain,isMSExchange:e.ismsexchange,isGroup:e.$isList(),isExpandableGroup:!1,isResource:e.isresource,name:e.c_cn,email:e.$$email,role:d.ROLES.REQ_PARTICIPANT,partstat:"needs-action",$avatarIcon:e.$avatarIcon},_.find(this.attendees,function(e){return e.email==n.email})||(e.$isList()&&d.$Preferences.defaults.SOGoLDAPGroupExpansionEnabled&&(o=e.$members().then(function(e){n.members=e,n.isExpandableGroup=!0})),n.image=d.$gravatar(n.email,32),this.component.attendees?_.findIndex(this.component.attendees,{email:n.email})<0&&this.component.attendees.push(n):this.component.attendees=[n],this.updateFreeBusyAttendee(n)))),o},d.prototype.nextRole=function(t){var e=_.values(d.ROLES),n=_.findIndex(e,function(e){return t.role===e});t.role=e[++n%4]},d.prototype.hasAttendee=function(e){var t=_.find(this.component.attendees,function(t){return _.find(e.emails,function(e){return e.value==t.email})});return angular.isDefined(t)},d.prototype.remove=function(t){var e=_.findIndex(this.component.attendees,function(e){return e.email==t.email});-1=this.startLimit;){for(var a,o=0,r=t;0===this.currentEntries[r]&&oe&&this.attachUrls.splice(e,1)},u.prototype.$addDueDate=function(){this.due=new Date,this.due.setMinutes(15*Math.round(this.due.getMinutes()/15)),this.dueDate=this.due.toISOString()},u.prototype.$deleteDueDate=function(){delete this.due,delete this.dueDate},u.prototype.$addStartDate=function(){this.start=new Date,this.start.setMinutes(15*Math.round(this.start.getMinutes()/15))},u.prototype.$deleteStartDate=function(){delete this.start,delete this.startDate},u.prototype.$addRecurrenceDate=function(){var e=new Date;e.setMinutes(15*Math.round(e.getMinutes()/15)),angular.isUndefined(this.repeat.dates)&&(this.repeat={frequency:"custom",dates:[]}),this.repeat.dates.push(e)},u.prototype.$deleteRecurrenceDate=function(e){-1e&&this.repeat.dates.splice(e,1)},u.prototype.$reset=function(){var n=this;angular.forEach(this,function(e,t){"constructor"!=t&&"$"!=t[0]&&delete n[t]}),this.init(this.$shadowData),this.$shadowData=this.$omit()},u.prototype.$reply=function(){var e,t=this,n=[this.pid,this.id];return this.occurrenceId&&n.push(this.occurrenceId),e={reply:this.reply,delegatedTo:this.delegatedTo,alarm:this.$hasAlarm?this.alarm:{},classification:this.classification},u.$$resource.save(n,e,{action:"rsvpAppointment"}).then(function(e){return t.$shadowData=t.$omit(),e})},u.prototype.$adjust=function(e){var t=[this.pid,this.id];return _.every(_.values(e),function(e){return 0===e})?u.$q.when():(this.occurrenceId&&t.push(this.occurrenceId),u.$log.debug("adjust "+t.join("/")+" "+JSON.stringify(e)),u.$$resource.save(t,e,{action:"adjust"}))},u.prototype.$save=function(e){var t,n,i=this,a=this.$omit(),o=u.$Preferences.$mdDateLocaleProvider;return a.startDate=a.start?a.start.format(o,"%Y-%m-%d"):"",a.startTime=a.start?a.start.format(o,"%H:%M"):"",a.endDate=a.end?a.end.format(o,"%Y-%m-%d"):"",a.endTime=a.end?a.end.format(o,"%H:%M"):"",a.dueDate=a.due?a.due.format(o,"%Y-%m-%d"):"",a.dueTime=a.due?a.due.format(o,"%H:%M"):"",a.completedDate=a.completed?a.completed.format(o,"%Y-%m-%d"):"",this.hasCustomRepeat()?"monthly"==this.repeat.frequency&&this.repeat.month.type&&"byday"==this.repeat.month.type&&"relative"!=this.repeat.month.day||"yearly"==this.repeat.frequency&&this.repeat.year.byday?(delete a.repeat.monthdays,a.repeat.days=[{day:this.repeat.month.day,occurrence:this.repeat.month.occurrence.toString()}]):"monthly"!=this.repeat.frequency&&"yearly"!=this.repeat.frequency||!this.repeat.month.type?"custom"==this.repeat.frequency&&this.repeat.dates&&_.forEach(a.repeat.dates,function(e,t,n){n[t]={date:e.format(o,"%Y-%m-%d"),time:e.format(o,"%H:%M")}}):(delete a.repeat.days,"relative"==this.repeat.month.day&&(a.repeat.monthdays=[this.repeat.month.occurrence])):this.repeat.frequency&&"never"!=this.repeat.frequency&&(a.repeat={frequency:this.repeat.frequency}),a.startDate&&this.repeat.frequency&&"never"!=this.repeat.frequency?"until"==this.repeat.end&&this.repeat.until?a.repeat.until=this.repeat.until.stringWithSeparator("-"):"count"==this.repeat.end&&this.repeat.count?a.repeat.count=this.repeat.count:(delete a.repeat.until,delete a.repeat.count):delete a.repeat,"not-specified"==this.status?delete a.status:"completed"!=this.status&&delete a.completedDate,(a.startDate||a.dueDate)&&this.$hasAlarm?!this.alarm.action||"email"!=this.alarm.action||this.attendees&&0',' ',"

"+l("editRepeatingItem")+"

","
"," ",' '+l("button_thisOccurrenceOnly")+"",' '+l("button_allOccurrences")+""," ",""].join(""),controller:r}).then(function(){d.$emit("calendars:list")},function(){}).finally(function(){u(function(){g.$resetGhost()})})),r.$inject=["$scope","$mdDialog","component","params"],c.$inject=["$scope","$mdDialog","component","params","conflictError"]}s={title:"Title",location:"Location",calendarName:"Calendar",start:"Start",priority:"Priority",category:"Category",status:"Status",events:{end:"End"},tasks:{end:"Due Date"}},c.component=g,c.componentType="events",c.selectedList=0,c.selectComponentType=$,c.unselectComponents=function(){_.forEach(g["$"+c.componentType],function(e){e.selected=!1}),c.mode.multiple=0},c.selectAll=function(){_.forEach(g["$"+c.componentType],function(e){e.selected=!0}),c.mode.multiple=g["$"+c.componentType].length},c.searchMode=v,c.toggleComponentSelection=function(e,t){t.selected=!t.selected,c.mode.multiple+=t.selected?1:-1,e.preventDefault(),e.stopPropagation()},c.confirmDeleteSelectedComponents=function(){o.confirm(l("Warning"),l("Are you sure you want to delete the selected components?"),{ok:l("Delete")}).then(function(){var e=_.filter(g["$"+c.componentType],function(e){return e.selected});f.$deleteComponents(e).then(function(){c.mode.multiple=0,d.$emit("calendars:list")})})},c.openEvent=function(e,t){C(e,t,"appointment")},c.openTask=function(e,t){C(e,t,"task")},c.newComponent=b,c.filter=function(e){{if(!e)return g["$query"+c.componentType.capitalize()].filterpopup;g.$filter(c.componentType,{filterpopup:e})}},c.filteredBy=function(e){return g["$query"+c.componentType.capitalize()].filterpopup==e},c.sort=function(e){{if(!e){var t=g["$query"+c.componentType.capitalize()].sort;return s[t]||s[c.componentType][t]}g.$filter(c.componentType,{sort:e})}},c.sortedBy=function(e){return g["$query"+c.componentType.capitalize()].sort==e},c.reload=function(){g.$loaded=g.STATUS.LOADING,f.reloadWebCalendars().finally(function(){d.$emit("calendars:list")})},c.cancelSearch=function(){c.mode.search=!1,g.$filter(c.componentType,{value:""})},c.mode={search:!1,multiple:0},this.$onInit=function(){var e;(e=y).push(n.createHotkey({key:l("hotkey_search"),description:l("Search"),callback:v})),e.push(n.createHotkey({key:l("hotkey_create_event"),description:l("Create a new event"),callback:b,args:"appointment"})),e.push(n.createHotkey({key:l("hotkey_create_task"),description:l("Create a new task"),callback:b,args:"task"})),_.forEach(e,function(e){n.registerHotkey(e)}),r="events","tasksListView"==p.settings.Calendar.SelectedList&&(c.selectedList=1,r="tasks"),$(r,{reload:!0}),d.$on("calendars:list",function(){g.$filter(c.componentType,{reload:!0})}),d.$on("calendar:dragend",D),t.$on("$destroy",function(){_.forEach(y,function(e){n.deregisterHotkey(e)})})},this.ascending=function(){return g["$query"+c.componentType.capitalize()].asc}}e.$inject=["$rootScope","$scope","$q","$timeout","$state","$mdDialog","sgHotkeys","sgFocus","Dialog","Preferences","CalendarSettings","Calendar","Component"],angular.module("SOGo.SchedulerUI").controller("CalendarListController",e)}(),function(){"use strict";function e(o,e,t,i,n,r,a,s,c,d,u,h){var p=this;this.activeUser=d.activeUser,this.service=h,this.filter={name:""},this.sortableMode=!1,this.sortableCalendars={scrollableContainer:"#sidenav-content",containment:"md-list",orderChanged:function(){h.saveFoldersOrder(_.flatMap(h.$findAll(),"id"))},accept:function(e,t,n){return e.sortableScope.element[0]==t.element[0]}},this.$onInit=function(){p.categories=_.map(u.defaults.SOGoCalendarCategories,function(e){return{id:e.asCSSIdentifier(),name:e,color:u.defaults.SOGoCalendarCategoriesColors[e]}}),e.$watch(function(){return _.union(_.map(h.$calendars,function(e){return _.pick(e,["id","active","color"])}),_.map(h.$subscriptions,function(e){return _.pick(e,["id","active","color"])}),_.map(h.$webcalendars,function(e){return _.pick(e,["id","active","color"])}))},function(e,n){var t=_.intersectionBy(e,n,"id"),i=_.map(_.filter(t,function(e){var t=_.find(n,{id:e.id});return!_.isEqual(e,t)}),"id"),a=h.$q.when();0"}))},this.newMessageWithRecipient=function(e,t,n){p(e,[t+" <"+n+">"])},this.edit=function(){var t="vevent"==this.component.component?"Appointment":"Task";s.hide().then(function(){var e="UIx"+t+"EditorTemplate";s.show({parent:angular.element(document.body),clickOutsideToClose:!0,escapeToClose:!0,templateUrl:e,controller:"ComponentEditorController",controllerAs:"editor",locals:{stateComponent:h.component}})})},this.editAllOccurrences=function(){(u=e.$get(this.component.pid).$getComponent(this.component.id)).$futureComponentData.then(function(){h.component=u,h.edit()})},this.reply=function(e){(e||this.component).$reply().then(function(){t.$emit("calendars:list"),n.getAlarms(),s.hide()})},this.replyAllOccurrences=function(){(u=e.$get(this.component.pid).$getComponent(this.component.id)).$futureComponentData.then(function(){u.reply=h.component.reply,u.delegatedTo=h.component.delegatedTo,u.$hasAlarm=h.component.$hasAlarm,u.classification=h.component.classification,u.alarm=h.component.alarm,h.reply(u)})},this.deleteOccurrence=function(){this.component.remove(!0).then(function(){t.$emit("calendars:list"),s.hide()})},this.deleteAllOccurrences=function(){this.component.remove().then(function(){t.$emit("calendars:list"),s.hide()})},this.toggleRawSource=function(n){e.$$resource.post(this.component.pid+"/"+this.component.id,"raw").then(function(e){function t(e,t,n){e.data=n,e.close=function(){t.hide()}}s.hide(),s.show({parent:angular.element(document.body),targetEvent:n,clickOutsideToClose:!0,escapeToClose:!0,template:['',' ','
',"  
"," ",' '+l("Close")+""," ","
"].join(""),controller:t,locals:{data:e}}),t.$inject=["scope","$mdDialog","data"]})},this.copySelectedComponent=function(e){this.component.copyTo(e).then(function(){s.hide(),t.$emit("calendars:list")})},this.moveSelectedComponent=function(e){this.component.moveTo(e).then(function(){s.hide(),t.$emit("calendars:list")})}}function t(n,e,u,t,h,i,a,o,r,s,c,d,p,m,f,g,y,$,v){var C,b,D,w,S=this;function k(){var e;S.attendeesEditor.containerElement||(S.attendeesEditor.containerElement=a[0].querySelector("#freebusy")),e=a[0].querySelector("#freebusy_day_"+S.component.start.getDayString()),S.attendeesEditor.containerElement&&e&&(e=e.offsetLeft-S.attendeesEditor.containerElement.offsetLeft,S.attendeesEditor.containerElement.scrollLeft=e)}function E(e){S.adjustStartTime(),S.adjustEndTime(),S.component.$attendees.findSlot(e).then(function(){S.startTime=new Date(S.component.start.getTime()),S.endTime=new Date(S.component.end.getTime())}).catch(function(e){S.component.start=new Date(S.component.start.getTime()+1),h(k),r.show({template:["",'
',' error_outline'," "+e+"","
","
"].join(""),hideDelay:5e3,position:"top right"})}).finally(function(){h(k)})}function T(){_.has(S.component,"$attendees")&&(S.component.$attendees.updateFreeBusyCoverage(),S.component.$attendees.updateFreeBusy(),h(k))}this.$onInit=function(){this.service=p,this.component=v,this.categories={},this.showRecurrenceEditor=this.component.$hasCustomRepeat,this.showAttendeesEditor=this.component.attendees&&this.component.attendees.length,"appointment"==this.component.type&&(this.component.initAttendees(),this.attendeeConflictError=!1,this.attendeesEditor={days:this.component.$attendees.$days,hours:function(){for(var e=[],t=0;t<=23;t++)e.push(t.toString());return e}(),containerElement:a[0].querySelector("#freebusy")}),this.component.start&&(C=new Date(this.component.start.getTime()),this.startTime=new Date(this.component.start.getTime())),this.component.end&&(b=new Date(this.component.end.getTime()),this.endTime=new Date(this.component.end.getTime())),this.component.due&&(new Date(this.component.due.getTime()),this.dueTime=new Date(this.component.due.getTime())),this.component.attendees&&h(k),D=parseInt($.defaults.SOGoDayStartTime),w=parseInt($.defaults.SOGoDayEndTime)},this.addAttachUrl=function(){var e=this.component.addAttachUrl("");s("attachUrl_"+e)},this.toggleRecurrenceEditor=function(){this.showRecurrenceEditor=!this.showRecurrenceEditor,this.component.$hasCustomRepeat=this.showRecurrenceEditor},this.toggleAttendeesEditor=function(){this.showAttendeesEditor=!this.showAttendeesEditor},this.recurrenceMonthDaysAreRequired=function(){return this.component&&"monthly"==this.component.repeat.frequency&&"bymonthday"==this.component.repeat.month.type},this.frequencies=function(){return _.filter(i.repeatFrequencies,function(e){return"custom"!=e[0]||"custom"==S.component.repeat.frequency})},this.changeFrequency=function(){"custom"==this.component.repeat.frequency&&(this.showRecurrenceEditor=!0)},this.changeCalendar=function(){this.component.attendees&&0? *"),"");return S.showAttendeesEditor|=a,S.searchText="",S.cardFilter(t).then(function(e){return e.length?e[0]:new y({c_cn:_.trim(n,' "'),emails:[{value:t}]})}).catch(function(e){return new y({c_cn:_.trim(n,' "'),emails:[{value:t}]})})}function d(e){if(!S.component.$attendees.hasAttendee(e))return S.component.$attendees.add(e,r)}if(t&&(r.partial=t),angular.isString(e)){for(i="",n=0;n",'
','
",'
',' {{'+t+"block.component.c_priority}}"," {{ "+t+"block.component.summary }}",' ',' repeat',' alarm',' visibility_off',' vpn_key'," ",'
',' place ',"
",'
',"
","
",'
{{ block.startHour }}
','
{{ block.endHour }}
',""].join("")},link:function(e,t,n){var i;_.has(n,"sgCalendarGhost")||(i=90/e.block.siblings,n=e.block.position*i,i=100-(e.block.position+1)*i,t.css("left",n+"%"),t.css("right",i+"%"),e.block.component&&e.block.component.c_isallday||(t.addClass("starts"+e.block.start),t.addClass("lasts"+e.block.length)),e.block.userState&&t.addClass("sg-event--"+e.block.userState),e.block.component&&(e.showCalendarName=a.activeUser.login!==e.block.component.c_owner,t.addClass("bg-folder"+e.block.component.pid),t.addClass("contrast-bdr-folder"+e.block.component.pid),0===e.block.component.c_isopaque&&t.addClass("sg-event--transparent"),0===e.block.component.c_status&&t.addClass("sg-event--cancelled")))}}}e.$inject=["Calendar"],angular.module("SOGo.SchedulerUI").directive("sgCalendarDayBlock",e)}(),function(){"use strict";angular.module("SOGo.SchedulerUI").directive("sgCalendarDayTable",function(){return{restrict:"E",scope:{blocks:"=sgBlocks",day:"@sgDay",clickBlock:"&sgClick"},template:["'].join("")}})}(),function(){"use strict";function e(r,e,f,g,s){return{restrict:"A",require:["^sgCalendarDay","^sgCalendarScrollView"],link:function(c,l,e,t){var n,d,u,h,p;n=l[0],d=t[0],u=t[1],h=-1,l.addClass("sg-event--ghost md-whiteframe-3dp ng-hide");var i=r.$on("calendar:dragstart",function(){var e,t;c.block=s.$ghost,(t=d.calendarData())&&(h=t.index,e=t.pid,p=c.block.pointerHandler.originalCalendar.index);e=e||c.block.component.pid;(t=c.block.component.blocks[0].userState)&&l.addClass("sg-event--"+t);l.addClass("bg-folder"+e)}),a=r.$on("calendar:drag",function(){var e,t,n,i,a,o,r,s;if(e=!1,g.$view&&g.$view.type==u.type){if(t="multiday-allday"===u.type,n=c.block.component.c_isallday,i=c.block.pointerHandler.currentEventCoordinates.dayNumber,a=c.block.pointerHandler.currentEventCoordinates.start,r=c.block.pointerHandler.currentEventCoordinates.duration,s=f.EventDragDayLength-a,angular.isUndefined(r))return;for(s<(o=r)&&(o=s),-1f.EventDragDayLength&&(o=f.EventDragDayLength),-1','
',' ','
','
","
"," {{ ::component.c_title }}",' ',' repeat',' alarm',' visibility_off',' vpn_key'," ",'
',' access_time ',"
",'
',' place ',"
","
",""].join("")},link:function(e,t,n){e.component.viewable&&t.addClass("md-clickable");e.component.userstate&&t.addClass("sg-event--"+e.component.userstate);t.addClass("bg-folder"+e.component.pid),t.addClass("contrast-bdr-folder"+e.component.pid),0===e.component.c_isopaque&&t.addClass("sg-event--transparent");0===e.component.c_status&&t.addClass("sg-event--cancelled")}}}e.$inject=["CalendarSettings"],angular.module("SOGo.SchedulerUI").directive("sgCalendarListEvent",e)}(),function(){function e(r,e,t,n,s,i,a,o,c,d,u){var h=this;this.$onInit=function(){this.editMode=!1},this.$postLink=function(){this.clickableElement=t.find("p")[0],this.nameElements=this.clickableElement.getElementsByClassName("sg-calendar-name"),this.inputContainer=t.find("md-input-container")[0],this.inputElement=t.find("input")[0],this.moreOptionsButton=_.last(t.find("md-icon")),this.updateCalendarName()},this.updateCalendarName=function(){_.forEach(this.nameElements,function(e){e.innerHTML=h.calendar.name})},this.editFolder=function(e){e.stopPropagation(),e.preventDefault(),this.editMode=!0,this.inputElement.value=this.calendar.name,this.clickableElement.classList.add("ng-hide"),this.inputContainer.classList.remove("ng-hide"),e.srcEvent&&"touchend"==e.srcEvent.type?n(function(){h.inputElement.focus(),h.inputElement.select()},200):(this.inputElement.select(),this.inputElement.focus()),this.panel&&this.panel.close()},this.saveFolder=function(e){this.inputElement.disabled||(0===this.inputElement.value.length&&this.revertEditing(),this.calendar.name=this.inputElement.value,this.inputElement.disabled=!0,this.calendar.$rename().then(function(e){h.editMode=!1,h.inputContainer.classList.add("ng-hide"),h.clickableElement.classList.remove("ng-hide"),h.updateCalendarName()},function(){h.editMode=!0,h.inputElement.value=h.calendar.name,n(function(){h.inputElement.focus(),h.inputElement.select()},200)}).finally(function(){h.inputElement.disabled=!1}))},this.revertEditing=function(){this.editMode=!1,this.clickableElement.classList.remove("ng-hide"),this.inputContainer.classList.add("ng-hide"),this.inputElement.value=this.calendar.name},this.confirmDelete=function(){this.calendar.isSubscription?this.calendar.$delete().catch(function(e,t){d.alert(l('An error occured while deleting the calendar "%{0}".',h.calendar.name),l(e.error))}):d.confirm(l("Warning"),l('Are you sure you want to delete the calendar "%{0}"?',this.calendar.name),{ok:l("Delete")}).then(function(){h.calendar.$delete().catch(function(e,t){d.alert(l('An error occured while deleting the calendar "%{0}".',h.calendar.name),l(e.error))})})},this.showMenu=function(o){var e=i.newPanelPosition().relativeTo(this.moreOptionsButton).addPanelPosition(i.xPosition.ALIGN_START,i.yPosition.ALIGN_TOPS),t=i.newPanelAnimation().openFrom(this.moreOptionsButton).duration(100).withAnimation(i.animation.FADE),t={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:n,controllerAs:"$menuCtrl",position:e,animation:t,targetEvent:o,templateUrl:"UIxCalendarMenu",trapFocus:!0,clickOutsideToClose:!0,escapeToClose:!0,focusOnOpen:!0};function n(e,n,i,t){var a=this;this.showOnly=function(){_.forEach(u.$findAll(),function(e){a.calendar.id==e.id?e.active=1:e.active=0})},this.showAll=function(){_.forEach(u.$findAll(),function(e){e.active=1})},this.showProperties=function(){var e=this.calendar.color;function t(e,t,n){var i=this;i.calendar=new u(n.$omit()),i.saveProperties=function(e){e.$valid&&i.calendar.$save().then(function(){n.init(i.calendar.$omit()),t.hide()},function(){e.$setPristine()})},i.close=function(){t.cancel()},e.$watch(function(){return i.calendar.color},function(){n.color=i.calendar.color})}n.show({templateUrl:this.calendar.id+"/properties",controller:t,controllerAs:"properties",clickOutsideToClose:!0,escapeToClose:!0,locals:{srcCalendar:this.calendar}}).catch(function(){a.calendar.color=e}),t.$inject=["$scope","$mdDialog","srcCalendar"]},this.showLinks=function(){function e(e,t){this.calendar=t,this.close=function(){e.hide()}}n.show({parent:angular.element(document.body),clickOutsideToClose:!0,escapeToClose:!0,templateUrl:this.calendar.id+"/links",controller:e,controllerAs:"links",locals:{calendar:this.calendar}}),e.$inject=["$mdDialog","calendar"]},this.importCalendar=function(){function e(e,o,t){function n(e){e=0===e.type.indexOf("text")||/\.(ics)$/.test(e.name);return e||s.show({template:["",'
',' error_outline'," "+l("Select an iCalendar file (.ics).")+"","
","
"].join(""),position:"top right",hideDelay:3e3}),e}this.uploader=new i({url:ApplicationBaseURL+[t.id,"import"].join("/"),autoUpload:!0,queueLimit:1,filters:[{name:n,fn:n}],onSuccessItem:function(e,t,n,i){var a;o.hide(),0===t.imported?a=l("No event was imported."):(a=l("A total of %{0} events were imported in the calendar.",t.imported),r.$emit("calendars:list")),s.show(s.simple().textContent(a).position("top right").hideDelay(3e3))},onErrorItem:function(e,t,n,i){s.show({template:["",'
',' error_outline'," "+l("An error occurred while importing calendar.")+"","
","
"].join(""),position:"top right",hideDelay:3e3})}}),this.close=function(){o.hide()}}n.show({parent:angular.element(document.body),targetEvent:o,clickOutsideToClose:!0,escapeToClose:!0,templateUrl:"UIxCalendarImportDialog",controller:e,controllerAs:"$CalendarImportDialogController",locals:{folder:this.calendar}}),e.$inject=["scope","$mdDialog","folder"]},this.share=function(){this.calendar.$acl.$users().then(function(){n.show({templateUrl:a.calendar.id+"/UIxAclEditor",controller:"AclController",controllerAs:"acl",clickOutsideToClose:!0,escapeToClose:!0,locals:{usersWithACL:a.calendar.$acl.users,User:t,folder:a.calendar}})})}}i.open(t).then(function(e){(h.panel=e).panelEl.one("click",function(){e.close()})}),n.$inject=["mdPanelRef","$mdDialog","FileUploader","User"]}}e.$inject=["$rootScope","$scope","$element","$timeout","$mdToast","$mdPanel","$mdMedia","$mdSidenav","sgConstant","Dialog","Calendar"],angular.module("SOGo.SchedulerUI").controller("sgCalendarListItemController",e).directive("sgCalendarListItem",function(){return{restrict:"C",scope:{},bindToController:{calendar:"=sgCalendar"},template:['','

',' ',' error',' ',' ',"

",'',' ',"",'drag_handle",'more_vert'].join(""),controller:"sgCalendarListItemController",controllerAs:"$ctrl"}})}(),function(){"use strict";angular.module("SOGo.SchedulerUI").directive("sgCalendarMonthDay",function(){return{restrict:"E",scope:{blocks:"=sgBlocks",day:"@sgDay",clickBlock:"&sgClick"},template:["'].join("")}})}(),function(){"use strict";angular.module("SOGo.SchedulerUI").directive("sgCalendarMonthEvent",function(){return{restrict:"E",scope:{block:"=sgBlock",clickBlock:"&sgClick"},replace:!0,template:function(e,t){t=_.has(t,"sgCalendarGhost")?"":"::";return['
','
",'
',' {{ '+t+"block.component.startHour }}",' {{'+t+"block.component.c_priority}}"," {{ "+t+"block.component.summary }}",' ',' repeat',' alarm',' visibility_off',' vpn_key'," ","
","
"].join("")},link:function(e,t,n){_.has(n,"sgCalendarGhost")||(e.block.userState&&t.addClass("sg-event--"+e.block.userState),e.block.component&&(t.addClass("bg-folder"+e.block.component.pid),0===e.block.component.c_isopaque&&t.addClass("sg-event--transparent"),0===e.block.component.c_status&&t.addClass("sg-event--cancelled")))}}})}(),function(){"use strict";function e(e,n){var t=this,i={portrait:{letter:[8.5,11,"in"],legal:[8.5,14,"in"],a4:[210,297,"mm"]},landscape:{letter:[11,8.5,"in"],legal:[14,8.5,"in"],a4:[297,210,"mm"]}},a={letter:[.4,2.1],legal:[.4,2.1],a4:[10,30]};this.$onInit=function(){e.$watchGroup([function(){return t.pageSize},function(){return t.workingHoursOnly}],angular.bind(this,function(){var e,t=i[this.orientation][this.pageSize];this.units=t[2],this.pageMargin=a[this.pageSize][0]+this.units,this.viewportHeight=(t[1]-2*a[this.pageSize][0]).toString()+this.units,this.hideHoursStart=0,this.hideHoursEnd=24,this.totalHours=24,this.clipTop=0,"month"===this.calendarView?this.viewHeight=(t[1]-3*a[this.pageSize][0]).toString()+this.units:(this.workingHoursOnly&&(n.defaults.SOGoDayEndTime&&(e=n.defaults.SOGoDayEndTime.split(":"),this.hideHoursEnd=parseInt(e[0]),this.totalHours=this.hideHoursEnd),n.defaults.SOGoDayStartTime&&(e=n.defaults.SOGoDayStartTime.split(":"),this.hideHoursStart=parseInt(e[0]),this.totalHours-=this.hideHoursStart)),this.hourHeight=(t[1]-2*a[this.pageSize][0]-a[this.pageSize][1])/this.totalHours,this.clipTop=(this.hourHeight*this.hideHoursStart).toString()+this.units,this.viewHeight=(this.hideHoursEnd*this.hourHeight).toString()+this.units)}))},this.eventsPositions=function(){var e,t=0,n=[];if("month"===this.calendarView)n.push("[ui-view=calendars] .monthView md-grid-list { min-height: "+this.viewHeight+"; }");else for(;t<=96;)t<=4*this.hideHoursStart&&(e=4*this.hideHoursStart-t,n.push("[ui-view=calendars] .sg-event.starts"+t+" .text { margin-top: "+this.hourHeight/4*e+this.units+"; }")),n.push("[ui-view=calendars] .sg-event.starts"+t+" { top: "+this.hourHeight/4*t+this.units+"; }"),n.push("[ui-view=calendars] .sg-event.lasts"+t+" { height: "+this.hourHeight/4*t+this.units+"; }"),t++;return n.join("\n")}}e.$inject=["$scope","Preferences"],angular.module("SOGo.SchedulerUI").directive("sgCalendarPrintStylesheet",function(){return{restrict:"E",scope:{calendarView:"'," @page {"," size: {{ $ctrl.pageSize }} {{ $ctrl.orientation }};"," margin: 0;"," }"," @media print {"," body {"," padding: {{ $ctrl.pageMargin }};"," }"," [ui-view=calendars] .view-list {"," height: {{ $ctrl.viewportHeight }};"," overflow: hidden;"," }"," [ui-view=calendars] .calendarView {"," transform: translateY(-{{ $ctrl.clipTop }});"," height: {{ $ctrl.viewHeight }};"," position: relative;"," overflow: hidden;"," }"," [ui-view=calendars] .allDaysView {"," max-height: {{ $ctrl.hourHeight }}{{ $ctrl.units }} !important;"," }"," [ui-view=calendars] .hours .hour,"," [ui-view=calendars] .days .day .clickableHourCell {"," min-height: {{ $ctrl.hourHeight }}{{ $ctrl.units }};"," max-height: {{ $ctrl.hourHeight }}{{ $ctrl.units }};"," }"," {{ $ctrl.eventsPositions() }}"," }",""].join("\n")}})}(),function(){"use strict";function e(c,l,e,t,d,n,u,h,p){return{restrict:"A",scope:{type:"@sgCalendarScrollView"},controller:i,link:function(e,n,t,i){var a,o,r;function s(e,t){this.$element=e,this.element=e[0],this.type=t,this.quarterHeight=this.getQuarterHeight(),this.scrollStep=6*this.quarterHeight,this.dayNumbers=this.getDayNumbers(),this.maxX=this.getMaxColumns(),this.deregisterDragStart=c.$on("calendar:dragstart",angular.bind(this,this.onDragStart)),this.deregisterDragStop=c.$on("calendar:dragend",angular.bind(this,this.onDragEnd)),this.bindedUpdateCoordinates=angular.bind(this,this.updateCoordinates),this.bindedUpdateFromPointerHandler=angular.bind(this,this.updateFromPointerHandler),this.updateCoordinates(),angular.element(l).on("resize",this.bindedUpdateCoordinates)}a=null,o=e.type,r="multicolumndayview"==n.attr("sg-view"),i.isMultiColumn=r,d(function(){var e,t;a=new s(n,o),"monthly"==o||p.defaults.SOGoDayStartTime&&(t=p.defaults.SOGoDayStartTime.split(":"),e=document.getElementById("hour"+parseInt(t[0])),t=parseInt(t[1])*a.quarterHeight,a.element.scrollTop=e.offsetTop+t);i.quarterHeight=a.quarterHeight}),e.$on("$destroy",function(){a&&a.$destroy()}),s.prototype={$destroy:function(){this.deregisterDragStart(),this.deregisterDragStop(),this.$element.off("mousemove",this.bindedUpdateFromPointerHandler),angular.element(l).off("resize",this.bindedUpdateCoordinates)},onDragStart:function(){this.$element.on("mousemove",this.bindedUpdateFromPointerHandler),this.updateCoordinates(),this.updateFromPointerHandler()},onDragEnd:function(){this.$element.off("mousemove",this.bindedUpdateFromPointerHandler),u.$view=null},getQuarterHeight:function(){var e=null,t=document.getElementById("hour0"),n=document.getElementById("hour23");return e=t&&n?(n.offsetTop-t.offsetTop)/92:e},getDayDimensions:function(e){var t,n,i,a,o=t=n=i=0,r=this.element.getElementsByClassName("day");return 0this.lastScroll+100)&&(this.lastScroll=t,(n=e.y-this.scrollStep)<0?(t=-this.element.scrollTop,this.element.scrollTop+=n=n'," .bg-category{{ ngModel.id }} {"," background-color: {{ ngModel.color }} !important;"," }"," .bdr-category{{ ngModel.id }} {"," border-color: {{ ngModel.color }} !important;"," }",""].join("")}})}(),function(){"use strict";function e(u,h,p,m,f,g,y){return{restrict:"CA",require:"^sgCalendarDay",link:function(o,r,e,s){if(o.block){if(!o.block.component.editable||o.block.userState)return void r.removeClass("sg-draggable-calendar-block");!function(){var e,t,n,i,a;o.block.length<3||(e=o.block.component,t=o.block.dayIndex,a=_.findIndex(e.blocks,["dayIndex",t]),i=0===a,t=a===e.blocks.length-1,(a=angular.element('
')).addClass("bdr-folder"+e.pid),e.c_isallday||"SG-CALENDAR-MONTH-DAY"===r[0].parentNode.tagName?(i&&(n=angular.element('
').append(a),r.append(n)),t&&(n=angular.element('
').append(a.clone()),r.append(n))):(i&&(i=angular.element('
').append(a),r.append(i)),t&&(a=angular.element('
').append(a.clone()),r.append(a))))}()}function t(e){var t;e.stopPropagation(),e.target.scrollHeight>e.target.clientHeight+1&&(t=(t=e.target.getBoundingClientRect()).left+t.width-18,e.pageX>t)||(t="move-event",o.block&&o.block.component?"dragGrip-top"==e.target.className||"dragGrip-left"==e.target.className?t="change-start":"dragGrip-bottom"!=e.target.className&&"dragGrip-right"!=e.target.className||(t="change-end"):t="change-end",(t=new d(t)).initFromEvent(e),y.$ghost.pointerHandler=t,angular.element(document).one("mouseup",n),angular.element(document).on("mousemove",i))}function i(e){var t=y.$ghost.pointerHandler;h(function(){t.updateFromEvent(e)})}function n(e){var t=o.block,n=y.$ghost.pointerHandler;angular.element(document).off("mousemove",i),n.dragHasStarted&&(u.$emit("calendar:dragend"),n.dragHasStarted=!1),t&&t.component&&_.forEach(t.component.blocks,function(e){e.dragging=!1})}function c(){}function a(e){this.setEventType(e)}function d(e){this.dragMode=e}r.on("mousedown",t),o.$on("$destroy",function(){r.off("mousedown",t),r.off("mousemove",i)}),c.prototype={x:-1,y:-1,getDelta:function(e){var t=new c;return t.x=this.x-e.x,t.y=this.y-e.y,f.$view&&(t.days=f.$view.dayNumbers[this.x]-f.$view.dayNumbers[e.x]),t},getDistance:function(e){e=this.getDelta(e);return Math.sqrt(e.x*e.x+e.y*e.y)},clone:function(){var e=new c;return e.x=this.x,e.y=this.y,e}},a.prototype={dayNumber:-1,weekDay:-1,start:-1,duration:-1,eventType:null,setEventType:function(e){this.eventType=e},initFromBlock:function(e){var i=-1;"monthly"===this.eventType?(this.start=0,this.duration=e.component.blocks.length*g.EventDragDayLength):(this.start=e.component.blocks[0].start,this.duration=_.sumBy(e.component.blocks,function(e){var t=e.dayNumber,n=i<0?0:t-i-1;return i=t,e.length+n*g.EventDragDayLength}))},initFromCalendar:function(e){this.dayNumber=e},getDelta:function(e){var t=new a;return t.dayNumber=this.dayNumber-e.dayNumber,t.start=this.start-e.start,t.duration=this.duration-e.duration,t},_quartersToHM:function(e){var t=15*e,e=Math.floor(t/60),t=t%60;return(e=e<10?"0"+e:e)+":"+(t=t<10?"0"+t:t)},getStartTime:function(){return this._quartersToHM(this.start)},getEndTime:function(){var e=(this.start+this.duration)%g.EventDragDayLength;return this._quartersToHM(e)},clone:function(){var e=new a;return e.dayNumber=this.dayNumber,e.start=this.start,e.duration=this.duration,e}},d.prototype={originalCoordinates:null,currentCoordinates:null,originalViewCoordinates:null,currentViewCoordinates:null,originalEventCoordinates:null,currentEventCoordinates:null,originalCalendar:null,dragHasStarted:!1,getEventViewCoordinates:null,initFromBlock:function(e){this.currentEventCoordinates=new a(this.eventType),this.originalEventCoordinates=new a(this.eventType),this.originalEventCoordinates.initFromBlock(e)},initFromEvent:function(e){this.currentCoordinates=new c,this.updateFromEvent(e),this.originalCoordinates=this.currentCoordinates.clone()},initFromCalendar:function(e){this.originalCalendar=e,this.currentEventCoordinates.initFromCalendar(e.index),this.originalEventCoordinates.initFromCalendar(e.index)},updateFromEvent:function(e){var t,n,i,a;this.currentCoordinates.x=e.pageX,this.currentCoordinates.y=e.pageY,this.dragHasStarted&&f.$view?(a=this.getEventViewCoordinates(f.$view),this.originalViewCoordinates||(this.originalViewCoordinates=this.getEventViewCoordinates(f.$view,this.originalCoordinates),y.$ghost.component.isNew&&(this.setTimeFromQuarters(y.$ghost.component.start,this.originalViewCoordinates.y),p.debug("new event start date "+y.$ghost.component.start))),this.currentViewCoordinates&&a&&a.x==this.currentViewCoordinates.x&&a.y==this.currentViewCoordinates.y||(this.currentViewCoordinates=a,this.originalViewCoordinates&&(a||(this.currentViewCoordinates=this.originalViewCoordinates.clone()),this.updateEventCoordinates()))):this.originalCoordinates&&this.currentCoordinates&&!this.dragHasStarted&&3=g.EventDragDayLength&&(t=Math.floor(this.currentEventCoordinates.start/g.EventDragDayLength),this.currentEventCoordinates.start-=t*g.EventDragDayLength,this.currentEventCoordinates.dayNumber+=t),p.debug("event coordinates "+JSON.stringify(this.currentEventCoordinates)),u.$emit("calendar:drag")},getContainerBasedCoordinates:function(e,t){var n=(t||this.currentCoordinates).getDelta(e.coordinates),t=e.element;return n=n.xt.clientWidth||n.y<0||n.y>t.clientHeight?null:n},prepareWithEventType:function(e){var t={multiday:this.getEventMultiDayViewCoordinates,"multiday-allday":this.getEventMultiDayAllDayViewCoordinates,monthly:this.getEventMonthlyViewCoordinates,unknown:null}[e];this.eventType=e,this.getEventViewCoordinates=t},getEventMultiDayViewCoordinates:function(e,t){var n,i=this.getEventMultiDayAllDayViewCoordinates(e,t);return i&&(n=e.quarterHeight,(t=this.getContainerBasedCoordinates(e,t)).y+=e.element.scrollTop,i.y=Math.floor((t.y-g.EventDragHorizontalOffset)/n),n=g.EventDragDayLength-1,i.y<0?i.y=0:i.y>n&&(i.y=n)),i},getEventMultiDayAllDayViewCoordinates:function(e,t){var n,i=this.getContainerBasedCoordinates(e,t);return i?(n=new c,t=e.dayWidth,e=e.daysOffset,n.x=Math.floor((i.x-e)/t),i=0,e=f.$view.maxX,"move-event"==this.dragMode||(t=s.calendarData())&&(i=e=t.index),n.xe&&(n.x=e),n.y=0):n=null,n},getEventMonthlyViewCoordinates:function(e,t){var n,i,a,o=this.getContainerBasedCoordinates(e,t);return o?(n=new c,i=e.maxX,a=e.dayWidth,t=e.daysOffset,e=e.dayHeight,(e=Math.floor(+o.y/e))<0&&(e=0),n.x=Math.floor((o.x-t)/a),n.x<0?n.x=0:n.x>i&&(n.x=i),n.x+=(i+1)*e,n.y=0):n=null,n},getDistance:function(){return this.currentCoordinates.getDistance(this.originalCoordinates)},setTimeFromQuarters:function(e,t){var n=Math.floor(t/4);e.setHours(n,t%4*15)}}}}}e.$inject=["$rootScope","$timeout","$log","Preferences","Calendar","CalendarSettings","Component"],angular.module("SOGo.SchedulerUI").directive("sgDraggableCalendarBlock",e)}(),function(){function e(e,t,n){var i=this;this.$onInit=function(){e.$watch(function(){return i.component?{start:i.component.start,end:i.component.end,attendees:_.keys(i.component.$attendees.$futureFreebusyData)}:null},function(e,t){e&&e.attendees&&e.attendees.length&&n.all(_.values(i.component.$attendees.$futureFreebusyData)).then(function(){i.onUpdate()})},!0)},this.onUpdate=function(){}}e.$inject=["$scope","$element","$q"],angular.module("SOGo.SchedulerUI").directive("sgFreebusy",function(){return{restrict:"C",scope:{},bindToController:{component:"=sgComponent"},controller:e}})}(),function(){function e(e,t){var c=this;this.$postLink=function(){var a,o=[],r=[],s=[];this.parentController=e.parentController,a=this.parentController.onUpdate,_.forEach(t.find("div"),function(e){e.className.startsWith("hour")?o.push(e):e.className.startsWith("quarter")?r.push(e):e.className.startsWith("busy")&&s.push(e)}),this.parentController.onUpdate=function(){var e=c.attendee.uid?c.attendee.freebusy[c.day]:null;c.attendee.uid||_.forEach(o,function(e){e.classList.add("sg-no-freebusy")});for(var t=0;t<24;t++)for(var n=0;n<4;n++){var i=4*t+n;c.coversFreebusy(t,n)?r[i].classList.add("event"):r[i].classList.remove("event"),e&&e[t][n]?s[i].classList.remove("ng-hide"):s[i].classList.add("ng-hide")}angular.bind(c.parentController,a)()}},this.coversFreebusy=function(e,t){return c.attendees.coversFreeBusy(c.day,e,t)}}e.$inject=["$scope","$element"],angular.module("SOGo.SchedulerUI").directive("sgFreebusyDay",function(){return{restrict:"E",require:"^^sgFreebusy",bindToController:{day:"=sgDay",attendees:"=sgAttendees",attendee:"=sgAttendee"},replace:!0,template:function(e,t){for(var n=[""],i=0;i<24;i++){n.push('
');for(var a=0;a<4;a++)n.push('
'),n.push('
'),n.push("
");n.push("
")}return n.push(" \x3c!-- divider --\x3e"),n.push("
"),n.join("")},link:function(e,t,n,i){e.parentController=i},controller:e,controllerAs:"$ctrl"}})}(),function(){"use strict";function e(r,s,c){var l,d=this,u=s.controller("sgCalendarScrollView");r.nowDay=null,r.lineElement=null,r.updateLine=function(e){var t=new Date,n=t.getDayString(),i=t.getHours(),a=4*r.quarterHeight,o=t.getMinutes(),t=r.quarterHeight/15,t=parseInt(i*a+o*t-1);!e&&n==r.nowDay||(r.lineElement&&r.lineElement.remove(),r.lineElement=function(t,e){var n=angular.element("");u.isMultiColumn?e&&e[0].attributes["sg-day"].value==t&&s.append(n):_.forEach(e,function(e){e.attributes["sg-day"].value==t&&angular.element(e).find("div").eq(0).append(n)});return n}(n,r.days),r.nowDay=n);r.lineElement&&(r.lineElement.css("top",t+"px"),l=c(angular.bind(d,r.updateLine),6e4))},r.$on("$destroy",function(){l&&c.cancel(l)})}e.$inject=["$scope","$element","$timeout"],angular.module("SOGo.SchedulerUI").directive("sgNowLine",function(){return{restrict:"C",require:"^^sgCalendarScrollView",link:function(n,e,t,i){function a(){return e.find("sg-calendar-day")}var o=n.$watch(function(){return i.quarterHeight},function(e){var t;e&&(o(),n.quarterHeight=e,t=n.$watch(a,function(e){e.length&&(t(),n.days=e,n.updateLine())}))})},controller:e}})}(); //# sourceMappingURL=Scheduler.services.js.map