!function(){"use strict";function c(e){if(this.init(e),this.name&&!this.id){var t=c.$$resource.create("createFolder",this.name);this.$unwrap(t)}}c.$factory=["$q","$timeout","$log","sgSettings","Resource","Preferences","Component","Acl",function(e,t,n,a,o,i,r,s){return angular.extend(c,{$q:e,$timeout:t,$log:n,$$resource:new o(a.activeUser("folderURL")+"Calendar",a.activeUser()),$Preferences:i,$Component:r,$$Acl:s,activeUser:a.activeUser(),$view:null}),c}];try{angular.module("SOGo.SchedulerUI")}catch(e){angular.module("SOGo.SchedulerUI",["SOGo.Common"])}angular.module("SOGo.SchedulerUI").value("CalendarSettings",{EventDragDayLength:96,EventDragHorizontalOffset:3,ConflictHTTPErrorCode:409}).factory("Calendar",c.$factory),c.$defaultCalendar=function(){var e;return"first"==c.$Preferences.defaults.SOGoDefaultCalendar&&(e=_.find(c.$findAll(null,!0),function(e){return e.active}))?e.id:"personal"},c.$add=function(n){var e,t;e=n.isWebCalendar?this.$webcalendars:n.isSubscription?this.$subscriptions:this.$calendars,(t=_.findIndex(e,function(e,t){return"personal"==n.id||"personal"!=e.id&&0e&&this.attachUrls.splice(e,1)},p.prototype.$addDueDate=function(){this.due=new Date,this.due.setMinutes(15*Math.round(this.due.getMinutes()/15)),this.dueDate=this.due.toISOString()},p.prototype.$deleteDueDate=function(){delete this.due,delete this.dueDate},p.prototype.$addStartDate=function(){this.start=new Date,this.start.setMinutes(15*Math.round(this.start.getMinutes()/15))},p.prototype.$deleteStartDate=function(){delete this.start,delete this.startDate},p.prototype.$addRecurrenceDate=function(){var e=new Date;e.setMinutes(15*Math.round(e.getMinutes()/15)),angular.isUndefined(this.repeat.dates)&&(this.repeat={frequency:"custom",dates:[]}),this.repeat.dates.push(e)},p.prototype.$deleteRecurrenceDate=function(e){-1e&&this.repeat.dates.splice(e,1)},p.prototype.$reset=function(){var n=this;angular.forEach(this,function(e,t){"constructor"!=t&&"$"!=t[0]&&delete n[t]}),this.init(this.$shadowData),this.$shadowData=this.$omit()},p.prototype.$reply=function(){var e,t=this,n=[this.pid,encodeURIComponent(this.id)];return this.occurrenceId&&n.push(this.occurrenceId),e={reply:this.reply,delegatedTo:this.delegatedTo,alarm:this.$hasAlarm?this.alarm:{}},p.$$resource.save(n.join("/"),e,{action:"rsvpAppointment"}).then(function(e){return t.$shadowData=t.$omit(),e})},p.prototype.$adjust=function(e){var t=[this.pid,encodeURIComponent(this.id)];return _.every(_.values(e),function(e){return 0===e})?p.$q.when():(this.occurrenceId&&t.push(this.occurrenceId),p.$log.debug("adjust "+t.join("/")+" "+JSON.stringify(e)),p.$$resource.save(t.join("/"),e,{action:"adjust"}))},p.prototype.$save=function(e){var t,n,a,o,i=this;return a=this.$omit(),o=p.$Preferences.$mdDateLocaleProvider,a.startDate=a.start?a.start.format(o,"%Y-%m-%d"):"",a.startTime=a.start?a.start.format(o,"%H:%M"):"",a.endDate=a.end?a.end.format(o,"%Y-%m-%d"):"",a.endTime=a.end?a.end.format(o,"%H:%M"):"",a.dueDate=a.due?a.due.format(o,"%Y-%m-%d"):"",a.dueTime=a.due?a.due.format(o,"%H:%M"):"",a.completedDate=a.completed?a.completed.format(o,"%Y-%m-%d"):"",this.hasCustomRepeat()?"monthly"==this.repeat.frequency&&this.repeat.month.type&&"byday"==this.repeat.month.type&&"relative"!=this.repeat.month.day||"yearly"==this.repeat.frequency&&this.repeat.year.byday?(delete a.repeat.monthdays,a.repeat.days=[{day:this.repeat.month.day,occurrence:this.repeat.month.occurrence.toString()}]):"monthly"!=this.repeat.frequency&&"yearly"!=this.repeat.frequency||!this.repeat.month.type?"custom"==this.repeat.frequency&&this.repeat.dates&&_.forEach(a.repeat.dates,function(e,t,n){n[t]={date:e.format(o,"%Y-%m-%d"),time:e.format(o,"%H:%M")}}):(delete a.repeat.days,"relative"==this.repeat.month.day&&(a.repeat.monthdays=[this.repeat.month.occurrence])):this.repeat.frequency&&"never"!=this.repeat.frequency&&(a.repeat={frequency:this.repeat.frequency}),a.startDate&&this.repeat.frequency&&"never"!=this.repeat.frequency?"until"==this.repeat.end&&this.repeat.until?a.repeat.until=this.repeat.until.stringWithSeparator("-"):"count"==this.repeat.end&&this.repeat.count?a.repeat.count=this.repeat.count:(delete a.repeat.until,delete a.repeat.count):delete a.repeat,"not-specified"==this.status?delete a.status:"completed"!=this.status&&delete a.completedDate,a.startDate&&this.$hasAlarm?!this.alarm.action||"email"!=this.alarm.action||this.attendees&&0',' ',"

"+l("editRepeatingItem")+"

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

',' ',' 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){var n=_.has(t,"sgCalendarGhost")?"":"::";return['
','
",' {{ '+n+"block.component.startHour }}",' {{'+n+"block.component.c_priority}}"," {{ "+n+"block.component.summary }}",' ',' ',' ',' ',' '," ","
"].join("")},link:function(e,t,n){_.has(n,"sgCalendarGhost")||(e.block.userState&&t.addClass("sg-event--"+e.block.userState),e.block.component&&(t.addClass("bg-folder"+e.block.component.pid),0===e.block.component.c_isopaque&&t.addClass("sg-event--transparent"),0===e.block.component.c_status&&t.addClass("sg-event--cancelled")))}}})}(),function(){"use strict";function e(c,l,e,t,d,n,u,p,h){return{restrict:"A",scope:{type:"@sgCalendarScrollView"},controller:a,link:function(e,a,t,o){var i,r,n;function s(e,t){this.$element=e,this.element=e[0],this.type=t,this.quarterHeight=this.getQuarterHeight(),this.scrollStep=6*this.quarterHeight,this.dayNumbers=this.getDayNumbers(),this.maxX=this.getMaxColumns(),this.deregisterDragStart=c.$on("calendar:dragstart",angular.bind(this,this.onDragStart)),this.deregisterDragStop=c.$on("calendar:dragend",angular.bind(this,this.onDragEnd)),this.bindedUpdateCoordinates=angular.bind(this,this.updateCoordinates),this.bindedUpdateFromPointerHandler=angular.bind(this,this.updateFromPointerHandler),this.updateCoordinates(),angular.element(l).on("resize",this.bindedUpdateCoordinates)}i=null,r=e.type,n="multicolumndayview"==a.attr("sg-view"),o.isMultiColumn=n,d(function(){var e,t,n;i=new s(a,r),"monthly"!=r&&h.defaults.SOGoDayStartTime&&(e=h.defaults.SOGoDayStartTime.split(":"),t=document.getElementById("hour"+parseInt(e[0])),n=parseInt(e[1])*i.quarterHeight,i.element.scrollTop=t.offsetTop+n);o.quarterHeight=i.quarterHeight}),e.$on("$destroy",function(){i&&i.$destroy()}),s.prototype={$destroy:function(){this.deregisterDragStart(),this.deregisterDragStop(),this.$element.off("mousemove",this.bindedUpdateFromPointerHandler),angular.element(l).off("resize",this.bindedUpdateCoordinates)},onDragStart:function(){this.$element.on("mousemove",this.bindedUpdateFromPointerHandler),this.updateCoordinates(),this.updateFromPointerHandler()},onDragEnd:function(){this.$element.off("mousemove",this.bindedUpdateFromPointerHandler),u.$view=null},getQuarterHeight:function(){var e,t,n=null;return e=document.getElementById("hour0"),t=document.getElementById("hour23"),e&&t&&(n=(t.offsetTop-e.offsetTop)/92),n},getDayDimensions:function(e){var t,n,a,o,i,r,s;return n=t=a=o=0,0<(i=this.element.getElementsByClassName("day")).length&&(n=(r=i[0].getBoundingClientRect()).height,t=r.width,a=r.left-e,0<(s=i[0].getElementsByClassName("sg-calendar-tile-header")).length&&(o=s[0].clientHeight)),{height:n,width:t,offset:{left:a,top:o}}},getDayNumbers:function(){var e;return e=this.element.getElementsByTagName("sg-calendar-day"),_.map(e,function(e,t){return n?t:parseInt(e.attributes["sg-day-number"].value)})},getMaxColumns:function(){var e,t=0;return"monthly"==this.type?(e=this.element.getElementsByTagName("md-grid-list")[0],t=parseInt(e.attributes["md-cols"].value)-1):t=this.element.getElementsByClassName("day").length-1,t},updateCoordinates:function(){var e,t;e=this.element.getBoundingClientRect(),t=this.getDayDimensions(e.left),angular.extend(this,{coordinates:{x:e.left,y:e.top},dayHeight:t.height,dayWidth:t.width,daysOffset:t.offset.left,topOffset:t.offset.top})},updateFromPointerHandler:function(){var e,t,n,a,o,i;e=p.$ghost.pointerHandler,this.coordinates&&e&&(t=e.getContainerBasedCoordinates(this))&&(u.$view=this,n=(new Date).getTime(),(!this.lastScroll||n>this.lastScroll+100)&&(this.lastScroll=n,(a=t.y-this.scrollStep)<0?(a<(o=-this.element.scrollTop)&&(a=o),this.element.scrollTop+=a):0<(i=(a=t.y+this.scrollStep)-this.element.clientHeight)&&(this.element.scrollTop+=i)))}}}}}function a(e){this.type=e.type}e.$inject=["$rootScope","$window","$document","$q","$timeout","$mdGesture","Calendar","Component","Preferences"],a.$inject=["$scope"],angular.module("SOGo.SchedulerUI").directive("sgCalendarScrollView",e)}(),function(){"use strict";angular.module("SOGo.SchedulerUI").directive("sgCategoryStylesheet",function(){return{restrict:"E",require:"ngModel",scope:{ngModel:"="},replace:!0,template:['"].join("")}})}(),function(){"use strict";function e(m,a,f,g,y,c,v){return{restrict:"CA",require:"^sgCalendarDay",link:function(u,p,e,h){if(u.block){if(!u.block.component.editable||u.block.userState)return void p.removeClass("sg-draggable-calendar-block");!function(){var e,t,n,a,o,i,r,s,c,l;if(u.block.length<3)return;e=u.block.component,t=u.block.dayIndex,n=_.findIndex(e.blocks,["dayIndex",t]),a=0===n,o=n===e.blocks.length-1,(i=angular.element('
')).addClass("bdr-folder"+e.pid),e.c_isallday||"SG-CALENDAR-MONTH-DAY"===p[0].parentNode.tagName?(a&&(r=angular.element('
').append(i),p.append(r)),o&&(s=angular.element('
').append(i.clone()),p.append(s))):(a&&(c=angular.element('
').append(i),p.append(c)),o&&(l=angular.element('
').append(i.clone()),p.append(l)))}()}function t(e){var t,n,a,o;e.stopPropagation(),e.target.scrollHeight>e.target.clientHeight+1&&(a=e.target.getBoundingClientRect(),o=a.left+a.width-18,e.pageX>o)||(t="move-event",u.block&&u.block.component?"dragGrip-top"==e.target.className||"dragGrip-left"==e.target.className?t="change-start":"dragGrip-bottom"!=e.target.className&&"dragGrip-right"!=e.target.className||(t="change-end"):t="change-end",(n=new s(t)).initFromEvent(e),v.$ghost.pointerHandler=n,angular.element(document).one("mouseup",r),angular.element(document).on("mousemove",i))}function i(e){var t=v.$ghost.pointerHandler;a(function(){t.updateFromEvent(e)})}function r(e){var t,n;t=u.block,n=v.$ghost.pointerHandler,angular.element(document).off("mousemove",i),n.dragHasStarted&&(m.$emit("calendar:dragend"),n.dragHasStarted=!1),t&&t.component&&_.forEach(t.component.blocks,function(e){e.dragging=!1})}function d(){}function n(e){this.setEventType(e)}function s(e){this.dragMode=e}p.on("mousedown",t),u.$on("$destroy",function(){p.off("mousedown",t),p.off("mousemove",i)}),d.prototype={x:-1,y:-1,getDelta:function(e){var t=new d;return t.x=this.x-e.x,t.y=this.y-e.y,y.$view&&(t.days=y.$view.dayNumbers[this.x]-y.$view.dayNumbers[e.x]),t},getDistance:function(e){var t=this.getDelta(e);return Math.sqrt(t.x*t.x+t.y*t.y)},clone:function(){var e=new d;return e.x=this.x,e.y=this.y,e}},n.prototype={dayNumber:-1,weekDay:-1,start:-1,duration:-1,eventType:null,setEventType:function(e){this.eventType=e},initFromBlock:function(e){var a=-1;"monthly"===this.eventType?(this.start=0,this.duration=e.component.blocks.length*c.EventDragDayLength):(this.start=e.component.blocks[0].start,this.duration=_.sumBy(e.component.blocks,function(e){var t,n;return n=e.dayNumber,t=a<0?0:n-a-1,a=n,e.length+t*c.EventDragDayLength}))},initFromCalendar:function(e){this.dayNumber=e},getDelta:function(e){var t=new n;return t.dayNumber=this.dayNumber-e.dayNumber,t.start=this.start-e.start,t.duration=this.duration-e.duration,t},_quartersToHM:function(e){var t=15*e,n=Math.floor(t/60);n<10&&(n="0"+n);var a=t%60;return a<10&&(a="0"+a),n+":"+a},getStartTime:function(){return this._quartersToHM(this.start)},getEndTime:function(){var e=(this.start+this.duration)%c.EventDragDayLength;return this._quartersToHM(e)},clone:function(){var e=new n;return e.dayNumber=this.dayNumber,e.start=this.start,e.duration=this.duration,e}},s.prototype={originalCoordinates:null,currentCoordinates:null,originalViewCoordinates:null,currentViewCoordinates:null,originalEventCoordinates:null,currentEventCoordinates:null,originalCalendar:null,dragHasStarted:!1,getEventViewCoordinates:null,initFromBlock:function(e){this.currentEventCoordinates=new n(this.eventType),this.originalEventCoordinates=new n(this.eventType),this.originalEventCoordinates.initFromBlock(e)},initFromEvent:function(e){this.currentCoordinates=new d,this.updateFromEvent(e),this.originalCoordinates=this.currentCoordinates.clone()},initFromCalendar:function(e){this.originalCalendar=e,this.currentEventCoordinates.initFromCalendar(e.index),this.originalEventCoordinates.initFromCalendar(e.index)},updateFromEvent:function(e){if(this.currentCoordinates.x=e.pageX,this.currentCoordinates.y=e.pageY,this.dragHasStarted&&y.$view){var t=this.getEventViewCoordinates(y.$view);this.originalViewCoordinates||(this.originalViewCoordinates=this.getEventViewCoordinates(y.$view,this.originalCoordinates),v.$ghost.component.isNew&&(this.setTimeFromQuarters(v.$ghost.component.start,this.originalViewCoordinates.y),f.debug("new event start date "+v.$ghost.component.start))),this.currentViewCoordinates&&t&&t.x==this.currentViewCoordinates.x&&t.y==this.currentViewCoordinates.y||(this.currentViewCoordinates=t,this.originalViewCoordinates&&(t||(this.currentViewCoordinates=this.originalViewCoordinates.clone()),this.updateEventCoordinates()))}else if(this.originalCoordinates&&this.currentCoordinates&&!this.dragHasStarted){var n=this.getDistance();3=c.EventDragDayLength&&(t=Math.floor(this.currentEventCoordinates.start/c.EventDragDayLength),this.currentEventCoordinates.start-=t*c.EventDragDayLength,this.currentEventCoordinates.dayNumber+=t),f.debug("event coordinates "+JSON.stringify(this.currentEventCoordinates)),m.$emit("calendar:drag")},getContainerBasedCoordinates:function(e,t){var n=t||this.currentCoordinates,a=n.getDelta(e.coordinates),o=e.element;return(a.xo.clientWidth||a.y<0||a.y>o.clientHeight)&&(a=null),a},prepareWithEventType:function(e){var t={multiday:this.getEventMultiDayViewCoordinates,"multiday-allday":this.getEventMultiDayAllDayViewCoordinates,monthly:this.getEventMonthlyViewCoordinates,unknown:null},n=t[e];this.eventType=e,this.getEventViewCoordinates=n},getEventMultiDayViewCoordinates:function(e,t){var n=this.getEventMultiDayAllDayViewCoordinates(e,t);if(n){var a=e.quarterHeight,o=this.getContainerBasedCoordinates(e,t);o.y+=e.element.scrollTop,n.y=Math.floor((o.y-c.EventDragHorizontalOffset)/a);var i=c.EventDragDayLength-1;n.y<0?n.y=0:n.y>i&&(n.y=i)}return n},getEventMultiDayAllDayViewCoordinates:function(e,t){var n,a=this.getContainerBasedCoordinates(e,t);if(a){n=new d;var o=e.dayWidth,i=e.daysOffset;n.x=Math.floor((a.x-i)/o);var r=0,s=y.$view.maxX;if("move-event"!=this.dragMode){var c=h.calendarData();c&&(r=s=c.index)}n.xs&&(n.x=s),n.y=0}else n=null;return n},getEventMonthlyViewCoordinates:function(e,t){var n,a=this.getContainerBasedCoordinates(e,t);if(a){n=new d;var o=e.maxX,i=e.dayWidth,r=e.daysOffset,s=e.dayHeight,c=Math.floor((a.y-0)/s);c<0&&(c=0),n.x=Math.floor((a.x-r)/i),n.x<0?n.x=0:n.x>o&&(n.x=o),n.x+=(o+1)*c,n.y=0}else n=null;return n},getDistance:function(){return this.currentCoordinates.getDistance(this.originalCoordinates)},setTimeFromQuarters:function(e,t){var n,a;n=Math.floor(t/4),a=t%4*15,e.setHours(n,a)}}}}}e.$inject=["$rootScope","$timeout","$log","Preferences","Calendar","CalendarSettings","Component"],angular.module("SOGo.SchedulerUI").directive("sgDraggableCalendarBlock",e)}(),function(){"use strict";function e(c,l,d){var u,p=this,h=l.controller("sgCalendarScrollView");c.nowDay=null,c.lineElement=null,c.updateLine=function(e){var t=new Date,n=t.getDayString(),a=t.getHours(),o=4*c.quarterHeight,i=t.getMinutes(),r=c.quarterHeight/15,s=parseInt(a*o+i*r-1);(e||n!=c.nowDay)&&(c.lineElement&&c.lineElement.remove(),c.lineElement=function(t,e){var n=angular.element("");h.isMultiColumn?e&&e[0].attributes["sg-day"].value==t&&l.append(n):_.forEach(e,function(e){e.attributes["sg-day"].value==t&&angular.element(e).find("div").eq(0).append(n)});return n}(n,c.days),c.nowDay=n);c.lineElement&&(c.lineElement.css("top",s+"px"),u=d(angular.bind(p,c.updateLine),6e4))},c.$on("$destroy",function(){u&&d.cancel(u)})}e.$inject=["$scope","$element","$timeout"],angular.module("SOGo.SchedulerUI").directive("sgNowLine",function(){return{restrict:"C",require:"^^sgCalendarScrollView",link:function(n,e,t,a){function o(){return e.find("sg-calendar-day")}var i=n.$watch(function(){return a.quarterHeight},function(e){if(e){i(),n.quarterHeight=e;var t=n.$watch(o,function(e){e.length&&(t(),n.days=e,n.updateLine())})}})},controller:e}})}(); //# sourceMappingURL=Scheduler.services.js.map