sogo/UI/WebServerResources/js/Scheduler.services.js.map
2017-03-02 01:27:34 -05:00

1 line
247 KiB
Plaintext

{"version":3,"sources":["Scheduler/Calendar.service.js","Scheduler/Component.service.js","Scheduler/CalendarController.js","Scheduler/CalendarListController.js","Scheduler/CalendarsController.js","Scheduler/ComponentController.js","Scheduler/sgCalendarDay.directive.js","Scheduler/sgCalendarDayBlock.directive.js","Scheduler/sgCalendarDayTable.directive.js","Scheduler/sgCalendarGhost.directive.js","Scheduler/sgCalendarMonthDay.directive.js","Scheduler/sgCalendarMonthEvent.directive.js","Scheduler/sgCalendarScrollView.directive.js","Scheduler/sgCategoryStylesheet.directive.js","Scheduler/sgDraggableCalendarBlock.directive.js","Scheduler/sgNowLine.directive.js"],"names":["Calendar","futureCalendarData","this","init","name","id","newCalendarData","$$resource","create","$unwrap","$factory","$q","$timeout","$log","Settings","Resource","Preferences","Component","Acl","angular","extend","activeUser","$Preferences","$Component","$$Acl","$view","module","e","value","EventDragDayLength","EventDragHorizontalOffset","ConflictHTTPErrorCode","factory","$defaultCalendar","calendar","defaultCalendar","defaults","SOGoDefaultCalendar","_","find","$findAll","active","$add","list","sibling","isWebCalendar","$webcalendars","isSubscription","$subscriptions","$calendars","findIndex","o","i","localeCompare","push","splice","ready","then","settings","FoldersOrder","saveFoldersOrder","flatMap","$reloadAll","data","writable","_this","forEach","isUndefined","fetch","calendars","union","filter","isOwned","acls","objectCreator","calendarData","group","owner","login","$get","$getIndex","indexOf","map","$subscribe","uid","path","userResource","$addWebCalendar","url","d","defer","urls","webCalendarURL","reject","post","isEditable","isRemote","debug","JSON","stringify","undefined","resolve","response","status","promise","reloadWebCalendars","promises","$error","l","statusText","all","$deleteComponents","components","component","isDefined","pid","uids","saveFoldersActivation","ids","request","folders","prototype","color","$acl","isSuperUser","$shadowData","$omit","$id","when","$futureCalendarData","getClassName","base","$rename","$save","$delete","remove","$reset","key","save","error","setCredentials","username","password","export","options","type","filename","download","$setActivation","$getComponent","componentId","recurrenceId","$find","isError","isObject","futureComponentData","newComponentData","newguid","isNew","$rootScope","Component_STATUS","Card","Gravatar","STATUS","$Card","$gravatar","timeFormat","$query","search","$queryEvents","sort","asc","filterpopup","$queryTasks","$refreshTimeout","$ghost","EventsFilterState","TasksFilterState","EventsSortingState","parseInt","TasksSortingState","show_completed","ShowCompletedTasks","$categories","SOGoCalendarCategoriesColors","SOGoTimeFormat","constant","NOT_LOADED","DELAYED_LOADING","LOADING","LOADED","DELAYED_MS","$selectedCount","count","$events","event","selected","length","$tasks","task","$startRefreshTimeout","cancel","refreshViewCheck","SOGoRefreshViewCheck","f","bind","$emit","timeInterval","$isLoading","$loaded","$filter","now","Date","day","getDate","month","getMonth","year","getFullYear","queryKey","capitalize","params","otherType","dirty","keys","$unwrapCollection","calendarId","occurrenceId","join","filterCategories","query","re","RegExp","category","saveSelectedList","componentType","$eventsBlocksForView","view","date","firstDayOfWeek","viewAction","startDate","endDate","SOGoFirstDayOfWeek","beginOfWeek","setTime","getTime","addDays","setDate","setMonth","endOfWeek","$eventsBlocks","j","dayDates","dayNumbers","deferred","toLowerCase","sd","getDayString","ed","views","reduceComponent","associateComponent","objects","eventData","componentData","zipObject","eventsFields","start","c_startdate","hour","getHourString","blocks","categories","block","nbr","isFirst","$views","viewIndex","viewData","allDayBlocks","reduce","events","flatten","days","dayIndex","dayNumber","calendarName","fields","invokeMap","$resetGhost","pointerHandler","startHour","endHour","$parseDate","dateString","time","substring","split","no_time","repeat","alarm","action","quantity","unit","reference","relation","delta","isString","setMinutes","Math","round","getMinutes","end","minutesTo","setDelta","dueDate","due","completedDate","completed","c_category","$isRecurrent","byDayMask","occurrence","frequency","byday","toString","interval","monthdays","months","until","$hasCustomRepeat","hasCustomRepeat","classification","units","M","H","D","W","match","exec","SOGoCalendarDefaultReminder","$hasAlarm","sendAppointmentNotifications","SOGoAppointmentSendEMailNotifications","destinationCalendar","attendees","attendee","image","email","updateFreeBusy","isReadOnly","isEditableOccurrence","isInvitation","userHasRSVP","isInvitationOccurrence","enablePercentComplete","coversFreeBusy","quarter","freebusy","updateFreeBusyCoverage","roundedStart","roundedEnd","startQuarter","endQuarter","daysUpTo","index","hourKey","currentDay","dayKey","getHours","beginOfDay","addMinutes","updateFreeBusyAttendee","resource","domain","sday","eday","isMSExchange","c_folder","addAttendee","card","$isList","expandable","container","c_name","listId","refs","ref","c_cn","$preferredEmail","role","partstat","c_uid","$avatarIcon","c_domain","ismsexchange","hasAttendee","emails","deleteAttendee","currentAttendee","canRemindAttendeesByEmail","addAttachUrl","attachUrl","attachUrls","deleteAttachUrl","$addDueDate","toISOString","$deleteDueDate","$addStartDate","$deleteStartDate","$reply","reply","delegatedTo","$adjust","every","values","v","extraAttributes","dlp","$mdDateLocaleProvider","format","startTime","endTime","dueTime","stringWithSeparator","organizer","occurrenceOnly","$futureComponentData","copy","repeatDescription","localizedString","toUpperCase","alarmDescription","copyTo","destination","moveTo","CalendarController","$scope","$state","$stateParams","sgHotkeys","stateEventsBlocks","_registerHotkeys","createHotkey","description","callback","changeDate","args","changeView","_goToPeriod","registerHotkey","$event","direction","vm","selectedDate","_formatDate","setHours","$dateFormat","replace","toggleAllDays","expandedAllDays","updateView","asDate","newDate","element","currentTarget","attr","go","deregisterCalendarsList","hotkeys","$on","deregisterHotkey","$inject","controller","CalendarListController","$mdDialog","focus","Dialog","CalendarSettings","Alarm","searchMode","newComponent","selectComponentType","reload","unselectComponents","mode","multiple","selectAll","toggleComponentSelection","preventDefault","stopPropagation","confirmDeleteSelectedComponents","confirm","ok","openEvent","openComponent","openTask","viewable","templateUrl","show","parent","document","body","targetEvent","clickOutsideToClose","escapeToClose","controllerAs","locals","stateComponent","baseComponent","updateComponentFromGhost","RecurrentComponentDialogController","updateThisOccurrence","hide","onComponentAdjustError","updateAllOccurrences","message","AttendeeConflictDialogController","conflictError","ignoreConflicts","coordinates","calendarNumber","activeCalendars","currentEventCoordinates","summary","isAllDay","duration","finally","getDelta","originalEventCoordinates","originalCalendar","isException","getAlarms","template","filteredBy","field","sortedBy","cancelSearch","selectedList","SelectedList","CalendarsController","$window","$mdToast","FileUploader","User","stateCalendars","_sortableAccept","sourceItemHandleScope","destSortableScope","destItemScope","sortableScope","_sortableEnd","toggleSortableMode","sortableMode","resetSort","newCalendar","ev","prompt","UserLogin","addWebCalendar","WebCalendarAuthDialogController","scope","parts","hostname","title","formatted","authenticate","form","$valid","required","reason","$setValidity","inputType","confirmDelete","folder","catch","alert","importCalendar","CalendarImportDialogController","filterByExtension","item","isTextFile","test","position","hideDelay","uploader","ApplicationBaseURL","autoUpload","queueLimit","filters","fn","onSuccessItem","headers","msg","imported","simple","content","onErrorItem","close","showOnly","showAll","showLinks","LinksDialogController","showProperties","PropertiesDialogController","srcCalendar","saveProperties","$watch","editFolder","editMode","revertEditing","renameFolder","share","$users","usersWithACL","users","subscribeToFolder","service","sortableCalendars","scrollableContainer","containment","orderChanged","accept","SOGoCalendarCategories","asCSSIdentifier","pick","newList","oldList","commonList","intersectionBy","oldObject","isEqual","ComponentController","AddressBook","Account","cardFilter","$filterAll","newMessageWithAllRecipients","_newMessage","newMessageWithRecipient","recipients","accounts","account","$getMailboxes","mailboxes","$newMessage","editable","to","subject","stateAccount","stateMessage","edit","editAllOccurrences","replyAllOccurrences","deleteOccurrence","deleteAllOccurrences","toggleRawSource","ComponentRawSourceDialogController","copySelectedComponent","moveSelectedComponent","calendarService","ComponentEditorController","toggleRecurrenceEditor","showRecurrenceEditor","toggleAttendeesEditor","showAttendeesEditor","recurrenceMonthDaysAreRequired","$cards","isValidEmail","searchText","removeAttendee","$setDirty","priorityLevel","priority","attendeeConflictError","reset","$setPristine","getDays","hours","addStartDate","oldStartDate","addDueDate","oldDueDate","adjustStartTime","valueOf","oldEndDate","adjustEndTime","adjustDueTime","attendeesEditor","sgCalendarDay","restrict","dayString","sgCalendarDayController","directive","sgCalendarDayBlock","tElem","tAttrs","p","has","link","iElement","attrs","pc","left","right","siblings","css","c_isallday","addClass","userState","c_isopaque","c_status","clickBlock","sgCalendarDayTable","sgCalendarGhost","ctrls","initGhost","calendarDayCtrl","originalCalendarNumber","hideGhost","forEachRight","domElement","classList","c","removeClass","updateGhost","showGhost","isRelative","durationLeft","maxDuration","scrollViewCtrl","getStartTime","quarterHeight","topOffset","getEndTime","quartersToHM","quarters","minutes","mins","floor","deregisterDragStart","deregisterDrag","deregisterDragEnd","require","sgCalendarMonthDay","sgCalendarMonthEvent","sgCalendarScrollView","$document","$mdGesture","sgCalendarScrollViewController","initView","sgScrollView","hourCell","quartersOffset","SOGoDayStartTime","getElementById","scrollTop","offsetTop","$element","getQuarterHeight","scrollStep","getDayNumbers","maxX","getMaxColumns","onDragStart","deregisterDragStop","onDragEnd","bindedUpdateCoordinates","updateCoordinates","bindedUpdateFromPointerHandler","updateFromPointerHandler","on","isMultiColumn","$destroy","off","hour0","hour23","height","getDayDimensions","viewLeft","width","leftOffset","nodes","domRect","tileHeader","getElementsByClassName","getBoundingClientRect","clientHeight","offset","top","getElementsByTagName","el","attributes","mdGridList","max","dayDimensions","x","y","dayHeight","dayWidth","daysOffset","pointerCoordinates","scrollY","minY","getContainerBasedCoordinates","lastScroll","sgCategoryStylesheet","ngModel","sgDraggableCalendarBlock","initGrips","blockIndex","isFirstBlock","isLastBlock","dragGrip","leftGrip","rightGrip","topGrip","bottomGrip","parentNode","tagName","append","clone","onDragDetect","dragMode","hasVerticalScrollbar","rect","target","scrollHeight","scrollableZone","pageX","className","SOGoEventDragPointerHandler","initFromEvent","one","onDrag","dragStart","eventType","isHourCell","isMonthly","newData","hasClass","parseDate","b","dragging","prepareWithEventType","initFromBlock","initFromCalendar","updateFromEvent","pointer","dragHasStarted","SOGoCoordinates","SOGoEventDragEventCoordinates","setEventType","otherCoordinates","getDistance","sqrt","weekDay","prevDayNumber","sumBy","currentDayNumber","_quartersToHM","originalCoordinates","currentCoordinates","originalViewCoordinates","currentViewCoordinates","getEventViewCoordinates","pageY","newEventCoordinates","setTimeFromQuarters","updateEventCoordinates","distance","newDuration","deltaQuarters","deltaDays","ceil","clientWidth","methods","multiday","getEventMultiDayViewCoordinates","multiday-allday","getEventMultiDayAllDayViewCoordinates","monthly","getEventMonthlyViewCoordinates","unknown","method","pxCoordinates","maxY","minX","daysY","sgNowLine","iAttr","sgCalendarScrollViewCtrl","_getDays","_getView","_unwatchView","_unwatchDays","updateLine","sgNowLineController","_updateLine","force","nowDay","hourHeight","minuteHeight","lineElement","_addLine","updater","$lineElement","dayElement","eq"],"mappings":"CAEA,WACE,YAOA,SAASA,GAASC,GAGhB,GADAC,KAAKC,KAAKF,GACNC,KAAKE,OAASF,KAAKG,GAAI,CAEzB,GAAIC,GAAkBN,EAASO,WAAWC,OAAO,eAAgBN,KAAKE,KACtEF,MAAKO,QAAQH,IASjBN,EAASU,UAAY,KAAM,WAAY,OAAQ,aAAc,WAAY,cAAe,YAAa,MAAO,SAASC,EAAIC,EAAUC,EAAMC,EAAUC,EAAUC,EAAaC,EAAWC,GAanL,MAZAC,SAAQC,OAAOpB,GACbW,GAAIA,EACJC,SAAUA,EACVC,KAAMA,EACNN,WAAY,GAAIQ,GAASD,EAASO,WAAW,aAAe,WAAYP,EAASO,cACjFC,aAAcN,EACdO,WAAYN,EACZO,MAAON,EACPG,WAAYP,EAASO,aACrBI,MAAO,OAGFzB,GAOT,KACEmB,QAAQO,OAAO,oBAEjB,MAAMC,GACJR,QAAQO,OAAO,oBAAqB,gBAEtCP,QAAQO,OAAO,oBACZE,MAAM,oBACLC,mBAA6B,GAC7BC,0BAA6B,EAC7BC,sBAA6B,MAE9BC,QAAQ,WAAYhC,EAASU,UAOhCV,EAASiC,iBAAmB,WAC1B,GACIC,GADAC,EAAkBnC,EAASsB,aAAac,SAASC,mBAGrD,OAAuB,SAAnBF,IACFD,EAAWI,EAAEC,KAAKvC,EAASwC,SAAS,MAAM,GAAO,SAASN,GACxD,MAAOA,GAASO,UAGTP,EAAS7B,GAGb,YAQTL,EAAS0C,KAAO,SAASR,GAEvB,GAAIS,GAAMC,CAGRD,GADET,E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,EAAWnH,WAAW,UAAU7vB,OAASy2B,GAC3Cl3B,QAAQ8b,QAAQ2b,GAAYr2B,KAAK,OAAOs2B,GAAG,GAAGxF,OAAOsF,KAIpDA,EAtDT,GAAkBD,GAAdz0B,EAAQ/D,KACRytB,EAAiB4B,EAAS7R,WAAW,uBAEzCpC,GAAO+c,OAAS,KAChB/c,EAAOkd,YAAc,KACrBld,EAAO2c,WAAaE,EAEpB7c,EAAOiC,IAAI,WAAY,WACjBmb,GACF93B,EAAS6L,OAAOisB,KAXtBR,EAAoBza,SAAW,SAAU,WAAY,YA4DrDtc,QACGO,OAAO,oBACP4pB,UAAU,YAAaoM","file":"Scheduler.services.js","sourcesContent":["/* -*- Mode: javascript; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n\n(function() {\n 'use strict';\n\n /**\n * @name Calendar\n * @constructor\n * @param {object} futureCalendarData - either an object literal or a promise\n */\n function Calendar(futureCalendarData) {\n // Data is immediately available\n this.init(futureCalendarData);\n if (this.name && !this.id) {\n // Create a new calendar on the server\n var newCalendarData = Calendar.$$resource.create('createFolder', this.name);\n this.$unwrap(newCalendarData);\n }\n }\n\n /**\n * @memberof Calendar\n * @desc The factory we'll use to register with Angular\n * @returns the Calendar constructor\n */\n Calendar.$factory = ['$q', '$timeout', '$log', 'sgSettings', 'Resource', 'Preferences', 'Component', 'Acl', function($q, $timeout, $log, Settings, Resource, Preferences, Component, Acl) {\n angular.extend(Calendar, {\n $q: $q,\n $timeout: $timeout,\n $log: $log,\n $$resource: new Resource(Settings.activeUser('folderURL') + 'Calendar', Settings.activeUser()),\n $Preferences: Preferences,\n $Component: Component,\n $$Acl: Acl,\n activeUser: Settings.activeUser(),\n $view: null\n });\n\n return Calendar; // return constructor\n }];\n\n /**\n * @module SOGo.SchedulerUI\n * @desc Factory registration of Calendar in Angular module.\n */\n try {\n angular.module('SOGo.SchedulerUI');\n }\n catch(e) {\n angular.module('SOGo.SchedulerUI', ['SOGo.Common']);\n }\n angular.module('SOGo.SchedulerUI')\n .value('CalendarSettings', {\n EventDragDayLength: 24 * 4, // hour quarters\n EventDragHorizontalOffset: 3, // pixels\n ConflictHTTPErrorCode: 409\n })\n .factory('Calendar', Calendar.$factory);\n\n /**\n * @memberof Calendar\n * @desc Return the default calendar id according to the user's defaults.\n * @returns a calendar id\n */\n Calendar.$defaultCalendar = function() {\n var defaultCalendar = Calendar.$Preferences.defaults.SOGoDefaultCalendar,\n calendar;\n\n if (defaultCalendar == 'first') {\n calendar = _.find(Calendar.$findAll(null, true), function(calendar) {\n return calendar.active;\n });\n if (calendar)\n return calendar.id;\n }\n\n return 'personal';\n };\n\n /**\n * @memberof Calendar\n * @desc Add a new calendar to the static list of calendars\n * @param {Calendar} calendar - an Calendar object instance\n */\n Calendar.$add = function(calendar) {\n // Insert new calendar at proper index\n var list, sibling;\n\n if (calendar.isWebCalendar)\n list = this.$webcalendars;\n else if (calendar.isSubscription)\n list = this.$subscriptions;\n else\n list = this.$calendars;\n\n sibling = _.findIndex(list, function(o, i) {\n return (calendar.id == 'personal' ||\n (o.id != 'personal' && o.name.localeCompare(calendar.name) > 0));\n });\n if (sibling < 0)\n list.push(calendar);\n else\n list.splice(sibling, 0, calendar);\n\n this.$Preferences.ready().then(function() {\n if (Calendar.$Preferences.settings.Calendar.FoldersOrder)\n // Save list order\n Calendar.saveFoldersOrder(_.flatMap(Calendar.$findAll(), 'id'));\n });\n // Refresh list of calendars to fetch links associated to new calendar\n Calendar.$reloadAll();\n };\n\n /**\n * @memberof Calendar\n * @desc Set or get the list of calendars. Will instanciate a new Calendar object for each item.\n * @param {object[]} [data] - the metadata of the calendars\n * @param {bool} [writable] - if true, returns only the list of writable calendars\n * @returns the list of calendars\n */\n Calendar.$findAll = function(data, writable) {\n var _this = this;\n if (data) {\n this.$calendars = [];\n this.$subscriptions = [];\n this.$webcalendars = [];\n // Instanciate Calendar objects\n angular.forEach(data, function(o, i) {\n var calendar = new Calendar(o);\n if (calendar.isWebCalendar)\n _this.$webcalendars.push(calendar);\n else if (calendar.isSubscription)\n _this.$subscriptions.push(calendar);\n else\n _this.$calendars.push(calendar);\n });\n }\n else if (angular.isUndefined(this.$calendars)) {\n this.$calendars = [];\n this.$subscriptions = [];\n this.$webcalendars = [];\n return Calendar.$$resource.fetch('calendarslist').then(function(data) {\n return Calendar.$findAll(data.calendars, writable);\n });\n }\n\n if (writable) {\n return _.union(this.$calendars, _.filter(this.$subscriptions, function(calendar) {\n return calendar.isOwned || calendar.acls.objectCreator;\n }));\n }\n\n return _.union(this.$calendars, this.$subscriptions, this.$webcalendars);\n };\n\n /**\n * @memberof Calendar\n * @desc Reload the list of known calendars.\n */\n Calendar.$reloadAll = function() {\n var _this = this;\n\n Calendar.$$resource.fetch('calendarslist').then(function(data) {\n _.forEach(data.calendars, function(calendarData) {\n var group, calendar;\n\n if (calendarData.isWebCalendar)\n group = _this.$webcalendars;\n else if (calendarData.owner != Calendar.activeUser.login)\n group = _this.$subscriptions;\n else\n group = _this.$calendars;\n\n calendar = _.find(group, function(o) { return o.id == calendarData.id; });\n if (calendar)\n calendar.init(calendarData);\n });\n });\n };\n\n /**\n * @memberof Calendar\n * @desc Find a calendar among local instances (personal calendars, subscriptions and Web calendars).\n * @param {string} id - the calendar ID\n * @returns an object literal of the matching Calendar instance\n */\n Calendar.$get = function(id) {\n var calendar;\n\n calendar = _.find(Calendar.$calendars, function(o) { return o.id == id; });\n if (!calendar)\n calendar = _.find(Calendar.$subscriptions, function(o) { return o.id == id; });\n if (!calendar)\n calendar = _.find(Calendar.$webcalendars, function(o) { return o.id == id; });\n\n return calendar;\n };\n\n /**\n * @memberof Calendar\n * @desc Find a calendar among local instances (personal calendars, subscriptions and Web calendars).\n * @param {string} id - the calendar ID\n * @returns an object literal of the matching Calendar instance\n */\n Calendar.$getIndex = function(id) {\n var i;\n\n i = _.indexOf(_.map(Calendar.$calendars, 'id'), id);\n if (i < 0)\n i = _.indexOf(_.map(Calendar.$subscriptions, 'id'), id);\n if (i < 0)\n i = _.indexOf(_.map(Calendar.$webcalendars, 'id'), id);\n\n return i;\n };\n\n /**\n * @memberOf Calendar\n * @desc Subscribe to another user's calendar and add it to the list of calendars.\n * @param {string} uid - user id\n * @param {string} path - path of folder for specified user\n * @returns a promise of the HTTP query result\n */\n Calendar.$subscribe = function(uid, path) {\n var _this = this;\n return Calendar.$$resource.userResource(uid).fetch(path, 'subscribe').then(function(calendarData) {\n var calendar = new Calendar(angular.extend({ active: 1 }, calendarData));\n if (!_.find(_this.$subscriptions, function(o) {\n return o.id == calendarData.id;\n })) {\n Calendar.$add(calendar);\n }\n return calendar;\n });\n };\n\n /**\n * @memberOf Calendar\n * @desc Subscribe to a remote Web calendar\n * @param {string} url - URL of .ics file\n * @returns a promise of the HTTP query result\n */\n Calendar.$addWebCalendar = function(url) {\n var _this = this,\n d = Calendar.$q.defer();\n\n if (_.find(_this.$webcalendars, function(o) {\n return o.urls.webCalendarURL == url;\n })) {\n // Already subscribed\n d.reject();\n }\n else {\n Calendar.$$resource.post(null, 'addWebCalendar', { url: url }).then(function(calendarData) {\n angular.extend(calendarData, {\n isWebCalendar: true,\n isEditable: true,\n isRemote: false,\n owner: Calendar.activeUser.login,\n urls: { webCalendarURL: url }\n });\n var calendar = new Calendar(calendarData);\n Calendar.$$resource.fetch(calendar.id, 'reload').then(function(data) {\n // TODO: show a toast of the reload status\n Calendar.$log.debug(JSON.stringify(data, undefined, 2));\n Calendar.$add(calendar);\n d.resolve();\n }, function(response) {\n if (response.status == 401) {\n // Web calendar requires authentication\n d.resolve(calendar);\n }\n else {\n d.reject();\n }\n });\n }, d.reject);\n }\n\n return d.promise;\n };\n\n /**\n * @function reloadWebCalendars\n * @memberof Calendar\n * @desc Reload all Web calendars\n * @return a promise combining the results of all HTTP operations\n */\n Calendar.reloadWebCalendars = function() {\n var promises = [];\n\n _.forEach(this.$webcalendars, function(calendar) {\n var promise = Calendar.$$resource.fetch(calendar.id, 'reload');\n promise.then(function(data) {\n calendar.$error = false;\n }, function(response) {\n calendar.$error = l(response.statusText);\n });\n promises.push(promise);\n });\n\n return Calendar.$q.all(promises);\n };\n\n /**\n * @function $deleteComponents\n * @memberof Calendar\n * @desc Delete multiple components from calendar.\n * @return a promise of the HTTP operation\n */\n Calendar.$deleteComponents = function(components) {\n var _this = this, calendars = {}, promises = [];\n\n _.forEach(components, function(component) {\n if (!angular.isDefined(calendars[component.pid]))\n calendars[component.pid] = [];\n calendars[component.pid].push(component.id);\n });\n\n _.forEach(calendars, function(uids, pid) {\n promises.push(Calendar.$$resource.post(pid, 'batchDelete', {uids: uids}));\n });\n\n return Calendar.$q.all(promises);\n };\n\n /**\n * @function saveFoldersActivation\n * @memberof Calendar\n * @desc Save to the user's settings the activation state of the calendars\n * @param {string[]} folders - the folders IDs\n * @returns a promise of the HTTP operation\n */\n Calendar.saveFoldersActivation = function(ids) {\n var request = {};\n\n _.forEach(ids, function(id) {\n var calendar = Calendar.$get(id);\n request[calendar.id] = calendar.active;\n });\n\n return Calendar.$$resource.post(null, 'saveFoldersActivation', request);\n };\n\n /**\n * @function saveFoldersOrder\n * @desc Save to the user's settings the current calendars order.\n * @param {string[]} folders - the folders IDs\n * @returns a promise of the HTTP operation\n */\n Calendar.saveFoldersOrder = function(folders) {\n return this.$$resource.post(null, 'saveFoldersOrder', { folders: folders }).then(function() {\n Calendar.$Preferences.settings.Calendar.FoldersOrder = folders;\n if (!folders)\n // Calendars order was reset; reload list\n return Calendar.$$resource.fetch('calendarslist').then(function(data) {\n return Calendar.$findAll(data.calendars);\n });\n });\n };\n\n /**\n * @function init\n * @memberof Calendar.prototype\n * @desc Extend instance with new data and compute additional attributes.\n * @param {object} data - attributes of calendar\n */\n Calendar.prototype.init = function(data) {\n this.color = this.color || '#AAAAAA';\n this.active = 1;\n angular.extend(this, data);\n if (this.id) {\n this.$acl = new Calendar.$$Acl('Calendar/' + this.id);\n }\n // Add 'isOwned' and 'isSubscription' attributes based on active user (TODO: add it server-side?)\n this.isOwned = Calendar.activeUser.isSuperUser || this.owner == Calendar.activeUser.login;\n this.isSubscription = !this.isRemote && this.owner != Calendar.activeUser.login;\n if (angular.isUndefined(this.$shadowData)) {\n // Make a copy of the data for an eventual reset\n this.$shadowData = this.$omit();\n }\n };\n\n /**\n * @function $id\n * @memberof Calendar.prototype\n * @desc Resolve the calendar id.\n * @returns a promise of the calendar id\n */\n Calendar.prototype.$id = function() {\n if (this.id) {\n // Object already unwrapped\n return Calendar.$q.when(this.id);\n }\n else {\n // Wait until object is unwrapped\n return this.$futureCalendarData.then(function(calendar) {\n return calendar.id;\n });\n }\n };\n\n /**\n * @function getClassName\n * @memberof Calendar.prototype\n * @desc Return the calendar CSS class name based on its ID.\n * @returns a string representing the foreground CSS class name\n */\n Calendar.prototype.getClassName = function(base) {\n if (angular.isUndefined(base))\n base = 'fg';\n return base + '-folder' + this.id;\n };\n\n /**\n * @function $rename\n * @memberof Calendar.prototype\n * @desc Rename the calendar and keep the list sorted\n * @param {string} name - the new name\n * @returns a promise of the HTTP operation\n */\n Calendar.prototype.$rename = function() {\n var _this = this,\n i,\n calendars;\n\n if (this.name == this.$shadowData.name) {\n // Name hasn't changed\n return Calendar.$q.when();\n }\n\n if (this.isWebCalendar)\n calendars = Calendar.$webcalendars;\n else if (this.isSubscription)\n calendars = Calendar.$subscriptions;\n else\n calendars = Calendar.$calendars;\n\n i = _.indexOf(_.map(calendars, 'id'), this.id);\n if (i > -1) {\n return this.$save().then(function() {\n calendars.splice(i, 1);\n Calendar.$add(_this);\n });\n }\n else {\n return Calendar.$q.reject();\n }\n };\n\n /**\n * @function $delete\n * @memberof Calendar.prototype\n * @desc Delete the calendar from the server and the static list of calendars.\n * @returns a promise of the HTTP operation\n */\n Calendar.prototype.$delete = function() {\n var _this = this,\n list,\n promise;\n\n if (this.isSubscription) {\n promise = Calendar.$$resource.fetch(this.id, 'unsubscribe');\n list = Calendar.$subscriptions;\n }\n else {\n promise = Calendar.$$resource.remove(this.id);\n if (this.isWebCalendar)\n list = Calendar.$webcalendars;\n else\n list = Calendar.$calendars;\n }\n\n return promise.then(function() {\n var i = _.indexOf(_.map(list, 'id'), _this.id);\n list.splice(i, 1);\n });\n };\n\n /**\n * @function $reset\n * @memberof Calendar.prototype\n * @desc Reset the original state the calendar's data.\n */\n Calendar.prototype.$reset = function() {\n var _this = this;\n angular.forEach(this, function(value, key) {\n if (key != 'constructor' && key[0] != '$') {\n delete _this[key];\n }\n });\n angular.extend(this, this.$shadowData);\n this.$shadowData = this.$omit();\n };\n\n /**\n * @function $save\n * @memberof Calendar.prototype\n * @desc Save the calendar properties to the server.\n * @returns a promise of the HTTP operation\n */\n Calendar.prototype.$save = function() {\n var _this = this;\n\n return Calendar.$$resource.save(this.id, this.$omit()).then(function(data) {\n // Make a copy of the data for an eventual reset\n _this.$shadowData = _this.$omit();\n return data;\n }, function(data) {\n Calendar.$log.error(JSON.stringify(data, undefined, 2));\n // Restore previous version\n _this.$reset();\n return data;\n });\n };\n\n /**\n * @function setCredentials\n * @memberof Calendar.prototype\n * @desc Set the credentials for a Web calendar that requires authentication\n * @returns a promise of the HTTP operation\n */\n Calendar.prototype.setCredentials = function(username, password) {\n var _this = this,\n d = Calendar.$q.defer();\n\n Calendar.$$resource.post(this.id, 'set-credentials', { username: username, password: password }).then(function() {\n Calendar.$$resource.fetch(_this.id, 'reload').then(function(data) {\n Calendar.$add(_this);\n d.resolve();\n }, function(response) {\n if (response.status == 401) {\n // Authentication failed\n d.reject(l('Wrong username or password'));\n }\n else {\n d.reject(response.statusText);\n }\n });\n }, d.reject);\n\n return d.promise;\n };\n\n /**\n * @function export\n * @memberof Calendar.prototype\n * @desc Export the calendar\n * @returns a promise of the HTTP operation\n */\n Calendar.prototype.export = function() {\n var options;\n\n options = {\n type: 'application/octet-stream',\n filename: this.name + '.ics'\n };\n\n return Calendar.$$resource.download(this.id + '.ics', 'export', null, options);\n };\n\n /**\n * @function $setActivation\n * @memberof Calendar.prototype\n * @desc Either activate or deactivate the calendar.\n * @returns a promise of the HTTP operation\n */\n Calendar.prototype.$setActivation = function() {\n return Calendar.$$resource.fetch(this.id, (this.active?'':'de') + 'activateFolder');\n };\n\n /**\n * @function $getComponent\n * @memberof Calendar.prototype\n * @desc Fetch a component attributes from the server.\n * @returns a promise of the HTTP operation\n */\n Calendar.prototype.$getComponent = function(componentId, recurrenceId) {\n return Calendar.$Component.$find(this.id, componentId, recurrenceId);\n };\n\n /**\n * @function $unwrap\n * @memberof Calendar.prototype\n * @desc Unwrap a promise\n * @param {promise} futureCalendarData - a promise of the Calendar's data\n */\n Calendar.prototype.$unwrap = function(futureCalendarData) {\n var _this = this;\n\n // Expose and resolve the promise\n this.$futureCalendarData = futureCalendarData.then(function(data) {\n return Calendar.$timeout(function() {\n // Extend Calendar instance with received data\n _this.init(data);\n return _this;\n });\n }, function(data) {\n _this.isError = true;\n if (angular.isObject(data)) {\n Calendar.$timeout(function() {\n angular.extend(_this, data);\n });\n }\n });\n };\n\n /**\n * @function $omit\n * @memberof Calendar.prototype\n * @desc Return a sanitized object used to send to the server.\n * @return an object literal copy of the Calendar instance\n */\n Calendar.prototype.$omit = function() {\n var calendar = {};\n angular.forEach(this, function(value, key) {\n if (key != 'constructor' &&\n key[0] != '$') {\n calendar[key] = value;\n }\n });\n return calendar;\n };\n})();\n","/* -*- Mode: javascript; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n\n(function() {\n 'use strict';\n\n /**\n * @name Component\n * @constructor\n * @param {object} futureComponentData - either an object literal or a promise\n */\n function Component(futureComponentData) {\n // Data is immediately available\n if (typeof futureComponentData.then !== 'function') {\n this.init(futureComponentData);\n if (this.pid && !this.id) {\n // Prepare for the creation of a new component;\n // Get UID from the server.\n var newComponentData = Component.$$resource.newguid(this.pid);\n this.$unwrap(newComponentData);\n this.isNew = true;\n }\n }\n else {\n // The promise will be unwrapped first\n this.$unwrap(futureComponentData);\n }\n }\n\n /**\n * @memberof Component\n * @desc The factory we'll use to register with Angular\n * @returns the Component constructor\n */\n Component.$factory = ['$q', '$timeout', '$log', '$rootScope', 'sgSettings', 'sgComponent_STATUS', 'Preferences', 'Card', 'Gravatar', 'Resource', function($q, $timeout, $log, $rootScope, Settings, Component_STATUS, Preferences, Card, Gravatar, Resource) {\n angular.extend(Component, {\n STATUS: Component_STATUS,\n $q: $q,\n $timeout: $timeout,\n $log: $log,\n $rootScope: $rootScope,\n $Preferences: Preferences,\n $Card: Card,\n $gravatar: Gravatar,\n $$resource: new Resource(Settings.activeUser('folderURL') + 'Calendar', Settings.activeUser()),\n timeFormat: \"%H:%M\",\n // Filter parameters common to events and tasks\n $query: { value: '', search: 'title_Category_Location' },\n // Filter paramaters specific to events\n $queryEvents: { sort: 'start', asc: 1, filterpopup: 'view_next7' },\n // Filter parameters specific to tasks\n $queryTasks: { sort: 'status', asc: 1, filterpopup: 'view_incomplete' },\n $refreshTimeout: null,\n $ghost: {}\n });\n Preferences.ready().then(function() {\n // Initialize filter parameters from user's settings\n if (Preferences.settings.Calendar.EventsFilterState)\n Component.$queryEvents.filterpopup = Preferences.settings.Calendar.EventsFilterState;\n if (Preferences.settings.Calendar.TasksFilterState)\n Component.$queryTasks.filterpopup = Preferences.settings.Calendar.TasksFilterState;\n if (Preferences.settings.Calendar.EventsSortingState) {\n Component.$queryEvents.sort = Preferences.settings.Calendar.EventsSortingState[0];\n Component.$queryEvents.asc = parseInt(Preferences.settings.Calendar.EventsSortingState[1]);\n }\n if (Preferences.settings.Calendar.TasksSortingState) {\n Component.$queryTasks.sort = Preferences.settings.Calendar.TasksSortingState[0];\n Component.$queryTasks.asc = parseInt(Preferences.settings.Calendar.TasksSortingState[1]);\n }\n Component.$queryTasks.show_completed = parseInt(Preferences.settings.ShowCompletedTasks);\n // Initialize categories from user's defaults\n Component.$categories = Preferences.defaults.SOGoCalendarCategoriesColors;\n // Initialize time format from user's defaults\n if (Preferences.defaults.SOGoTimeFormat) {\n Component.timeFormat = Preferences.defaults.SOGoTimeFormat;\n }\n });\n\n return Component; // return constructor\n }];\n\n /**\n * @module SOGo.SchedulerUI\n * @desc Factory registration of Component in Angular module.\n */\n try {\n angular.module('SOGo.SchedulerUI');\n }\n catch(e) {\n angular.module('SOGo.SchedulerUI', ['SOGo.Common']);\n }\n angular.module('SOGo.SchedulerUI')\n .constant('sgComponent_STATUS', {\n NOT_LOADED: 0,\n DELAYED_LOADING: 1,\n LOADING: 2,\n LOADED: 3,\n DELAYED_MS: 300\n })\n .factory('Component', Component.$factory);\n\n /**\n * @function $selectedCount\n * @memberof Component\n * @desc Return the number of events or tasks selected by the user.\n * @returns the number of selected events or tasks\n */\n Component.$selectedCount = function() {\n var count;\n\n count = 0;\n if (Component.$events) {\n count += (_.filter(Component.$events, function(event) { return event.selected; })).length;\n }\n if (Component.$tasks) {\n count += (_.filter(Component.$tasks, function(task) { return task.selected; })).length;\n }\n return count;\n };\n\n /**\n * @function $startRefreshTimeout\n * @memberof Component\n * @desc Starts the refresh timeout for the current selected list (events or tasks) and\n * current view.\n */\n Component.$startRefreshTimeout = function(type) {\n var _this = this;\n\n if (Component.$refreshTimeout)\n Component.$timeout.cancel(Component.$refreshTimeout);\n\n Component.$Preferences.ready().then(function() {\n // Restart the refresh timer, if needed\n var refreshViewCheck = Component.$Preferences.defaults.SOGoRefreshViewCheck;\n if (refreshViewCheck && refreshViewCheck != 'manually') {\n var f = angular.bind(Component.$rootScope, Component.$rootScope.$emit, 'calendars:list');\n Component.$refreshTimeout = Component.$timeout(f, refreshViewCheck.timeInterval()*1000);\n }\n });\n };\n\n /**\n * @function $isLoading\n * @memberof Component\n * @returns true if the components list is still being retrieved from server after a specific delay\n * @see sgMessage_STATUS\n */\n Component.$isLoading = function() {\n return Component.$loaded == Component.STATUS.LOADING;\n };\n\n /**\n * @function $filter\n * @memberof Component\n * @desc Search for components matching some criterias\n * @param {string} type - either 'events' or 'tasks'\n * @param {object} [options] - additional options to the query\n * @returns a collection of Components instances\n */\n Component.$filter = function(type, options) {\n var _this = this,\n now = new Date(),\n day = now.getDate(),\n month = now.getMonth() + 1,\n year = now.getFullYear(),\n queryKey = '$query' + type.capitalize(),\n params = {\n day: '' + year + (month < 10?'0':'') + month + (day < 10?'0':'') + day,\n };\n\n Component.$startRefreshTimeout(type);\n\n return this.$Preferences.ready().then(function() {\n var futureComponentData,\n dirty = false,\n otherType;\n\n angular.extend(_this.$query, params);\n\n if (options) {\n _.forEach(_.keys(options), function(key) {\n // Query parameters common to events and tasks are compared\n dirty |= (_this.$query[key] && options[key] != Component.$query[key]);\n if (key == 'reload' && options[key])\n dirty = true;\n // Update either the common parameters or the type-specific parameters\n else if (angular.isDefined(_this.$query[key]))\n _this.$query[key] = options[key];\n else\n _this[queryKey][key] = options[key];\n });\n }\n\n // Perform query with both common and type-specific parameters\n futureComponentData = _this.$$resource.fetch(null, type + 'list',\n angular.extend(_this[queryKey], _this.$query));\n\n // Invalidate cached results of other type if $query has changed\n if (dirty) {\n otherType = (type == 'tasks')? '$events' : '$tasks';\n delete Component[otherType];\n Component.$log.debug('force reload of ' + otherType);\n }\n\n return _this.$unwrapCollection(type, futureComponentData);\n });\n };\n\n /**\n * @function $find\n * @desc Fetch a component from a specific calendar.\n * @param {string} calendarId - the calendar ID\n * @param {string} componentId - the component ID\n * @param {string} [occurrenceId] - the component ID\n * @see {@link Calendar.$getComponent}\n */\n Component.$find = function(calendarId, componentId, occurrenceId) {\n var futureComponentData, path = [calendarId, componentId];\n\n if (occurrenceId)\n path.push(occurrenceId);\n\n futureComponentData = this.$$resource.fetch(path.join('/'), 'view');\n\n return new Component(futureComponentData);\n };\n\n /**\n * @function filterCategories\n * @desc Search for categories matching some criterias\n * @param {string} search - the search string to match\n * @returns a collection of strings\n */\n Component.filterCategories = function(query) {\n var re = new RegExp(query, 'i');\n return _.filter(_.keys(Component.$categories), function(category) {\n return category.search(re) != -1;\n });\n };\n\n /**\n * @function saveSelectedList\n * @desc Save to the user's settings the currently selected list.\n * @param {string} componentType - either \"events\" or \"tasks\"\n * @returns a promise of the HTTP operation\n */\n Component.saveSelectedList = function(componentType) {\n return this.$$resource.post(null, 'saveSelectedList', { list: componentType + 'ListView' });\n };\n\n /**\n * @function $eventsBlocksForView\n * @desc Events blocks for a specific week\n * @param {string} view - Either 'day' or 'week'\n * @param {Date} type - Date of any day of the desired period\n * @returns a promise of a collection of objects describing the events blocks\n */\n Component.$eventsBlocksForView = function(view, date) {\n var _this = this;\n\n return Component.$Preferences.ready().then(function(data) {\n var firstDayOfWeek, viewAction, startDate, endDate, params;\n firstDayOfWeek = Component.$Preferences.defaults.SOGoFirstDayOfWeek;\n\n if (view == 'day') {\n viewAction = 'dayView';\n startDate = endDate = date;\n }\n else if (view == 'multicolumnday') {\n viewAction = 'multicolumndayView';\n startDate = endDate = date;\n }\n else if (view == 'week') {\n viewAction = 'weekView';\n startDate = date.beginOfWeek(firstDayOfWeek);\n endDate = new Date();\n endDate.setTime(startDate.getTime());\n endDate.addDays(6);\n }\n else if (view == 'month') {\n viewAction = 'monthView';\n startDate = date;\n startDate.setDate(1);\n startDate = startDate.beginOfWeek(firstDayOfWeek);\n endDate = new Date();\n endDate.setTime(date.getTime());\n endDate.setMonth(endDate.getMonth() + 1);\n endDate.addDays(-1);\n endDate = endDate.endOfWeek(firstDayOfWeek);\n }\n return _this.$eventsBlocks(viewAction, startDate, endDate);\n });\n };\n\n /**\n * @function $eventsBlocks\n * @desc Events blocks for a specific view and period\n * @param {string} view - Either 'day', 'multicolumnday', 'week' or 'month'\n * @param {Date} startDate - period's start date\n * @param {Date} endDate - period's end date\n * @returns a promise of a collection of objects describing the events blocks\n */\n Component.$eventsBlocks = function(view, startDate, endDate) {\n var params, futureComponentData, i, j, dayDates = [], dayNumbers = [],\n deferred = Component.$q.defer();\n\n params = { view: view.toLowerCase(), sd: startDate.getDayString(), ed: endDate.getDayString() };\n futureComponentData = this.$$resource.fetch(null, 'eventsblocks', params);\n futureComponentData.then(function(views) {\n var reduceComponent, associateComponent;\n\n reduceComponent = function(objects, eventData, i) {\n var componentData = _.zipObject(this.eventsFields, eventData),\n start = new Date(componentData.c_startdate * 1000),\n component;\n componentData.hour = start.getHourString();\n componentData.blocks = [];\n component = new Component(componentData);\n // Filter out categories for which there's no associated color\n component.categories = _.filter(component.categories, function(name) {\n return Component.$Preferences.defaults.SOGoCalendarCategoriesColors[name];\n });\n objects.push(component);\n return objects;\n };\n\n associateComponent = function(block) {\n this[block.nbr].blocks.push(block); // Associate block to component\n block.component = this[block.nbr]; // Associate component to block\n block.isFirst = (this[block.nbr].blocks.length == 1);\n };\n\n Component.$views = [];\n Component.$timeout(function() {\n _.forEach(views, function(data, viewIndex) {\n var components = [], blocks = {}, allDayBlocks = {}, viewData;\n\n // Change some attributes names\n data.eventsFields.splice(_.indexOf(data.eventsFields, 'c_folder'), 1, 'pid');\n data.eventsFields.splice(_.indexOf(data.eventsFields, 'c_name'), 1, 'id');\n data.eventsFields.splice(_.indexOf(data.eventsFields, 'c_recurrence_id'), 1, 'occurrenceId');\n data.eventsFields.splice(_.indexOf(data.eventsFields, 'c_title'), 1, 'summary');\n\n // Instantiate Component objects\n _.reduce(data.events, _.bind(reduceComponent, data), components);\n\n // Associate Component objects to blocks positions\n _.forEach(_.flatten(data.blocks), _.bind(associateComponent, components));\n\n // Associate Component objects to all-day blocks positions\n _.forEach(_.flatten(data.allDayBlocks), _.bind(associateComponent, components));\n\n // Build array of dates\n if (dayDates.length === 0) {\n dayDates = _.flatMap(data.days, 'date');\n dayNumbers = _.flatMap(data.days, 'number');\n }\n\n // Convert array of blocks to an object literal with date strings as keys\n for (i = 0; i < data.blocks.length; i++) {\n for (j = 0; j < data.blocks[i].length; j++) {\n data.blocks[i][j].dayIndex = i + (viewIndex * data.blocks.length);\n data.blocks[i][j].dayNumber = dayNumbers[i];\n }\n blocks[dayDates[i]] = data.blocks[i];\n }\n\n // Convert array of all-day blocks to object with days as keys\n for (i = 0; i < data.allDayBlocks.length; i++) {\n for (j = 0; j < data.allDayBlocks[i].length; j++) {\n data.allDayBlocks[i][j].dayIndex = i + (viewIndex * data.allDayBlocks.length);\n data.allDayBlocks[i][j].dayNumber = dayNumbers[i];\n }\n allDayBlocks[dayDates[i]] = data.allDayBlocks[i];\n }\n\n // \"blocks\" is now an object literal with the following structure:\n // { day: [\n // { start: number,\n // length: number,\n // siblings: number,\n // realSiblings: number,\n // position: number,\n // nbr: number,\n // component: Component },\n // .. ],\n // .. }\n //\n // Where day is a string with format YYYYMMDD\n\n Component.$log.debug('blocks ready (' + _.flatten(data.blocks).length + ')');\n Component.$log.debug('all day blocks ready (' + _.flatten(data.allDayBlocks).length + ')');\n\n // Save the blocks to the object model\n viewData = { blocks: blocks, allDayBlocks: allDayBlocks };\n if (data.id && data.calendarName) {\n // The multicolumnday view also includes calendar information\n viewData.id = data.id;\n viewData.calendarName = data.calendarName;\n }\n Component.$views.push(viewData);\n });\n\n deferred.resolve(Component.$views);\n });\n }, deferred.reject);\n\n return deferred.promise;\n };\n\n /**\n * @function $unwrapCollection\n * @desc Unwrap a promise and instanciate new Component objects using received data.\n * @param {string} type - either 'events' or 'tasks'\n * @param {promise} futureComponentData - a promise of the components' metadata\n * @returns a promise of the HTTP operation\n */\n Component.$unwrapCollection = function(type, futureComponentData) {\n var _this = this,\n components = [];\n\n // Components list is not loaded yet\n Component.$loaded = Component.STATUS.DELAYED_LOADING;\n Component.$timeout(function() {\n if (Component.$loaded != Component.STATUS.LOADED)\n Component.$loaded = Component.STATUS.LOADING;\n }, Component.STATUS.DELAYED_MS);\n\n return futureComponentData.then(function(data) {\n return Component.$timeout(function() {\n var fields = _.invokeMap(data.fields, 'toLowerCase');\n fields.splice(_.indexOf(fields, 'c_folder'), 1, 'pid');\n fields.splice(_.indexOf(fields, 'c_name'), 1, 'id');\n fields.splice(_.indexOf(fields, 'c_recurrence_id'), 1, 'occurrenceId');\n\n // Instanciate Component objects\n _.reduce(data[type], function(components, componentData, i) {\n var data = _.zipObject(fields, componentData), component;\n component = new Component(data);\n // Filter out categories for which there's no associated color\n component.categories = _.filter(component.categories, function(name) {\n return Component.$Preferences.defaults.SOGoCalendarCategoriesColors[name];\n });\n components.push(component);\n return components;\n }, components);\n\n Component.$log.debug('list of ' + type + ' ready (' + components.length + ')');\n\n // Save the list of components to the object model\n Component['$' + type] = components;\n\n Component.$loaded = Component.STATUS.LOADED;\n\n return components;\n });\n });\n };\n\n /**\n * @function $resetGhost\n * @desc Prepare the ghost object for the next drag by resetting appropriate attributes\n */\n Component.$resetGhost = function() {\n this.$ghost.pointerHandler = null;\n this.$ghost.component = null;\n this.$ghost.startHour = null;\n this.$ghost.endHour = null;\n };\n\n /**\n * @function $parseDate\n * @desc Parse a date string with format YYYY-MM-DDTHH:MM\n * @param {string} dateString - the string representing the date\n * @param {object} [options] - additional options (use {no_time: true} to ignore the time)\n * @returns a date object\n */\n Component.$parseDate = function(dateString, options) {\n var date, time;\n\n date = dateString.substring(0,10).split('-');\n\n if (options && options.no_time)\n return new Date(parseInt(date[0]), parseInt(date[1]) - 1, parseInt(date[2]));\n\n time = dateString.substring(11,16).split(':');\n\n return new Date(parseInt(date[0]), parseInt(date[1]) - 1, parseInt(date[2]),\n parseInt(time[0]), parseInt(time[1]), 0, 0);\n };\n\n /**\n * @function init\n * @memberof Component.prototype\n * @desc Extend instance with required attributes and new data.\n * @param {object} data - attributes of component\n */\n Component.prototype.init = function(data) {\n var _this = this;\n\n this.categories = [];\n this.repeat = {};\n this.alarm = { action: 'display', quantity: 5, unit: 'MINUTES', reference: 'BEFORE', relation: 'START' };\n this.status = 'not-specified';\n this.delta = 60;\n angular.extend(this, data);\n\n if (this.component == 'vevent')\n this.type = 'appointment';\n else if (this.component == 'vtodo')\n this.type = 'task';\n\n if (this.startDate) {\n if (angular.isString(this.startDate))\n // Ex: 2015-10-25T22:34:51+00:00\n this.start = Component.$parseDate(this.startDate);\n else\n // Date object\n this.start = this.startDate;\n }\n else if (this.type == 'appointment') {\n this.start = new Date();\n this.start.setMinutes(Math.round(this.start.getMinutes()/15)*15);\n }\n\n if (this.endDate) {\n this.end = Component.$parseDate(this.endDate);\n this.delta = this.start.minutesTo(this.end);\n }\n else if (this.type == 'appointment') {\n this.setDelta(this.delta);\n }\n\n if (this.dueDate)\n this.due = Component.$parseDate(this.dueDate);\n\n if (this.completedDate)\n this.completed = Component.$parseDate(this.completedDate);\n else if (this.type == 'task')\n this.completed = new Date();\n\n if (this.c_category)\n this.categories = _.invokeMap(this.c_category, 'asCSSIdentifier');\n\n // Parse recurrence rule definition and initialize default values\n this.$isRecurrent = angular.isDefined(data.repeat);\n if (this.repeat.days) {\n var byDayMask = _.find(this.repeat.days, function(o) {\n return angular.isDefined(o.occurrence);\n });\n if (byDayMask) {\n if (this.repeat.frequency == 'yearly')\n this.repeat.year = { byday: true };\n this.repeat.month = {\n type: 'byday',\n occurrence: byDayMask.occurrence.toString(),\n day: byDayMask.day\n };\n }\n }\n else {\n this.repeat.days = [];\n }\n if (angular.isUndefined(this.repeat.frequency))\n this.repeat.frequency = 'never';\n if (angular.isUndefined(this.repeat.interval))\n this.repeat.interval = 1;\n if (angular.isUndefined(this.repeat.monthdays))\n // TODO: initialize this.repeat.monthdays with month day of start date\n this.repeat.monthdays = [];\n else if (this.repeat.monthdays.length > 0)\n this.repeat.month = { type: 'bymonthday' };\n if (angular.isUndefined(this.repeat.month))\n this.repeat.month = {};\n if (angular.isUndefined(this.repeat.month.occurrence))\n angular.extend(this.repeat.month, { occurrence: '1', day: 'SU' });\n if (angular.isUndefined(this.repeat.months))\n // TODO: initialize this.repeat.months with month of start date\n this.repeat.months = [];\n if (angular.isUndefined(this.repeat.year))\n this.repeat.year = {};\n if (this.repeat.count)\n this.repeat.end = 'count';\n else if (this.repeat.until) {\n this.repeat.end = 'until';\n if (angular.isString(this.repeat.until))\n this.repeat.until = Component.$parseDate(this.repeat.until, { no_time: true });\n }\n else\n this.repeat.end = 'never';\n this.$hasCustomRepeat = this.hasCustomRepeat();\n\n if (this.isNew) {\n // Set default values\n Component.$Preferences.ready().then(function() {\n var type = (_this.type == 'appointment')? 'Events' : 'Tasks';\n\n // Set default classification\n _this.classification = Component.$Preferences.defaults['SOGoCalendar' + type + 'DefaultClassification'].toLowerCase();\n\n // Set default alarm\n var units = { M: 'MINUTES', H: 'HOURS', D: 'DAYS', W: 'WEEKS' };\n var match = /-PT?([0-9]+)([MHDW])/.exec(Component.$Preferences.defaults.SOGoCalendarDefaultReminder);\n if (match) {\n _this.$hasAlarm = true;\n _this.alarm.quantity = parseInt(match[1]);\n _this.alarm.unit = units[match[2]];\n }\n\n // Set notitifications\n _this.sendAppointmentNotifications = Component.$Preferences.defaults.SOGoAppointmentSendEMailNotifications;\n });\n }\n else if (angular.isUndefined(data.$hasAlarm)) {\n this.$hasAlarm = angular.isDefined(data.alarm);\n }\n\n // Allow the component to be moved to a different calendar\n this.destinationCalendar = this.pid;\n\n // if (this.organizer && this.organizer.email) {\n // this.organizer.$image = Component.$gravatar(this.organizer.email, 32);\n // }\n\n if (this.attendees) {\n _.forEach(this.attendees, function(attendee) {\n attendee.image = Component.$gravatar(attendee.email, 32);\n });\n }\n\n // Load freebusy of attendees\n this.updateFreeBusy();\n\n this.selected = false;\n };\n\n /**\n * @function hasCustomRepeat\n * @memberof Component.prototype\n * @desc Check if the component has a custom recurrence rule.\n * @returns true if the recurrence rule requires the full recurrence editor\n */\n Component.prototype.hasCustomRepeat = function() {\n var b = angular.isDefined(this.repeat) &&\n (this.repeat.interval > 1 ||\n angular.isDefined(this.repeat.days) && this.repeat.days.length > 0 ||\n angular.isDefined(this.repeat.monthdays) && this.repeat.monthdays.length > 0 ||\n angular.isDefined(this.repeat.months) && this.repeat.months.length > 0 ||\n angular.isDefined(this.repeat.month) && angular.isDefined(this.repeat.month.type));\n return b;\n };\n\n /**\n * @function isEditable\n * @memberof Component.prototype\n * @desc Check if the component is editable and not an occurrence of a recurrent component\n * @returns true or false\n */\n Component.prototype.isEditable = function() {\n return (!this.occurrenceId && !this.isReadOnly);\n };\n\n /**\n * @function isEditableOccurrence\n * @memberof Component.prototype\n * @desc Check if the component is editable and an occurrence of a recurrent component\n * @returns true or false\n */\n Component.prototype.isEditableOccurrence = function() {\n return (this.occurrenceId && !this.isReadOnly);\n };\n\n /**\n * @function isInvitation\n * @memberof Component.prototype\n * @desc Check if the component an invitation and not an occurrence of a recurrent component\n * @returns true or false\n */\n Component.prototype.isInvitation = function() {\n return (!this.occurrenceId && this.userHasRSVP);\n };\n\n /**\n * @function isInvitationOccurrence\n * @memberof Component.prototype\n * @desc Check if the component an invitation and an occurrence of a recurrent component\n * @returns true or false\n */\n Component.prototype.isInvitationOccurrence = function() {\n return (this.occurrenceId && this.userHasRSVP);\n };\n\n /**\n * @function isReadOnly\n * @memberof Component.prototype\n * @desc Check if the component is not editable and not an invitation\n * @returns true or false\n */\n Component.prototype.isReadOnly = function() {\n return (this.isReadOnly && !this.userHasRSVP);\n };\n\n /**\n * @function enablePercentComplete\n * @memberof Component.prototype\n * @desc Check if the percent completion should be enabled with respect to the\n * component's type and status.\n * @returns true if the percent completion should be displayed\n */\n Component.prototype.enablePercentComplete = function() {\n return (this.type == 'task' &&\n this.status != 'not-specified' &&\n this.status != 'cancelled');\n };\n\n /**\n * @function coversFreeBusy\n * @memberof Component.prototype\n * @desc Check if a specific quarter matches the component's period\n * @returns true if the quarter covers the component's period\n */\n Component.prototype.coversFreeBusy = function(day, hour, quarter) {\n var b = (angular.isDefined(this.freebusy[day]) &&\n angular.isDefined(this.freebusy[day][hour]) &&\n this.freebusy[day][hour][quarter] == 1);\n return b;\n };\n\n /**\n * @function updateFreeBusyCoverage\n * @memberof Component.prototype\n * @desc Build a 15-minute-based representation of the component's period.\n * @returns an object literal hashed by days and hours and arrays of four 1's and 0's\n */\n Component.prototype.updateFreeBusyCoverage = function() {\n var _this = this, freebusy = {};\n\n if (this.start && this.end) {\n var roundedStart = new Date(this.start.getTime()),\n roundedEnd = new Date(this.end.getTime()),\n startQuarter = parseInt(roundedStart.getMinutes()/15 + 0.5),\n endQuarter = parseInt(roundedEnd.getMinutes()/15 + 0.5);\n roundedStart.setMinutes(15*startQuarter);\n roundedEnd.setMinutes(15*endQuarter);\n\n _.forEach(roundedStart.daysUpTo(roundedEnd), function(date, index) {\n var currentDay = date.getDate(),\n dayKey = date.getDayString(),\n hourKey;\n if (dayKey == _this.start.getDayString()) {\n hourKey = date.getHours().toString();\n freebusy[dayKey] = {};\n freebusy[dayKey][hourKey] = [];\n while (startQuarter > 0) {\n freebusy[dayKey][hourKey].push(0);\n startQuarter--;\n }\n }\n else {\n date = date.beginOfDay();\n freebusy[dayKey] = {};\n }\n while (date.getTime() < _this.end.getTime() &&\n date.getDate() == currentDay) {\n hourKey = date.getHours().toString();\n if (angular.isUndefined(freebusy[dayKey][hourKey]))\n freebusy[dayKey][hourKey] = [];\n freebusy[dayKey][hourKey].push(1);\n date.addMinutes(15);\n }\n });\n return freebusy;\n }\n };\n\n /**\n * @function updateFreeBusy\n * @memberof Component.prototype\n * @desc Update the freebusy coverage representation and the attendees freebusy information\n */\n Component.prototype.updateFreeBusy = function() {\n var _this = this;\n\n this.freebusy = this.updateFreeBusyCoverage();\n\n if (this.attendees) {\n _.forEach(this.attendees, function(attendee) {\n _this.updateFreeBusyAttendee(attendee);\n });\n }\n };\n\n /**\n * @function setDelta\n * @memberof Component.prototype\n * @desc Set the end time to the specified number of minutes after the start time.\n * @param {number} delta - the number of minutes\n */\n Component.prototype.setDelta = function(delta) {\n this.delta = delta;\n this.end = new Date(this.start.getTime());\n this.end.setMinutes(Math.round(this.end.getMinutes()/15)*15);\n this.end.addMinutes(this.delta);\n };\n\n /**\n * @function updateFreeBusyAttendee\n * @memberof Component.prototype\n * @desc Update the freebusy information for the component's period for a specific attendee.\n * @param {Object} card - an Card object instance of the attendee\n */\n Component.prototype.updateFreeBusyAttendee = function(attendee) {\n var resource, uid, params, days;\n\n if (attendee.uid) {\n uid = attendee.uid;\n if (attendee.domain)\n uid += '@' + attendee.domain;\n params =\n {\n sday: this.start.getDayString(),\n eday: this.end.getDayString()\n };\n\n if (attendee.isMSExchange) {\n // Attendee is not a local user, but her freebusy data is available from an external MS Exchange server;\n // we query /SOGo/so/<login_user>/freebusy.ifb/ajaxRead?uid=<uid>\n resource = Component.$$resource.userResource();\n params.uid = uid;\n }\n else {\n // Attendee is a user;\n // web query /SOGo/so/<uid>/freebusy.ifb/ajaxRead\n resource = Component.$$resource.userResource(uid);\n }\n\n days = _.map(this.start.daysUpTo(this.end), function(day) { return day.getDayString(); });\n\n if (angular.isUndefined(attendee.freebusy))\n attendee.freebusy = {};\n\n // Fetch FreeBusy information\n resource.fetch('freebusy.ifb', 'ajaxRead', params).then(function(data) {\n _.forEach(days, function(day) {\n var hour;\n\n if (angular.isUndefined(attendee.freebusy[day]))\n attendee.freebusy[day] = {};\n\n if (angular.isUndefined(data[day]))\n data[day] = {};\n\n for (var i = 0; i <= 23; i++) {\n hour = i.toString();\n if (data[day][hour])\n attendee.freebusy[day][hour] = [\n data[day][hour][\"0\"],\n data[day][hour][\"15\"],\n data[day][hour][\"30\"],\n data[day][hour][\"45\"]\n ];\n else\n attendee.freebusy[day][hour] = [0, 0, 0, 0];\n }\n });\n });\n }\n };\n\n /**\n * @function getClassName\n * @memberof Component.prototype\n * @desc Return the component CSS class name based on its container (calendar) ID.\n * @param {string} [base] - the prefix to add to the class name (defaults to \"fg\")\n * @returns a string representing the foreground CSS class name\n */\n Component.prototype.getClassName = function(base) {\n if (angular.isUndefined(base))\n base = 'fg';\n return base + '-folder' + (this.destinationCalendar || this.c_folder || this.pid);\n };\n\n /**\n * @function addAttendee\n * @memberof Component.prototype\n * @desc Add an attendee and fetch his freebusy info.\n * @param {Object} card - an Card object instance to be added to the attendees list\n */\n Component.prototype.addAttendee = function(card) {\n var _this = this, attendee, list, url, params;\n if (card) {\n if (card.$isList({expandable: true})) {\n // Decompose list members\n list = Component.$Card.$find(card.container, card.c_name);\n list.$id().then(function(listId) {\n _.forEach(list.refs, function(ref) {\n attendee = {\n name: ref.c_cn,\n email: ref.$preferredEmail(),\n role: 'req-participant',\n partstat: 'needs-action',\n uid: ref.c_uid,\n $avatarIcon: 'person',\n };\n if (!_.find(_this.attendees, function(o) {\n return o.email == attendee.email;\n })) {\n // Contact is not already an attendee, add it\n attendee.image = Component.$gravatar(attendee.email, 32);\n if (_this.attendees)\n _this.attendees.push(attendee);\n else\n _this.attendees = [attendee];\n _this.updateFreeBusyAttendee(attendee);\n }\n });\n });\n }\n else {\n // Single contact\n attendee = {\n uid: card.c_uid,\n domain: card.c_domain,\n isMSExchange: card.ismsexchange,\n name: card.c_cn,\n email: card.$preferredEmail(),\n role: 'req-participant',\n partstat: 'needs-action',\n $avatarIcon: card.$avatarIcon\n };\n if (!_.find(this.attendees, function(o) {\n return o.email == attendee.email;\n })) {\n attendee.image = Component.$gravatar(attendee.email, 32);\n if (this.attendees)\n this.attendees.push(attendee);\n else\n this.attendees = [attendee];\n this.updateFreeBusyAttendee(attendee);\n }\n }\n }\n };\n\n /**\n * @function hasAttendee\n * @memberof Component.prototype\n * @desc Verify if one of the email addresses of a Card instance matches an attendee.\n * @param {Object} card - an Card object instance\n * @returns true if the Card matches an attendee\n */\n Component.prototype.hasAttendee = function(card) {\n var attendee = _.find(this.attendees, function(attendee) {\n return _.find(card.emails, function(email) {\n return email.value == attendee.email;\n });\n });\n return angular.isDefined(attendee);\n };\n\n /**\n * @function deleteAttendee\n * @memberof Component.prototype\n * @desc Remove an attendee from the component\n * @param {Object} attendee - an object literal defining an attendee\n */\n Component.prototype.deleteAttendee = function(attendee) {\n var index = _.findIndex(this.attendees, function(currentAttendee) {\n return currentAttendee.email == attendee.email;\n });\n this.attendees.splice(index, 1);\n };\n\n /**\n * @function canRemindAttendeesByEmail\n * @memberof Component.prototype\n * @desc Verify if the component's reminder must be send by email and if it has at least one attendee.\n * @returns true if attendees can receive a reminder by email\n */\n Component.prototype.canRemindAttendeesByEmail = function() {\n return this.alarm.action == 'email' &&\n !this.isReadOnly &&\n this.attendees && this.attendees.length > 0;\n };\n\n /**\n * @function addAttachUrl\n * @memberof Component.prototype\n * @desc Add a new attach URL if not already defined\n * @param {string} attachUrl - the URL\n * @returns the number of values in the list of attach URLs\n */\n Component.prototype.addAttachUrl = function(attachUrl) {\n if (angular.isUndefined(this.attachUrls)) {\n this.attachUrls = [{value: attachUrl}];\n }\n else {\n for (var i = 0; i < this.attachUrls.length; i++) {\n if (this.attachUrls[i].value == attachUrl) {\n break;\n }\n }\n if (i == this.attachUrls.length)\n this.attachUrls.push({value: attachUrl});\n }\n return this.attachUrls.length - 1;\n };\n\n /**\n * @function deleteAttachUrl\n * @memberof Component.prototype\n * @desc Remove an attach URL\n * @param {number} index - the URL index in the list of attach URLs\n */\n Component.prototype.deleteAttachUrl = function(index) {\n if (index > -1 && this.attachUrls.length > index) {\n this.attachUrls.splice(index, 1);\n }\n };\n\n /**\n * @function $addDueDate\n * @memberof Component.prototype\n * @desc Add a due date\n */\n Component.prototype.$addDueDate = function() {\n this.due = new Date();\n this.due.setMinutes(Math.round(this.due.getMinutes()/15)*15);\n this.dueDate = this.due.toISOString();\n };\n\n /**\n * @function $deleteDueDate\n * @memberof Component.prototype\n * @desc Delete a due date\n */\n Component.prototype.$deleteDueDate = function() {\n delete this.due;\n delete this.dueDate;\n };\n\n /**\n * @function $addStartDate\n * @memberof Component.prototype\n * @desc Add a start date\n */\n Component.prototype.$addStartDate = function() {\n this.start = new Date();\n this.start.setMinutes(Math.round(this.start.getMinutes()/15)*15);\n };\n\n /**\n * @function $deleteStartDate\n * @memberof Component.prototype\n * @desc Delete a start date\n */\n Component.prototype.$deleteStartDate = function() {\n delete this.start;\n delete this.startDate;\n };\n\n /**\n * @function $reset\n * @memberof Component.prototype\n * @desc Reset the original state the component's data.\n */\n Component.prototype.$reset = function() {\n var _this = this;\n angular.forEach(this, function(value, key) {\n if (key != 'constructor' && key[0] != '$') {\n delete _this[key];\n }\n });\n this.init(this.$shadowData);\n this.$shadowData = this.$omit();\n };\n\n /**\n * @function $reply\n * @memberof Component.prototype\n * @desc Reply to an invitation.\n * @returns a promise of the HTTP operation\n */\n Component.prototype.$reply = function() {\n var _this = this, data, path = [this.pid, this.id];\n\n if (this.occurrenceId)\n path.push(this.occurrenceId);\n\n data = {\n reply: this.reply,\n delegatedTo: this.delegatedTo,\n alarm: this.$hasAlarm? this.alarm : {}\n };\n\n return Component.$$resource.save(path.join('/'), data, { action: 'rsvpAppointment' })\n .then(function(data) {\n // Make a copy of the data for an eventual reset\n _this.$shadowData = _this.$omit();\n return data;\n });\n };\n\n /**\n * @function $adjust\n * @memberof Component.prototype\n * @desc Adjust the start, day, and/or duration of the component\n * @returns a promise of the HTTP operation\n */\n Component.prototype.$adjust = function(params) {\n var path = [this.pid, this.id];\n\n if (_.every(_.values(params), function(v) { return v === 0; }))\n // No changes\n return Component.$q.when();\n\n if (this.occurrenceId)\n path.push(this.occurrenceId);\n\n Component.$log.debug('adjust ' + path.join('/') + ' ' + JSON.stringify(params));\n\n return Component.$$resource.save(path.join('/'), params, { action: 'adjust' });\n };\n\n /**\n * @function $save\n * @memberof Component.prototype\n * @desc Save the component to the server.\n * @param {object} extraAttributes - additional attributes to send to the server\n */\n Component.prototype.$save = function(extraAttributes) {\n var _this = this, options, path, component, date, dlp;\n\n component = this.$omit();\n dlp = Component.$Preferences.$mdDateLocaleProvider;\n\n // Format dates and times\n component.startDate = component.start ? component.start.format(dlp, '%Y-%m-%d') : '';\n component.startTime = component.start ? component.start.format(dlp, '%H:%M') : '';\n component.endDate = component.end ? component.end.format(dlp, '%Y-%m-%d') : '';\n component.endTime = component.end ? component.end.format(dlp, '%H:%M') : '';\n component.dueDate = component.due ? component.due.format(dlp, '%Y-%m-%d') : '';\n component.dueTime = component.due ? component.due.format(dlp, '%H:%M') : '';\n component.completedDate = component.completed ? component.completed.format(dlp, '%Y-%m-%d') : '';\n\n // Update recurrence definition depending on selections\n if (this.hasCustomRepeat()) {\n if (this.repeat.frequency == 'monthly' && this.repeat.month.type && this.repeat.month.type == 'byday' ||\n this.repeat.frequency == 'yearly' && this.repeat.year.byday) {\n // BYDAY mask for a monthly or yearly recurrence\n delete component.repeat.monthdays;\n component.repeat.days = [{ day: this.repeat.month.day, occurrence: this.repeat.month.occurrence.toString() }];\n }\n else if ((this.repeat.frequency == 'monthly' || this.repeat.frequency == 'yearly') &&\n this.repeat.month.type) {\n // montly recurrence by month days or yearly by month\n delete component.repeat.days;\n }\n }\n else if (this.repeat.frequency && this.repeat.frequency != 'never') {\n component.repeat = { frequency: this.repeat.frequency };\n }\n if (component.startDate && this.repeat.frequency && this.repeat.frequency != 'never') {\n if (this.repeat.end == 'until' && this.repeat.until)\n component.repeat.until = this.repeat.until.stringWithSeparator('-');\n else if (this.repeat.end == 'count' && this.repeat.count)\n component.repeat.count = this.repeat.count;\n else {\n delete component.repeat.until;\n delete component.repeat.count;\n }\n }\n else {\n delete component.repeat;\n }\n\n // Check status\n if (this.status == 'not-specified')\n delete component.status;\n else if (this.status != 'completed')\n delete component.completedDate;\n\n // Verify alarm\n if (component.startDate && this.$hasAlarm) {\n if (this.alarm.action && this.alarm.action == 'email' &&\n !(this.attendees && this.attendees.length > 0)) {\n // No attendees; email reminder must be sent to organizer only\n component.alarm.attendees = 0;\n component.alarm.organizer = 1;\n }\n }\n else {\n component.alarm = {};\n }\n\n // Build URL\n path = [this.pid, this.id];\n\n if (this.isNew)\n options = { action: 'saveAs' + this.type.capitalize() };\n\n if (this.occurrenceId)\n path.push(this.occurrenceId);\n\n angular.extend(component, extraAttributes);\n\n return Component.$$resource.save(path.join('/'), component, options)\n .then(function(data) {\n // Make a copy of the data for an eventual reset\n _this.$shadowData = _this.$omit();\n return data;\n });\n };\n\n /**\n * @function $delete\n * @memberof Component.prototype\n * @desc Delete the component from the server.\n * @param {boolean} occurrenceOnly - delete this occurrence only\n */\n Component.prototype.remove = function(occurrenceOnly) {\n var _this = this, path = [this.pid, this.id];\n\n if (occurrenceOnly && this.occurrenceId)\n path.push(this.occurrenceId);\n\n return Component.$$resource.remove(path.join('/'));\n };\n\n /**\n * @function $unwrap\n * @memberof Component.prototype\n * @desc Unwrap a promise.\n * @param {promise} futureComponentData - a promise of some of the Component's data\n */\n Component.prototype.$unwrap = function(futureComponentData) {\n var _this = this;\n\n // Expose the promise\n this.$futureComponentData = futureComponentData;\n\n // Resolve the promise\n this.$futureComponentData.then(function(data) {\n _this.init(data);\n // Make a copy of the data for an eventual reset\n _this.$shadowData = _this.$omit();\n }, function(data) {\n angular.extend(_this, data);\n _this.isError = true;\n Component.$log.error(_this.error);\n });\n };\n\n /**\n * @function $omit\n * @memberof Component.prototype\n * @desc Return a sanitized object used to send to the server.\n * @return an object literal copy of the Component instance\n */\n Component.prototype.$omit = function() {\n var component = {};\n angular.forEach(this, function(value, key) {\n if (key != 'constructor' &&\n (key == '$hasAlarm' || key[0] != '$') &&\n key != 'blocks') {\n component[key] = angular.copy(value);\n }\n });\n\n return component;\n };\n\n /**\n * @function repeatDescription\n * @memberof Component.prototype\n * @desc Return a localized description of the recurrence definition\n * @return a localized string\n */\n Component.prototype.repeatDescription = function() {\n var localizedString = null;\n if (this.repeat)\n localizedString = l('repeat_' + this.repeat.frequency.toUpperCase());\n\n return localizedString;\n };\n\n /**\n * @function alarmDescription\n * @memberof Component.prototype\n * @desc Return a localized description of the reminder definition\n * @return a localized string\n */\n Component.prototype.alarmDescription = function() {\n var key, localizedString = null;\n if (this.alarm) {\n key = ['reminder' + this.alarm.quantity, this.alarm.unit, this.alarm.reference].join('_');\n localizedString = l(key);\n if (key === localizedString)\n // No localized string for this reminder definition\n localizedString = [this.alarm.quantity,\n l('reminder_' + this.alarm.unit),\n l('reminder_' + this.alarm.reference)].join(' ');\n }\n\n return localizedString;\n };\n\n /**\n * @function copyTo\n * @memberof Component.prototype\n * @desc Copy an event to a calendar\n * @param {string} calendar - a target calendar UID\n * @returns a promise of the HTTP operation\n */\n Component.prototype.copyTo = function(calendar) {\n return Component.$$resource.post(this.pid + '/' + this.id, 'copy', {destination: calendar});\n };\n\n /**\n * @function moveTo\n * @memberof Component.prototype\n * @desc Move an event to a calendar\n * @param {string} calendar - a target calendar UID\n * @returns a promise of the HTTP operation\n */\n Component.prototype.moveTo = function(calendar) {\n return Component.$$resource.post(this.pid + '/' + this.id, 'move', {destination: calendar});\n };\n\n Component.prototype.toString = function() {\n return '[Component ' + this.id + ']';\n };\n\n\n})();\n","/* -*- Mode: javascript; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n\n(function() {\n /* jshint loopfunc: true */\n 'use strict';\n\n /**\n * @ngInject\n */\n CalendarController.$inject = ['$scope', '$rootScope', '$state', '$stateParams', 'sgHotkeys', 'Calendar', 'Component', 'Preferences', 'stateEventsBlocks'];\n function CalendarController($scope, $rootScope, $state, $stateParams, sgHotkeys, Calendar, Component, Preferences, stateEventsBlocks) {\n var vm = this, deregisterCalendarsList, hotkeys = [];\n\n // Make the toolbar state of all-day events persistent\n if (angular.isUndefined(CalendarController.expandedAllDays))\n CalendarController.expandedAllDays = false;\n\n vm.selectedDate = $stateParams.day.asDate();\n vm.expandedAllDays = CalendarController.expandedAllDays;\n vm.toggleAllDays = toggleAllDays;\n vm.views = stateEventsBlocks;\n vm.changeDate = changeDate;\n vm.changeView = changeView;\n\n\n _registerHotkeys(hotkeys);\n\n Preferences.ready().then(function() {\n _formatDate(vm.selectedDate);\n });\n\n // Refresh current view when the list of calendars is modified\n deregisterCalendarsList = $rootScope.$on('calendars:list', updateView);\n\n $scope.$on('$destroy', function() {\n // Destroy event listener when the controller is being deactivated\n deregisterCalendarsList();\n // Deregister hotkeys\n _.forEach(hotkeys, function(key) {\n sgHotkeys.deregisterHotkey(key);\n });\n });\n\n\n function _registerHotkeys(keys) {\n keys.push(sgHotkeys.createHotkey({\n key: l('hotkey_today'),\n description: l('Today'),\n callback: changeDate,\n args: new Date()\n }));\n keys.push(sgHotkeys.createHotkey({\n key: l('hotkey_dayview'),\n description: l('Day'),\n callback: changeView,\n args: 'day'\n }));\n keys.push(sgHotkeys.createHotkey({\n key: l('hotkey_weekview'),\n description: l('Week'),\n callback: changeView,\n args: 'week'\n }));\n keys.push(sgHotkeys.createHotkey({\n key: l('hotkey_monthview'),\n description: l('Month'),\n callback: changeView,\n args: 'month'\n }));\n keys.push(sgHotkeys.createHotkey({\n key: l('hotkey_multicolumndayview'),\n description: l('Multicolumn Day View'),\n callback: changeView,\n args: 'multicolumnday'\n }));\n keys.push(sgHotkeys.createHotkey({\n key: 'left',\n description: l('Move backward'),\n callback: _goToPeriod,\n args: -1\n }));\n keys.push(sgHotkeys.createHotkey({\n key: 'right',\n description: l('Move forward'),\n callback: _goToPeriod,\n args: +1\n }));\n\n // Register the hotkeys\n _.forEach(keys, function(key) {\n sgHotkeys.registerHotkey(key);\n });\n }\n\n\n function _goToPeriod($event, direction) {\n var date;\n\n if ($stateParams.view == 'week') {\n date = vm.selectedDate.beginOfWeek(Preferences.defaults.SOGoFirstDayOfWeek).addDays(7 * direction);\n }\n else if ($stateParams.view == 'month') {\n date = vm.selectedDate;\n date.setDate(1);\n date.setMonth(date.getMonth() + direction);\n }\n else {\n date = vm.selectedDate.addDays(direction);\n }\n\n changeDate($event, date);\n }\n\n /**\n * Format a date according to the current view.\n * - Day/Multicolumn: name of weekday\n * - Week: week number\n * - Month: name of month\n */\n function _formatDate(date) {\n if ($stateParams.view == 'month') {\n date.setDate(1);\n date.setHours(12);\n date.$dateFormat = '%B %Y';\n }\n else if ($stateParams.view == 'week') {\n date.setTime(date.beginOfWeek(Preferences.defaults.SOGoFirstDayOfWeek).getTime());\n date.$dateFormat = l('Week %d').replace('%d', '%U');\n }\n else {\n date.$dateFormat = '%A';\n }\n }\n\n // Expand or collapse all-day events\n function toggleAllDays() {\n CalendarController.expandedAllDays = !CalendarController.expandedAllDays;\n vm.expandedAllDays = CalendarController.expandedAllDays;\n }\n\n function updateView() {\n // The list of calendars has changed; update the views\n // See stateEventsBlocks in Scheduler.app.js\n Component.$eventsBlocksForView($stateParams.view, $stateParams.day.asDate()).then(function(data) {\n var i, j, view;\n for (i = 0; i < data.length; i++) {\n view = data[i];\n if (vm.views[i]) {\n _.forEach(view.allDayBlocks, function(blocks, day) {\n vm.views[i].allDayBlocks[day] = blocks;\n });\n _.forEach(view.blocks, function(blocks, day) {\n vm.views[i].blocks[day] = blocks;\n });\n }\n else {\n vm.views[i] = view;\n }\n if (view.id) {\n // Note: this can't be done in Component service since it would make Component dependent on\n // the Calendar service and create a circular dependency\n vm.views[i].calendar = new Calendar({ id: view.id, name: view.calendarName });\n }\n }\n // Remove previous views\n for (j = vm.views.length; j >= i; j--)\n vm.views.splice(j, 1);\n });\n }\n\n // Change calendar's date\n function changeDate($event, newDate) {\n var date = newDate? newDate.getDayString() : angular.element($event.currentTarget).attr('date');\n if (newDate)\n _formatDate(newDate);\n $state.go('calendars.view', { day: date });\n }\n\n // Change calendar's view\n function changeView($event, view) {\n $state.go('calendars.view', { view: view });\n }\n}\n\n angular\n .module('SOGo.SchedulerUI') \n .controller('CalendarController', CalendarController);\n})();\n","/* -*- Mode: javascript; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n\n(function() {\n 'use strict';\n\n /**\n * @ngInject\n */\n CalendarListController.$inject = ['$rootScope', '$scope', '$timeout', '$state', '$mdDialog', 'sgHotkeys', 'sgFocus', 'Dialog', 'Preferences', 'CalendarSettings', 'Calendar', 'Component', 'Alarm'];\n function CalendarListController($rootScope, $scope, $timeout, $state, $mdDialog, sgHotkeys, focus, Dialog, Preferences, CalendarSettings, Calendar, Component, Alarm) {\n var vm = this, hotkeys = [];\n\n vm.component = Component;\n vm.componentType = 'events';\n vm.selectedList = 0;\n vm.selectComponentType = selectComponentType;\n vm.unselectComponents = unselectComponents;\n vm.selectAll = selectAll;\n vm.searchMode = searchMode;\n vm.toggleComponentSelection = toggleComponentSelection;\n vm.confirmDeleteSelectedComponents = confirmDeleteSelectedComponents;\n vm.openEvent = openEvent;\n vm.openTask = openTask;\n vm.newComponent = newComponent;\n vm.filterpopup = filterpopup;\n vm.filter = filter;\n vm.filteredBy = filteredBy;\n vm.sort = sort;\n vm.sortedBy = sortedBy;\n vm.reload = reload;\n vm.cancelSearch = cancelSearch;\n vm.mode = { search: false, multiple: 0 };\n\n\n _registerHotkeys(hotkeys);\n\n // Select list based on user's settings\n Preferences.ready().then(function() {\n var type = 'events';\n if (Preferences.settings.Calendar.SelectedList == 'tasksListView') {\n vm.selectedList = 1;\n type = 'tasks';\n }\n selectComponentType(type, { reload: true }); // fetch events/tasks lists\n });\n\n // Refresh current list when the list of calendars is modified\n $rootScope.$on('calendars:list', function() {\n Component.$filter(vm.componentType, { reload: true });\n });\n\n // Update the component being dragged\n $rootScope.$on('calendar:dragend', updateComponentFromGhost);\n\n $scope.$on('$destroy', function() {\n // Deregister hotkeys\n _.forEach(hotkeys, function(key) {\n sgHotkeys.deregisterHotkey(key);\n });\n });\n\n\n function _registerHotkeys(keys) {\n keys.push(sgHotkeys.createHotkey({\n key: l('hotkey_search'),\n description: l('Search'),\n callback: searchMode\n }));\n keys.push(sgHotkeys.createHotkey({\n key: l('hotkey_create_event'),\n description: l('Create a new event'),\n callback: newComponent,\n args: 'appointment'\n }));\n keys.push(sgHotkeys.createHotkey({\n key: l('hotkey_create_task'),\n description: l('Create a new task'),\n callback: newComponent,\n args: 'task'\n }));\n\n // Register the hotkeys\n _.forEach(keys, function(key) {\n sgHotkeys.registerHotkey(key);\n });\n }\n\n // Switch between components tabs\n function selectComponentType(type, options) {\n if (options && options.reload || vm.componentType != type) {\n if (angular.isUndefined(Component['$' + type]))\n Component.$filter(type);\n vm.unselectComponents();\n vm.componentType = type;\n Component.saveSelectedList(type);\n }\n }\n\n function unselectComponents() {\n _.forEach(Component['$' + vm.componentType], function(component) {\n component.selected = false;\n });\n vm.mode.multiple = 0;\n }\n\n function selectAll() {\n _.forEach(Component['$' + vm.componentType], function(component) {\n component.selected = true;\n });\n vm.mode.multiple = Component['$' + vm.componentType].length;\n }\n\n function toggleComponentSelection($event, component) {\n component.selected = !component.selected;\n vm.mode.multiple += component.selected? 1 : -1;\n $event.preventDefault();\n $event.stopPropagation();\n }\n\n function searchMode() {\n vm.mode.search = true;\n focus('search');\n }\n\n function confirmDeleteSelectedComponents() {\n Dialog.confirm(l('Warning'),\n l('Are you sure you want to delete the selected components?'),\n { ok: l('Delete') })\n .then(function() {\n // User confirmed the deletion\n var components = _.filter(Component['$' + vm.componentType], function(component) {\n return component.selected;\n });\n Calendar.$deleteComponents(components).then(function() {\n vm.mode.multiple = 0;\n $rootScope.$emit('calendars:list');\n });\n });\n }\n\n function openEvent($event, event) {\n openComponent($event, event, 'appointment');\n }\n\n function openTask($event, task) {\n openComponent($event, task, 'task');\n }\n\n function openComponent($event, component, type) {\n if (component.viewable) {\n // UI/Templates/SchedulerUI/UIxAppointmentViewTemplate.wox or\n // UI/Templates/SchedulerUI/UIxTaskViewTemplate.wox\n var templateUrl = 'UIx' + type.capitalize() + 'ViewTemplate';\n $mdDialog.show({\n parent: angular.element(document.body),\n targetEvent: $event,\n clickOutsideToClose: true,\n escapeToClose: true,\n templateUrl: templateUrl,\n controller: 'ComponentController',\n controllerAs: 'editor',\n locals: {\n stateComponent: component\n }\n });\n }\n }\n\n function newComponent($event, type, baseComponent) {\n var component;\n\n if (baseComponent) {\n component = baseComponent;\n }\n else {\n component = new Component({ pid: Calendar.$defaultCalendar(), type: type });\n }\n\n // UI/Templates/SchedulerUI/UIxAppointmentEditorTemplate.wox or\n // UI/Templates/SchedulerUI/UIxTaskEditorTemplate.wox\n var templateUrl = 'UIx' + type.capitalize() + 'EditorTemplate';\n return $mdDialog.show({\n parent: angular.element(document.body),\n targetEvent: $event,\n clickOutsideToClose: true,\n escapeToClose: true,\n templateUrl: templateUrl,\n controller: 'ComponentEditorController',\n controllerAs: 'editor',\n locals: {\n stateComponent: component\n }\n });\n }\n\n // Adjust component or create new component through drag'n'drop\n function updateComponentFromGhost($event) {\n var component, pointerHandler, coordinates, delta, params, calendarNumber, activeCalendars;\n\n component = Component.$ghost.component;\n pointerHandler = Component.$ghost.pointerHandler;\n\n if (component.isNew) {\n coordinates = pointerHandler.currentEventCoordinates;\n component.summary = '';\n if (component.isAllDay)\n coordinates.duration -= 96;\n component.setDelta(coordinates.duration * 15);\n newComponent(null, 'appointment', component).finally(function() {\n $timeout(function() {\n Component.$resetGhost();\n });\n });\n }\n else {\n delta = pointerHandler.currentEventCoordinates.getDelta(pointerHandler.originalEventCoordinates);\n params = {\n days: delta.dayNumber,\n start: delta.start * 15,\n duration: delta.duration * 15\n };\n if (pointerHandler.originalCalendar && delta.dayNumber !== 0) {\n // The day number actually represents the destination calendar among the active calendars\n calendarNumber = pointerHandler.currentEventCoordinates.dayNumber;\n activeCalendars = _.filter(Calendar.$findAll(), { active: 1 });\n params.destination = activeCalendars[calendarNumber].id;\n params.days = 0;\n }\n if (component.isException || !component.occurrenceId)\n // Component is an exception to a recurrence or is not recurrent;\n // Immediately perform the adjustments\n component.$adjust(params).then(function() {\n $rootScope.$emit('calendars:list');\n Alarm.getAlarms();\n }, function(response) {\n onComponentAdjustError(response, component, params);\n }).finally(function() {\n $timeout(function() {\n Component.$resetGhost();\n });\n });\n else if (component.occurrenceId) {\n $mdDialog.show({\n clickOutsideToClose: true,\n escapeToClose: true,\n locals: {\n component: component,\n params: params\n },\n template: [\n '<md-dialog flex=\"50\" sm-flex=\"80\" xs-flex=\"90\">',\n ' <md-dialog-content class=\"md-dialog-content\">',\n ' <p>' + l('editRepeatingItem') + '</p>',\n ' </md-dialog-content>',\n ' <md-dialog-actions>',\n ' <md-button ng-click=\"updateThisOccurrence()\">' + l('button_thisOccurrenceOnly') + '</md-button>',\n ' <md-button ng-click=\"updateAllOccurrences()\">' + l('button_allOccurrences') + '</md-button>',\n ' </md-dialog-actions>',\n '</md-dialog>'\n ].join(''),\n controller: RecurrentComponentDialogController\n }).then(function() {\n $rootScope.$emit('calendars:list');\n }).finally(function() {\n $timeout(function() {\n Component.$resetGhost();\n });\n });\n }\n }\n\n /**\n * @ngInject\n */\n RecurrentComponentDialogController.$inject = ['$scope', '$mdDialog', 'component', 'params'];\n function RecurrentComponentDialogController($scope, $mdDialog, component, params) {\n $scope.updateThisOccurrence = function() {\n component.$adjust(params).then($mdDialog.hide, function(response) {\n $mdDialog.cancel().then(function() {\n onComponentAdjustError(response, component, params);\n });\n });\n };\n $scope.updateAllOccurrences = function() {\n delete component.occurrenceId;\n component.$adjust(params).then($mdDialog.hide, function(response) {\n $mdDialog.cancel().then(function() {\n onComponentAdjustError(response, component, params);\n });\n });\n };\n }\n\n function onComponentAdjustError(response, component, params) {\n if (response.status == CalendarSettings.ConflictHTTPErrorCode &&\n response.data && response.data.message && angular.isObject(response.data.message)) {\n $mdDialog.show({\n parent: angular.element(document.body),\n clickOutsideToClose: false,\n escapeToClose: false,\n templateUrl: 'UIxAttendeeConflictDialog',\n controller: AttendeeConflictDialogController,\n controllerAs: '$AttendeeConflictDialogController',\n locals: {\n component: component,\n params: params,\n conflictError: response.data.message\n }\n }).then(function() {\n $rootScope.$emit('calendars:list');\n });\n }\n }\n\n /**\n * @ngInject\n */\n AttendeeConflictDialogController.$inject = ['$scope', '$mdDialog', 'component', 'params', 'conflictError'];\n function AttendeeConflictDialogController($scope, $mdDialog, component, params, conflictError) {\n var vm = this;\n\n vm.conflictError = conflictError;\n vm.cancel = $mdDialog.cancel;\n vm.save = save;\n\n function save() {\n component.$adjust(angular.extend({ ignoreConflicts: true }, params)).then($mdDialog.hide);\n }\n }\n }\n\n function filterpopup() {\n return Component['$query' + vm.componentType.capitalize()].filterpopup;\n }\n\n function filter(filterpopup) {\n Component.$filter(vm.componentType, { filterpopup: filterpopup });\n }\n\n function filteredBy(filterpopup) {\n return Component['$query' + vm.componentType.capitalize()].filterpopup == filterpopup;\n }\n\n function sort(field) {\n Component.$filter(vm.componentType, { sort: field });\n }\n\n function sortedBy(field) {\n return Component['$query' + vm.componentType.capitalize()].sort == field;\n }\n\n function reload() {\n Calendar.reloadWebCalendars().finally(function() {\n $rootScope.$emit('calendars:list');\n });\n }\n\n function cancelSearch() {\n vm.mode.search = false;\n Component.$filter(vm.componentType, { value: '' });\n }\n }\n\n angular\n .module('SOGo.SchedulerUI')\n .controller('CalendarListController', CalendarListController);\n})();\n","/* -*- Mode: javascript; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n\n(function() {\n 'use strict';\n\n /**\n * @ngInject\n */\n CalendarsController.$inject = ['$rootScope', '$scope', '$window', '$mdDialog', '$log', '$mdToast', 'FileUploader', 'sgFocus', 'Dialog', 'sgSettings', 'Preferences', 'Calendar', 'User', 'stateCalendars'];\n function CalendarsController($rootScope, $scope, $window, $mdDialog, $log, $mdToast, FileUploader, focus, Dialog, Settings, Preferences, Calendar, User, stateCalendars) {\n var vm = this;\n\n vm.activeUser = Settings.activeUser;\n vm.service = Calendar;\n vm.newCalendar = newCalendar;\n vm.addWebCalendar = addWebCalendar;\n vm.confirmDelete = confirmDelete;\n vm.editFolder = editFolder;\n vm.revertEditing = revertEditing;\n vm.renameFolder = renameFolder;\n vm.share = share;\n vm.importCalendar = importCalendar;\n vm.showOnly = showOnly;\n vm.showAll = showAll;\n vm.showLinks = showLinks;\n vm.showProperties = showProperties;\n vm.subscribeToFolder = subscribeToFolder;\n // vm.today = today;\n\n vm.filter = { name: '' };\n vm.sortableMode = false;\n vm.toggleSortableMode = toggleSortableMode;\n vm.resetSort = resetSort;\n vm.sortableCalendars = {\n scrollableContainer: '#sidenav-content',\n containment: 'md-list',\n orderChanged: _sortableEnd,\n accept: _sortableAccept\n };\n\n Preferences.ready().then(function() {\n vm.categories = _.map(Preferences.defaults.SOGoCalendarCategories, function(name) {\n return { id: name.asCSSIdentifier(),\n name: name,\n color: Preferences.defaults.SOGoCalendarCategoriesColors[name]\n };\n });\n });\n\n // Dispatch the event named 'calendars:list' when a calendar is activated or deactivated or\n // when the color of a calendar is changed\n $scope.$watch(\n function() {\n return _.union(\n _.map(Calendar.$calendars, function(o) { return _.pick(o, ['id', 'active', 'color']); }),\n _.map(Calendar.$subscriptions, function(o) { return _.pick(o, ['id', 'active', 'color']); }),\n _.map(Calendar.$webcalendars, function(o) { return _.pick(o, ['id', 'active', 'color']); })\n );\n },\n function(newList, oldList) {\n var commonList, ids, promise;\n\n // Identify which calendar has changed\n commonList = _.intersectionBy(newList, oldList, 'id');\n ids = _.map(_.filter(commonList, function(o) {\n var oldObject = _.find(oldList, { id: o.id });\n return !_.isEqual(o, oldObject);\n }), 'id');\n promise = Calendar.$q.when();\n\n if (ids.length > 0) {\n $log.debug(ids.join(', ') + ' changed');\n promise = Calendar.saveFoldersActivation(ids);\n }\n if (ids.length > 0 || commonList.length != newList.length || commonList.length != oldList.length)\n promise.then(function() {\n $rootScope.$emit('calendars:list');\n });\n },\n true // compare for object equality\n );\n\n /**\n * Only allow to sort items within the same list.\n */\n function _sortableAccept(sourceItemHandleScope, destSortableScope, destItemScope) {\n return sourceItemHandleScope.sortableScope.element[0] == destSortableScope.element[0];\n }\n\n function _sortableEnd() {\n Calendar.saveFoldersOrder(_.flatMap(Calendar.$findAll(), 'id'));\n }\n\n function toggleSortableMode() {\n vm.sortableMode = !vm.sortableMode;\n vm.filter.name = '';\n }\n\n function resetSort() {\n Calendar.saveFoldersOrder();\n }\n\n function newCalendar(ev) {\n Dialog.prompt(l('New calendar'), l('Name of the Calendar'))\n .then(function(name) {\n var calendar = new Calendar(\n {\n name: name,\n isEditable: true,\n isRemote: false,\n owner: UserLogin\n }\n );\n calendar.$id().then(function() {\n Calendar.$add(calendar);\n });\n });\n }\n\n function addWebCalendar() {\n Dialog.prompt(l('Subscribe to a web calendar...'), l('URL of the Calendar'), {inputType: 'url'})\n .then(function(url) {\n Calendar.$addWebCalendar(url).then(function(calendar) {\n if (angular.isObject(calendar)) {\n // Web calendar requires HTTP authentication\n $mdDialog.show({\n parent: angular.element(document.body),\n clickOutsideToClose: true,\n escapeToClose: true,\n templateUrl: 'UIxWebCalendarAuthDialog',\n controller: WebCalendarAuthDialogController,\n controllerAs: '$WebCalendarAuthDialogController',\n locals: {\n url: url,\n calendar: calendar\n }\n });\n }\n });\n });\n\n /**\n * @ngInject\n */\n WebCalendarAuthDialogController.$inject = ['scope', '$mdDialog', 'url', 'calendar'];\n function WebCalendarAuthDialogController(scope, $mdDialog, url, calendar) {\n var vm = this,\n parts = url.split(\"/\"),\n hostname = parts[2];\n\n vm.title = l(\"Please identify yourself to %{0}\").formatted(hostname);\n vm.authenticate = function(form) {\n if (form.$valid || !form.$error.required) {\n calendar.setCredentials(vm.username, vm.password).then(function(message) {\n $mdDialog.hide();\n }, function(reason) {\n form.password.$setValidity('credentials', false);\n });\n }\n };\n vm.cancel = function() {\n $mdDialog.cancel();\n };\n }\n }\n\n function confirmDelete(folder) {\n if (folder.isSubscription) {\n // Unsubscribe without confirmation\n folder.$delete()\n .catch(function(data, status) {\n Dialog.alert(l('An error occured while deleting the calendar \"%{0}\".', folder.name),\n l(data.error));\n });\n }\n else {\n Dialog.confirm(l('Warning'), l('Are you sure you want to delete the calendar \"%{0}\"?', folder.name),\n { ok: l('Delete') })\n .then(function() {\n folder.$delete()\n .catch(function(data, status) {\n Dialog.alert(l('An error occured while deleting the calendar \"%{0}\".', folder.name),\n l(data.error));\n });\n });\n }\n }\n\n function importCalendar($event, folder) {\n $mdDialog.show({\n parent: angular.element(document.body),\n targetEvent: $event,\n clickOutsideToClose: true,\n escapeToClose: true,\n templateUrl: 'UIxCalendarImportDialog',\n controller: CalendarImportDialogController,\n controllerAs: '$CalendarImportDialogController',\n locals: {\n folder: folder\n }\n });\n\n /**\n * @ngInject\n */\n CalendarImportDialogController.$inject = ['scope', '$mdDialog', 'folder'];\n function CalendarImportDialogController(scope, $mdDialog, folder) {\n var vm = this;\n\n vm.uploader = new FileUploader({\n url: ApplicationBaseURL + [folder.id, 'import'].join('/'),\n autoUpload: true,\n queueLimit: 1,\n filters: [{ name: filterByExtension, fn: filterByExtension }],\n onSuccessItem: function(item, response, status, headers) {\n var msg;\n\n $mdDialog.hide();\n\n if (response.imported === 0)\n msg = l('No event was imported.');\n else {\n msg = l('A total of %{0} events were imported in the calendar.', response.imported);\n $rootScope.$emit('calendars:list');\n }\n\n $mdToast.show(\n $mdToast.simple()\n .content(msg)\n .position('top right')\n .hideDelay(3000));\n },\n onErrorItem: function(item, response, status, headers) {\n $mdToast.show({\n template: [\n '<md-toast>',\n ' <div class=\"md-toast-content\">',\n ' <md-icon class=\"md-warn md-hue-1\">error_outline</md-icon>',\n ' <span>' + l('An error occurred while importing calendar.') + '</span>',\n ' </div>',\n '</md-toast>'\n ].join(''),\n position: 'top right',\n hideDelay: 3000\n });\n }\n });\n\n vm.close = function() {\n $mdDialog.hide();\n };\n\n function filterByExtension(item) {\n var isTextFile = item.type.indexOf('text') === 0 ||\n /\\.(ics)$/.test(item.name);\n\n if (!isTextFile)\n $mdToast.show({\n template: [\n '<md-toast>',\n ' <div class=\"md-toast-content\">',\n ' <md-icon class=\"md-warn md-hue-1\">error_outline</md-icon>',\n ' <span>' + l('Select an iCalendar file (.ics).') + '</span>',\n ' </div>',\n '</md-toast>'\n ].join(''),\n position: 'top right',\n hideDelay: 3000\n });\n\n return isTextFile;\n }\n }\n }\n\n function showOnly(calendar) {\n _.forEach(Calendar.$findAll(), function(o) {\n if (calendar.id == o.id)\n o.active = 1;\n else\n o.active = 0;\n });\n }\n\n function showAll() {\n _.forEach(Calendar.$findAll(), function(o) { o.active = 1; });\n }\n\n function showLinks(calendar) {\n $mdDialog.show({\n parent: angular.element(document.body),\n clickOutsideToClose: true,\n escapeToClose: true,\n templateUrl: calendar.id + '/links',\n controller: LinksDialogController,\n controllerAs: 'links',\n locals: {\n calendar: calendar\n }\n });\n \n /**\n * @ngInject\n */\n LinksDialogController.$inject = ['$mdDialog', 'calendar'];\n function LinksDialogController($mdDialog, calendar) {\n var vm = this;\n vm.calendar = calendar;\n vm.close = close;\n\n function close() {\n $mdDialog.hide();\n }\n }\n }\n\n function showProperties(calendar) {\n var color = calendar.color;\n $mdDialog.show({\n templateUrl: calendar.id + '/properties',\n controller: PropertiesDialogController,\n controllerAs: 'properties',\n clickOutsideToClose: true,\n escapeToClose: true,\n locals: {\n srcCalendar: calendar\n }\n }).catch(function() {\n // Restore original color when cancelling or closing the dialog\n calendar.color = color;\n });\n \n /**\n * @ngInject\n */\n PropertiesDialogController.$inject = ['$scope', '$mdDialog', 'srcCalendar'];\n function PropertiesDialogController($scope, $mdDialog, srcCalendar) {\n var vm = this;\n\n vm.calendar = new Calendar(srcCalendar.$omit());\n vm.saveProperties = saveProperties;\n vm.close = close;\n\n $scope.$watch(function() { return vm.calendar.color; }, function() {\n srcCalendar.color = vm.calendar.color;\n });\n\n function saveProperties() {\n vm.calendar.$save();\n // Refresh list instance\n srcCalendar.init(vm.calendar.$omit());\n $mdDialog.hide();\n }\n\n function close() {\n $mdDialog.cancel();\n }\n }\n }\n\n function editFolder(folder) {\n vm.calendarName = folder.name;\n vm.editMode = folder.id;\n focus('calendarName_' + folder.id);\n }\n\n function revertEditing(folder) {\n folder.$reset();\n vm.editMode = false;\n }\n\n function renameFolder(folder) {\n folder.$rename()\n .then(function(data) {\n vm.editMode = false;\n });\n }\n\n function share(calendar) {\n calendar.$acl.$users().then(function() {\n $mdDialog.show({\n templateUrl: calendar.id + '/UIxAclEditor', // UI/Templates/UIxAclEditor.wox\n controller: 'AclController', // from the ng module SOGo.Common\n controllerAs: 'acl',\n clickOutsideToClose: true,\n escapeToClose: true,\n locals: {\n usersWithACL: calendar.$acl.users,\n User: User,\n folder: calendar\n }\n });\n });\n }\n\n // Callback of sgSubscribe directive\n function subscribeToFolder(calendarData) {\n $log.debug('subscribeToFolder ' + calendarData.owner + calendarData.name);\n Calendar.$subscribe(calendarData.owner, calendarData.name).then(function(data) {\n $mdToast.show(\n $mdToast.simple()\n .content(l('Successfully subscribed to calendar'))\n .position('top right')\n .hideDelay(3000));\n });\n }\n\n // function today() {\n // var fragments = $window.location.hash.split('/'),\n // state = fragments[1],\n // view = fragments[2],\n // now = new Date(),\n // path = ['#', state, view, now.getDayString()];\n // $window.location = path.join('/');\n // }\n }\n\n angular\n .module('SOGo.SchedulerUI')\n .controller('CalendarsController', CalendarsController);\n})();\n","/* -*- Mode: javascript; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n\n(function() {\n 'use strict';\n\n /**\n * @ngInject\n */\n ComponentController.$inject = ['$rootScope', '$mdDialog', 'Calendar', 'Component', 'AddressBook', 'Alarm', 'Account', 'stateComponent'];\n function ComponentController($rootScope, $mdDialog, Calendar, Component, AddressBook, Alarm, Account, stateComponent) {\n var vm = this, component;\n\n vm.calendarService = Calendar;\n vm.service = Component;\n vm.component = stateComponent;\n vm.close = close;\n vm.cardFilter = cardFilter;\n vm.newMessageWithAllRecipients = newMessageWithAllRecipients;\n vm.newMessageWithRecipient = newMessageWithRecipient;\n vm.edit = edit;\n vm.editAllOccurrences = editAllOccurrences;\n vm.reply = reply;\n vm.replyAllOccurrences = replyAllOccurrences;\n vm.deleteOccurrence = deleteOccurrence;\n vm.deleteAllOccurrences = deleteAllOccurrences;\n vm.toggleRawSource = toggleRawSource;\n vm.copySelectedComponent = copySelectedComponent;\n vm.moveSelectedComponent = moveSelectedComponent;\n\n // Load all attributes of component\n if (angular.isUndefined(vm.component.$futureComponentData)) {\n component = Calendar.$get(vm.component.pid).$getComponent(vm.component.id, vm.component.occurrenceId);\n component.$futureComponentData.then(function() {\n vm.component = component;\n vm.organizer = [vm.component.organizer];\n });\n }\n\n function close() {\n $mdDialog.hide();\n }\n\n // Autocomplete cards for attendees\n function cardFilter($query) {\n return AddressBook.$filterAll($query);\n }\n\n function newMessageWithAllRecipients($event) {\n var recipients = _.map(vm.component.attendees, function(attendee) {\n return attendee.name + \" <\" + attendee.email + \">\";\n });\n _newMessage($event, recipients);\n }\n\n function newMessageWithRecipient($event, name, email) {\n _newMessage($event, [name + \" <\" + email + \">\"]);\n }\n\n function _newMessage($event, recipients) {\n Account.$findAll().then(function(accounts) {\n var account = _.find(accounts, function(o) {\n if (o.id === 0)\n return o;\n });\n\n // We must initialize the Account with its mailbox\n // list before proceeding with message's creation\n account.$getMailboxes().then(function(mailboxes) {\n account.$newMessage().then(function(message) {\n angular.extend(message.editable, { to: recipients, subject: vm.component.summary });\n $mdDialog.show({\n parent: angular.element(document.body),\n targetEvent: $event,\n clickOutsideToClose: false,\n escapeToClose: false,\n templateUrl: '../Mail/UIxMailEditor',\n controller: 'MessageEditorController',\n controllerAs: 'editor',\n locals: {\n stateAccount: account,\n stateMessage: message\n }\n });\n });\n });\n });\n\n $event.preventDefault();\n $event.stopPropagation();\n }\n\n function edit() {\n var type = (vm.component.component == 'vevent')? 'Appointment':'Task';\n $mdDialog.hide().then(function() {\n // UI/Templates/SchedulerUI/UIxAppointmentEditorTemplate.wox or\n // UI/Templates/SchedulerUI/UIxTaskEditorTemplate.wox\n var templateUrl = 'UIx' + type + 'EditorTemplate';\n $mdDialog.show({\n parent: angular.element(document.body),\n clickOutsideToClose: true,\n escapeToClose: true,\n templateUrl: templateUrl,\n controller: 'ComponentEditorController',\n controllerAs: 'editor',\n locals: {\n stateComponent: vm.component\n }\n });\n });\n }\n\n function editAllOccurrences() {\n component = Calendar.$get(vm.component.pid).$getComponent(vm.component.id);\n component.$futureComponentData.then(function() {\n vm.component = component;\n edit();\n });\n }\n\n function reply(component) {\n var c = component || vm.component;\n\n c.$reply().then(function() {\n $rootScope.$emit('calendars:list');\n Alarm.getAlarms();\n $mdDialog.hide();\n });\n }\n\n function replyAllOccurrences() {\n // Retrieve master event\n component = Calendar.$get(vm.component.pid).$getComponent(vm.component.id);\n component.$futureComponentData.then(function() {\n // Propagate the participant status and alarm to the master event\n component.reply = vm.component.reply;\n component.delegatedTo = vm.component.delegatedTo;\n component.$hasAlarm = vm.component.$hasAlarm;\n component.alarm = vm.component.alarm;\n // Send reply to the server\n reply(component);\n });\n }\n\n function deleteOccurrence() {\n vm.component.remove(true).then(function() {\n $rootScope.$emit('calendars:list');\n $mdDialog.hide();\n });\n }\n\n function deleteAllOccurrences() {\n vm.component.remove().then(function() {\n $rootScope.$emit('calendars:list');\n $mdDialog.hide();\n });\n }\n\n function toggleRawSource($event) {\n Calendar.$$resource.post(vm.component.pid + '/' + vm.component.id, \"raw\").then(function(data) {\n $mdDialog.hide();\n $mdDialog.show({\n parent: angular.element(document.body),\n targetEvent: $event,\n clickOutsideToClose: true,\n escapeToClose: true,\n template: [\n '<md-dialog flex=\"40\" flex-sm=\"80\" flex-xs=\"100\" aria-label=\"' + l('View Raw Source') + '\">',\n ' <md-dialog-content class=\"md-dialog-content\">',\n ' <pre ng-bind-html=\"data\"></pre>',\n ' </md-dialog-content>',\n ' <md-dialog-actions>',\n ' <md-button ng-click=\"close()\">' + l('Close') + '</md-button>',\n ' </md-dialog-actions>',\n '</md-dialog>'\n ].join(''),\n controller: ComponentRawSourceDialogController,\n locals: { data: data }\n });\n\n /**\n * @ngInject\n */\n ComponentRawSourceDialogController.$inject = ['scope', '$mdDialog', 'data'];\n function ComponentRawSourceDialogController(scope, $mdDialog, data) {\n scope.data = data;\n scope.close = function() {\n $mdDialog.hide();\n };\n }\n });\n }\n\n function copySelectedComponent(calendar) {\n vm.component.copyTo(calendar).then(function() {\n $mdDialog.hide();\n $rootScope.$emit('calendars:list');\n });\n }\n\n function moveSelectedComponent(calendar) {\n vm.component.moveTo(calendar).then(function() {\n $mdDialog.hide();\n $rootScope.$emit('calendars:list');\n });\n }\n }\n\n /**\n * @ngInject\n */\n ComponentEditorController.$inject = ['$rootScope', '$scope', '$log', '$timeout', '$mdDialog', 'User', 'CalendarSettings', 'Calendar', 'Component', 'AddressBook', 'Card', 'Alarm', 'stateComponent'];\n function ComponentEditorController($rootScope, $scope, $log, $timeout, $mdDialog, User, CalendarSettings, Calendar, Component, AddressBook, Card, Alarm, stateComponent) {\n var vm = this, component, oldStartDate, oldEndDate, oldDueDate;\n\n vm.service = Calendar;\n vm.component = stateComponent;\n vm.categories = {};\n vm.showRecurrenceEditor = vm.component.$hasCustomRepeat;\n vm.toggleRecurrenceEditor = toggleRecurrenceEditor;\n vm.recurrenceMonthDaysAreRequired = recurrenceMonthDaysAreRequired;\n vm.showAttendeesEditor = false;\n vm.toggleAttendeesEditor = toggleAttendeesEditor;\n //vm.searchText = null;\n vm.cardFilter = cardFilter;\n vm.addAttendee = addAttendee;\n vm.removeAttendee = removeAttendee;\n vm.addAttachUrl = addAttachUrl;\n vm.priorityLevel = priorityLevel;\n vm.reset = reset;\n vm.cancel = cancel;\n vm.edit = edit;\n vm.save = save;\n vm.attendeeConflictError = false;\n vm.attendeesEditor = {\n days: getDays(),\n hours: getHours()\n };\n vm.addStartDate = addStartDate;\n vm.addDueDate = addDueDate;\n\n // Synchronize start and end dates\n vm.adjustStartTime = adjustStartTime;\n vm.adjustEndTime = adjustEndTime;\n vm.adjustDueTime = adjustDueTime;\n\n if (vm.component.start)\n oldStartDate = new Date(vm.component.start.getTime());\n if (vm.component.end)\n oldEndDate = new Date(vm.component.end.getTime());\n if (vm.component.due)\n oldDueDate = new Date(vm.component.due.getTime());\n\n function addAttachUrl() {\n var i = vm.component.addAttachUrl('');\n focus('attachUrl_' + i);\n }\n\n function toggleRecurrenceEditor() {\n vm.showRecurrenceEditor = !vm.showRecurrenceEditor;\n vm.component.$hasCustomRepeat = vm.showRecurrenceEditor;\n }\n\n function toggleAttendeesEditor() {\n vm.showAttendeesEditor = !vm.showAttendeesEditor;\n }\n\n function recurrenceMonthDaysAreRequired() {\n return vm.component.repeat.frequency == 'monthly' &&\n vm.component.repeat.month.type == 'bymonthday';\n }\n\n // Autocomplete cards for attendees\n function cardFilter($query) {\n AddressBook.$filterAll($query);\n return AddressBook.$cards;\n }\n\n function addAttendee(card) {\n if (angular.isString(card)) {\n // User pressed \"Enter\" in search field, adding a non-matching card\n if (card.isValidEmail()) {\n vm.component.addAttendee(new Card({ emails: [{ value: card }] }));\n vm.searchText = '';\n }\n }\n else {\n vm.component.addAttendee(card);\n }\n }\n\n function removeAttendee(attendee, form) {\n vm.component.deleteAttendee(attendee);\n if (vm.component.attendees.length === 0)\n vm.showAttendeesEditor = false;\n form.$setDirty();\n }\n\n function priorityLevel() {\n if (vm.component && vm.component.priority) {\n if (vm.component.priority > 5)\n return l('low');\n else if (vm.component.priority > 4)\n return l('normal');\n else\n return l('high');\n }\n }\n\n function save(form, options) {\n if (form.$valid) {\n vm.component.$save(options)\n .then(function(data) {\n $rootScope.$emit('calendars:list');\n Alarm.getAlarms();\n $mdDialog.hide();\n }, function(response) {\n if (response.status == CalendarSettings.ConflictHTTPErrorCode &&\n _.isObject(response.data.message))\n vm.attendeeConflictError = response.data.message;\n else\n edit(form);\n });\n }\n }\n\n function reset(form) {\n vm.component.$reset();\n form.$setPristine();\n }\n\n function cancel(form) {\n reset(form);\n if (vm.component.isNew) {\n // Cancelling the creation of a component\n vm.component = null;\n }\n $mdDialog.cancel();\n }\n\n function edit(form) {\n vm.attendeeConflictError = false;\n form.$setPristine();\n form.$setDirty();\n }\n\n function getDays() {\n var days = [];\n\n if (vm.component.start && vm.component.end)\n days = vm.component.start.daysUpTo(vm.component.end);\n\n return _.map(days, function(date) {\n return { stringWithSeparator: date.stringWithSeparator(),\n getDayString: date.getDayString() };\n });\n }\n\n function getHours() {\n var hours = [];\n for (var i = 0; i <= 23; i++) {\n hours.push(i.toString());\n }\n return hours;\n }\n\n function addStartDate() {\n vm.component.$addStartDate();\n oldStartDate = new Date(vm.component.start.getTime());\n }\n\n function addDueDate() {\n vm.component.$addDueDate();\n oldDueDate = new Date(vm.component.due.getTime());\n }\n\n function adjustStartTime() {\n if (vm.component.start) {\n // Preserve the delta between the start and end dates\n var delta;\n delta = oldStartDate.valueOf() - vm.component.start.valueOf();\n if (delta !== 0) {\n oldStartDate = new Date(vm.component.start.getTime());\n if (vm.component.type === 'appointment') {\n vm.component.end = new Date(vm.component.start.getTime());\n vm.component.end.addMinutes(vm.component.delta);\n oldEndDate = new Date(vm.component.end.getTime());\n }\n updateFreeBusy();\n }\n }\n }\n\n function adjustEndTime() {\n if (vm.component.end) {\n // The end date must be after the start date\n var delta = oldEndDate.valueOf() - vm.component.end.valueOf();\n if (delta !== 0) {\n delta = vm.component.start.minutesTo(vm.component.end);\n if (delta < 0)\n vm.component.end = new Date(oldEndDate.getTime());\n else {\n vm.component.delta = delta;\n oldEndDate = new Date(vm.component.end.getTime());\n }\n updateFreeBusy();\n }\n }\n }\n\n function adjustDueTime() {\n oldDueDate = new Date(vm.component.due.getTime());\n }\n\n function updateFreeBusy() {\n vm.attendeesEditor.days = getDays();\n vm.component.updateFreeBusy();\n }\n }\n\n angular\n .module('SOGo.SchedulerUI')\n .controller('ComponentController', ComponentController)\n .controller('ComponentEditorController', ComponentEditorController);\n})();\n","/* -*- Mode: javascript; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n\n(function() {\n /* jshint validthis: true */\n 'use strict';\n\n /*\n * sgCalendarDay - An element that represents a day in the calendar's view\n * @memberof SOGo.SchedulerUI\n * @restrict element\n * @param {string} sgDay - the day of the events to display (YYYYMMDD)\n * @param {string} sgDayString - the day in ISO8601 format (YYYY-MM-DDTHH:MM+-HH:MM)\n * @param {number} sgDayNumber - the day index within the calendar's view\n *\n * @example:\n\n <sg-calendar-day\n sg-day-string=\"2015-11-01T00:00-05:00\"\n sg-day-number=\"0\"\n sg-day=\"20151101\">\n ..\n </sg-calendar-day-table>\n */\n function sgCalendarDay() {\n return {\n restrict: 'E',\n scope: {\n day: '@sgDay',\n dayNumber: '@sgDayNumber',\n dayString: '@sgDayString',\n calendar: '@sgCalendar'\n },\n controller: sgCalendarDayController\n };\n }\n\n /**\n * @ngInject\n */\n sgCalendarDayController.$inject = ['$scope', 'Calendar'];\n function sgCalendarDayController($scope, Calendar) {\n // Expose some scope variables to the controller\n // See the sgCalendarDayTable directive\n this.day = $scope.day;\n this.dayNumber = $scope.dayNumber;\n this.dayString = $scope.dayString;\n this.calendarData = function() {\n var pid, index, activeCalendars;\n if ($scope.calendar) {\n // A calendar is associated to the day; identify its index among active calendars\n pid = $scope.calendar;\n activeCalendars = _.filter(Calendar.$findAll(), { active: 1 });\n index = _.findIndex(activeCalendars, function(calendar) {\n return calendar.id == pid;\n });\n return { pid: pid, index: index };\n }\n\n return null;\n };\n }\n\n angular\n .module('SOGo.SchedulerUI')\n .directive('sgCalendarDay', sgCalendarDay);\n})();\n","/* -*- Mode: javascript; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n\n(function() {\n 'use strict';\n\n /*\n * sgCalendarDayBlock - An event block to be displayed in a week\n * @memberof SOGo.SchedulerUI\n * @restrict element\n * @param {object} sgBlock - the event block definition\n * @param {function} sgClick - the function to call when clicking on a block.\n * Two variables are available: clickEvent (the event that triggered the mouse click),\n * and clickComponent (a Component object)\n *\n * @example:\n\n <sg-calendar-day-block\n ng-repeat=\"block in blocks[day]\"\n sg-block=\"block\"\n sg-click=\"open(clickEvent, clickComponent)\" />\n */\n sgCalendarDayBlock.$inject = ['CalendarSettings'];\n function sgCalendarDayBlock(CalendarSettings) {\n return {\n restrict: 'E',\n scope: {\n block: '=sgBlock',\n clickBlock: '&sgClick'\n },\n replace: true,\n template: template,\n link: link\n };\n\n function template(tElem, tAttrs) {\n var p = _.has(tAttrs, 'sgCalendarGhost')? '' : '::';\n\n return [\n '<div class=\"sg-event\"',\n // Add a class while dragging\n ' ng-class=\"{\\'sg-event--dragging\\': block.dragging}\">',\n ' <div class=\"eventInside\"',\n ' ng-click=\"clickBlock({clickEvent: $event, clickComponent: block.component})\">',\n // Categories color stripes\n ' <div class=\"sg-category\" ng-repeat=\"category in '+p+'block.component.categories\"',\n ' ng-class=\"'+p+'(\\'bg-category\\' + category)\"',\n ' ng-style=\"'+p+'{ right: ($index * 3) + \\'px\\' }\"></div>',\n ' <div class=\"text\">',\n // Priority\n ' <span ng-show=\"'+p+'block.component.c_priority\" class=\"sg-priority\">{{'+p+'block.component.c_priority}}</span>',\n // Summary\n ' {{ '+p+'block.component.summary }}',\n ' <span class=\"icons\">',\n // Component is reccurent\n ' <md-icon ng-if=\"'+p+'block.component.occurrenceId\" class=\"material-icons icon-repeat\"></md-icon>',\n // Component has an alarm\n ' <md-icon ng-if=\"'+p+'block.component.c_nextalarm\" class=\"material-icons icon-alarm\"></md-icon>',\n // Component is confidential\n ' <md-icon ng-if=\"'+p+'block.component.c_classification == 2\" class=\"material-icons icon-visibility-off\"></md-icon>',\n // Component is private\n ' <md-icon ng-if=\"'+p+'block.component.c_classification == 1\" class=\"material-icons icon-vpn-key\"></md-icon>',\n ' </span>',\n // Location\n ' <div class=\"secondary\" ng-if=\"'+p+'block.component.c_location\">',\n ' <md-icon>place</md-icon> {{'+p+'block.component.c_location}}',\n ' </div>',\n ' </div>',\n ' </div>',\n ' <div class=\"ghostStartHour\" ng-if=\"block.startHour\">{{ block.startHour }}</div>',\n ' <div class=\"ghostEndHour\" ng-if=\"block.endHour\">{{ block.endHour }}</div>',\n '</div>'\n ].join('');\n }\n\n function link(scope, iElement, attrs) {\n var pc, left, right;\n\n if (!_.has(attrs, 'sgCalendarGhost')) {\n\n // Compute overlapping (2%)\n pc = 100 / scope.block.siblings;\n left = scope.block.position * pc;\n right = 100 - (scope.block.position + 1) * pc;\n if (pc < 100) {\n if (left > 0)\n left -= 2;\n if (right > 0)\n right -= 2;\n }\n\n // Add some padding (2%)\n if (left === 0)\n left = 2;\n if (right === 0)\n right = 2;\n\n // Set position\n iElement.css('left', left + '%');\n iElement.css('right', right + '%');\n if (!scope.block.component || !scope.block.component.c_isallday) {\n iElement.addClass('starts' + scope.block.start);\n iElement.addClass('lasts' + scope.block.length);\n }\n\n // Add class for user's participation state\n if (scope.block.userState)\n iElement.addClass('sg-event--' + scope.block.userState);\n\n if (scope.block.component) {\n // Set background color\n iElement.addClass('bg-folder' + scope.block.component.pid);\n iElement.addClass('contrast-bdr-folder' + scope.block.component.pid);\n\n // Add class for transparency\n if (scope.block.component.c_isopaque === 0)\n iElement.addClass('sg-event--transparent');\n\n // Add class for cancelled event\n if (scope.block.component.c_status === 0)\n iElement.addClass('sg-event--cancelled');\n }\n\n }\n }\n }\n\n angular\n .module('SOGo.SchedulerUI')\n .directive('sgCalendarDayBlock', sgCalendarDayBlock);\n})();\n","/* -*- Mode: javascript; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n\n(function() {\n 'use strict';\n\n /*\n * sgCalendarDayTable - Build list of blocks for a specific day\n * @memberof SOGo.SchedulerUI\n * @restrict element\n * @param {object} sgBlocks - the events blocks definitions for the current view\n * @param {string} sgDay - the day of the events to display\n * @param {function} sgClick - the function to call when clicking on a block.\n * Two variables are available: event (the event that triggered the mouse click),\n * and component (a Component object)\n *\n * @example:\n\n <sg-calendar-day-table\n sg-blocks=\"calendar.blocks\"\n sg-day=\"20150330\"\n sg-click=\"open({ event: clickEvent, component: clickComponent })\"/>\n */\n function sgCalendarDayTable() {\n return {\n restrict: 'E',\n scope: {\n blocks: '=sgBlocks',\n day: '@sgDay',\n clickBlock: '&sgClick'\n },\n template: [\n '<sg-calendar-day-block',\n ' class=\"sg-draggable-calendar-block\"',\n ' ng-repeat=\"block in blocks[day]\"',\n ' sg-block=\"block\"',\n ' sg-click=\"clickBlock({event: clickEvent, component: clickComponent})\"/>'\n ].join('')\n };\n }\n\n angular\n .module('SOGo.SchedulerUI')\n .directive('sgCalendarDayTable', sgCalendarDayTable);\n})();\n","/* -*- Mode: javascript; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n\n(function() {\n 'use strict';\n\n /*\n * sgCalendarBlock - Applied to an event ghost block to be displayed while dragging an event block. Each day of the\n * calendar's view must have a ghost block.\n * @memberof SOGo.SchedulerUI\n * @restrict attribute\n *\n * @example:\n\n <sg-calendar-day-block\n sg-calendar-ghost\n sg-block=\"list.component.$ghost\">/\n */\n sgCalendarGhost.$inject = ['$rootScope', '$timeout', 'CalendarSettings', 'Calendar', 'Component'];\n function sgCalendarGhost($rootScope, $timeout, CalendarSettings, Calendar, Component) {\n return {\n restrict: 'A',\n require: ['^sgCalendarDay', '^sgCalendarScrollView'],\n link: link\n };\n\n function link(scope, iElement, attrs, ctrls) {\n var domElement, calendarDayCtrl, scrollViewCtrl, calendarNumber, originalCalendarNumber;\n\n domElement = iElement[0];\n calendarDayCtrl = ctrls[0];\n scrollViewCtrl = ctrls[1];\n calendarNumber = -1;\n\n iElement.addClass('sg-event--ghost md-whiteframe-3dp ng-hide');\n\n // Listen on drag gestures\n var deregisterDragStart = $rootScope.$on('calendar:dragstart', initGhost);\n var deregisterDrag = $rootScope.$on('calendar:drag', updateGhost);\n var deregisterDragEnd = $rootScope.$on('calendar:dragend', hideGhost);\n\n // Deregister listeners on destroy\n scope.$on('$destroy', function() {\n deregisterDragStart();\n deregisterDrag();\n deregisterDragEnd();\n });\n\n function initGhost() {\n var pid, calendarData, userState;\n\n // Expose ghost block to the scope\n scope.block = Component.$ghost;\n\n calendarData = calendarDayCtrl.calendarData();\n if (calendarData) {\n // A calendar is associated to the day; this is a special multicolumn day view\n calendarNumber = calendarData.index;\n pid = calendarData.pid;\n originalCalendarNumber = scope.block.pointerHandler.originalCalendar.index;\n }\n\n if (!pid)\n pid = scope.block.component.pid;\n\n // Add class for user's participation state\n userState = scope.block.component.blocks[0].userState;\n if (userState)\n iElement.addClass('sg-event--' + userState);\n\n // Set background color\n iElement.addClass('bg-folder' + pid);\n }\n\n function hideGhost() {\n // Remove background color\n _.forEachRight(domElement.classList, function(c) {\n if (/^bg-folder/.test(c))\n iElement.removeClass(c);\n });\n // Hide ghost\n iElement.addClass('ng-hide');\n }\n\n function updateGhost() {\n // From SOGoEventDragGhostController._updateGhosts\n var showGhost, isRelative, isAllDay, currentDay,\n start, duration, durationLeft, maxDuration;\n\n showGhost = false;\n\n if (Calendar.$view && Calendar.$view.type == scrollViewCtrl.type) {\n // The view of the dragging block is the scrolling view of this ghost block\n\n isRelative = scrollViewCtrl.type === 'multiday-allday';\n isAllDay = scope.block.component.c_isallday;\n currentDay = scope.block.pointerHandler.currentEventCoordinates.dayNumber;\n start = scope.block.pointerHandler.currentEventCoordinates.start;\n durationLeft = scope.block.pointerHandler.currentEventCoordinates.duration;\n maxDuration = CalendarSettings.EventDragDayLength - start;\n\n if (angular.isUndefined(durationLeft))\n return;\n duration = durationLeft;\n if (duration > maxDuration)\n duration = maxDuration;\n\n if (currentDay > -1 && // pointer is inside viewport\n ((calendarNumber < 0 && // day is not associated to a calendar\n currentDay == calendarDayCtrl.dayNumber) || // pointer is inside ghost's day\n currentDay == calendarNumber && // pointer is inside ghost's calendar\n (originalCalendarNumber == calendarNumber || // still inside original calendar\n !scope.block.component.isException) // not an exception, event can be moved to a\n // different calendar\n )) {\n // This ghost block (day) is the first of the dragging event\n showGhost = true;\n if (!isRelative) {\n if (!isAllDay)\n // Show start hour and set the vertical position\n scope.block.startHour = getStartTime(start);\n // Set the height\n if (Calendar.$view.quarterHeight) {\n iElement.css('top', (start * Calendar.$view.quarterHeight) + 'px');\n iElement.css('height', (duration * Calendar.$view.quarterHeight) + 'px');\n }\n else\n iElement.css('top', Calendar.$view.topOffset + 'px');\n }\n iElement.removeClass('fg-folder' + scope.block.component.pid);\n iElement.removeClass('sg-event--ghost--last');\n iElement.addClass('sg-event--ghost--first');\n scope.block.isFirst = true;\n }\n\n durationLeft -= duration;\n currentDay++;\n\n // Search a subsequent block that matches the current ghost's day\n while (!showGhost && durationLeft && currentDay <= calendarDayCtrl.dayNumber) {\n duration = durationLeft;\n if (duration > CalendarSettings.EventDragDayLength)\n duration = CalendarSettings.EventDragDayLength;\n if (currentDay > -1 && currentDay == calendarDayCtrl.dayNumber) {\n // The dragging event overlaps this current ghost's day\n showGhost = true;\n if (!isRelative) {\n iElement.css('top', Calendar.$view.topOffset + 'px');\n // Set the height\n if (Calendar.$view.quarterHeight)\n iElement.css('height', (duration * Calendar.$view.quarterHeight) + 'px');\n }\n iElement.removeClass('sg-event--ghost--first');\n iElement.removeClass('sg-event--ghost--last');\n // Trick for all-day events: set the foreground color to the background color so the event's title\n // is not visible but the div size remains identical.\n iElement.addClass('fg-folder' + scope.block.component.pid);\n }\n durationLeft -= duration;\n currentDay++;\n start = 0;\n }\n if (!durationLeft) {\n // Reached last ghost block\n if (isRelative) {\n iElement.addClass('sg-event--ghost--last');\n }\n else if (!isAllDay) {\n // Set the end date\n scope.block.endHour = getEndTime(start, duration);\n }\n }\n }\n\n if (showGhost)\n iElement.removeClass('ng-hide');\n else\n iElement.addClass('ng-hide');\n }\n\n function quartersToHM(quarters) {\n var minutes, hours, mins;\n\n minutes = quarters * 15;\n hours = Math.floor(minutes / 60);\n if (hours < 10)\n hours = \"0\" + hours;\n mins = minutes % 60;\n if (mins < 10)\n mins = \"0\" + mins;\n\n return \"\" + hours + \":\" + mins;\n }\n\n function getStartTime(start) {\n return quartersToHM(start);\n }\n\n function getEndTime(start, duration) {\n var end = (start + duration) % CalendarSettings.EventDragDayLength;\n return quartersToHM(end);\n }\n }\n }\n\n angular\n .module('SOGo.SchedulerUI')\n .directive('sgCalendarGhost', sgCalendarGhost);\n})();\n","/* -*- Mode: javascript; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n\n(function() {\n 'use strict';\n\n /*\n * sgCalendarMonthDay - Build list of blocks for a specific day in a month\n * @memberof SOGo.SchedulerUI\n * @restrict element\n * @param {object} sgBlocks - the events blocks definitions for the current view\n * @param {string} sgDay - the day of the events to display\n * @param {function} sgClick - the function to call when clicking on a block.\n * Two variables are available: event (the event that triggered the mouse click),\n * and component (a Component object)\n *\n * @example:\n\n <sg-calendar-monh-day\n sg-blocks=\"calendar.blocks\"\n sg-day=\"20150408\"\n sg-click=\"open({ event: clickEvent, component: clickComponent })\"/>\n */\n function sgCalendarMonthDay() {\n return {\n restrict: 'E',\n scope: {\n blocks: '=sgBlocks',\n day: '@sgDay',\n clickBlock: '&sgClick'\n },\n template: [\n '<sg-calendar-month-event',\n ' class=\"sg-draggable-calendar-block\"',\n ' ng-repeat=\"block in blocks[day]\"',\n ' sg-block=\"block\"',\n ' sg-click=\"clickBlock({event: clickEvent, component: clickComponent})\"/>'\n ].join('')\n };\n }\n\n angular\n .module('SOGo.SchedulerUI')\n .directive('sgCalendarMonthDay', sgCalendarMonthDay);\n})();\n","/* -*- Mode: javascript; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n\n(function() {\n 'use strict';\n\n /*\n * sgCalendarMonthEvent - An event block to be displayed in a month\n * @memberof SOGo.Common\n * @restrict element\n * @param {object} sgBlock - the event block definition\n * @ngInject\n * @example:\n\n <sg-calendar-month-event\n ng-repeat=\"block in blocks[day]\"\n sg-block=\"block\"/>\n */\n function sgCalendarMonthEvent() {\n return {\n restrict: 'E',\n scope: {\n block: '=sgBlock',\n clickBlock: '&sgClick'\n },\n replace: true,\n template: template,\n link: link\n };\n\n function template(tElem, tAttrs) {\n var p = _.has(tAttrs, 'sgCalendarGhost')? '' : '::';\n\n return [\n '<div class=\"sg-event\"',\n // Add a class while dragging\n ' ng-class=\"{\\'sg-event--dragging\\': block.dragging}\"',\n ' ng-click=\"clickBlock({clickEvent: $event, clickComponent: block.component})\">',\n // Categories color stripes\n ' <div class=\"sg-category\" ng-repeat=\"category in '+p+'block.component.categories\"',\n ' ng-class=\"'+p+'(\\'bg-category\\' + category)\"',\n ' ng-style=\"'+p+'{ right: ($index * 3) + \\'px\\' }\"></div>',\n ' <span class=\"secondary\" ng-if=\"'+p+'(!block.component.c_isallday && block.isFirst)\">{{ '+p+'block.component.startHour }}</span>',\n // Priority\n ' <span ng-show=\"'+p+'block.component.c_priority\" class=\"sg-priority\">{{'+p+'block.component.c_priority}}</span>',\n // Summary\n ' {{ '+p+'block.component.summary }}',\n ' <span class=\"icons\">',\n // Component is reccurent\n ' <md-icon ng-if=\"'+p+'block.component.occurrenceId\" class=\"material-icons icon-repeat\"></md-icon>',\n // Component has an alarm\n ' <md-icon ng-if=\"'+p+'block.component.c_nextalarm\" class=\"material-icons icon-alarm\"></md-icon>',\n // Component is confidential\n ' <md-icon ng-if=\"'+p+'block.component.c_classification == 2\" class=\"material-icons icon-visibility-off\"></md-icon>',\n // Component is private\n ' <md-icon ng-if=\"'+p+'block.component.c_classification == 1\" class=\"material-icons icon-vpn-key\"></md-icon>',\n ' </span>',\n '</div>'\n ].join('');\n }\n\n function link(scope, iElement, attrs) {\n if (!_.has(attrs, 'sgCalendarGhost')) {\n\n // Add class for user's participation state\n if (scope.block.userState)\n iElement.addClass('sg-event--' + scope.block.userState);\n\n if (scope.block.component) {\n // Set background color\n iElement.addClass('bg-folder' + scope.block.component.pid);\n\n // Add class for transparency\n if (scope.block.component.c_isopaque === 0)\n iElement.addClass('sg-event--transparent');\n\n // Add class for cancelled event\n if (scope.block.component.c_status === 0)\n iElement.addClass('sg-event--cancelled');\n }\n\n }\n }\n }\n\n angular\n .module('SOGo.SchedulerUI')\n .directive('sgCalendarMonthEvent', sgCalendarMonthEvent);\n})();\n","/* -*- Mode: javascript; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n\n(function() {\n /* jshint validthis: true */\n 'use strict';\n\n /*\n * sgCalendarScrollView - scrollable view that contains draggable elements\n * @memberof SOGo.SchedulerUI\n * @restrict attribute\n * @param {string} sgCalendarScrollView - the view type (multiday, multiday-allday, or monthly)\n *\n * @example:\n\n <md-content sg-calendar-scroll-view=\"multiday\">\n ..\n </md-content>\n */\n sgCalendarScrollView.$inject = ['$rootScope', '$window', '$document', '$q', '$timeout', '$mdGesture', 'Calendar', 'Component', 'Preferences'];\n function sgCalendarScrollView($rootScope, $window, $document, $q, $timeout, $mdGesture, Calendar, Component, Preferences) {\n return {\n restrict: 'A',\n scope: {\n type: '@sgCalendarScrollView'\n },\n controller: sgCalendarScrollViewController,\n link: function(scope, element, attrs, controller) {\n var view, type, isMultiColumn = false;\n\n view = null;\n type = scope.type; // multiday, multiday-allday, monthly, unknown?\n isMultiColumn = (element.attr('sg-view') == 'multicolumndayview');\n\n // Expose isMultiColumn in the controller\n // See sgNowLine directive\n controller.isMultiColumn = isMultiColumn;\n\n // Update the \"view\" object literal once the Angular template has been transformed\n $timeout(initView);\n\n // Deregister listeners when destroying the view\n scope.$on('$destroy', function() {\n if (view) {\n view.$destroy();\n }\n });\n\n function initView() {\n view = new sgScrollView(element, type);\n\n if (type != 'monthly')\n // Scroll to the day start hour defined in the user's defaults\n Preferences.ready().then(function() {\n var time, hourCell, quartersOffset;\n if (Preferences.defaults.SOGoDayStartTime) {\n time = Preferences.defaults.SOGoDayStartTime.split(':');\n hourCell = document.getElementById('hour' + parseInt(time[0]));\n quartersOffset = parseInt(time[1]) * view.quarterHeight;\n view.element.scrollTop = hourCell.offsetTop + quartersOffset;\n }\n });\n\n // Expose quarter height to the controller\n // See sgNowLine directive\n controller.quarterHeight = view.quarterHeight;\n }\n\n /**\n * sgScrollView\n */\n function sgScrollView($element, type) {\n this.$element = $element;\n this.element = $element[0];\n this.type = type;\n this.quarterHeight = this.getQuarterHeight();\n this.scrollStep = 6 * this.quarterHeight;\n this.dayNumbers = this.getDayNumbers();\n this.maxX = this.getMaxColumns();\n\n // Listen to dragstart and dragend events\n this.deregisterDragStart = $rootScope.$on('calendar:dragstart', angular.bind(this, this.onDragStart));\n this.deregisterDragStop = $rootScope.$on('calendar:dragend', angular.bind(this, this.onDragEnd));\n\n this.bindedUpdateCoordinates = angular.bind(this, this.updateCoordinates);\n this.bindedUpdateFromPointerHandler = angular.bind(this, this.updateFromPointerHandler);\n\n // Compute coordinates of view element; recompute it on window resize\n this.updateCoordinates();\n angular.element($window).on('resize', this.bindedUpdateCoordinates);\n }\n\n sgScrollView.prototype = {\n\n $destroy: function() {\n this.deregisterDragStart();\n this.deregisterDragStop();\n this.$element.off('mousemove', this.bindedUpdateFromPointerHandler);\n angular.element($window).off('resize', this.bindedUpdateCoordinates);\n },\n\n onDragStart: function() {\n this.$element.on('mousemove', this.bindedUpdateFromPointerHandler);\n this.updateCoordinates();\n this.updateFromPointerHandler();\n },\n\n onDragEnd: function() {\n this.$element.off('mousemove', this.bindedUpdateFromPointerHandler);\n Calendar.$view = null;\n },\n\n getQuarterHeight: function() {\n var hour0, hour23, height = null;\n\n hour0 = document.getElementById('hour0');\n hour23 = document.getElementById('hour23');\n if (hour0 && hour23)\n height = ((hour23.offsetTop - hour0.offsetTop) / (23 * 4));\n\n return height;\n },\n\n\n getDayDimensions: function(viewLeft) {\n var width, height, leftOffset, topOffset, nodes, domRect, tileHeader;\n\n height = width = leftOffset = topOffset = 0;\n nodes = this.element.getElementsByClassName('day');\n\n if (nodes.length > 0) {\n domRect = nodes[0].getBoundingClientRect();\n height = domRect.height;\n width = domRect.width;\n leftOffset = domRect.left - viewLeft;\n tileHeader = nodes[0].getElementsByClassName('sg-calendar-tile-header');\n if (tileHeader.length > 0)\n topOffset = tileHeader[0].clientHeight;\n }\n\n return { height: height, width: width, offset: { left: leftOffset, top: topOffset } };\n },\n\n\n getDayNumbers: function() {\n var viewType = null, days, total, sum;\n\n days = this.element.getElementsByTagName('sg-calendar-day');\n\n return _.map(days, function(el, index) {\n if (isMultiColumn)\n return index;\n else\n return parseInt(el.attributes['sg-day-number'].value);\n });\n },\n\n\n getMaxColumns: function() {\n var mdGridList, max = 0;\n\n if (this.type == 'monthly') {\n mdGridList = this.element.getElementsByTagName('md-grid-list')[0];\n max = parseInt(mdGridList.attributes['md-cols'].value) - 1;\n }\n else {\n max = this.element.getElementsByClassName('day').length - 1;\n }\n\n return max;\n },\n\n // View has been resized;\n // Compute the view's origins (x, y), a day's dimensions and left margin.\n updateCoordinates: function() {\n var domRect, dayDimensions;\n\n domRect = this.element.getBoundingClientRect();\n dayDimensions = this.getDayDimensions(domRect.left);\n\n angular.extend(this, {\n coordinates: {\n x: domRect.left,\n y: domRect.top\n },\n dayHeight: dayDimensions.height,\n dayWidth: dayDimensions.width,\n daysOffset: dayDimensions.offset.left,\n topOffset: dayDimensions.offset.top\n });\n },\n\n\n // From SOGoScrollController.updateFromPointerHandler\n updateFromPointerHandler: function() {\n var pointerHandler, pointerCoordinates, now, scrollY, minY, delta;\n\n pointerHandler = Component.$ghost.pointerHandler;\n if (this.coordinates && pointerHandler) {\n pointerCoordinates = pointerHandler.getContainerBasedCoordinates(this);\n\n if (pointerCoordinates) {\n // Pointer is inside view; Adjust scrollbar if necessary\n Calendar.$view = this;\n now = new Date().getTime();\n if (!this.lastScroll || now > this.lastScroll + 100) {\n this.lastScroll = now;\n scrollY = pointerCoordinates.y - this.scrollStep;\n if (scrollY < 0) {\n minY = -this.element.scrollTop;\n if (scrollY < minY)\n scrollY = minY;\n this.element.scrollTop += scrollY;\n }\n else {\n scrollY = pointerCoordinates.y + this.scrollStep;\n delta = scrollY - this.element.clientHeight;\n if (delta > 0) {\n this.element.scrollTop += delta;\n }\n }\n }\n }\n }\n }\n\n\n };\n }\n };\n }\n\n sgCalendarScrollViewController.$inject = ['$scope'];\n function sgCalendarScrollViewController($scope) {\n // Expose the view type to the controller\n // See sgCalendarGhost directive\n this.type = $scope.type;\n }\n\n angular\n .module('SOGo.SchedulerUI')\n .directive('sgCalendarScrollView', sgCalendarScrollView);\n})();\n","/* -*- Mode: javascript; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n\n(function() {\n /* jshint validthis: true */\n 'use strict';\n\n /*\n * sgCategoryStylesheet - Add CSS stylesheet for a category's color\n * @memberof SOGo.SchedulerUI\n * @restrict attribute\n * @param {object} ngModel - the object literal describing the category\n * @example:\n\n <sg-category-stylesheet\n ng-repeat=\"category in categories\"\n ng-model=\"category\" />\n */\n function sgCategoryStylesheet() {\n return {\n restrict: 'E',\n require: 'ngModel',\n scope: {\n ngModel: '='\n },\n replace: true,\n template: [\n '<style type=\"text/css\">',\n /* Background color */\n ' .bg-category{{ ngModel.id }} {',\n ' background-color: {{ ngModel.color }} !important;',\n ' }',\n /* Border color */\n ' .bdr-category{{ ngModel.id }} {',\n ' border-color: {{ ngModel.color }} !important;',\n ' }',\n '</style>'\n ].join('')\n };\n }\n\n angular\n .module('SOGo.SchedulerUI')\n .directive('sgCategoryStylesheet', sgCategoryStylesheet);\n})();\n","/* -*- Mode: javascript; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n\n(function() {\n 'use strict';\n\n /*\n * sgDraggableCalendarBlock - Make an element draggable\n * @memberof SOGo.SchedulerUI\n * @restrict class or attribute\n *\n * @example:\n\n <div class=\"sg-draggable-calendar-block\"/>\n */\n sgDraggableCalendarBlock.$inject = ['$rootScope', '$timeout', '$log', 'Preferences', 'Calendar', 'CalendarSettings', 'Component'];\n function sgDraggableCalendarBlock($rootScope, $timeout, $log, Preferences, Calendar, CalendarSettings, Component) {\n return {\n restrict: 'CA',\n require: '^sgCalendarDay',\n link: link\n };\n\n function link(scope, element, attrs, calendarDayCtrl) {\n if (scope.block) {\n if (scope.block.component.editable && !scope.block.userState) {\n // Add dragging grips to existing event block\n initGrips();\n }\n else {\n element.removeClass('sg-draggable-calendar-block');\n return;\n }\n }\n\n // Start dragging on mousedown\n element.on('mousedown', onDragDetect);\n\n // Deregister listeners when removing the element from the DOM\n scope.$on('$destroy', function() {\n element.off('mousedown', onDragDetect);\n element.off('mousemove', onDrag);\n });\n\n function initGrips() {\n var component, dayIndex, blockIndex, isFirstBlock, isLastBlock,\n dragGrip, leftGrip, rightGrip, topGrip, bottomGrip;\n\n // Don't show grips for blocks of less than 45 minutes\n if (scope.block.length < 3) return;\n\n component = scope.block.component;\n dayIndex = scope.block.dayIndex;\n blockIndex = _.findIndex(component.blocks, ['dayIndex', dayIndex]);\n isFirstBlock = (blockIndex === 0);\n isLastBlock = (blockIndex === component.blocks.length - 1);\n\n dragGrip = angular.element('<div class=\"dragGrip\"></div>');\n dragGrip.addClass('bdr-folder' + component.pid);\n\n if (component.c_isallday ||\n element[0].parentNode.tagName === 'SG-CALENDAR-MONTH-DAY') {\n if (isFirstBlock) {\n leftGrip = angular.element('<div class=\"dragGrip-left\"></div>').append(dragGrip);\n element.append(leftGrip);\n }\n if (isLastBlock) {\n rightGrip = angular.element('<div class=\"dragGrip-right\"></div>').append(dragGrip.clone());\n element.append(rightGrip);\n }\n }\n else {\n if (isFirstBlock) {\n topGrip = angular.element('<div class=\"dragGrip-top\"></div>').append(dragGrip);\n element.append(topGrip);\n }\n if (isLastBlock) {\n bottomGrip = angular.element('<div class=\"dragGrip-bottom\"></div>').append(dragGrip.clone());\n element.append(bottomGrip);\n }\n }\n }\n\n function onDragDetect(ev) {\n var dragMode, pointerHandler, hasVerticalScrollbar, rect;\n\n ev.stopPropagation();\n\n hasVerticalScrollbar = ev.target.scrollHeight > ev.target.clientHeight + 1;\n\n if (hasVerticalScrollbar) {\n // Check if mouse click is inside scrollbar\n rect = ev.target.getBoundingClientRect();\n scrollableZone = rect.left + rect.width - 18;\n if (ev.pageX > scrollableZone)\n return;\n }\n\n dragMode = 'move-event';\n\n if (scope.block && scope.block.component) {\n // Move or resize existing component\n if (ev.target.className == 'dragGrip-top' ||\n ev.target.className == 'dragGrip-left')\n dragMode = 'change-start';\n else if (ev.target.className == 'dragGrip-bottom' ||\n ev.target.className == 'dragGrip-right' )\n dragMode = 'change-end';\n }\n else {\n // Create new component from dragging\n dragMode = 'change-end';\n }\n\n // Initialize pointer handler\n pointerHandler = new SOGoEventDragPointerHandler(dragMode);\n pointerHandler.initFromEvent(ev);\n\n // Update Component.$ghost\n Component.$ghost.pointerHandler = pointerHandler;\n\n // Stop dragging on the next \"mouseup\"\n angular.element(document).one('mouseup', onDragEnd);\n\n // Listen to mousemove and start dragging when mouse has moved from at least 3 pixels\n angular.element(document).on('mousemove', onDrag);\n }\n\n function dragStart(ev) {\n var block, eventType, isHourCell, isMonthly, startDate, newData, newComponent, pointerHandler, calendarData;\n\n isHourCell = element.hasClass('clickableHourCell');\n isMonthly = (element[0].parentNode.tagName == 'SG-CALENDAR-MONTH-DAY') ||\n element.hasClass('clickableDayCell');\n\n calendarData = calendarDayCtrl.calendarData();\n\n if (scope.block && scope.block.component) {\n // Move or resize existing component\n block = scope.block;\n }\n else {\n // Create new component from dragging\n startDate = calendarDayCtrl.dayString.parseDate(Preferences.$mdDateLocaleProvider, '%Y-%m-%e');\n newData = {\n type: 'appointment',\n pid: calendarData? calendarData.pid : Calendar.$defaultCalendar(),\n summary: l('New Event'),\n startDate: startDate,\n isAllDay: isHourCell? 0 : 1\n };\n newComponent = new Component(newData);\n block = {\n component: newComponent,\n dayNumber: calendarDayCtrl.dayNumber,\n length: 0\n };\n block.component.blocks = [block];\n }\n\n // Determine event type\n eventType = 'multiday';\n if (isMonthly)\n eventType = 'monthly';\n else if (block.component.c_isallday)\n eventType = 'multiday-allday';\n\n // Mark all blocks as being dragged\n _.forEach(block.component.blocks, function(b) {\n b.dragging = true;\n });\n\n // Update pointer handler\n pointerHandler = Component.$ghost.pointerHandler;\n pointerHandler.prepareWithEventType(eventType);\n pointerHandler.initFromBlock(block);\n if (calendarData)\n // When the day is associated to a calendar, the day number becomes the calendar index\n // among the active calendars\n pointerHandler.initFromCalendar(calendarData);\n\n // Update Component.$ghost\n Component.$ghost.component = block.component;\n\n $log.debug('emit calendar:dragstart ' + eventType);\n $rootScope.$emit('calendar:dragstart');\n }\n\n function onDrag(ev) {\n var pointerHandler = Component.$ghost.pointerHandler;\n\n // Update\n // - currentCoordinates\n // - currentViewCoordinates\n // - currentEventCoordinates\n $timeout(function() {\n pointerHandler.updateFromEvent(ev);\n });\n }\n\n function onDragEnd(ev) {\n var block, pointer;\n\n block = scope.block;\n pointer = Component.$ghost.pointerHandler;\n\n // Deregister mouse events\n angular.element(document).off('mousemove', onDrag);\n\n if (pointer.dragHasStarted) {\n $rootScope.$emit('calendar:dragend');\n pointer.dragHasStarted = false;\n }\n\n // Unmark all blocks as being dragged\n if (block && block.component)\n _.forEach(block.component.blocks, function(b) {\n b.dragging = false;\n });\n }\n\n /**\n * SOGoCoordinates\n */\n function SOGoCoordinates() {\n }\n\n SOGoCoordinates.prototype = {\n x: -1,\n y: -1,\n\n getDelta: function SC_getDelta(otherCoordinates) {\n var delta = new SOGoCoordinates();\n delta.x = this.x - otherCoordinates.x;\n delta.y = this.y - otherCoordinates.y;\n\n if (Calendar.$view) {\n delta.days = Calendar.$view.dayNumbers[this.x] - Calendar.$view.dayNumbers[otherCoordinates.x];\n }\n\n return delta;\n },\n\n getDistance: function SC_getDistance(otherCoordinates) {\n var delta = this.getDelta(otherCoordinates);\n\n return Math.sqrt(delta.x * delta.x + delta.y * delta.y);\n },\n\n clone: function SC_clone() {\n var coordinates = new SOGoCoordinates();\n coordinates.x = this.x;\n coordinates.y = this.y;\n\n return coordinates;\n }\n };\n\n /**\n * SOGoEventDragEventCoordinates\n */\n function SOGoEventDragEventCoordinates(eventType) {\n this.setEventType(eventType);\n }\n\n SOGoEventDragEventCoordinates.prototype = {\n dayNumber: -1,\n weekDay: -1,\n start: -1,\n duration: -1,\n\n eventType: null,\n\n setEventType: function(eventType) {\n this.eventType = eventType;\n },\n\n initFromBlock: function(block) {\n var prevDayNumber = -1;\n\n if (this.eventType === 'monthly') {\n this.start = 0;\n this.duration = block.component.blocks.length * CalendarSettings.EventDragDayLength;\n }\n else {\n // Get the start (first quarter) from the event's first block\n // Compute overall length\n this.start = block.component.blocks[0].start;\n this.duration = _.sumBy(block.component.blocks, function(b) {\n var delta, currentDayNumber;\n\n currentDayNumber = b.dayNumber;\n if (prevDayNumber < 0)\n delta = 0;\n else\n delta = currentDayNumber - prevDayNumber - 1;\n prevDayNumber = currentDayNumber;\n\n return b.length + delta * CalendarSettings.EventDragDayLength;\n });\n }\n },\n\n initFromCalendar: function(calendarNumber) {\n this.dayNumber = calendarNumber;\n },\n\n getDelta: function(otherCoordinates) {\n var delta = new SOGoEventDragEventCoordinates();\n delta.dayNumber = (this.dayNumber - otherCoordinates.dayNumber);\n delta.start = (this.start - otherCoordinates.start);\n delta.duration = (this.duration - otherCoordinates.duration);\n\n return delta;\n },\n\n _quartersToHM: function(quarters) {\n var minutes = quarters * 15;\n var hours = Math.floor(minutes / 60);\n if (hours < 10)\n hours = \"0\" + hours;\n var mins = minutes % 60;\n if (mins < 10)\n mins = \"0\" + mins;\n\n return \"\" + hours + \":\" + mins;\n },\n\n getStartTime: function() {\n return this._quartersToHM(this.start);\n },\n\n getEndTime: function() {\n var end = (this.start + this.duration) % CalendarSettings.EventDragDayLength;\n return this._quartersToHM(end);\n },\n\n clone: function() {\n var coordinates = new SOGoEventDragEventCoordinates();\n coordinates.dayNumber = this.dayNumber;\n coordinates.start = this.start;\n coordinates.duration = this.duration;\n\n return coordinates;\n }\n };\n\n /**\n * SOGoEventDragPointerHandler\n */\n function SOGoEventDragPointerHandler(dragMode) {\n this.dragMode = dragMode;\n }\n\n SOGoEventDragPointerHandler.prototype = {\n // Pointer absolute xy coordinates within page\n originalCoordinates: null,\n currentCoordinates: null,\n\n // Pointer relative xy coordinates within view (row-column)\n originalViewCoordinates: null,\n currentViewCoordinates: null,\n\n // Event start-duration coordinates\n originalEventCoordinates: null,\n currentEventCoordinates: null,\n\n originalCalendar: null,\n\n dragHasStarted: false,\n\n // Function to return the day and quarter coordinates of the pointer cursor\n // within the day view\n getEventViewCoordinates: null,\n\n initFromBlock: function SEDPH_initFromBlock(block) {\n this.currentEventCoordinates = new SOGoEventDragEventCoordinates(this.eventType);\n this.originalEventCoordinates = new SOGoEventDragEventCoordinates(this.eventType);\n this.originalEventCoordinates.initFromBlock(block);\n },\n\n initFromEvent: function SEDPH_initFromEvent(event) {\n this.currentCoordinates = new SOGoCoordinates();\n this.updateFromEvent(event);\n this.originalCoordinates = this.currentCoordinates.clone();\n },\n\n initFromCalendar: function SEDPH_initFromCalendar(calendarData) {\n this.originalCalendar = calendarData;\n this.currentEventCoordinates.initFromCalendar(calendarData.index);\n this.originalEventCoordinates.initFromCalendar(calendarData.index);\n },\n\n // Method continuously called while dragging\n updateFromEvent: function SEDPH_updateFromEvent(event) {\n // Event here is a DOM event, not a calendar event!\n this.currentCoordinates.x = event.pageX;\n this.currentCoordinates.y = event.pageY;\n\n // From SOGoEventDragGhostController.updateFromPointerHandler\n if (this.dragHasStarted && Calendar.$view) {\n var newEventCoordinates = this.getEventViewCoordinates(Calendar.$view);\n if (!this.originalViewCoordinates) {\n this.originalViewCoordinates = this.getEventViewCoordinates(Calendar.$view, this.originalCoordinates);\n if (Component.$ghost.component.isNew) {\n this.setTimeFromQuarters(Component.$ghost.component.start, this.originalViewCoordinates.y);\n $log.debug('new event start date ' + Component.$ghost.component.start);\n }\n }\n if (!this.currentViewCoordinates ||\n !newEventCoordinates ||\n newEventCoordinates.x != this.currentViewCoordinates.x ||\n newEventCoordinates.y != this.currentViewCoordinates.y) {\n this.currentViewCoordinates = newEventCoordinates;\n if (this.originalViewCoordinates) {\n if (!newEventCoordinates) {\n this.currentViewCoordinates = this.originalViewCoordinates.clone();\n }\n this.updateEventCoordinates();\n }\n }\n }\n else if (this.originalCoordinates &&\n this.currentCoordinates &&\n !this.dragHasStarted) {\n var distance = this.getDistance();\n if (distance > 3) {\n this.dragHasStarted = true;\n dragStart(event);\n }\n }\n },\n\n // SOGoEventDragGhostController._updateCoordinates\n // Extend this.currentCoordinates with start, dayNumber and duration\n updateEventCoordinates: function SEDGC__updateCoordinates() {\n var newDuration;\n\n // Compute delta wrt to position of mouse at dragstart on the day/quarter grid\n var delta = this.currentViewCoordinates.getDelta(this.originalViewCoordinates);\n var deltaQuarters = delta.days * CalendarSettings.EventDragDayLength + delta.y;\n $log.debug('quarters delta ' + deltaQuarters);\n\n if (angular.isUndefined(this.originalEventCoordinates.start)) {\n // Creating new appointment from DnD\n this.originalEventCoordinates.dayNumber = Calendar.$view.dayNumbers[this.originalViewCoordinates.x];\n this.originalEventCoordinates.start = this.originalViewCoordinates.y;\n }\n else if (this.originalEventCoordinates.dayNumber < 0) {\n this.originalEventCoordinates.dayNumber = Calendar.$view.dayNumbers[scope.block.component.blocks[0].dayIndex];\n }\n // if (currentView == \"multicolumndayview\")\n // this._updateMulticolumnViewDayNumber_SEDGC();\n // else\n this.currentEventCoordinates.dayNumber = this.originalEventCoordinates.dayNumber;\n\n if (this.dragMode == \"move-event\") {\n this.currentEventCoordinates.start = this.originalEventCoordinates.start + deltaQuarters;\n this.currentEventCoordinates.duration = this.originalEventCoordinates.duration;\n }\n else {\n if (this.dragMode == \"change-start\") {\n newDuration = this.originalEventCoordinates.duration - deltaQuarters;\n if (newDuration > 0) {\n this.currentEventCoordinates.start = this.originalEventCoordinates.start + deltaQuarters;\n this.currentEventCoordinates.duration = newDuration;\n }\n else if (newDuration < 0) {\n this.currentEventCoordinates.start = (this.originalEventCoordinates.start + this.originalEventCoordinates.duration);\n this.currentEventCoordinates.duration = -newDuration;\n }\n }\n else if (this.dragMode == \"change-end\") {\n newDuration = this.originalEventCoordinates.duration + deltaQuarters;\n if (newDuration > 0) {\n this.currentEventCoordinates.start = this.originalEventCoordinates.start;\n this.currentEventCoordinates.duration = newDuration;\n }\n else if (newDuration < 0) {\n this.currentEventCoordinates.start = this.originalEventCoordinates.start + newDuration;\n this.currentEventCoordinates.duration = -newDuration;\n }\n }\n }\n\n var deltaDays;\n if (this.currentEventCoordinates.start < 0) {\n deltaDays = Math.ceil(-this.currentEventCoordinates.start / CalendarSettings.EventDragDayLength);\n this.currentEventCoordinates.start += deltaDays * CalendarSettings.EventDragDayLength;\n this.currentEventCoordinates.dayNumber -= deltaDays;\n }\n else if (this.currentEventCoordinates.start >= CalendarSettings.EventDragDayLength) {\n deltaDays = Math.floor(this.currentEventCoordinates.start / CalendarSettings.EventDragDayLength);\n this.currentEventCoordinates.start -= deltaDays * CalendarSettings.EventDragDayLength;\n this.currentEventCoordinates.dayNumber += deltaDays;\n }\n\n $log.debug('event coordinates ' + JSON.stringify(this.currentEventCoordinates));\n $rootScope.$emit('calendar:drag');\n },\n\n // SOGoEventDragPointerHandler.getContainerBasedCoordinates\n getContainerBasedCoordinates: function SEDPH_getCBC(view, pointerCoordinates) {\n var currentCoordinates = pointerCoordinates || this.currentCoordinates;\n var coordinates = currentCoordinates.getDelta(view.coordinates);\n var container = view.element;\n\n if (coordinates.x < view.daysOffset || coordinates.x > container.clientWidth ||\n coordinates.y < 0 || coordinates.y > container.clientHeight)\n coordinates = null;\n\n return coordinates;\n },\n\n prepareWithEventType: function SEDPH_prepareWithEventType(eventType) {\n var methods = { \"multiday\": this.getEventMultiDayViewCoordinates,\n \"multiday-allday\": this.getEventMultiDayAllDayViewCoordinates,\n \"monthly\": this.getEventMonthlyViewCoordinates,\n \"unknown\": null };\n var method = methods[eventType];\n this.eventType = eventType;\n this.getEventViewCoordinates = method;\n },\n\n getEventMultiDayViewCoordinates: function SEDPH_gEMultiDayViewC(view, pointerCoordinates) {\n /* x = day; y = quarter */\n var coordinates = this.getEventMultiDayAllDayViewCoordinates(view, pointerCoordinates); // get the x coordinate\n if (coordinates) {\n var quarterHeight = view.quarterHeight;\n var pxCoordinates = this.getContainerBasedCoordinates(view, pointerCoordinates);\n pxCoordinates.y += view.element.scrollTop;\n\n coordinates.y = Math.floor((pxCoordinates.y - CalendarSettings.EventDragHorizontalOffset) / quarterHeight);\n var maxY = CalendarSettings.EventDragDayLength - 1;\n if (coordinates.y < 0)\n coordinates.y = 0;\n else if (coordinates.y > maxY)\n coordinates.y = maxY;\n }\n\n return coordinates;\n },\n getEventMultiDayAllDayViewCoordinates: function SEDPH_gEMultiDayADVC(view, pointerCoordinates) {\n /* x = day; y = quarter */\n var coordinates;\n\n var pxCoordinates = this.getContainerBasedCoordinates(view, pointerCoordinates);\n if (pxCoordinates) {\n coordinates = new SOGoCoordinates();\n\n var dayWidth = view.dayWidth;\n var daysOffset = view.daysOffset;\n\n coordinates.x = Math.floor((pxCoordinates.x - daysOffset) / dayWidth);\n var minX = 0;\n var maxX = Calendar.$view.maxX;\n if (this.dragMode != 'move-event') {\n var calendarData = calendarDayCtrl.calendarData();\n if (calendarData)\n // Resizing an event can't span a different day when in multicolumn view\n minX = maxX = calendarData.index;\n }\n if (coordinates.x < minX)\n coordinates.x = minX;\n else if (coordinates.x > maxX)\n coordinates.x = maxX;\n coordinates.y = 0;\n }\n else {\n coordinates = null;\n }\n\n return coordinates;\n },\n getEventMonthlyViewCoordinates: function SEDPH_gEMonthlyViewC(view, pointerCoordinates) {\n /* x = day; y = quarter */\n var coordinates;\n\n var pxCoordinates = this.getContainerBasedCoordinates(view, pointerCoordinates);\n if (pxCoordinates) {\n coordinates = new SOGoCoordinates();\n\n var maxX = view.maxX;\n var daysTopOffset = 0;\n var dayWidth = view.dayWidth;\n var daysOffset = view.daysOffset;\n var dayHeight = view.dayHeight;\n var daysY = Math.floor((pxCoordinates.y - daysTopOffset) / dayHeight);\n if (daysY < 0)\n daysY = 0;\n\n coordinates.x = Math.floor((pxCoordinates.x - daysOffset) / dayWidth);\n if (coordinates.x < 0)\n coordinates.x = 0;\n else if (coordinates.x > maxX)\n coordinates.x = maxX;\n coordinates.x += (maxX + 1) * daysY;\n coordinates.y = 0;\n }\n else {\n coordinates = null;\n }\n\n return coordinates;\n },\n\n getDistance: function SEDPH_getDistance() {\n return this.currentCoordinates.getDistance(this.originalCoordinates);\n },\n\n setTimeFromQuarters: function SEDPH_setTimeFromQuarters(date, quarters) {\n var hours, minutes;\n hours = Math.floor(quarters / 4);\n minutes = (quarters % 4) * 15;\n date.setHours(hours, minutes);\n }\n };\n }\n }\n\n angular\n .module('SOGo.SchedulerUI')\n .directive('sgDraggableCalendarBlock', sgDraggableCalendarBlock);\n})();\n\n","/* -*- Mode: js; indent-tabs-mode: nil; js-indent-level: 2 -*- */\n\n(function() {\n /* jshint validthis: true */\n 'use strict';\n\n /*\n * sgNowLine - Now line to be displayed on top of current day\n * @restrict class\n */\n function sgNowLine() {\n return {\n restrict: 'C',\n require: '^^sgCalendarScrollView',\n link: link,\n controller: sgNowLineController\n };\n\n function link(scope, iElement, iAttr, sgCalendarScrollViewCtrl) {\n function _getDays() {\n return iElement.find('sg-calendar-day');\n }\n function _getView() {\n return sgCalendarScrollViewCtrl.quarterHeight;\n }\n\n // We need to wait for the view to be compiled\n var _unwatchView = scope.$watch(_getView, function(quarterHeight) {\n if (quarterHeight) {\n _unwatchView(); // self release\n scope.quarterHeight = quarterHeight;\n // We need to wait for the days to be compiled\n var _unwatchDays = scope.$watch(_getDays, function(days) {\n if (days.length) {\n _unwatchDays(); // self release\n scope.days = days;\n // Draw the line\n scope.updateLine();\n }\n });\n }\n });\n }\n }\n\n /**\n * @ngInject\n */\n sgNowLineController.$inject = ['$scope', '$element', '$timeout'];\n function sgNowLineController($scope, $element, $timeout) {\n var _this = this, updater,\n scrollViewCtrl = $element.controller('sgCalendarScrollView');\n\n $scope.nowDay = null;\n $scope.lineElement = null;\n $scope.updateLine = _updateLine;\n\n $scope.$on('$destroy', function() {\n if (updater)\n $timeout.cancel(updater);\n });\n\n\n function _updateLine(force) {\n var now = new Date(), // TODO: adjust to user's timezone\n nowDay = now.getDayString(),\n hours = now.getHours(),\n hourHeight = $scope.quarterHeight * 4,\n minutes = now.getMinutes(),\n minuteHeight = $scope.quarterHeight/15,\n position = parseInt(hours * hourHeight +\n minutes * minuteHeight -\n 1);\n\n if (force || nowDay != $scope.nowDay) {\n if ($scope.lineElement)\n $scope.lineElement.remove();\n $scope.lineElement = _addLine(nowDay, $scope.days);\n $scope.nowDay = nowDay;\n }\n\n if ($scope.lineElement) {\n // Current day is displayed\n $scope.lineElement.css('top', position + \"px\");\n // Update line every minute\n updater = $timeout(angular.bind(_this, $scope.updateLine), 60000);\n }\n }\n\n function _addLine(nowDay, days) {\n var $lineElement = angular.element('<sg-now-line>');\n\n if (scrollViewCtrl.isMultiColumn) {\n // In multicolumn day view, the line must go over all columns\n if (days && days[0].attributes['sg-day'].value == nowDay)\n $element.append($lineElement);\n }\n else\n _.forEach(days, function(dayElement) {\n if (dayElement.attributes['sg-day'].value == nowDay) {\n angular.element(dayElement).find('div').eq(0).append($lineElement);\n }\n });\n\n return $lineElement;\n }\n }\n\n angular\n .module('SOGo.SchedulerUI')\n .directive('sgNowLine', sgNowLine);\n})();\n"]}