diff --git a/UI/WebServerResources/js/Contacts.js b/UI/WebServerResources/js/Contacts.js index c13976d04..d21e85a3f 100644 --- a/UI/WebServerResources/js/Contacts.js +++ b/UI/WebServerResources/js/Contacts.js @@ -1,2 +1,2 @@ -!function(){"use strict";function a(a,f){a.state("app",{url:"/addressbooks","abstract":!0,views:{addressbooks:{templateUrl:"UIxContactFoldersView",controller:"AddressBooksController",controllerAs:"app"}},resolve:{stateAddressbooks:b}}).state("app.addressbook",{url:"/:addressbookId",views:{addressbook:{templateUrl:"addressbook",controller:"AddressBookController",controllerAs:"addressbook"}},resolve:{stateAddressbook:c}}).state("app.addressbook.new",{url:"/{contactType:(?:card|list)}/new",views:{card:{templateUrl:"UIxContactEditorTemplate",controller:"CardController",controllerAs:"editor"}},resolve:{stateCard:d}}).state("app.addressbook.card",{url:"/:cardId","abstract":!0,views:{card:{template:""}},resolve:{stateCard:e}}).state("app.addressbook.card.view",{url:"/view",views:{"card@app.addressbook":{templateUrl:"UIxContactViewTemplate",controller:"CardController",controllerAs:"editor"}}}).state("app.addressbook.card.editor",{url:"/edit",views:{"card@app.addressbook":{templateUrl:"UIxContactEditorTemplate",controller:"CardController",controllerAs:"editor"}}}),f.otherwise("/addressbooks/personal")}function b(a){return a.$findAll(window.contactFolders)}function c(a,b,c,d){var e=_.find(d.$findAll(),function(a){return a.id==c.addressbookId});return e?(e.selectedCard=!1,e.$reload(),e):a.reject("Addressbook "+c.addressbookId+" not found")}function d(a,b,c){var d="v"+a.contactType,e=new c({pid:a.addressbookId,c_component:d});return b.selectedCard=!0,e}function e(a,b){return b.selectedCard=a.cardId,b.$getCard(a.cardId)}function f(a,b,c){a.$on("$stateChangeError",function(a,d,e,f,g,h){b.error(h),c.go("app.addressbook",{addressbookId:"personal"})}),a.$on("$routeChangeError",function(a,c,d,e){b.error(a,c,d,e)})}angular.module("SOGo.ContactsUI",["ui.router","angularFileUpload","ck","SOGo.Common","SOGo.PreferencesUI","SOGo.MailerUI"]).config(a).run(f),a.$inject=["$stateProvider","$urlRouterProvider"],b.$inject=["AddressBook"],c.$inject=["$q","$state","$stateParams","AddressBook"],d.$inject=["$stateParams","stateAddressbook","Card"],e.$inject=["$stateParams","stateAddressbook"],f.$inject=["$rootScope","$log","$state"]}(),function(){"use strict";function a(a,b,c,d,e,f,g,h,i,j,k,m,n){function o(a){d.go("app.addressbook.card.view",{addressbookId:n.id,cardId:a.id})}function p(a,b){b.selected=!b.selected,D.mode.multiple+=b.selected?1:-1,a.preventDefault(),a.stopPropagation()}function q(a){function b(a,b,c,d){a.create=function(a){b.hide(),c.go("app.addressbook.new",{addressbookId:d,contactType:a})}}f.show({parent:angular.element(document.body),targetEvent:a,clickOutsideToClose:!0,escapeToClose:!0,template:[''," ",'
'," "," "+l("Contact")," "," "," "+l("List")," ","
","
","
"].join(""),locals:{addressbookId:D.selectedFolder.id},controller:b}),b.$inject=["scope","$mdDialog","$state","addressbookId"]}function r(a,b){return a&&a.c_component==b&&!a.selected}function s(){_.forEach(D.selectedFolder.$cards,function(a){a.selected=!1}),D.mode.multiple=0}function t(){j.confirm(l("Warning"),l("Are you sure you want to delete the selected contacts?"),{ok:l("Delete")}).then(function(){var a=_.filter(D.selectedFolder.$cards,function(a){return a.selected});D.selectedFolder.$deleteCards(a),delete D.selectedFolder.selectedCard})}function u(){var a=_.filter(D.selectedFolder.$cards,function(a){return a.selected}),b=_.map(a,"id");c.location.href=ApplicationBaseURL+"/"+D.selectedFolder.id+"/export?uid="+b.join("&uid=")}function v(a){var b=_.filter(D.selectedFolder.$cards,function(a){return a.selected});D.selectedFolder.$copyCards(b,a).then(function(){})}function w(){_.forEach(D.selectedFolder.$cards,function(a){a.selected=!0}),D.mode.multiple=D.selectedFolder.$cards.length}function x(a){D.selectedFolder.$filter("",{sort:a})}function y(a){return i.$query.sort==a}function z(){D.mode.search=!1,D.selectedFolder.$filter("")}function A(a,b){g.$findAll().then(function(c){var d=_.filter(c,function(a){return 0===a.id?a:void 0})[0];d.$getMailboxes().then(function(e){d.$newMessage().then(function(d){f.show({parent:angular.element(document.body),targetEvent:a,clickOutsideToClose:!1,escapeToClose:!1,templateUrl:"../Mail/UIxMailEditor",controller:"MessageEditorController",controllerAs:"editor",locals:{stateAccounts:c,stateMessage:d,stateRecipients:b}})})})})}function B(a,b,c){var d=[{full:c+" <"+b+">"}];D.newMessage(a,d),a.stopPropagation(),a.preventDefault()}function C(a){var c=_.filter(D.selectedFolder.$cards,function(a){return a.selected}),d=[],e=[];_.forEach(c,function(a){"vcard"==a.c_component&&a.c_mail.length?e.push({full:a.c_cn+" <"+a.c_mail+">"}):a.$isList()&&(angular.isDefined(a.refs)&&a.refs.length?_.forEach(a.refs,function(a){a.email.length&&e.push({full:a.c_cn+" <"+a.email+">"})}):d.push(D.selectedFolder.$getCard(a.id).then(function(a){return a.$futureCardData.then(function(a){_.forEach(a.refs,function(a){a.email.length&&e.push({full:a.c_cn+" <"+a.email+">"})})})})))}),b.all(d).then(function(){e.length&&D.newMessage(a,e)})}var D=this;i.selectedFolder=n,D.service=i,D.selectedFolder=n,D.selectCard=o,D.toggleCardSelection=p,D.newComponent=q,D.notSelectedComponent=r,D.unselectCards=s,D.confirmDeleteSelectedCards=t,D.saveSelectedCards=u,D.copySelectedCards=v,D.selectAll=w,D.sort=x,D.sortedBy=y,D.cancelSearch=z,D.newMessage=A,D.newMessageWithSelectedCards=C,D.newMessageWithRecipient=B,D.mode={search:!1,multiple:0}}a.$inject=["$scope","$q","$window","$state","$timeout","$mdDialog","Account","Card","AddressBook","Dialog","sgSettings","stateAddressbooks","stateAddressbook"],angular.module("SOGo.ContactsUI").controller("AddressBookController",a)}(),function(){"use strict";function a(a,b,c,d,e,f,g,h,i,j,k,m,n,o,p,q,r,s){function t(b,c){a.params.addressbookId!=c.id&&F.editMode!=c.id?(F.editMode=!1,o.$query.value="",i("xs")&&j("left").close(),a.go("app.addressbook",{addressbookId:c.id})):(b.preventDefault(),b.stopPropagation())}function u(){p.prompt(l("New addressbook"),l("Name of new addressbook")).then(function(a){var b=new o({name:a,isEditable:!0,isRemote:!1,owner:UserLogin});o.$add(b)})}function v(a){a.isRemote||(F.editMode=a.id,F.originalAddressbook=angular.extend({},a.$omit()),m("addressBookName_"+a.id))}function w(a){a.name=F.originalAddressbook.name,F.editMode=!1}function x(a){var b=a.name;b&&b.length>0&&b!=F.originalAddressbook.name&&a.$rename(b).then(function(a){F.editMode=!1},function(a,b){p.alert(l("Warning"),a)})}function y(){F.service.selectedFolder.isSubscription?F.service.selectedFolder.$delete().then(function(){F.service.selectedFolder=null,a.go("app.addressbook",{addressbookId:"personal"})},function(a,b){p.alert(l('An error occured while deleting the addressbook "%{0}".',F.service.selectedFolder.name),l(a.error))}):p.confirm(l("Warning"),l("Are you sure you want to delete the addressbook %{0}?",F.service.selectedFolder.name),{ok:l("Delete")}).then(function(){return F.service.selectedFolder.$delete()}).then(function(){return F.service.selectedFolder=null,a.go("app.addressbook",{addressbookId:"personal"}),!0})["catch"](function(a){var b=a.data.message||a.statusText;p.alert(l('An error occured while deleting the addressbook "%{0}".',F.service.selectedFolder.name),b)})}function z(a,b){function c(a,b,c){function d(a){var b=0===a.type.indexOf("text")||/\.(ldif|vcf|vcard)$/.test(a.name);return b||h.show({template:["",'
',' error_outline'," "+l("Select a vCard or LDIF file.")+"","
","
"].join(""),position:"top right",hideDelay:3e3}),b}var e=this;e.uploader=new k({url:ApplicationBaseURL+[c.id,"import"].join("/"),autoUpload:!0,queueLimit:1,filters:[{name:d,fn:d}],onSuccessItem:function(a,c,d,e){var f;b.hide(),0===c.imported?f=l("No card was imported."):(f=l("A total of %{0} cards were imported in the addressbook.",c.imported),o.selectedFolder.$reload()),h.show(h.simple().content(f).position("top right").hideDelay(3e3))},onErrorItem:function(a,b,c,d){h.show({template:["",'
',' error_outline'," "+l("An error occured while importing contacts.")+"","
","
"].join(""),position:"top right",hideDelay:3e3})}}),e.close=function(){b.hide()}}g.show({parent:angular.element(document.body),targetEvent:a,clickOutsideToClose:!0,escapeToClose:!0,templateUrl:"UIxContactsImportDialog",controller:c,controllerAs:"$CardsImportDialogController",locals:{folder:b}}),c.$inject=["scope","$mdDialog","folder"]}function A(){f.location.href=ApplicationBaseURL+"/"+F.service.selectedFolder.id+"/exportFolder"}function B(a){function b(a,b){function c(){a.hide()}this.addressbook=b,this.close=c}g.show({parent:angular.element(document.body),clickOutsideToClose:!0,escapeToClose:!0,templateUrl:a.id+"/links",controller:b,controllerAs:"links",locals:{addressbook:a}}),b.$inject=["$mdDialog","addressbook"]}function C(a){function b(a,b,c){function d(){f.addressbook.$save().then(function(){c.init(f.addressbook.$omit()),b.hide()})}function e(){b.cancel()}var f=this;f.addressbook=new o(c.$omit()),f.saveProperties=d,f.close=e}g.show({templateUrl:a.id+"/properties",controller:b,controllerAs:"properties",clickOutsideToClose:!0,escapeToClose:!0,locals:{srcAddressBook:a}})["catch"](function(){}),b.$inject=["$scope","$mdDialog","srcAddressBook"]}function D(a){a.$acl.$users().then(function(){g.show({templateUrl:a.id+"/UIxAclEditor",controller:"AclController",controllerAs:"acl",clickOutsideToClose:!0,escapeToClose:!0,locals:{usersWithACL:a.$acl.users,User:r,folder:a}})})}function E(a){console.debug("subscribeToFolder "+a.owner+a.name),o.$subscribe(a.owner,a.name).then(function(a){h.show(h.simple().content(l("Successfully subscribed to address book")).position("top right").hideDelay(3e3))})}var F=this;F.activeUser=q.activeUser,F.service=o,F.select=t,F.newAddressbook=u,F.edit=v,F.revertEditing=w,F.save=x,F.confirmDelete=y,F.importCards=z,F.exportCards=A,F.showLinks=B,F.showProperties=C,F.share=D,F.subscribeToFolder=E}a.$inject=["$state","$scope","$rootScope","$stateParams","$timeout","$window","$mdDialog","$mdToast","$mdMedia","$mdSidenav","FileUploader","sgFocus","Card","AddressBook","Dialog","sgSettings","User","stateAddressbooks"],angular.module("SOGo.ContactsUI").controller("AddressBooksController",a)}(),function(){"use strict";function a(a,b,c,d,e,f,g,h,i,j,k){function m(a){return angular.isString(a)?{value:a}:a}function n(){var a=C.card.$addOrgUnit("");h("orgUnit_"+a)}function o(){C.card.birthday=new Date}function p(){C.card.$addScreenName("")}function q(){var a=C.card.$addEmail("");h("email_"+a)}function r(){var a=C.card.$addPhone("");h("phone_"+a)}function s(){var a=C.card.$addUrl("","");h("url_"+a)}function t(){var a=C.card.$addAddress("","","","","","","","");h("address_"+a)}function u(a,b){return e.selectedFolder.$filter(a,{dry:!0,excludeLists:!0},b),e.selectedFolder.$$cards}function v(a){a.$valid&&C.card.$save().then(function(a){var b=_.indexOf(_.map(e.selectedFolder.$cards,"id"),C.card.id);0>b?e.selectedFolder.$reload():e.selectedFolder.$cards[b]=angular.copy(C.card),i.go("app.addressbook.card.view",{cardId:C.card.id})})}function w(){i.go("app.addressbook",{addressbookId:e.selectedFolder.id}).then(function(){C.card=null,delete e.selectedFolder.selectedCard})}function x(){C.card.$reset()}function y(){C.card.$reset(),C.card.isNew?(C.card=null,delete e.selectedFolder.selectedCard,i.go("app.addressbook",{addressbookId:e.selectedFolder.id})):i.go("app.addressbook.card.view",{cardId:C.card.id})}function z(a){g.confirm(l("Warning"),l("Are you sure you want to delete the card of %{0}?",""+a.$fullname()+""),{ok:l("Delete")}).then(function(){a.$delete().then(function(){e.selectedFolder.$cards=_.reject(e.selectedFolder.$cards,function(b){return b.id==a.id}),w()},function(b,c){g.alert(l("Warning"),l('An error occured while deleting the card "%{0}".',a.$fullname()))})})}function A(){c.location.href=ApplicationBaseURL+"/"+C.currentFolder.id+"/export?uid="+C.card.id}function B(a){C.showRawSource||C.rawSource?C.showRawSource=!C.showRawSource:f.$$resource.post(C.currentFolder.id+"/"+C.card.id,"raw").then(function(a){C.rawSource=a,C.showRawSource=!0})}var C=this;C.card=k,C.currentFolder=e.selectedFolder,C.allEmailTypes=f.$EMAIL_TYPES,C.allTelTypes=f.$TEL_TYPES,C.allUrlTypes=f.$URL_TYPES,C.allAddressTypes=f.$ADDRESS_TYPES,C.categories={},C.userFilterResults=[],C.transformCategory=m,C.addOrgUnit=n,C.addBirthday=o,C.addScreenName=p,C.addEmail=q,C.addPhone=r,C.addUrl=s,C.addAddress=t,C.userFilter=u,C.save=v,C.close=w,C.reset=x,C.cancel=y,C.confirmDelete=z,C.exportCard=A,C.toggleRawSource=B,C.showRawSource=!1}a.$inject=["$scope","$timeout","$window","$mdDialog","AddressBook","Card","Dialog","sgFocus","$state","$stateParams","stateCard"],angular.module("SOGo.ContactsUI").controller("CardController",a)}(),function(){"use strict";function a(){return{restrict:"A",scope:{data:"=sgAddress"},controller:["$scope",function(a){a.addressLines=function(a){var b=[],c=[];return a.street&&b.push(a.street),a.street2&&b.push(a.street2),a.locality&&c.push(a.locality),a.region&&c.push(a.region),c.length>0&&b.push(c.join(", ")),a.country&&b.push(a.country),a.postalcode&&b.push(a.postalcode),b.join("
")}}],template:'
'}}angular.module("SOGo.Common").directive("sgAddress",a)}(); +!function(){"use strict";function a(a,f){a.state("app",{url:"/addressbooks","abstract":!0,views:{addressbooks:{templateUrl:"UIxContactFoldersView",controller:"AddressBooksController",controllerAs:"app"}},resolve:{stateAddressbooks:b}}).state("app.addressbook",{url:"/:addressbookId",views:{addressbook:{templateUrl:"addressbook",controller:"AddressBookController",controllerAs:"addressbook"}},resolve:{stateAddressbook:c}}).state("app.addressbook.new",{url:"/{contactType:(?:card|list)}/new",views:{card:{templateUrl:"UIxContactEditorTemplate",controller:"CardController",controllerAs:"editor"}},resolve:{stateCard:d}}).state("app.addressbook.card",{url:"/:cardId","abstract":!0,views:{card:{template:""}},resolve:{stateCard:e}}).state("app.addressbook.card.view",{url:"/view",views:{"card@app.addressbook":{templateUrl:"UIxContactViewTemplate",controller:"CardController",controllerAs:"editor"}}}).state("app.addressbook.card.editor",{url:"/edit",views:{"card@app.addressbook":{templateUrl:"UIxContactEditorTemplate",controller:"CardController",controllerAs:"editor"}}}),f.otherwise("/addressbooks/personal")}function b(a){return a.$findAll(window.contactFolders)}function c(a,b,c,d){var e=_.find(d.$findAll(),function(a){return a.id==c.addressbookId});return e?(e.selectedCard=!1,e.$reload(),e):a.reject("Addressbook "+c.addressbookId+" not found")}function d(a,b,c){var d="v"+a.contactType,e=new c({pid:a.addressbookId,c_component:d});return b.selectedCard=!0,e}function e(a,b){return b.selectedCard=a.cardId,b.$getCard(a.cardId)}function f(a,b,c){a.$on("$stateChangeError",function(a,d,e,f,g,h){b.error(h),c.go("app.addressbook",{addressbookId:"personal"})}),a.$on("$routeChangeError",function(a,c,d,e){b.error(a,c,d,e)})}angular.module("SOGo.ContactsUI",["ui.router","angularFileUpload","ck","SOGo.Common","SOGo.PreferencesUI","SOGo.MailerUI"]).config(a).run(f),a.$inject=["$stateProvider","$urlRouterProvider"],b.$inject=["AddressBook"],c.$inject=["$q","$state","$stateParams","AddressBook"],d.$inject=["$stateParams","stateAddressbook","Card"],e.$inject=["$stateParams","stateAddressbook"],f.$inject=["$rootScope","$log","$state"]}(),function(){"use strict";function a(a,b,c,d,e,f,g,h,i,j,k,m,n){function o(a){d.go("app.addressbook.card.view",{addressbookId:n.id,cardId:a.id})}function p(a,b){b.selected=!b.selected,D.mode.multiple+=b.selected?1:-1,a.preventDefault(),a.stopPropagation()}function q(a){function b(a,b,c,d){a.create=function(a){b.hide(),c.go("app.addressbook.new",{addressbookId:d,contactType:a})}}f.show({parent:angular.element(document.body),targetEvent:a,clickOutsideToClose:!0,escapeToClose:!0,template:[''," ",'
'," "," "+l("Contact")," "," "," "+l("List")," ","
","
","
"].join(""),locals:{addressbookId:D.selectedFolder.id},controller:b}),b.$inject=["scope","$mdDialog","$state","addressbookId"]}function r(a,b){return a&&a.c_component==b&&!a.selected}function s(){_.forEach(D.selectedFolder.$cards,function(a){a.selected=!1}),D.mode.multiple=0}function t(){j.confirm(l("Warning"),l("Are you sure you want to delete the selected contacts?"),{ok:l("Delete")}).then(function(){var a=_.filter(D.selectedFolder.$cards,function(a){return a.selected});D.selectedFolder.$deleteCards(a),delete D.selectedFolder.selectedCard})}function u(){var a=_.filter(D.selectedFolder.$cards,function(a){return a.selected}),b=_.map(a,"id");c.location.href=ApplicationBaseURL+"/"+D.selectedFolder.id+"/export?uid="+b.join("&uid=")}function v(a){var b=_.filter(D.selectedFolder.$cards,function(a){return a.selected});D.selectedFolder.$copyCards(b,a).then(function(){})}function w(){_.forEach(D.selectedFolder.$cards,function(a){a.selected=!0}),D.mode.multiple=D.selectedFolder.$cards.length}function x(a){D.selectedFolder.$filter("",{sort:a})}function y(a){return i.$query.sort==a}function z(){D.mode.search=!1,D.selectedFolder.$filter("")}function A(a,b){g.$findAll().then(function(c){var d=_.filter(c,function(a){return 0===a.id?a:void 0})[0];d.$getMailboxes().then(function(e){d.$newMessage().then(function(d){f.show({parent:angular.element(document.body),targetEvent:a,clickOutsideToClose:!1,escapeToClose:!1,templateUrl:"../Mail/UIxMailEditor",controller:"MessageEditorController",controllerAs:"editor",locals:{stateAccounts:c,stateMessage:d,stateRecipients:b}})})})})}function B(a,b,c){var d=[{full:c+" <"+b+">"}];D.newMessage(a,d),a.stopPropagation(),a.preventDefault()}function C(a){var c=_.filter(D.selectedFolder.$cards,function(a){return a.selected}),d=[],e=[];_.forEach(c,function(a){"vcard"==a.c_component&&a.c_mail.length?e.push({full:a.c_cn+" <"+a.c_mail+">"}):a.$isList()&&(angular.isDefined(a.refs)&&a.refs.length?_.forEach(a.refs,function(a){a.email.length&&e.push({full:a.c_cn+" <"+a.email+">"})}):d.push(D.selectedFolder.$getCard(a.id).then(function(a){return a.$futureCardData.then(function(a){_.forEach(a.refs,function(a){a.email.length&&e.push({full:a.c_cn+" <"+a.email+">"})})})})))}),b.all(d).then(function(){e.length&&D.newMessage(a,e)})}var D=this;i.selectedFolder=n,D.service=i,D.selectedFolder=n,D.selectCard=o,D.toggleCardSelection=p,D.newComponent=q,D.notSelectedComponent=r,D.unselectCards=s,D.confirmDeleteSelectedCards=t,D.saveSelectedCards=u,D.copySelectedCards=v,D.selectAll=w,D.sort=x,D.sortedBy=y,D.cancelSearch=z,D.newMessage=A,D.newMessageWithSelectedCards=C,D.newMessageWithRecipient=B,D.mode={search:!1,multiple:0}}a.$inject=["$scope","$q","$window","$state","$timeout","$mdDialog","Account","Card","AddressBook","Dialog","sgSettings","stateAddressbooks","stateAddressbook"],angular.module("SOGo.ContactsUI").controller("AddressBookController",a)}(),function(){"use strict";function a(a,b,c,d,e,f,g,h,i,j,k,m,n,o,p,q,r,s){function t(b,c){a.params.addressbookId!=c.id&&F.editMode!=c.id?(F.editMode=!1,o.$query.value="",i("xs")&&j("left").close(),a.go("app.addressbook",{addressbookId:c.id})):(b.preventDefault(),b.stopPropagation())}function u(){p.prompt(l("New addressbook"),l("Name of new addressbook")).then(function(a){var b=new o({name:a,isEditable:!0,isRemote:!1,owner:UserLogin});o.$add(b)})}function v(a){a.isRemote||(F.editMode=a.id,F.originalAddressbook=angular.extend({},a.$omit()),m("addressBookName_"+a.id))}function w(a){a.name=F.originalAddressbook.name,F.editMode=!1}function x(a){var b=a.name;b&&b.length>0&&b!=F.originalAddressbook.name&&a.$rename(b).then(function(a){F.editMode=!1},function(a,b){p.alert(l("Warning"),a)})}function y(){F.service.selectedFolder.isSubscription?F.service.selectedFolder.$delete().then(function(){F.service.selectedFolder=null,a.go("app.addressbook",{addressbookId:"personal"})},function(a,b){p.alert(l('An error occured while deleting the addressbook "%{0}".',F.service.selectedFolder.name),l(a.error))}):p.confirm(l("Warning"),l('Are you sure you want to delete the addressbook "%{0}"?',F.service.selectedFolder.name),{ok:l("Delete")}).then(function(){return F.service.selectedFolder.$delete()}).then(function(){return F.service.selectedFolder=null,a.go("app.addressbook",{addressbookId:"personal"}),!0})["catch"](function(a){var b=a.data.message||a.statusText;p.alert(l('An error occured while deleting the addressbook "%{0}".',F.service.selectedFolder.name),b)})}function z(a,b){function c(a,b,c){function d(a){var b=0===a.type.indexOf("text")||/\.(ldif|vcf|vcard)$/.test(a.name);return b||h.show({template:["",'
',' error_outline'," "+l("Select a vCard or LDIF file.")+"","
","
"].join(""),position:"top right",hideDelay:3e3}),b}var e=this;e.uploader=new k({url:ApplicationBaseURL+[c.id,"import"].join("/"),autoUpload:!0,queueLimit:1,filters:[{name:d,fn:d}],onSuccessItem:function(a,c,d,e){var f;b.hide(),0===c.imported?f=l("No card was imported."):(f=l("A total of %{0} cards were imported in the addressbook.",c.imported),o.selectedFolder.$reload()),h.show(h.simple().content(f).position("top right").hideDelay(3e3))},onErrorItem:function(a,b,c,d){h.show({template:["",'
',' error_outline'," "+l("An error occured while importing contacts.")+"","
","
"].join(""),position:"top right",hideDelay:3e3})}}),e.close=function(){b.hide()}}g.show({parent:angular.element(document.body),targetEvent:a,clickOutsideToClose:!0,escapeToClose:!0,templateUrl:"UIxContactsImportDialog",controller:c,controllerAs:"$CardsImportDialogController",locals:{folder:b}}),c.$inject=["scope","$mdDialog","folder"]}function A(){f.location.href=ApplicationBaseURL+"/"+F.service.selectedFolder.id+"/exportFolder"}function B(a){function b(a,b){function c(){a.hide()}this.addressbook=b,this.close=c}g.show({parent:angular.element(document.body),clickOutsideToClose:!0,escapeToClose:!0,templateUrl:a.id+"/links",controller:b,controllerAs:"links",locals:{addressbook:a}}),b.$inject=["$mdDialog","addressbook"]}function C(a){function b(a,b,c){function d(){f.addressbook.$save().then(function(){c.init(f.addressbook.$omit()),b.hide()})}function e(){b.cancel()}var f=this;f.addressbook=new o(c.$omit()),f.saveProperties=d,f.close=e}g.show({templateUrl:a.id+"/properties",controller:b,controllerAs:"properties",clickOutsideToClose:!0,escapeToClose:!0,locals:{srcAddressBook:a}})["catch"](function(){}),b.$inject=["$scope","$mdDialog","srcAddressBook"]}function D(a){a.$acl.$users().then(function(){g.show({templateUrl:a.id+"/UIxAclEditor",controller:"AclController",controllerAs:"acl",clickOutsideToClose:!0,escapeToClose:!0,locals:{usersWithACL:a.$acl.users,User:r,folder:a}})})}function E(a){console.debug("subscribeToFolder "+a.owner+a.name),o.$subscribe(a.owner,a.name).then(function(a){h.show(h.simple().content(l("Successfully subscribed to address book")).position("top right").hideDelay(3e3))})}var F=this;F.activeUser=q.activeUser,F.service=o,F.select=t,F.newAddressbook=u,F.edit=v,F.revertEditing=w,F.save=x,F.confirmDelete=y,F.importCards=z,F.exportCards=A,F.showLinks=B,F.showProperties=C,F.share=D,F.subscribeToFolder=E}a.$inject=["$state","$scope","$rootScope","$stateParams","$timeout","$window","$mdDialog","$mdToast","$mdMedia","$mdSidenav","FileUploader","sgFocus","Card","AddressBook","Dialog","sgSettings","User","stateAddressbooks"],angular.module("SOGo.ContactsUI").controller("AddressBooksController",a)}(),function(){"use strict";function a(a,b,c,d,e,f,g,h,i,j,k){function m(a){return angular.isString(a)?{value:a}:a}function n(){var a=C.card.$addOrgUnit("");h("orgUnit_"+a)}function o(){C.card.birthday=new Date}function p(){C.card.$addScreenName("")}function q(){var a=C.card.$addEmail("");h("email_"+a)}function r(){var a=C.card.$addPhone("");h("phone_"+a)}function s(){var a=C.card.$addUrl("","");h("url_"+a)}function t(){var a=C.card.$addAddress("","","","","","","","");h("address_"+a)}function u(a,b){return e.selectedFolder.$filter(a,{dry:!0,excludeLists:!0},b),e.selectedFolder.$$cards}function v(a){a.$valid&&C.card.$save().then(function(a){var b=_.indexOf(_.map(e.selectedFolder.$cards,"id"),C.card.id);0>b?e.selectedFolder.$reload():e.selectedFolder.$cards[b]=angular.copy(C.card),i.go("app.addressbook.card.view",{cardId:C.card.id})})}function w(){i.go("app.addressbook",{addressbookId:e.selectedFolder.id}).then(function(){C.card=null,delete e.selectedFolder.selectedCard})}function x(){C.card.$reset()}function y(){C.card.$reset(),C.card.isNew?(C.card=null,delete e.selectedFolder.selectedCard,i.go("app.addressbook",{addressbookId:e.selectedFolder.id})):i.go("app.addressbook.card.view",{cardId:C.card.id})}function z(a){g.confirm(l("Warning"),l("Are you sure you want to delete the card of %{0}?",""+a.$fullname()+""),{ok:l("Delete")}).then(function(){a.$delete().then(function(){e.selectedFolder.$cards=_.reject(e.selectedFolder.$cards,function(b){return b.id==a.id}),w()},function(b,c){g.alert(l("Warning"),l('An error occured while deleting the card "%{0}".',a.$fullname()))})})}function A(){c.location.href=ApplicationBaseURL+"/"+C.currentFolder.id+"/export?uid="+C.card.id}function B(a){C.showRawSource||C.rawSource?C.showRawSource=!C.showRawSource:f.$$resource.post(C.currentFolder.id+"/"+C.card.id,"raw").then(function(a){C.rawSource=a,C.showRawSource=!0})}var C=this;C.card=k,C.currentFolder=e.selectedFolder,C.allEmailTypes=f.$EMAIL_TYPES,C.allTelTypes=f.$TEL_TYPES,C.allUrlTypes=f.$URL_TYPES,C.allAddressTypes=f.$ADDRESS_TYPES,C.categories={},C.userFilterResults=[],C.transformCategory=m,C.addOrgUnit=n,C.addBirthday=o,C.addScreenName=p,C.addEmail=q,C.addPhone=r,C.addUrl=s,C.addAddress=t,C.userFilter=u,C.save=v,C.close=w,C.reset=x,C.cancel=y,C.confirmDelete=z,C.exportCard=A,C.toggleRawSource=B,C.showRawSource=!1}a.$inject=["$scope","$timeout","$window","$mdDialog","AddressBook","Card","Dialog","sgFocus","$state","$stateParams","stateCard"],angular.module("SOGo.ContactsUI").controller("CardController",a)}(),function(){"use strict";function a(){return{restrict:"A",scope:{data:"=sgAddress"},controller:["$scope",function(a){a.addressLines=function(a){var b=[],c=[];return a.street&&b.push(a.street),a.street2&&b.push(a.street2),a.locality&&c.push(a.locality),a.region&&c.push(a.region),c.length>0&&b.push(c.join(", ")),a.country&&b.push(a.country),a.postalcode&&b.push(a.postalcode),b.join("
")}}],template:'
'}}angular.module("SOGo.Common").directive("sgAddress",a)}(); //# sourceMappingURL=Contacts.js.map \ No newline at end of file diff --git a/UI/WebServerResources/js/Contacts.js.map b/UI/WebServerResources/js/Contacts.js.map index 7bcf41969..489bcf674 100644 --- a/UI/WebServerResources/js/Contacts.js.map +++ b/UI/WebServerResources/js/Contacts.js.map @@ -1 +1 @@ -{"version":3,"sources":["Contacts/Contacts.app.js","Contacts/AddressBookController.js","Contacts/AddressBooksController.js","Contacts/CardController.js","Contacts/sgAddress.directive.js"],"names":["configure","$stateProvider","$urlRouterProvider","state","url","abstract","views","addressbooks","templateUrl","controller","controllerAs","resolve","stateAddressbooks","addressbook","stateAddressbook","card","stateCard","stateNewCard","template","card@app.addressbook","otherwise","AddressBook","$findAll","window","contactFolders","$q","$state","$stateParams","_","find","id","addressbookId","selectedCard","$reload","reject","Card","tag","contactType","pid","c_component","cardId","$getCard","runBlock","$rootScope","$log","$on","event","toState","toParams","fromState","fromParams","error","go","current","previous","rejection","angular","module","config","run","$inject","AddressBookController","$scope","$window","$timeout","$mdDialog","Account","Dialog","Settings","selectCard","toggleCardSelection","$event","selected","vm","mode","multiple","preventDefault","stopPropagation","newComponent","ev","ComponentDialogController","scope","create","type","hide","show","parent","element","document","body","targetEvent","clickOutsideToClose","escapeToClose","l","join","locals","selectedFolder","notSelectedComponent","currentCard","unselectCards","forEach","$cards","confirmDeleteSelectedCards","confirm","ok","then","selectedCards","filter","$deleteCards","saveSelectedCards","selectedUIDs","map","location","href","ApplicationBaseURL","copySelectedCards","folder","$copyCards","selectAll","length","sort","field","$filter","sortedBy","$query","cancelSearch","search","newMessage","recipients","accounts","account","o","$getMailboxes","mailboxes","$newMessage","message","stateAccounts","stateMessage","stateRecipients","newMessageWithRecipient","recipient","fn","full","newMessageWithSelectedCards","promises","c_mail","push","c_cn","$isList","isDefined","refs","ref","email","$futureCardData","data","all","this","service","AddressBooksController","$mdToast","$mdMedia","$mdSidenav","FileUploader","focus","User","select","params","editMode","value","close","newAddressbook","prompt","name","isEditable","isRemote","owner","UserLogin","$add","edit","originalAddressbook","extend","$omit","revertEditing","save","$rename","status","alert","confirmDelete","isSubscription","$delete","response","statusText","importCards","CardsImportDialogController","filterByExtension","item","isTextFile","indexOf","test","position","hideDelay","uploader","autoUpload","queueLimit","filters","onSuccessItem","headers","msg","imported","simple","content","onErrorItem","exportCards","showLinks","LinksDialogController","showProperties","PropertiesDialogController","srcAddressBook","saveProperties","$save","init","cancel","share","$acl","$users","usersWithACL","users","subscribeToFolder","addressbookData","console","debug","$subscribe","activeUser","CardController","transformCategory","input","isString","addOrgUnit","i","$addOrgUnit","addBirthday","birthday","Date","addScreenName","$addScreenName","addEmail","$addEmail","addPhone","$addPhone","addUrl","$addUrl","addAddress","$addAddress","userFilter","excludedCards","dry","excludeLists","$$cards","form","$valid","copy","reset","$reset","isNew","$fullname","exportCard","currentFolder","toggleRawSource","showRawSource","rawSource","$$resource","post","allEmailTypes","$EMAIL_TYPES","allTelTypes","$TEL_TYPES","allUrlTypes","$URL_TYPES","allAddressTypes","$ADDRESS_TYPES","categories","userFilterResults","sgAddress","restrict","addressLines","lines","locality_region","street","street2","locality","region","country","postalcode","directive"],"mappings":"CAGA,WACE,YAUA,SAASA,GAAUC,EAAgBC,GACjCD,EACGE,MAAM,OACLC,IAAK,gBACLC,YAAU,EACVC,OACEC,cACEC,YAAa,wBACbC,WAAY,yBACZC,aAAc,QAGlBC,SACEC,kBAAmBA,KAGtBT,MAAM,mBACLC,IAAK,kBACLE,OACEO,aACEL,YAAa,cACbC,WAAY,wBACZC,aAAc,gBAGlBC,SACEG,iBAAkBA,KAGrBX,MAAM,uBACLC,IAAK,mCACLE,OACES,MACEP,YAAa,2BACbC,WAAY,iBACZC,aAAc,WAGlBC,SACEK,UAAWC,KAGdd,MAAM,wBACLC,IAAK,WACLC,YAAU,EACVC,OACES,MACEG,SAAU,eAGdP,SACEK,UAAWA,KAGdb,MAAM,6BACLC,IAAK,QACLE,OACEa,wBACEX,YAAa,yBACbC,WAAY,iBACZC,aAAc,aAInBP,MAAM,+BACLC,IAAK,QACLE,OACEa,wBACEX,YAAa,2BACbC,WAAY,iBACZC,aAAc,aAMtBR,EAAmBkB,UAAU,0BAO/B,QAASR,GAAkBS,GACzB,MAAOA,GAAYC,SAASC,OAAOC,gBAOrC,QAASV,GAAiBW,EAAIC,EAAQC,EAAcN,GAClD,GAAIR,GAAce,EAAEC,KAAKR,EAAYC,WAAY,SAAST,GACxD,MAAOA,GAAYiB,IAAMH,EAAaI,eAExC,OAAIlB,IACFA,EAAYmB,cAAe,EAC3BnB,E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KyI,SAASN,EAAM3I,KAAKQ,EAAKyI,SAC9BzI,EAAK0I,YAAYP,EAAM3I,KAAKQ,EAAK0I,YAC9BP,EAAM/L,KAAK,WAGtB5E,SAAU,yDAIdsC,QACGC,OAAO,eACP4O,UAAU,YAAaX","file":"Contacts.js","sourcesContent":["/* -*- Mode: javascript; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n/* JavaScript for SOGoContacts */\n\n(function() {\n 'use strict';\n\n angular.module('SOGo.ContactsUI', ['ui.router', 'angularFileUpload', 'ck', 'SOGo.Common', 'SOGo.PreferencesUI', 'SOGo.MailerUI'])\n .config(configure)\n .run(runBlock);\n\n /**\n * @ngInject\n */\n configure.$inject = ['$stateProvider', '$urlRouterProvider'];\n function configure($stateProvider, $urlRouterProvider) {\n $stateProvider\n .state('app', {\n url: '/addressbooks',\n abstract: true,\n views: {\n addressbooks: {\n templateUrl: 'UIxContactFoldersView', // UI/Templates/Contacts/UIxContactFoldersView.wox\n controller: 'AddressBooksController',\n controllerAs: 'app'\n }\n },\n resolve: {\n stateAddressbooks: stateAddressbooks\n }\n })\n .state('app.addressbook', {\n url: '/:addressbookId',\n views: {\n addressbook: {\n templateUrl: 'addressbook',\n controller: 'AddressBookController',\n controllerAs: 'addressbook'\n }\n },\n resolve: {\n stateAddressbook: stateAddressbook\n }\n })\n .state('app.addressbook.new', {\n url: '/{contactType:(?:card|list)}/new',\n views: {\n card: {\n templateUrl: 'UIxContactEditorTemplate', // UI/Templates/Contacts/UIxContactEditorTemplate.wox\n controller: 'CardController',\n controllerAs: 'editor'\n }\n },\n resolve: {\n stateCard: stateNewCard\n }\n })\n .state('app.addressbook.card', {\n url: '/:cardId',\n abstract: true,\n views: {\n card: {\n template: ''\n }\n },\n resolve: {\n stateCard: stateCard\n }\n })\n .state('app.addressbook.card.view', {\n url: '/view',\n views: {\n 'card@app.addressbook': {\n templateUrl: 'UIxContactViewTemplate', // UI/Templates/Contacts/UIxContactViewTemplate.wox\n controller: 'CardController',\n controllerAs: 'editor'\n }\n }\n })\n .state('app.addressbook.card.editor', {\n url: '/edit',\n views: {\n 'card@app.addressbook': {\n templateUrl: 'UIxContactEditorTemplate', // UI/Templates/Contacts/UIxContactEditorTemplate.wox\n controller: 'CardController',\n controllerAs: 'editor'\n }\n }\n });\n\n // if none of the above states are matched, use this as the fallback\n $urlRouterProvider.otherwise('/addressbooks/personal');\n }\n\n /**\n * @ngInject\n */\n stateAddressbooks.$inject = ['AddressBook'];\n function stateAddressbooks(AddressBook) {\n return AddressBook.$findAll(window.contactFolders);\n }\n\n /**\n * @ngInject\n */\n stateAddressbook.$inject = ['$q', '$state', '$stateParams', 'AddressBook'];\n function stateAddressbook($q, $state, $stateParams, AddressBook) {\n var addressbook = _.find(AddressBook.$findAll(), function(addressbook) {\n return addressbook.id == $stateParams.addressbookId;\n });\n if (addressbook) {\n addressbook.selectedCard = false;\n addressbook.$reload();\n return addressbook;\n }\n return $q.reject('Addressbook ' + $stateParams.addressbookId + ' not found');\n }\n\n /**\n * @ngInject\n */\n stateNewCard.$inject = ['$stateParams', 'stateAddressbook', 'Card'];\n function stateNewCard($stateParams, stateAddressbook, Card) {\n var tag = 'v' + $stateParams.contactType,\n card = new Card({ pid: $stateParams.addressbookId, c_component: tag });\n stateAddressbook.selectedCard = true;\n return card;\n }\n\n /**\n * @ngInject\n */\n stateCard.$inject = ['$stateParams', 'stateAddressbook'];\n function stateCard($stateParams, stateAddressbook) {\n stateAddressbook.selectedCard = $stateParams.cardId;\n return stateAddressbook.$getCard($stateParams.cardId);\n }\n\n /**\n * @ngInject\n */\n runBlock.$inject = ['$rootScope', '$log', '$state'];\n function runBlock($rootScope, $log, $state) {\n $rootScope.$on('$stateChangeError', function(event, toState, toParams, fromState, fromParams, error) {\n $log.error(error);\n $state.go('app.addressbook', { addressbookId: 'personal' });\n });\n $rootScope.$on('$routeChangeError', function(event, current, previous, rejection) {\n $log.error(event, current, previous, rejection);\n });\n }\n\n})();\n","/* -*- Mode: javascript; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n\n(function() {\n 'use strict';\n\n /**\n * @ngInject\n */\n AddressBookController.$inject = ['$scope', '$q', '$window', '$state', '$timeout', '$mdDialog', 'Account', 'Card', 'AddressBook', 'Dialog', 'sgSettings', 'stateAddressbooks', 'stateAddressbook'];\n function AddressBookController($scope, $q, $window, $state, $timeout, $mdDialog, Account, Card, AddressBook, Dialog, Settings, stateAddressbooks, stateAddressbook) {\n var vm = this;\n\n AddressBook.selectedFolder = stateAddressbook;\n\n vm.service = AddressBook;\n vm.selectedFolder = stateAddressbook;\n vm.selectCard = selectCard;\n vm.toggleCardSelection = toggleCardSelection;\n vm.newComponent = newComponent;\n vm.notSelectedComponent = notSelectedComponent;\n vm.unselectCards = unselectCards;\n vm.confirmDeleteSelectedCards = confirmDeleteSelectedCards;\n vm.saveSelectedCards = saveSelectedCards;\n vm.copySelectedCards = copySelectedCards;\n vm.selectAll = selectAll;\n vm.sort = sort;\n vm.sortedBy = sortedBy;\n vm.cancelSearch = cancelSearch;\n vm.newMessage = newMessage;\n vm.newMessageWithSelectedCards = newMessageWithSelectedCards;\n vm.newMessageWithRecipient = newMessageWithRecipient;\n vm.mode = { search: false, multiple: 0 };\n \n function selectCard(card) {\n $state.go('app.addressbook.card.view', {addressbookId: stateAddressbook.id, cardId: card.id});\n }\n \n function toggleCardSelection($event, card) {\n card.selected = !card.selected;\n vm.mode.multiple += card.selected? 1 : -1;\n $event.preventDefault();\n $event.stopPropagation();\n }\n\n function newComponent(ev) {\n $mdDialog.show({\n parent: angular.element(document.body),\n targetEvent: ev,\n clickOutsideToClose: true,\n escapeToClose: true,\n template: [\n '',\n ' ',\n '
',\n ' ',\n ' ' + l('Contact'),\n ' ',\n ' ',\n ' ' + l('List'),\n ' ',\n '
',\n '
',\n '
'\n ].join(''),\n locals: {\n addressbookId: vm.selectedFolder.id\n },\n controller: ComponentDialogController\n });\n \n /**\n * @ngInject\n */\n ComponentDialogController.$inject = ['scope', '$mdDialog', '$state', 'addressbookId'];\n function ComponentDialogController(scope, $mdDialog, $state, addressbookId) {\n scope.create = function(type) {\n $mdDialog.hide();\n $state.go('app.addressbook.new', { addressbookId: addressbookId, contactType: type });\n };\n }\n }\n\n function notSelectedComponent(currentCard, type) {\n return (currentCard && currentCard.c_component == type && !currentCard.selected);\n }\n\n function unselectCards() {\n _.forEach(vm.selectedFolder.$cards, function(card) {\n card.selected = false;\n });\n vm.mode.multiple = 0;\n }\n \n function confirmDeleteSelectedCards() {\n Dialog.confirm(l('Warning'),\n l('Are you sure you want to delete the selected contacts?'),\n { ok: l('Delete') })\n .then(function() {\n // User confirmed the deletion\n var selectedCards = _.filter(vm.selectedFolder.$cards, function(card) { return card.selected; });\n vm.selectedFolder.$deleteCards(selectedCards);\n delete vm.selectedFolder.selectedCard;\n });\n }\n\n function saveSelectedCards() {\n var selectedCards = _.filter(vm.selectedFolder.$cards, function(card) { return card.selected; });\n var selectedUIDs = _.map(selectedCards, 'id');\n $window.location.href = ApplicationBaseURL + '/' + vm.selectedFolder.id + '/export?uid=' + selectedUIDs.join('&uid=');\n }\n\n function copySelectedCards(folder) {\n var selectedCards = _.filter(vm.selectedFolder.$cards, function(card) { return card.selected; });\n vm.selectedFolder.$copyCards(selectedCards, folder).then(function() {\n // TODO: refresh target addressbook?\n });\n }\n\n function selectAll() {\n _.forEach(vm.selectedFolder.$cards, function(card) {\n card.selected = true;\n });\n vm.mode.multiple = vm.selectedFolder.$cards.length;\n }\n\n function sort(field) {\n vm.selectedFolder.$filter('', { sort: field });\n }\n\n function sortedBy(field) {\n return AddressBook.$query.sort == field;\n }\n\n function cancelSearch() {\n vm.mode.search = false;\n vm.selectedFolder.$filter('');\n }\n\n function newMessage($event, recipients) {\n Account.$findAll().then(function(accounts) {\n var account = _.filter(accounts, function(o) {\n if (o.id === 0)\n return o;\n })[0];\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 $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 stateAccounts: accounts,\n stateMessage: message,\n stateRecipients: recipients\n }\n });\n });\n });\n });\n }\n\n function newMessageWithRecipient($event, recipient, fn) {\n var recipients = [{full: fn + ' <' + recipient + '>'}];\n vm.newMessage($event, recipients);\n $event.stopPropagation();\n $event.preventDefault();\n }\n\n function newMessageWithSelectedCards($event) {\n var selectedCards = _.filter(vm.selectedFolder.$cards, function(card) { return card.selected; });\n var promises = [], recipients = [];\n\n _.forEach(selectedCards, function(card) {\n if (card.c_component == 'vcard' && card.c_mail.length) {\n recipients.push({full: card.c_cn + ' <' + card.c_mail + '>'});\n }\n else if (card.$isList()) {\n // If the list's members were already fetch, use them\n if (angular.isDefined(card.refs) && card.refs.length) {\n _.forEach(card.refs, function(ref) {\n if (ref.email.length)\n recipients.push({full: ref.c_cn + ' <' + ref.email + '>'});\n });\n }\n else {\n promises.push(vm.selectedFolder.$getCard(card.id).then(function(card) {\n return card.$futureCardData.then(function(data) {\n _.forEach(data.refs, function(ref) {\n if (ref.email.length)\n recipients.push({full: ref.c_cn + ' <' + ref.email + '>'});\n });\n });\n }));\n }\n }\n });\n\n $q.all(promises).then(function() {\n if (recipients.length)\n vm.newMessage($event, recipients);\n });\n }\n }\n\n angular\n .module('SOGo.ContactsUI') \n .controller('AddressBookController', AddressBookController); \n})();\n","/* -*- Mode: javascript; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n\n(function() {\n 'use strict';\n\n /**\n * @ngInject\n */\n AddressBooksController.$inject = ['$state', '$scope', '$rootScope', '$stateParams', '$timeout', '$window', '$mdDialog', '$mdToast', '$mdMedia', '$mdSidenav', 'FileUploader', 'sgFocus', 'Card', 'AddressBook', 'Dialog', 'sgSettings', 'User', 'stateAddressbooks'];\n function AddressBooksController($state, $scope, $rootScope, $stateParams, $timeout, $window, $mdDialog, $mdToast, $mdMedia, $mdSidenav, FileUploader, focus, Card, AddressBook, Dialog, Settings, User, stateAddressbooks) {\n var vm = this;\n\n vm.activeUser = Settings.activeUser;\n vm.service = AddressBook;\n vm.select = select;\n vm.newAddressbook = newAddressbook;\n vm.edit = edit;\n vm.revertEditing = revertEditing;\n vm.save = save;\n vm.confirmDelete = confirmDelete;\n vm.importCards = importCards;\n vm.exportCards = exportCards;\n vm.showLinks = showLinks;\n vm.showProperties = showProperties;\n vm.share = share;\n vm.subscribeToFolder = subscribeToFolder;\n\n function select($event, folder) {\n if ($state.params.addressbookId != folder.id &&\n vm.editMode != folder.id) {\n vm.editMode = false;\n AddressBook.$query.value = '';\n // Close sidenav on small devices\n if ($mdMedia('xs'))\n $mdSidenav('left').close();\n $state.go('app.addressbook', {addressbookId: folder.id});\n }\n else {\n $event.preventDefault();\n $event.stopPropagation();\n }\n }\n\n function newAddressbook() {\n Dialog.prompt(l('New addressbook'),\n l('Name of new addressbook'))\n .then(function(name) {\n var addressbook = new AddressBook(\n {\n name: name,\n isEditable: true,\n isRemote: false,\n owner: UserLogin\n }\n );\n AddressBook.$add(addressbook);\n });\n }\n\n function edit(folder) {\n if (!folder.isRemote) {\n vm.editMode = folder.id;\n vm.originalAddressbook = angular.extend({}, folder.$omit());\n focus('addressBookName_' + folder.id);\n }\n }\n\n function revertEditing(folder) {\n folder.name = vm.originalAddressbook.name;\n vm.editMode = false;\n }\n\n function save(folder) {\n var name = folder.name;\n if (name && name.length > 0 && name != vm.originalAddressbook.name) {\n folder.$rename(name)\n .then(function(data) {\n vm.editMode = false;\n }, function(data, status) {\n Dialog.alert(l('Warning'), data);\n });\n }\n }\n\n function confirmDelete() {\n if (vm.service.selectedFolder.isSubscription) {\n // Unsubscribe without confirmation\n vm.service.selectedFolder.$delete()\n .then(function() {\n vm.service.selectedFolder = null;\n $state.go('app.addressbook', { addressbookId: 'personal' });\n }, function(data, status) {\n Dialog.alert(l('An error occured while deleting the addressbook \"%{0}\".',\n vm.service.selectedFolder.name),\n l(data.error));\n });\n }\n else {\n Dialog.confirm(l('Warning'), l('Are you sure you want to delete the addressbook %{0}?',\n vm.service.selectedFolder.name),\n { ok: l('Delete') })\n .then(function() {\n return vm.service.selectedFolder.$delete();\n })\n .then(function() {\n vm.service.selectedFolder = null;\n $state.go('app.addressbook', { addressbookId: 'personal' });\n return true;\n })\n .catch(function(response) {\n var message = response.data.message || response.statusText;\n Dialog.alert(l('An error occured while deleting the addressbook \"%{0}\".',\n vm.service.selectedFolder.name),\n message);\n });\n }\n }\n\n function importCards($event, folder) {\n $mdDialog.show({\n parent: angular.element(document.body),\n targetEvent: $event,\n clickOutsideToClose: true,\n escapeToClose: true,\n templateUrl: 'UIxContactsImportDialog',\n controller: CardsImportDialogController,\n controllerAs: '$CardsImportDialogController',\n locals: {\n folder: folder\n }\n });\n\n /**\n * @ngInject\n */\n CardsImportDialogController.$inject = ['scope', '$mdDialog', 'folder'];\n function CardsImportDialogController(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 card was imported.');\n else {\n msg = l('A total of %{0} cards were imported in the addressbook.', response.imported);\n AddressBook.selectedFolder.$reload();\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 '',\n '
',\n ' error_outline',\n ' ' + l('An error occured while importing contacts.') + '',\n '
',\n '
'\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 /\\.(ldif|vcf|vcard)$/.test(item.name);\n\n if (!isTextFile)\n $mdToast.show({\n template: [\n '',\n '
',\n ' error_outline',\n ' ' + l('Select a vCard or LDIF file.') + '',\n '
',\n '
'\n ].join(''),\n position: 'top right',\n hideDelay: 3000\n });\n\n return isTextFile;\n }\n }\n }\n\n function exportCards() {\n $window.location.href = ApplicationBaseURL + '/' + vm.service.selectedFolder.id + '/exportFolder';\n }\n\n function showLinks(addressbook) {\n $mdDialog.show({\n parent: angular.element(document.body),\n clickOutsideToClose: true,\n escapeToClose: true,\n templateUrl: addressbook.id + '/links',\n controller: LinksDialogController,\n controllerAs: 'links',\n locals: {\n addressbook: addressbook\n }\n });\n \n /**\n * @ngInject\n */\n LinksDialogController.$inject = ['$mdDialog', 'addressbook'];\n function LinksDialogController($mdDialog, addressbook) {\n var vm = this;\n this.addressbook = addressbook;\n this.close = close;\n\n function close() {\n $mdDialog.hide();\n }\n }\n }\n\n function showProperties(addressbook) {\n $mdDialog.show({\n templateUrl: addressbook.id + '/properties',\n controller: PropertiesDialogController,\n controllerAs: 'properties',\n clickOutsideToClose: true,\n escapeToClose: true,\n locals: {\n srcAddressBook: addressbook\n }\n }).catch(function() {\n // Do nothing\n });\n\n /**\n * @ngInject\n */\n PropertiesDialogController.$inject = ['$scope', '$mdDialog', 'srcAddressBook'];\n function PropertiesDialogController($scope, $mdDialog, srcAddressBook) {\n var vm = this;\n\n vm.addressbook = new AddressBook(srcAddressBook.$omit());\n vm.saveProperties = saveProperties;\n vm.close = close;\n\n function saveProperties() {\n vm.addressbook.$save().then(function() {\n // Refresh list instance\n srcAddressBook.init(vm.addressbook.$omit());\n $mdDialog.hide();\n });\n }\n\n function close() {\n $mdDialog.cancel();\n }\n }\n }\n\n function share(addressbook) {\n // Fetch list of ACL users\n addressbook.$acl.$users().then(function() {\n // Show ACL editor\n $mdDialog.show({\n templateUrl: addressbook.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: addressbook.$acl.users,\n User: User,\n folder: addressbook\n }\n });\n });\n }\n\n /**\n * subscribeToFolder - Callback of sgSubscribe directive\n */\n function subscribeToFolder(addressbookData) {\n console.debug('subscribeToFolder ' + addressbookData.owner + addressbookData.name);\n AddressBook.$subscribe(addressbookData.owner, addressbookData.name).then(function(data) {\n $mdToast.show(\n $mdToast.simple()\n .content(l('Successfully subscribed to address book'))\n .position('top right')\n .hideDelay(3000));\n });\n }\n }\n\n angular\n .module('SOGo.ContactsUI')\n .controller('AddressBooksController', AddressBooksController);\n})();\n","/* -*- Mode: javascript; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n\n(function() {\n 'use strict';\n\n /**\n * Controller to view and edit a card\n * @ngInject\n */\n CardController.$inject = ['$scope', '$timeout', '$window', '$mdDialog', 'AddressBook', 'Card', 'Dialog', 'sgFocus', '$state', '$stateParams', 'stateCard'];\n function CardController($scope, $timeout, $window, $mdDialog, AddressBook, Card, Dialog, focus, $state, $stateParams, stateCard) {\n var vm = this;\n\n vm.card = stateCard;\n\n vm.currentFolder = AddressBook.selectedFolder;\n vm.allEmailTypes = Card.$EMAIL_TYPES;\n vm.allTelTypes = Card.$TEL_TYPES;\n vm.allUrlTypes = Card.$URL_TYPES;\n vm.allAddressTypes = Card.$ADDRESS_TYPES;\n vm.categories = {};\n vm.userFilterResults = [];\n vm.transformCategory = transformCategory;\n vm.addOrgUnit = addOrgUnit;\n vm.addBirthday = addBirthday;\n vm.addScreenName = addScreenName;\n vm.addEmail = addEmail;\n vm.addPhone = addPhone;\n vm.addUrl = addUrl;\n vm.addAddress = addAddress;\n vm.userFilter = userFilter;\n vm.save = save;\n vm.close = close;\n vm.reset = reset;\n vm.cancel = cancel;\n vm.confirmDelete = confirmDelete;\n vm.exportCard = exportCard;\n vm.toggleRawSource = toggleRawSource;\n vm.showRawSource = false;\n\n function transformCategory(input) {\n if (angular.isString(input))\n return { value: input };\n else\n return input;\n }\n function addOrgUnit() {\n var i = vm.card.$addOrgUnit('');\n focus('orgUnit_' + i);\n }\n function addBirthday() {\n vm.card.birthday = new Date();\n }\n function addScreenName() {\n vm.card.$addScreenName('');\n }\n function addEmail() {\n var i = vm.card.$addEmail('');\n focus('email_' + i);\n }\n function addPhone() {\n var i = vm.card.$addPhone('');\n focus('phone_' + i);\n }\n function addUrl() {\n var i = vm.card.$addUrl('', '');\n focus('url_' + i);\n }\n function addAddress() {\n var i = vm.card.$addAddress('', '', '', '', '', '', '', '');\n focus('address_' + i);\n }\n function userFilter($query, excludedCards) {\n AddressBook.selectedFolder.$filter($query, {dry: true, excludeLists: true}, excludedCards);\n return AddressBook.selectedFolder.$$cards;\n }\n function save(form) {\n if (form.$valid) {\n vm.card.$save()\n .then(function(data) {\n var i = _.indexOf(_.map(AddressBook.selectedFolder.$cards, 'id'), vm.card.id);\n if (i < 0) {\n // New card; reload contacts list and show addressbook in which the card has been created\n AddressBook.selectedFolder.$reload();\n }\n else {\n // Update contacts list with new version of the Card object\n AddressBook.selectedFolder.$cards[i] = angular.copy(vm.card);\n }\n $state.go('app.addressbook.card.view', { cardId: vm.card.id });\n });\n }\n }\n function close() {\n $state.go('app.addressbook', { addressbookId: AddressBook.selectedFolder.id }).then(function() {\n vm.card = null;\n delete AddressBook.selectedFolder.selectedCard;\n });\n }\n function reset() {\n vm.card.$reset();\n }\n function cancel() {\n vm.card.$reset();\n if (vm.card.isNew) {\n // Cancelling the creation of a card\n vm.card = null;\n delete AddressBook.selectedFolder.selectedCard;\n $state.go('app.addressbook', { addressbookId: AddressBook.selectedFolder.id });\n }\n else {\n // Cancelling the edition of an existing card\n $state.go('app.addressbook.card.view', { cardId: vm.card.id });\n }\n }\n function confirmDelete(card) {\n Dialog.confirm(l('Warning'),\n l('Are you sure you want to delete the card of %{0}?', '' + card.$fullname() + ''),\n { ok: l('Delete') })\n .then(function() {\n // User confirmed the deletion\n card.$delete()\n .then(function() {\n // Remove card from addressbook\n AddressBook.selectedFolder.$cards = _.reject(AddressBook.selectedFolder.$cards, function(o) {\n return o.id == card.id;\n });\n close();\n }, function(data, status) {\n Dialog.alert(l('Warning'), l('An error occured while deleting the card \"%{0}\".',\n card.$fullname()));\n });\n });\n }\n\n function exportCard() {\n $window.location.href = ApplicationBaseURL + '/' + vm.currentFolder.id + '/export?uid=' + vm.card.id;\n }\n\n function toggleRawSource($event) {\n if (!vm.showRawSource && !vm.rawSource) {\n Card.$$resource.post(vm.currentFolder.id + '/' + vm.card.id, \"raw\").then(function(data) {\n vm.rawSource = data;\n vm.showRawSource = true;\n });\n }\n else {\n vm.showRawSource = !vm.showRawSource;\n }\n }\n }\n\n angular\n .module('SOGo.ContactsUI')\n .controller('CardController', CardController);\n})();\n","/* -*- Mode: javascript; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n\n(function() {\n 'use strict';\n\n /**\n * @name sgAddress\n * @memberof ContactsUI\n * @desc Directive to format a postal address.\n * @ngInject\n */\n function sgAddress() {\n return {\n restrict: 'A',\n scope: { data: '=sgAddress' },\n controller: ['$scope', function($scope) {\n $scope.addressLines = function(data) {\n var lines = [],\n locality_region = [];\n if (data.street) lines.push(data.street);\n if (data.street2) lines.push(data.street2);\n if (data.locality) locality_region.push(data.locality);\n if (data.region) locality_region.push(data.region);\n if (locality_region.length > 0) lines.push(locality_region.join(', '));\n if (data.country) lines.push(data.country);\n if (data.postalcode) lines.push(data.postalcode);\n return lines.join('
');\n };\n }],\n template: '
'\n };\n }\n \n angular\n .module('SOGo.Common')\n .directive('sgAddress', sgAddress);\n})();\n"]} \ No newline at end of file +{"version":3,"sources":["Contacts/Contacts.app.js","Contacts/AddressBookController.js","Contacts/AddressBooksController.js","Contacts/CardController.js","Contacts/sgAddress.directive.js"],"names":["configure","$stateProvider","$urlRouterProvider","state","url","abstract","views","addressbooks","templateUrl","controller","controllerAs","resolve","stateAddressbooks","addressbook","stateAddressbook","card","stateCard","stateNewCard","template","card@app.addressbook","otherwise","AddressBook","$findAll","window","contactFolders","$q","$state","$stateParams","_","find","id","addressbookId","selectedCard","$reload","reject","Card","tag","contactType","pid","c_component","cardId","$getCard","runBlock","$rootScope","$log","$on","event","toState","toParams","fromState","fromParams","error","go","current","previous","rejection","angular","module","config","run","$inject","AddressBookController","$scope","$window","$timeout","$mdDialog","Account","Dialog","Settings","selectCard","toggleCardSelection","$event","selected","vm","mode","multiple","preventDefault","stopPropagation","newComponent","ev","ComponentDialogController","scope","create","type","hide","show","parent","element","document","body","targetEvent","clickOutsideToClose","escapeToClose","l","join","locals","selectedFolder","notSelectedComponent","currentCard","unselectCards","forEach","$cards","confirmDeleteSelectedCards","confirm","ok","then","selectedCards","filter","$deleteCards","saveSelectedCards","selectedUIDs","map","location","href","ApplicationBaseURL","copySelectedCards","folder","$copyCards","selectAll","length","sort","field","$filter","sortedBy","$query","cancelSearch","search","newMessage","recipients","accounts","account","o","$getMailboxes","mailboxes","$newMessage","message","stateAccounts","stateMessage","stateRecipients","newMessageWithRecipient","recipient","fn","full","newMessageWithSelectedCards","promises","c_mail","push","c_cn","$isList","isDefined","refs","ref","email","$futureCardData","data","all","this","service","AddressBooksController","$mdToast","$mdMedia","$mdSidenav","FileUploader","focus","User","select","params","editMode","value","close","newAddressbook","prompt","name","isEditable","isRemote","owner","UserLogin","$add","edit","originalAddressbook","extend","$omit","revertEditing","save","$rename","status","alert","confirmDelete","isSubscription","$delete","response","statusText","importCards","CardsImportDialogController","filterByExtension","item","isTextFile","indexOf","test","position","hideDelay","uploader","autoUpload","queueLimit","filters","onSuccessItem","headers","msg","imported","simple","content","onErrorItem","exportCards","showLinks","LinksDialogController","showProperties","PropertiesDialogController","srcAddressBook","saveProperties","$save","init","cancel","share","$acl","$users","usersWithACL","users","subscribeToFolder","addressbookData","console","debug","$subscribe","activeUser","CardController","transformCategory","input","isString","addOrgUnit","i","$addOrgUnit","addBirthday","birthday","Date","addScreenName","$addScreenName","addEmail","$addEmail","addPhone","$addPhone","addUrl","$addUrl","addAddress","$addAddress","userFilter","excludedCards","dry","excludeLists","$$cards","form","$valid","copy","reset","$reset","isNew","$fullname","exportCard","currentFolder","toggleRawSource","showRawSource","rawSource","$$resource","post","allEmailTypes","$EMAIL_TYPES","allTelTypes","$TEL_TYPES","allUrlTypes","$URL_TYPES","allAddressTypes","$ADDRESS_TYPES","categories","userFilterResults","sgAddress","restrict","addressLines","lines","locality_region","street","street2","locality","region","country","postalcode","directive"],"mappings":"CAGA,WACE,YAUA,SAASA,GAAUC,EAAgBC,GACjCD,EACGE,MAAM,OACLC,IAAK,gBACLC,YAAU,EACVC,OACEC,cACEC,YAAa,wBACbC,WAAY,yBACZC,aAAc,QAGlBC,SACEC,kBAAmBA,KAGtBT,MAAM,mBACLC,IAAK,kBACLE,OACEO,aACEL,YAAa,cACbC,WAAY,wBACZC,aAAc,gBAGlBC,SACEG,iBAAkBA,KAGrBX,MAAM,uBACLC,IAAK,mCACLE,OACES,MACEP,YAAa,2BACbC,WAAY,iBACZC,aAAc,WAGlBC,SACEK,UAAWC,KAGdd,MAAM,wBACLC,IAAK,WACLC,YAAU,EACVC,OACES,MACEG,SAAU,eAGdP,SACEK,UAAWA,KAGdb,MAAM,6BACLC,IAAK,QACLE,OACEa,wBACEX,YAAa,yBACbC,WAAY,iBACZC,aAAc,aAInBP,MAAM,+BACLC,IAAK,QACLE,OACEa,wBACEX,YAAa,2BACbC,WAAY,iBACZC,aAAc,aAMtBR,EAAmBkB,UAAU,0BAO/B,QAASR,GAAkBS,GACzB,MAAOA,GAAYC,SAASC,OAAOC,gBAOrC,QAASV,GAAiBW,EAAIC,EAAQC,EAAcN,GAClD,GAAIR,GAAce,EAAEC,KAAKR,EAAYC,WAAY,SAAST,GACxD,MAAOA,GAAYiB,IAAMH,EAAaI,eAExC,OAAIlB,IACFA,EAAYmB,cAAe,EAC3BnB,EAAYoB,UACLpB,GAEFY,EAAGS,OAAO,eAAiBP,EAAaI,cAAgB,cAOjE,QAASd,GAAaU,EAAcb,EAAkBqB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,EAAM/L,KAAK,WAGtB5E,SAAU,yDAIdsC,QACGC,OAAO,eACP4O,UAAU,YAAaX","file":"Contacts.js","sourcesContent":["/* -*- Mode: javascript; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n/* JavaScript for SOGoContacts */\n\n(function() {\n 'use strict';\n\n angular.module('SOGo.ContactsUI', ['ui.router', 'angularFileUpload', 'ck', 'SOGo.Common', 'SOGo.PreferencesUI', 'SOGo.MailerUI'])\n .config(configure)\n .run(runBlock);\n\n /**\n * @ngInject\n */\n configure.$inject = ['$stateProvider', '$urlRouterProvider'];\n function configure($stateProvider, $urlRouterProvider) {\n $stateProvider\n .state('app', {\n url: '/addressbooks',\n abstract: true,\n views: {\n addressbooks: {\n templateUrl: 'UIxContactFoldersView', // UI/Templates/Contacts/UIxContactFoldersView.wox\n controller: 'AddressBooksController',\n controllerAs: 'app'\n }\n },\n resolve: {\n stateAddressbooks: stateAddressbooks\n }\n })\n .state('app.addressbook', {\n url: '/:addressbookId',\n views: {\n addressbook: {\n templateUrl: 'addressbook',\n controller: 'AddressBookController',\n controllerAs: 'addressbook'\n }\n },\n resolve: {\n stateAddressbook: stateAddressbook\n }\n })\n .state('app.addressbook.new', {\n url: '/{contactType:(?:card|list)}/new',\n views: {\n card: {\n templateUrl: 'UIxContactEditorTemplate', // UI/Templates/Contacts/UIxContactEditorTemplate.wox\n controller: 'CardController',\n controllerAs: 'editor'\n }\n },\n resolve: {\n stateCard: stateNewCard\n }\n })\n .state('app.addressbook.card', {\n url: '/:cardId',\n abstract: true,\n views: {\n card: {\n template: ''\n }\n },\n resolve: {\n stateCard: stateCard\n }\n })\n .state('app.addressbook.card.view', {\n url: '/view',\n views: {\n 'card@app.addressbook': {\n templateUrl: 'UIxContactViewTemplate', // UI/Templates/Contacts/UIxContactViewTemplate.wox\n controller: 'CardController',\n controllerAs: 'editor'\n }\n }\n })\n .state('app.addressbook.card.editor', {\n url: '/edit',\n views: {\n 'card@app.addressbook': {\n templateUrl: 'UIxContactEditorTemplate', // UI/Templates/Contacts/UIxContactEditorTemplate.wox\n controller: 'CardController',\n controllerAs: 'editor'\n }\n }\n });\n\n // if none of the above states are matched, use this as the fallback\n $urlRouterProvider.otherwise('/addressbooks/personal');\n }\n\n /**\n * @ngInject\n */\n stateAddressbooks.$inject = ['AddressBook'];\n function stateAddressbooks(AddressBook) {\n return AddressBook.$findAll(window.contactFolders);\n }\n\n /**\n * @ngInject\n */\n stateAddressbook.$inject = ['$q', '$state', '$stateParams', 'AddressBook'];\n function stateAddressbook($q, $state, $stateParams, AddressBook) {\n var addressbook = _.find(AddressBook.$findAll(), function(addressbook) {\n return addressbook.id == $stateParams.addressbookId;\n });\n if (addressbook) {\n addressbook.selectedCard = false;\n addressbook.$reload();\n return addressbook;\n }\n return $q.reject('Addressbook ' + $stateParams.addressbookId + ' not found');\n }\n\n /**\n * @ngInject\n */\n stateNewCard.$inject = ['$stateParams', 'stateAddressbook', 'Card'];\n function stateNewCard($stateParams, stateAddressbook, Card) {\n var tag = 'v' + $stateParams.contactType,\n card = new Card({ pid: $stateParams.addressbookId, c_component: tag });\n stateAddressbook.selectedCard = true;\n return card;\n }\n\n /**\n * @ngInject\n */\n stateCard.$inject = ['$stateParams', 'stateAddressbook'];\n function stateCard($stateParams, stateAddressbook) {\n stateAddressbook.selectedCard = $stateParams.cardId;\n return stateAddressbook.$getCard($stateParams.cardId);\n }\n\n /**\n * @ngInject\n */\n runBlock.$inject = ['$rootScope', '$log', '$state'];\n function runBlock($rootScope, $log, $state) {\n $rootScope.$on('$stateChangeError', function(event, toState, toParams, fromState, fromParams, error) {\n $log.error(error);\n $state.go('app.addressbook', { addressbookId: 'personal' });\n });\n $rootScope.$on('$routeChangeError', function(event, current, previous, rejection) {\n $log.error(event, current, previous, rejection);\n });\n }\n\n})();\n","/* -*- Mode: javascript; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n\n(function() {\n 'use strict';\n\n /**\n * @ngInject\n */\n AddressBookController.$inject = ['$scope', '$q', '$window', '$state', '$timeout', '$mdDialog', 'Account', 'Card', 'AddressBook', 'Dialog', 'sgSettings', 'stateAddressbooks', 'stateAddressbook'];\n function AddressBookController($scope, $q, $window, $state, $timeout, $mdDialog, Account, Card, AddressBook, Dialog, Settings, stateAddressbooks, stateAddressbook) {\n var vm = this;\n\n AddressBook.selectedFolder = stateAddressbook;\n\n vm.service = AddressBook;\n vm.selectedFolder = stateAddressbook;\n vm.selectCard = selectCard;\n vm.toggleCardSelection = toggleCardSelection;\n vm.newComponent = newComponent;\n vm.notSelectedComponent = notSelectedComponent;\n vm.unselectCards = unselectCards;\n vm.confirmDeleteSelectedCards = confirmDeleteSelectedCards;\n vm.saveSelectedCards = saveSelectedCards;\n vm.copySelectedCards = copySelectedCards;\n vm.selectAll = selectAll;\n vm.sort = sort;\n vm.sortedBy = sortedBy;\n vm.cancelSearch = cancelSearch;\n vm.newMessage = newMessage;\n vm.newMessageWithSelectedCards = newMessageWithSelectedCards;\n vm.newMessageWithRecipient = newMessageWithRecipient;\n vm.mode = { search: false, multiple: 0 };\n \n function selectCard(card) {\n $state.go('app.addressbook.card.view', {addressbookId: stateAddressbook.id, cardId: card.id});\n }\n \n function toggleCardSelection($event, card) {\n card.selected = !card.selected;\n vm.mode.multiple += card.selected? 1 : -1;\n $event.preventDefault();\n $event.stopPropagation();\n }\n\n function newComponent(ev) {\n $mdDialog.show({\n parent: angular.element(document.body),\n targetEvent: ev,\n clickOutsideToClose: true,\n escapeToClose: true,\n template: [\n '',\n ' ',\n '
',\n ' ',\n ' ' + l('Contact'),\n ' ',\n ' ',\n ' ' + l('List'),\n ' ',\n '
',\n '
',\n '
'\n ].join(''),\n locals: {\n addressbookId: vm.selectedFolder.id\n },\n controller: ComponentDialogController\n });\n \n /**\n * @ngInject\n */\n ComponentDialogController.$inject = ['scope', '$mdDialog', '$state', 'addressbookId'];\n function ComponentDialogController(scope, $mdDialog, $state, addressbookId) {\n scope.create = function(type) {\n $mdDialog.hide();\n $state.go('app.addressbook.new', { addressbookId: addressbookId, contactType: type });\n };\n }\n }\n\n function notSelectedComponent(currentCard, type) {\n return (currentCard && currentCard.c_component == type && !currentCard.selected);\n }\n\n function unselectCards() {\n _.forEach(vm.selectedFolder.$cards, function(card) {\n card.selected = false;\n });\n vm.mode.multiple = 0;\n }\n \n function confirmDeleteSelectedCards() {\n Dialog.confirm(l('Warning'),\n l('Are you sure you want to delete the selected contacts?'),\n { ok: l('Delete') })\n .then(function() {\n // User confirmed the deletion\n var selectedCards = _.filter(vm.selectedFolder.$cards, function(card) { return card.selected; });\n vm.selectedFolder.$deleteCards(selectedCards);\n delete vm.selectedFolder.selectedCard;\n });\n }\n\n function saveSelectedCards() {\n var selectedCards = _.filter(vm.selectedFolder.$cards, function(card) { return card.selected; });\n var selectedUIDs = _.map(selectedCards, 'id');\n $window.location.href = ApplicationBaseURL + '/' + vm.selectedFolder.id + '/export?uid=' + selectedUIDs.join('&uid=');\n }\n\n function copySelectedCards(folder) {\n var selectedCards = _.filter(vm.selectedFolder.$cards, function(card) { return card.selected; });\n vm.selectedFolder.$copyCards(selectedCards, folder).then(function() {\n // TODO: refresh target addressbook?\n });\n }\n\n function selectAll() {\n _.forEach(vm.selectedFolder.$cards, function(card) {\n card.selected = true;\n });\n vm.mode.multiple = vm.selectedFolder.$cards.length;\n }\n\n function sort(field) {\n vm.selectedFolder.$filter('', { sort: field });\n }\n\n function sortedBy(field) {\n return AddressBook.$query.sort == field;\n }\n\n function cancelSearch() {\n vm.mode.search = false;\n vm.selectedFolder.$filter('');\n }\n\n function newMessage($event, recipients) {\n Account.$findAll().then(function(accounts) {\n var account = _.filter(accounts, function(o) {\n if (o.id === 0)\n return o;\n })[0];\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 $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 stateAccounts: accounts,\n stateMessage: message,\n stateRecipients: recipients\n }\n });\n });\n });\n });\n }\n\n function newMessageWithRecipient($event, recipient, fn) {\n var recipients = [{full: fn + ' <' + recipient + '>'}];\n vm.newMessage($event, recipients);\n $event.stopPropagation();\n $event.preventDefault();\n }\n\n function newMessageWithSelectedCards($event) {\n var selectedCards = _.filter(vm.selectedFolder.$cards, function(card) { return card.selected; });\n var promises = [], recipients = [];\n\n _.forEach(selectedCards, function(card) {\n if (card.c_component == 'vcard' && card.c_mail.length) {\n recipients.push({full: card.c_cn + ' <' + card.c_mail + '>'});\n }\n else if (card.$isList()) {\n // If the list's members were already fetch, use them\n if (angular.isDefined(card.refs) && card.refs.length) {\n _.forEach(card.refs, function(ref) {\n if (ref.email.length)\n recipients.push({full: ref.c_cn + ' <' + ref.email + '>'});\n });\n }\n else {\n promises.push(vm.selectedFolder.$getCard(card.id).then(function(card) {\n return card.$futureCardData.then(function(data) {\n _.forEach(data.refs, function(ref) {\n if (ref.email.length)\n recipients.push({full: ref.c_cn + ' <' + ref.email + '>'});\n });\n });\n }));\n }\n }\n });\n\n $q.all(promises).then(function() {\n if (recipients.length)\n vm.newMessage($event, recipients);\n });\n }\n }\n\n angular\n .module('SOGo.ContactsUI') \n .controller('AddressBookController', AddressBookController); \n})();\n","/* -*- Mode: javascript; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n\n(function() {\n 'use strict';\n\n /**\n * @ngInject\n */\n AddressBooksController.$inject = ['$state', '$scope', '$rootScope', '$stateParams', '$timeout', '$window', '$mdDialog', '$mdToast', '$mdMedia', '$mdSidenav', 'FileUploader', 'sgFocus', 'Card', 'AddressBook', 'Dialog', 'sgSettings', 'User', 'stateAddressbooks'];\n function AddressBooksController($state, $scope, $rootScope, $stateParams, $timeout, $window, $mdDialog, $mdToast, $mdMedia, $mdSidenav, FileUploader, focus, Card, AddressBook, Dialog, Settings, User, stateAddressbooks) {\n var vm = this;\n\n vm.activeUser = Settings.activeUser;\n vm.service = AddressBook;\n vm.select = select;\n vm.newAddressbook = newAddressbook;\n vm.edit = edit;\n vm.revertEditing = revertEditing;\n vm.save = save;\n vm.confirmDelete = confirmDelete;\n vm.importCards = importCards;\n vm.exportCards = exportCards;\n vm.showLinks = showLinks;\n vm.showProperties = showProperties;\n vm.share = share;\n vm.subscribeToFolder = subscribeToFolder;\n\n function select($event, folder) {\n if ($state.params.addressbookId != folder.id &&\n vm.editMode != folder.id) {\n vm.editMode = false;\n AddressBook.$query.value = '';\n // Close sidenav on small devices\n if ($mdMedia('xs'))\n $mdSidenav('left').close();\n $state.go('app.addressbook', {addressbookId: folder.id});\n }\n else {\n $event.preventDefault();\n $event.stopPropagation();\n }\n }\n\n function newAddressbook() {\n Dialog.prompt(l('New addressbook'),\n l('Name of new addressbook'))\n .then(function(name) {\n var addressbook = new AddressBook(\n {\n name: name,\n isEditable: true,\n isRemote: false,\n owner: UserLogin\n }\n );\n AddressBook.$add(addressbook);\n });\n }\n\n function edit(folder) {\n if (!folder.isRemote) {\n vm.editMode = folder.id;\n vm.originalAddressbook = angular.extend({}, folder.$omit());\n focus('addressBookName_' + folder.id);\n }\n }\n\n function revertEditing(folder) {\n folder.name = vm.originalAddressbook.name;\n vm.editMode = false;\n }\n\n function save(folder) {\n var name = folder.name;\n if (name && name.length > 0 && name != vm.originalAddressbook.name) {\n folder.$rename(name)\n .then(function(data) {\n vm.editMode = false;\n }, function(data, status) {\n Dialog.alert(l('Warning'), data);\n });\n }\n }\n\n function confirmDelete() {\n if (vm.service.selectedFolder.isSubscription) {\n // Unsubscribe without confirmation\n vm.service.selectedFolder.$delete()\n .then(function() {\n vm.service.selectedFolder = null;\n $state.go('app.addressbook', { addressbookId: 'personal' });\n }, function(data, status) {\n Dialog.alert(l('An error occured while deleting the addressbook \"%{0}\".',\n vm.service.selectedFolder.name),\n l(data.error));\n });\n }\n else {\n Dialog.confirm(l('Warning'), l('Are you sure you want to delete the addressbook \"%{0}\"?',\n vm.service.selectedFolder.name),\n { ok: l('Delete') })\n .then(function() {\n return vm.service.selectedFolder.$delete();\n })\n .then(function() {\n vm.service.selectedFolder = null;\n $state.go('app.addressbook', { addressbookId: 'personal' });\n return true;\n })\n .catch(function(response) {\n var message = response.data.message || response.statusText;\n Dialog.alert(l('An error occured while deleting the addressbook \"%{0}\".',\n vm.service.selectedFolder.name),\n message);\n });\n }\n }\n\n function importCards($event, folder) {\n $mdDialog.show({\n parent: angular.element(document.body),\n targetEvent: $event,\n clickOutsideToClose: true,\n escapeToClose: true,\n templateUrl: 'UIxContactsImportDialog',\n controller: CardsImportDialogController,\n controllerAs: '$CardsImportDialogController',\n locals: {\n folder: folder\n }\n });\n\n /**\n * @ngInject\n */\n CardsImportDialogController.$inject = ['scope', '$mdDialog', 'folder'];\n function CardsImportDialogController(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 card was imported.');\n else {\n msg = l('A total of %{0} cards were imported in the addressbook.', response.imported);\n AddressBook.selectedFolder.$reload();\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 '',\n '
',\n ' error_outline',\n ' ' + l('An error occured while importing contacts.') + '',\n '
',\n '
'\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 /\\.(ldif|vcf|vcard)$/.test(item.name);\n\n if (!isTextFile)\n $mdToast.show({\n template: [\n '',\n '
',\n ' error_outline',\n ' ' + l('Select a vCard or LDIF file.') + '',\n '
',\n '
'\n ].join(''),\n position: 'top right',\n hideDelay: 3000\n });\n\n return isTextFile;\n }\n }\n }\n\n function exportCards() {\n $window.location.href = ApplicationBaseURL + '/' + vm.service.selectedFolder.id + '/exportFolder';\n }\n\n function showLinks(addressbook) {\n $mdDialog.show({\n parent: angular.element(document.body),\n clickOutsideToClose: true,\n escapeToClose: true,\n templateUrl: addressbook.id + '/links',\n controller: LinksDialogController,\n controllerAs: 'links',\n locals: {\n addressbook: addressbook\n }\n });\n \n /**\n * @ngInject\n */\n LinksDialogController.$inject = ['$mdDialog', 'addressbook'];\n function LinksDialogController($mdDialog, addressbook) {\n var vm = this;\n this.addressbook = addressbook;\n this.close = close;\n\n function close() {\n $mdDialog.hide();\n }\n }\n }\n\n function showProperties(addressbook) {\n $mdDialog.show({\n templateUrl: addressbook.id + '/properties',\n controller: PropertiesDialogController,\n controllerAs: 'properties',\n clickOutsideToClose: true,\n escapeToClose: true,\n locals: {\n srcAddressBook: addressbook\n }\n }).catch(function() {\n // Do nothing\n });\n\n /**\n * @ngInject\n */\n PropertiesDialogController.$inject = ['$scope', '$mdDialog', 'srcAddressBook'];\n function PropertiesDialogController($scope, $mdDialog, srcAddressBook) {\n var vm = this;\n\n vm.addressbook = new AddressBook(srcAddressBook.$omit());\n vm.saveProperties = saveProperties;\n vm.close = close;\n\n function saveProperties() {\n vm.addressbook.$save().then(function() {\n // Refresh list instance\n srcAddressBook.init(vm.addressbook.$omit());\n $mdDialog.hide();\n });\n }\n\n function close() {\n $mdDialog.cancel();\n }\n }\n }\n\n function share(addressbook) {\n // Fetch list of ACL users\n addressbook.$acl.$users().then(function() {\n // Show ACL editor\n $mdDialog.show({\n templateUrl: addressbook.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: addressbook.$acl.users,\n User: User,\n folder: addressbook\n }\n });\n });\n }\n\n /**\n * subscribeToFolder - Callback of sgSubscribe directive\n */\n function subscribeToFolder(addressbookData) {\n console.debug('subscribeToFolder ' + addressbookData.owner + addressbookData.name);\n AddressBook.$subscribe(addressbookData.owner, addressbookData.name).then(function(data) {\n $mdToast.show(\n $mdToast.simple()\n .content(l('Successfully subscribed to address book'))\n .position('top right')\n .hideDelay(3000));\n });\n }\n }\n\n angular\n .module('SOGo.ContactsUI')\n .controller('AddressBooksController', AddressBooksController);\n})();\n","/* -*- Mode: javascript; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n\n(function() {\n 'use strict';\n\n /**\n * Controller to view and edit a card\n * @ngInject\n */\n CardController.$inject = ['$scope', '$timeout', '$window', '$mdDialog', 'AddressBook', 'Card', 'Dialog', 'sgFocus', '$state', '$stateParams', 'stateCard'];\n function CardController($scope, $timeout, $window, $mdDialog, AddressBook, Card, Dialog, focus, $state, $stateParams, stateCard) {\n var vm = this;\n\n vm.card = stateCard;\n\n vm.currentFolder = AddressBook.selectedFolder;\n vm.allEmailTypes = Card.$EMAIL_TYPES;\n vm.allTelTypes = Card.$TEL_TYPES;\n vm.allUrlTypes = Card.$URL_TYPES;\n vm.allAddressTypes = Card.$ADDRESS_TYPES;\n vm.categories = {};\n vm.userFilterResults = [];\n vm.transformCategory = transformCategory;\n vm.addOrgUnit = addOrgUnit;\n vm.addBirthday = addBirthday;\n vm.addScreenName = addScreenName;\n vm.addEmail = addEmail;\n vm.addPhone = addPhone;\n vm.addUrl = addUrl;\n vm.addAddress = addAddress;\n vm.userFilter = userFilter;\n vm.save = save;\n vm.close = close;\n vm.reset = reset;\n vm.cancel = cancel;\n vm.confirmDelete = confirmDelete;\n vm.exportCard = exportCard;\n vm.toggleRawSource = toggleRawSource;\n vm.showRawSource = false;\n\n function transformCategory(input) {\n if (angular.isString(input))\n return { value: input };\n else\n return input;\n }\n function addOrgUnit() {\n var i = vm.card.$addOrgUnit('');\n focus('orgUnit_' + i);\n }\n function addBirthday() {\n vm.card.birthday = new Date();\n }\n function addScreenName() {\n vm.card.$addScreenName('');\n }\n function addEmail() {\n var i = vm.card.$addEmail('');\n focus('email_' + i);\n }\n function addPhone() {\n var i = vm.card.$addPhone('');\n focus('phone_' + i);\n }\n function addUrl() {\n var i = vm.card.$addUrl('', '');\n focus('url_' + i);\n }\n function addAddress() {\n var i = vm.card.$addAddress('', '', '', '', '', '', '', '');\n focus('address_' + i);\n }\n function userFilter($query, excludedCards) {\n AddressBook.selectedFolder.$filter($query, {dry: true, excludeLists: true}, excludedCards);\n return AddressBook.selectedFolder.$$cards;\n }\n function save(form) {\n if (form.$valid) {\n vm.card.$save()\n .then(function(data) {\n var i = _.indexOf(_.map(AddressBook.selectedFolder.$cards, 'id'), vm.card.id);\n if (i < 0) {\n // New card; reload contacts list and show addressbook in which the card has been created\n AddressBook.selectedFolder.$reload();\n }\n else {\n // Update contacts list with new version of the Card object\n AddressBook.selectedFolder.$cards[i] = angular.copy(vm.card);\n }\n $state.go('app.addressbook.card.view', { cardId: vm.card.id });\n });\n }\n }\n function close() {\n $state.go('app.addressbook', { addressbookId: AddressBook.selectedFolder.id }).then(function() {\n vm.card = null;\n delete AddressBook.selectedFolder.selectedCard;\n });\n }\n function reset() {\n vm.card.$reset();\n }\n function cancel() {\n vm.card.$reset();\n if (vm.card.isNew) {\n // Cancelling the creation of a card\n vm.card = null;\n delete AddressBook.selectedFolder.selectedCard;\n $state.go('app.addressbook', { addressbookId: AddressBook.selectedFolder.id });\n }\n else {\n // Cancelling the edition of an existing card\n $state.go('app.addressbook.card.view', { cardId: vm.card.id });\n }\n }\n function confirmDelete(card) {\n Dialog.confirm(l('Warning'),\n l('Are you sure you want to delete the card of %{0}?', '' + card.$fullname() + ''),\n { ok: l('Delete') })\n .then(function() {\n // User confirmed the deletion\n card.$delete()\n .then(function() {\n // Remove card from addressbook\n AddressBook.selectedFolder.$cards = _.reject(AddressBook.selectedFolder.$cards, function(o) {\n return o.id == card.id;\n });\n close();\n }, function(data, status) {\n Dialog.alert(l('Warning'), l('An error occured while deleting the card \"%{0}\".',\n card.$fullname()));\n });\n });\n }\n\n function exportCard() {\n $window.location.href = ApplicationBaseURL + '/' + vm.currentFolder.id + '/export?uid=' + vm.card.id;\n }\n\n function toggleRawSource($event) {\n if (!vm.showRawSource && !vm.rawSource) {\n Card.$$resource.post(vm.currentFolder.id + '/' + vm.card.id, \"raw\").then(function(data) {\n vm.rawSource = data;\n vm.showRawSource = true;\n });\n }\n else {\n vm.showRawSource = !vm.showRawSource;\n }\n }\n }\n\n angular\n .module('SOGo.ContactsUI')\n .controller('CardController', CardController);\n})();\n","/* -*- Mode: javascript; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n\n(function() {\n 'use strict';\n\n /**\n * @name sgAddress\n * @memberof ContactsUI\n * @desc Directive to format a postal address.\n * @ngInject\n */\n function sgAddress() {\n return {\n restrict: 'A',\n scope: { data: '=sgAddress' },\n controller: ['$scope', function($scope) {\n $scope.addressLines = function(data) {\n var lines = [],\n locality_region = [];\n if (data.street) lines.push(data.street);\n if (data.street2) lines.push(data.street2);\n if (data.locality) locality_region.push(data.locality);\n if (data.region) locality_region.push(data.region);\n if (locality_region.length > 0) lines.push(locality_region.join(', '));\n if (data.country) lines.push(data.country);\n if (data.postalcode) lines.push(data.postalcode);\n return lines.join('
');\n };\n }],\n template: '
'\n };\n }\n \n angular\n .module('SOGo.Common')\n .directive('sgAddress', sgAddress);\n})();\n"]} \ No newline at end of file diff --git a/UI/WebServerResources/js/Scheduler.services.js b/UI/WebServerResources/js/Scheduler.services.js index 922ba41dd..70ebb18bf 100644 --- a/UI/WebServerResources/js/Scheduler.services.js +++ b/UI/WebServerResources/js/Scheduler.services.js @@ -1,3 +1,3 @@ -!function(){"use strict";function a(b){if(this.init(b),this.name&&!this.id){var c=a.$$resource.create("createFolder",this.name);this.$unwrap(c)}}a.$factory=["$q","$timeout","$log","sgSettings","Resource","Preferences","Component","Acl",function(b,c,d,e,f,g,h,i){return angular.extend(a,{$q:b,$timeout:c,$log:d,$$resource:new f(e.activeUser("folderURL")+"Calendar",e.activeUser()),$Preferences:g,$Component:h,$$Acl:i,activeUser:e.activeUser(),$view:null}),a}];try{angular.module("SOGo.SchedulerUI")}catch(b){angular.module("SOGo.SchedulerUI",["SOGo.Common"])}angular.module("SOGo.SchedulerUI").value("CalendarSettings",{EventDragDayLength:96,EventDragHorizontalOffset:3}).factory("Calendar",a.$factory),a.$defaultCalendar=function(){var b,c=a.$Preferences.defaults.SOGoDefaultCalendar;return"first"==c&&(b=_.find(a.$findAll(null,!0),function(a){return a.active}))?b.id:"personal"},a.$add=function(a){var b,c,d;b=a.isWebCalendar?this.$webcalendars:a.isSubscription?this.$subscriptions:this.$calendars,c=_.find(b,function(b){return"personal"==a.id||"personal"!=b.id&&1===b.name.localeCompare(a.name)}),d=c?_.indexOf(_.map(b,"id"),c.id):1,b.splice(d,0,a)},a.$findAll=function(b,c){var d=this;return b?(this.$calendars=[],this.$subscriptions=[],this.$webcalendars=[],angular.forEach(b,function(b,c){var e=new a(b);e.isWebCalendar?d.$webcalendars.push(e):e.isSubscription?d.$subscriptions.push(e):d.$calendars.push(e)})):angular.isUndefined(this.$calendars)&&(this.$calendars=[],this.$subscriptions=[],this.$webcalendars=[],a.$$resource.fetch("calendarslist").then(function(b){a.$findAll(b.calendars,c)})),c?_.union(this.$calendars,_.filter(this.$subscriptions,function(a){return a.isOwned||a.acls.objectCreator})):_.union(this.$calendars,this.$subscriptions,this.$webcalendars)},a.$get=function(b){var c;return c=_.find(a.$calendars,function(a){return a.id==b}),c||(c=_.find(a.$subscriptions,function(a){return a.id==b})),c||(c=_.find(a.$webcalendars,function(a){return a.id==b})),c},a.$getIndex=function(b){var c;return c=_.indexOf(_.map(a.$calendars,"id"),b),0>c&&(c=_.indexOf(_.map(a.$subscriptions,"id"),b)),0>c&&(c=_.indexOf(_.map(a.$webcalendars,"id"),b)),c},a.$subscribe=function(b,c){var d=this;return a.$$resource.userResource(b).fetch(c,"subscribe").then(function(b){var c=new a(angular.extend({active:1},b));return _.find(d.$subscriptions,function(a){return a.id==b.id})||a.$add(c),c})},a.$addWebCalendar=function(b){var c=this,d=a.$q.defer();return _.find(c.$webcalendars,function(a){return a.urls.webCalendarURL==b})?d.reject():a.$$resource.post(null,"addWebCalendar",{url:b}).then(function(c){angular.extend(c,{isWebCalendar:!0,isEditable:!0,isRemote:!1,owner:a.activeUser.login,urls:{webCalendarURL:b}});var e=new a(c);a.$add(e),a.$$resource.fetch(e.id,"reload").then(function(b){a.$log.debug(JSON.stringify(b,void 0,2))}),d.resolve()},function(){d.reject()}),d.promise},a.$deleteComponents=function(b){var c={},d=[];return _.forEach(b,function(a){angular.isDefined(c[a.pid])||(c[a.pid]=[]),c[a.pid].push(a.id)}),_.forEach(c,function(b,c){d.push(a.$$resource.post(c,"batchDelete",{uids:b}))}),a.$q.all(d)},a.prototype.init=function(b){this.color=this.color||"#AAAAAA",angular.extend(this,b),this.id&&(this.$acl=new a.$$Acl("Calendar/"+this.id)),this.isOwned=a.activeUser.isSuperUser||this.owner==a.activeUser.login,this.isSubscription=!this.isRemote&&this.owner!=a.activeUser.login,angular.isUndefined(this.$shadowData)&&(this.$shadowData=this.$omit())},a.prototype.$id=function(){return this.id?a.$q.when(this.id):this.$futureCalendarData.then(function(a){return a.id})},a.prototype.getClassName=function(a){return angular.isUndefined(a)&&(a="fg"),a+"-folder"+this.id},a.prototype.$rename=function(){var b,c,d=this;return this.name==this.$shadowData.name?a.$q.when():(c=this.isWebCalendar?a.$webcalendars:this.isSubscription?a.$subscriptions:a.$calendars,b=_.indexOf(_.map(c,"id"),this.id),b>-1?this.$save().then(function(){c.splice(b,1),a.$add(d)}):a.$q.reject())},a.prototype.$delete=function(){var b,c,d=this;return this.isSubscription?(c=a.$$resource.fetch(this.id,"unsubscribe"),b=a.$subscriptions):(c=a.$$resource.remove(this.id),b=this.isWebCalendar?a.$webcalendars:a.$calendars),c.then(function(){var a=_.indexOf(_.map(b,"id"),d.id);b.splice(a,1)})},a.prototype.$reset=function(){var a=this;angular.forEach(this,function(b,c){"constructor"!=c&&"$"!=c[0]&&delete a[c]}),angular.extend(this,this.$shadowData),this.$shadowData=this.$omit()},a.prototype.$save=function(){var b=this;return a.$$resource.save(this.id,this.$omit()).then(function(a){return b.$shadowData=b.$omit(),a},function(c){return a.$log.error(JSON.stringify(c,void 0,2)),b.$reset(),c})},a.prototype.$setActivation=function(){return a.$$resource.fetch(this.id,(this.active?"":"de")+"activateFolder")},a.prototype.$getComponent=function(b,c){return a.$Component.$find(this.id,b,c)},a.prototype.$unwrap=function(b){var c=this;this.$futureCalendarData=b.then(function(b){return a.$timeout(function(){return c.init(b),c})},function(b){c.isError=!0,angular.isObject(b)&&a.$timeout(function(){angular.extend(c,b)})})},a.prototype.$omit=function(){var a={};return angular.forEach(this,function(b,c){"constructor"!=c&&"$"!=c[0]&&(a[c]=b)}),a}}(),function(){"use strict";function a(b){if("function"!=typeof b.then){if(this.init(b),this.pid&&!this.id){var c=a.$$resource.newguid(this.pid);this.$unwrap(c),this.isNew=!0}}else this.$unwrap(b)}a.$factory=["$q","$timeout","$log","sgSettings","Preferences","Card","Gravatar","Resource",function(b,c,d,e,f,g,h,i){return angular.extend(a,{$q:b,$timeout:c,$log:d,$Preferences:f,$Card:g,$gravatar:h,$$resource:new i(e.activeUser("folderURL")+"Calendar",e.activeUser()),timeFormat:"%H:%M",$query:{value:"",search:"title_Category_Location"},$queryEvents:{sort:"start",asc:1,filterpopup:"view_next7"},$queryTasks:{sort:"status",asc:1,filterpopup:"view_incomplete"},$refreshTimeout:null,$ghost:{}}),f.ready().then(function(){f.settings.Calendar.EventsFilterState&&(a.$queryEvents.filterpopup=f.settings.Calendar.EventsFilterState),f.settings.Calendar.TasksFilterState&&(a.$queryTasks.filterpopup=f.settings.Calendar.TasksFilterState),f.settings.Calendar.EventsSortingState&&(a.$queryEvents.sort=f.settings.Calendar.EventsSortingState[0],a.$queryEvents.asc=parseInt(f.settings.Calendar.EventsSortingState[1])),f.settings.Calendar.TasksSortingState&&(a.$queryTasks.sort=f.settings.Calendar.TasksSortingState[0],a.$queryTasks.asc=parseInt(f.settings.Calendar.TasksSortingState[1])),a.$queryTasks.show_completed=parseInt(f.settings.ShowCompletedTasks),a.$categories=f.defaults.SOGoCalendarCategoriesColors,f.defaults.SOGoTimeFormat&&(a.timeFormat=f.defaults.SOGoTimeFormat)}),a}];try{angular.module("SOGo.SchedulerUI")}catch(b){angular.module("SOGo.SchedulerUI",["SOGo.Common"])}angular.module("SOGo.SchedulerUI").factory("Component",a.$factory),a.$selectedCount=function(){var b;return b=0,a.$events&&(b+=_.filter(a.$events,function(a){return a.selected}).length),a.$tasks&&(b+=_.filter(a.$tasks,function(a){return a.selected}).length),b},a.$startRefreshTimeout=function(b){var c=this;a.$refreshTimeout&&a.$timeout.cancel(a.$refreshTimeout),a.$Preferences.ready().then(function(){var d=a.$Preferences.defaults.SOGoRefreshViewCheck;if(d&&"manually"!=d){var e=angular.bind(c,a.$filter,b);a.$refreshTimeout=a.$timeout(e,1e3*d.timeInterval())}})},a.$filter=function(b,c){var d=this,e=new Date,f=e.getDate(),g=e.getMonth()+1,h=e.getFullYear(),i="$query"+b.capitalize(),j={day:""+h+(10>g?"0":"")+g+(10>f?"0":"")+f};return a.$startRefreshTimeout(b),this.$Preferences.ready().then(function(){var e,f,g=!1;return angular.extend(d.$query,j),c&&_.forEach(_.keys(c),function(b){g|=d.$query[b]&&c[b]!=a.$query[b],"reload"==b&&c[b]?g=!0:angular.isDefined(d.$query[b])?d.$query[b]=c[b]:d[i][b]=c[b]}),e=d.$$resource.fetch(null,b+"list",angular.extend(d[i],d.$query)),f="tasks"==b?"$events":"$tasks",g&&(delete a[f],a.$log.debug("force reload of "+f)),d.$unwrapCollection(b,e)})},a.$find=function(b,c,d){var e,f=[b,c];return d&&f.push(d),e=this.$$resource.fetch(f.join("/"),"view"),new a(e)},a.filterCategories=function(b){var c=new RegExp(b,"i");return _.filter(_.keys(a.$categories),function(a){return-1!=a.search(c)})},a.saveSelectedList=function(a){return this.$$resource.post(null,"saveSelectedList",{list:a+"ListView"})},a.$eventsBlocksForView=function(b,c){var d=this;return a.$Preferences.ready().then(function(e){var f,g,h,i;return f=a.$Preferences.defaults.SOGoFirstDayOfWeek,"day"==b?(g="dayView",h=i=c):"multicolumnday"==b?(g="multicolumndayView",h=i=c):"week"==b?(g="weekView",h=c.beginOfWeek(f),i=new Date,i.setTime(h.getTime()),i.addDays(6)):"month"==b&&(g="monthView",h=c,h.setDate(1),h=h.beginOfWeek(f),i=new Date,i.setTime(h.getTime()),i.setMonth(i.getMonth()+1),i.addDays(-1),i=i.endOfWeek(f)),d.$eventsBlocks(g,h,i)})},a.$eventsBlocks=function(b,c,d){var e,f,g,h,i=[],j=a.$q.defer();return e={view:b.toLowerCase(),sd:c.getDayString(),ed:d.getDayString()},a.$log.debug("eventsblocks "+JSON.stringify(e,void 0,2)),f=this.$$resource.fetch(null,"eventsblocks",e),f.then(function(b){var d,e;d=function(b,c,d){var e=_.zipObject(this.eventsFields,c),f=new Date(1e3*e.c_startdate);return e.hour=f.getHourString(),e.blocks=[],b.push(new a(e)),b},e=function(a){this[a.nbr].blocks.push(a),a.component=this[a.nbr]},a.$views=[],a.$timeout(function(){_.forEach(b,function(b){var f,j=[],k={},l={};if(b.eventsFields.splice(_.indexOf(b.eventsFields,"c_folder"),1,"pid"),b.eventsFields.splice(_.indexOf(b.eventsFields,"c_name"),1,"id"),b.eventsFields.splice(_.indexOf(b.eventsFields,"c_recurrence_id"),1,"occurrenceId"),b.eventsFields.splice(_.indexOf(b.eventsFields,"c_title"),1,"summary"),_.reduce(b.events,_.bind(d,b),j),_.forEach(_.flatten(b.blocks),_.bind(e,j)),_.forEach(_.flatten(b.allDayBlocks),_.bind(e,j)),0===i.length)for(g=0;g1||this.repeat.days&&this.repeat.days.length>0||this.repeat.monthdays&&this.repeat.monthdays.length>0||this.repeat.months&&this.repeat.months.length>0);return a},a.prototype.isEditable=function(){return!this.occurrenceId&&!this.isReadOnly},a.prototype.isEditableOccurrence=function(){return this.occurrenceId&&!this.isReadOnly},a.prototype.isInvitation=function(){return!this.occurrenceId&&this.userHasRSVP},a.prototype.isInvitationOccurrence=function(){return this.occurrenceId&&this.userHasRSVP},a.prototype.isReadOnly=function(){return this.isReadOnly&&!this.userHasRSVP},a.prototype.enablePercentComplete=function(){return"task"==this.type&&"not-specified"!=this.status&&"cancelled"!=this.status},a.prototype.coversFreeBusy=function(a,b,c){var d=angular.isDefined(this.freebusy[a])&&angular.isDefined(this.freebusy[a][b])&&1==this.freebusy[a][b][c];return d},a.prototype.updateFreeBusyCoverage=function(){var a=this,b={};if(this.start&&this.end){var c=new Date(this.start.getTime()),d=new Date(this.end.getTime()),e=parseInt(c.getMinutes()/15+.5),f=parseInt(d.getMinutes()/15+.5);return c.setMinutes(15*e),d.setMinutes(15*f),_.forEach(c.daysUpTo(d),function(c,d){var f,g=c.getDate(),h=c.getDayString();if(h==a.start.getDayString())for(f=c.getHours().toString(),b[h]={},b[h][f]=[];e>0;)b[h][f].push(0),e--;else c=c.beginOfDay(),b[h]={};for(;c.getTime()=e;e++)d=e.toString(),a[c][d]?b.freebusy[c][d]=[a[c][d][0],a[c][d][15],a[c][d][30],a[c][d][45]]:b.freebusy[c][d]=[0,0,0,0]})}))},a.prototype.getClassName=function(a){return angular.isUndefined(a)&&(a="fg"),a+"-folder"+(this.destinationCalendar||this.c_folder||this.pid)},a.prototype.addAttendee=function(b){var c,d,e=this;b&&(b.$isList()&&1!==b.isGroup?(d=a.$Card.$find(b.container,b.c_name),d.$id().then(function(b){_.forEach(d.refs,function(b){c={name:b.c_cn,email:b.$preferredEmail(),role:"req-participant",status:"needs-action",uid:b.c_uid},_.find(e.attendees,function(a){return a.email==c.email})||(c.image=a.$gravatar(c.email,32),e.attendees?e.attendees.push(c):e.attendees=[c],e.updateFreeBusyAttendee(c))})})):(c={name:b.c_cn,email:b.$preferredEmail(),role:"req-participant",status:"needs-action",uid:b.c_uid},_.find(this.attendees,function(a){return a.email==c.email})||(c.image=a.$gravatar(c.email,32),this.attendees?this.attendees.push(c):this.attendees=[c],this.updateFreeBusyAttendee(c))))},a.prototype.hasAttendee=function(a){var b=_.find(this.attendees,function(b){return _.find(a.emails,function(a){return a.value==b.email})});return angular.isDefined(b)},a.prototype.deleteAttendee=function(a){var b=_.findIndex(this.attendees,function(b){return b.email==a.email});this.attendees.splice(b,1)},a.prototype.canRemindAttendeesByEmail=function(){return"email"==this.alarm.action&&!this.isReadOnly&&this.attendees&&this.attendees.length>0},a.prototype.addAttachUrl=function(a){if(angular.isUndefined(this.attachUrls))this.attachUrls=[{value:a}];else{for(var b=0;b-1&&this.attachUrls.length>a&&this.attachUrls.splice(a,1)},a.prototype.$addDueDate=function(){this.due=new Date,this.due.setMinutes(15*Math.round(this.due.getMinutes()/15)),this.dueDate=this.due.toISOString()},a.prototype.$deleteDueDate=function(){delete this.due,delete this.dueDate},a.prototype.$addStartDate=function(){this.start=new Date,this.start.setMinutes(15*Math.round(this.start.getMinutes()/15))},a.prototype.$deleteStartDate=function(){delete this.start,delete this.startDate},a.prototype.$reset=function(){var a=this;angular.forEach(this,function(b,c){"constructor"!=c&&"$"!=c[0]&&delete a[c]}),this.init(this.$shadowData),this.$shadowData=this.$omit()},a.prototype.$reply=function(){var b,c=this,d=[this.pid,this.id];return this.occurrenceId&&d.push(this.occurrenceId),b={reply:this.reply,delegatedTo:this.delegatedTo,alarm:this.$hasAlarm?this.alarm:{}},a.$$resource.save(d.join("/"),b,{action:"rsvpAppointment"}).then(function(a){return c.$shadowData=c.$omit(),a})},a.prototype.$adjust=function(b){var c=[this.pid,this.id];return _.every(_.values(b),function(a){return 0===a})?a.$q.when():(this.occurrenceId&&c.push(this.occurrenceId),a.$log.debug("adjust "+c.join("/")+" "+JSON.stringify(b)),a.$$resource.save(c.join("/"),b,{action:"adjust"}))},a.prototype.$save=function(b){var c,d,e,f,g=this;return e=this.$omit(),f=a.$Preferences.constructor.$mdDateLocaleProvider,e.startDate=e.start?e.start.format(f,"%Y-%m-%d"):"",e.startTime=e.start?e.start.format(f,"%H:%M"):"",e.endDate=e.end?e.end.format(f,"%Y-%m-%d"):"",e.endTime=e.end?e.end.format(f,"%H:%M"):"",e.dueDate=e.due?e.due.format(f,"%Y-%m-%d"):"",e.dueTime=e.due?e.due.format(f,"%H:%M"):"",e.completedDate=e.completed?e.completed.format(f,"%Y-%m-%d"):"",this.$hasCustomRepeat?"monthly"==this.repeat.frequency&&this.repeat.month.type&&"byday"==this.repeat.month.type||"yearly"==this.repeat.frequency&&this.repeat.year.byday?(delete e.repeat.monthdays,e.repeat.days=[{day:this.repeat.month.day,occurrence:this.repeat.month.occurrence.toString()}]):this.repeat.month.type&&delete e.repeat.days:this.repeat.frequency&&"never"!=this.repeat.frequency&&(e.repeat={frequency:this.repeat.frequency}),this.repeat.frequency?"until"==this.repeat.end&&this.repeat.until?e.repeat.until=this.repeat.until.stringWithSeparator("-"):"count"==this.repeat.end&&this.repeat.count?e.repeat.count=this.repeat.count:(delete e.repeat.until,delete e.repeat.count):delete e.repeat,"not-specified"==this.status?delete e.status:"completed"!=this.status&&delete e.completedDate,this.$hasAlarm?!this.alarm.action||"email"!=this.alarm.action||this.attendees&&this.attendees.length>0||(e.alarm.attendees=0,e.alarm.organizer=1):e.alarm={},d=[this.pid,this.id],this.isNew&&(c={action:"saveAs"+this.type.capitalize()}),this.occurrenceId&&d.push(this.occurrenceId),angular.extend(e,b),a.$$resource.save(d.join("/"),e,c).then(function(a){return g.$shadowData=g.$omit(),a})},a.prototype.remove=function(b){var c=[this.pid,this.id];return b&&this.occurrenceId&&c.push(this.occurrenceId),a.$$resource.remove(c.join("/"))},a.prototype.$unwrap=function(b){var c=this;this.$futureComponentData=b,this.$futureComponentData.then(function(a){c.init(a),c.$shadowData=c.$omit()},function(b){angular.extend(c,b),c.isError=!0,a.$log.error(c.error)})},a.prototype.$omit=function(){var a={};return angular.forEach(this,function(b,c){"constructor"!=c&&"$"!=c[0]&&"blocks"!=c&&(a[c]=angular.copy(b))}),a},a.prototype.repeatDescription=function(){var a=null;return this.repeat&&(a=l("repeat_"+this.repeat.frequency.toUpperCase())),a},a.prototype.alarmDescription=function(){var a,b=null;return this.alarm&&(a=["reminder"+this.alarm.quantity,this.alarm.unit,this.alarm.reference].join("_"),b=l(a),a===b&&(b=[this.alarm.quantity,l("reminder_"+this.alarm.unit),l("reminder_"+this.alarm.reference)].join(" "))),b},a.prototype.toString=function(){return"[Component "+this.id+"]"}}(),function(){"use strict";function a(a,b,c,d,e,f,g){function h(){f.$eventsBlocksForView(d.view,d.day.asDate()).then(function(a){l.views=a,_.forEach(l.views,function(a){a.id&&(a.calendar=new e({id:a.id,name:a.calendarName}))})})}function i(a){var b=angular.element(a.currentTarget).attr("date");c.go("calendars.view",{day:b})}function j(a){c.go("calendars.view",{view:a})}var k,l=this;l.views=g,l.changeDate=i,l.changeView=j,k=b.$on("calendars:list",h),a.$on("$destroy",k)}a.$inject=["$scope","$rootScope","$state","$stateParams","Calendar","Component","stateEventsBlocks"],angular.module("SOGo.SchedulerUI").controller("CalendarController",a)}(),function(){"use strict";function a(a,b,c,d,e,f,g,h){function i(a,b){(b&&b.reload||A.componentType!=a)&&(angular.isUndefined(h["$"+a])&&h.$filter(a),A.unselectComponents(),A.componentType=a,h.saveSelectedList(a))}function j(){_.forEach(h["$"+A.componentType],function(a){a.selected=!1}),A.mode.multiple=0}function k(){_.forEach(h["$"+A.componentType],function(a){a.selected=!0}),A.mode.multiple=h["$"+A.componentType].length}function m(a,b){b.selected=!b.selected,A.mode.multiple+=b.selected?1:-1,a.preventDefault(),a.stopPropagation()}function n(){e.confirm(l("Warning"),l("Are you sure you want to delete the selected components?"),{ok:l("Delete")}).then(function(){var b=_.filter(h["$"+A.componentType],function(a){return a.selected});g.$deleteComponents(b).then(function(){a.$emit("calendars:list")})})}function o(a,b){q(a,b,"appointment")}function p(a,b){q(a,b,"task")}function q(a,b,c){if(b.viewable){var e="UIx"+c.capitalize()+"ViewTemplate";d.show({parent:angular.element(document.body),targetEvent:a,clickOutsideToClose:!0,escapeToClose:!0,templateUrl:e,controller:"ComponentController",controllerAs:"editor",locals:{stateComponent:b}})}}function r(a,b){var c,e="appointment";b?(c=b,e=b.type):("tasks"==A.componentType&&(e="task"),c=new h({pid:g.$defaultCalendar(),type:e}));var f="UIx"+e.capitalize()+"EditorTemplate";return d.show({parent:angular.element(document.body),targetEvent:a,clickOutsideToClose:!0,escapeToClose:!0,templateUrl:f,controller:"ComponentEditorController",controllerAs:"editor",locals:{stateComponent:c}})}function s(c){function e(a,b,c,d){a.updateThisOccurrence=function(){c.$adjust(d).then(b.hide,function(a){b.cancel().then(function(){f(a,c,d)})})},a.updateAllOccurrences=function(){delete c.occurrenceId,c.$adjust(d).then(b.hide,function(a){b.cancel().then(function(){f(a,c,d)})})}}function f(b,c,e){403==b.status&&b.data&&b.data.message&&angular.isObject(b.data.message)&&d.show({parent:angular.element(document.body),clickOutsideToClose:!1,escapeToClose:!1,templateUrl:"UIxAttendeeConflictDialog",controller:i,controllerAs:"$AttendeeConflictDialogController",locals:{component:c,params:e,conflictError:b.data.message}}).then(function(){a.$emit("calendars:list")})}function i(a,b,c,d,e){function f(){c.$adjust(angular.extend({ignoreConflicts:!0},d)).then(b.hide)}var g=this;g.conflictError=e,g.cancel=b.cancel,g.save=f}var j,k,m,n,o,p,q;j=h.$ghost.component,k=h.$ghost.pointerHandler,j.isNew?(m=k.currentEventCoordinates,j.summary="",j.isAllDay&&(m.duration-=96),j.setDelta(15*m.duration),r(null,j)["finally"](function(){b(function(){h.$resetGhost()})})):(n=k.currentEventCoordinates.getDelta(k.originalEventCoordinates),o={days:n.dayNumber,start:15*n.start,duration:15*n.duration},k.originalCalendar&&0!==n.dayNumber&&(p=k.currentEventCoordinates.dayNumber,q=_.filter(g.$findAll(),{active:1}),o.destination=q[p].id,o.days=0),j.isException||!j.occurrenceId?j.$adjust(o).then(function(){a.$emit("calendars:list")},function(a){f(a,j,o)})["finally"](function(){b(function(){h.$resetGhost()})}):j.occurrenceId&&d.show({clickOutsideToClose:!0,escapeToClose:!0,locals:{component:j,params:o},template:['',' ',"

"+l("editRepeatingItem")+"

","
"," ",' '+l("button_thisOccurrenceOnly")+"",' '+l("button_allOccurrences")+""," ","
"].join(""),controller:e}).then(function(){a.$emit("calendars:list")})["finally"](function(){b(function(){h.$resetGhost()})})),e.$inject=["$scope","$mdDialog","component","params"],i.$inject=["$scope","$mdDialog","component","params","conflictError"]}function t(){return h["$query"+A.componentType.capitalize()].filterpopup}function u(a){h.$filter(A.componentType,{filterpopup:a})}function v(a){return h["$query"+A.componentType.capitalize()].filterpopup==a}function w(a){h.$filter(A.componentType,{sort:a})}function x(a){return h["$query"+A.componentType.capitalize()].sort==a}function y(){a.$emit("calendars:list")}function z(){A.mode.search=!1,h.$filter(A.componentType,{value:""})}var A=this;A.component=h,A.componentType="events",A.selectedList=0,A.selectComponentType=i,A.unselectComponents=j,A.selectAll=k,A.toggleComponentSelection=m,A.confirmDeleteSelectedComponents=n,A.openEvent=o,A.openTask=p,A.newComponent=r,A.filterpopup=t,A.filter=u,A.filteredBy=v,A.sort=w,A.sortedBy=x,A.reload=y,A.cancelSearch=z,A.mode={search:!1,multiple:0},f.ready().then(function(){var a="events";"tasksListView"==f.settings.Calendar.SelectedList&&(A.selectedList=1,a="tasks"),i(a,{reload:!0})}),a.$on("calendars:list",function(){h.$filter(A.componentType,{reload:!0})}),a.$on("calendar:dragend",s)}a.$inject=["$rootScope","$timeout","$state","$mdDialog","Dialog","Preferences","Calendar","Component"],angular.module("SOGo.SchedulerUI").controller("CalendarListController",a)}(),function(){"use strict";function a(a,b,c,d,e,f,g,h,i,j,k,m,n,o){function p(a){i.prompt(l("New calendar"),l("Name of the Calendar")).then(function(a){var b=new m({name:a,isEditable:!0,isRemote:!1,owner:UserLogin});b.$id().then(function(){m.$add(b)})})}function q(){i.prompt(l("Subscribe to a web calendar..."),l("URL of the Calendar"),{inputType:"url"}).then(function(a){m.$addWebCalendar(a)})}function r(a){a.isSubscription?a.$delete()["catch"](function(b,c){i.alert(l('An error occured while deleting the calendar "%{0}".',a.name),l(b.error))}):i.confirm(l("Warning"),l("Are you sure you want to delete the calendar %{0}?",a.name),{ok:l("Delete")}).then(function(){a.$delete()["catch"](function(b,c){i.alert(l('An error occured while deleting the calendar "%{0}".',a.name),l(b.error))})})}function s(b,c){function e(b,c,d){function e(a){var b=0===a.type.indexOf("text")||/\.(ics)$/.test(a.name);return b||f.show({template:["",'
',' error_outline'," "+l("Select an iCalendar file (.ics).")+"","
","
"].join(""),position:"top right",hideDelay:3e3}),b}var h=this;h.uploader=new g({url:ApplicationBaseURL+[d.id,"import"].join("/"),autoUpload:!0,queueLimit:1,filters:[{name:e,fn:e}],onSuccessItem:function(b,d,e,g){var h;c.hide(),0===d.imported?h=l("No event was imported."):(h=l("A total of %{0} events were imported in the calendar.",d.imported),a.$emit("calendars:list")),f.show(f.simple().content(h).position("top right").hideDelay(3e3))},onErrorItem:function(a,b,c,d){f.show({template:["",'
',' error_outline'," "+l("An error occurred while importing calendar.")+"","
","
"].join(""),position:"top right",hideDelay:3e3})}}),h.close=function(){c.hide()}}d.show({parent:angular.element(document.body),targetEvent:b,clickOutsideToClose:!0,escapeToClose:!0,templateUrl:"UIxCalendarImportDialog",controller:e,controllerAs:"$CalendarImportDialogController",locals:{folder:c}}),e.$inject=["scope","$mdDialog","folder"]}function t(a){window.location.href=ApplicationBaseURL+"/"+a.id+".ics/export"}function u(a){_.forEach(m.$findAll(),function(b){a.id==b.id?b.active=1:b.active=0})}function v(){_.forEach(m.$findAll(),function(a){a.active=1})}function w(a){function b(a,b){function c(){a.hide()}var d=this;d.calendar=b,d.close=c}d.show({parent:angular.element(document.body),clickOutsideToClose:!0,escapeToClose:!0,templateUrl:a.id+"/links",controller:b,controllerAs:"links",locals:{calendar:a}}),b.$inject=["$mdDialog","calendar"]}function x(a){function b(a,b,c){function d(){f.calendar.$save(),c.init(f.calendar.$omit()),b.hide()}function e(){b.cancel()}var f=this;f.calendar=new m(c.$omit()),f.saveProperties=d,f.close=e,a.$watch("properties.calendar.color",function(){c.color=f.calendar.color})}var c=a.color;d.show({templateUrl:a.id+"/properties",controller:b,controllerAs:"properties",clickOutsideToClose:!0,escapeToClose:!0,locals:{srcCalendar:a}})["catch"](function(){a.color=c}),b.$inject=["$scope","$mdDialog","srcCalendar"]}function y(a){E.calendarName=a.name,E.editMode=a.id,h("calendarName_"+a.id)}function z(a){a.$reset(),E.editMode=!1}function A(a){a.$rename().then(function(a){E.editMode=!1})}function B(a){a.$acl.$users().then(function(){d.show({templateUrl:a.id+"/UIxAclEditor",controller:"AclController",controllerAs:"acl",clickOutsideToClose:!0,escapeToClose:!0,locals:{usersWithACL:a.$acl.users,User:n,folder:a}})})}function C(a){e.debug("subscribeToFolder "+a.owner+a.name),m.$subscribe(a.owner,a.name).then(function(a){f.show(f.simple().content(l("Successfully subscribed to calendar")).position("top right").hideDelay(3e3))})}function D(){var a=c.location.hash.split("/"),b=a[1],d=a[2],e=new Date,f=["#",b,d,e.getDayString()];c.location=f.join("/")}var E=this;E.activeUser=j.activeUser,E.service=m,E.newCalendar=p,E.addWebCalendar=q,E.confirmDelete=r,E.editFolder=y,E.revertEditing=z,E.renameFolder=A,E.share=B,E.importCalendar=s,E.exportCalendar=t,E.showOnly=u,E.showAll=v,E.showLinks=w,E.showProperties=x,E.subscribeToFolder=C,E.today=D,k.ready().then(function(){E.categories=_.map(k.defaults.SOGoCalendarCategories,function(a){return{id:a.asCSSIdentifier(),name:a,color:k.defaults.SOGoCalendarCategoriesColors[a]}})}),b.$watch(function(){return _.union(_.map(m.$calendars,function(a){ +!function(){"use strict";function a(b){if(this.init(b),this.name&&!this.id){var c=a.$$resource.create("createFolder",this.name);this.$unwrap(c)}}a.$factory=["$q","$timeout","$log","sgSettings","Resource","Preferences","Component","Acl",function(b,c,d,e,f,g,h,i){return angular.extend(a,{$q:b,$timeout:c,$log:d,$$resource:new f(e.activeUser("folderURL")+"Calendar",e.activeUser()),$Preferences:g,$Component:h,$$Acl:i,activeUser:e.activeUser(),$view:null}),a}];try{angular.module("SOGo.SchedulerUI")}catch(b){angular.module("SOGo.SchedulerUI",["SOGo.Common"])}angular.module("SOGo.SchedulerUI").value("CalendarSettings",{EventDragDayLength:96,EventDragHorizontalOffset:3}).factory("Calendar",a.$factory),a.$defaultCalendar=function(){var b,c=a.$Preferences.defaults.SOGoDefaultCalendar;return"first"==c&&(b=_.find(a.$findAll(null,!0),function(a){return a.active}))?b.id:"personal"},a.$add=function(a){var b,c,d;b=a.isWebCalendar?this.$webcalendars:a.isSubscription?this.$subscriptions:this.$calendars,c=_.find(b,function(b){return"personal"==a.id||"personal"!=b.id&&1===b.name.localeCompare(a.name)}),d=c?_.indexOf(_.map(b,"id"),c.id):1,b.splice(d,0,a)},a.$findAll=function(b,c){var d=this;return b?(this.$calendars=[],this.$subscriptions=[],this.$webcalendars=[],angular.forEach(b,function(b,c){var e=new a(b);e.isWebCalendar?d.$webcalendars.push(e):e.isSubscription?d.$subscriptions.push(e):d.$calendars.push(e)})):angular.isUndefined(this.$calendars)&&(this.$calendars=[],this.$subscriptions=[],this.$webcalendars=[],a.$$resource.fetch("calendarslist").then(function(b){a.$findAll(b.calendars,c)})),c?_.union(this.$calendars,_.filter(this.$subscriptions,function(a){return a.isOwned||a.acls.objectCreator})):_.union(this.$calendars,this.$subscriptions,this.$webcalendars)},a.$get=function(b){var c;return c=_.find(a.$calendars,function(a){return a.id==b}),c||(c=_.find(a.$subscriptions,function(a){return a.id==b})),c||(c=_.find(a.$webcalendars,function(a){return a.id==b})),c},a.$getIndex=function(b){var c;return c=_.indexOf(_.map(a.$calendars,"id"),b),0>c&&(c=_.indexOf(_.map(a.$subscriptions,"id"),b)),0>c&&(c=_.indexOf(_.map(a.$webcalendars,"id"),b)),c},a.$subscribe=function(b,c){var d=this;return a.$$resource.userResource(b).fetch(c,"subscribe").then(function(b){var c=new a(angular.extend({active:1},b));return _.find(d.$subscriptions,function(a){return a.id==b.id})||a.$add(c),c})},a.$addWebCalendar=function(b){var c=this,d=a.$q.defer();return _.find(c.$webcalendars,function(a){return a.urls.webCalendarURL==b})?d.reject():a.$$resource.post(null,"addWebCalendar",{url:b}).then(function(c){angular.extend(c,{isWebCalendar:!0,isEditable:!0,isRemote:!1,owner:a.activeUser.login,urls:{webCalendarURL:b}});var e=new a(c);a.$add(e),a.$$resource.fetch(e.id,"reload").then(function(b){a.$log.debug(JSON.stringify(b,void 0,2))}),d.resolve()},function(){d.reject()}),d.promise},a.$deleteComponents=function(b){var c={},d=[];return _.forEach(b,function(a){angular.isDefined(c[a.pid])||(c[a.pid]=[]),c[a.pid].push(a.id)}),_.forEach(c,function(b,c){d.push(a.$$resource.post(c,"batchDelete",{uids:b}))}),a.$q.all(d)},a.prototype.init=function(b){this.color=this.color||"#AAAAAA",angular.extend(this,b),this.id&&(this.$acl=new a.$$Acl("Calendar/"+this.id)),this.isOwned=a.activeUser.isSuperUser||this.owner==a.activeUser.login,this.isSubscription=!this.isRemote&&this.owner!=a.activeUser.login,angular.isUndefined(this.$shadowData)&&(this.$shadowData=this.$omit())},a.prototype.$id=function(){return this.id?a.$q.when(this.id):this.$futureCalendarData.then(function(a){return a.id})},a.prototype.getClassName=function(a){return angular.isUndefined(a)&&(a="fg"),a+"-folder"+this.id},a.prototype.$rename=function(){var b,c,d=this;return this.name==this.$shadowData.name?a.$q.when():(c=this.isWebCalendar?a.$webcalendars:this.isSubscription?a.$subscriptions:a.$calendars,b=_.indexOf(_.map(c,"id"),this.id),b>-1?this.$save().then(function(){c.splice(b,1),a.$add(d)}):a.$q.reject())},a.prototype.$delete=function(){var b,c,d=this;return this.isSubscription?(c=a.$$resource.fetch(this.id,"unsubscribe"),b=a.$subscriptions):(c=a.$$resource.remove(this.id),b=this.isWebCalendar?a.$webcalendars:a.$calendars),c.then(function(){var a=_.indexOf(_.map(b,"id"),d.id);b.splice(a,1)})},a.prototype.$reset=function(){var a=this;angular.forEach(this,function(b,c){"constructor"!=c&&"$"!=c[0]&&delete a[c]}),angular.extend(this,this.$shadowData),this.$shadowData=this.$omit()},a.prototype.$save=function(){var b=this;return a.$$resource.save(this.id,this.$omit()).then(function(a){return b.$shadowData=b.$omit(),a},function(c){return a.$log.error(JSON.stringify(c,void 0,2)),b.$reset(),c})},a.prototype.$setActivation=function(){return a.$$resource.fetch(this.id,(this.active?"":"de")+"activateFolder")},a.prototype.$getComponent=function(b,c){return a.$Component.$find(this.id,b,c)},a.prototype.$unwrap=function(b){var c=this;this.$futureCalendarData=b.then(function(b){return a.$timeout(function(){return c.init(b),c})},function(b){c.isError=!0,angular.isObject(b)&&a.$timeout(function(){angular.extend(c,b)})})},a.prototype.$omit=function(){var a={};return angular.forEach(this,function(b,c){"constructor"!=c&&"$"!=c[0]&&(a[c]=b)}),a}}(),function(){"use strict";function a(b){if("function"!=typeof b.then){if(this.init(b),this.pid&&!this.id){var c=a.$$resource.newguid(this.pid);this.$unwrap(c),this.isNew=!0}}else this.$unwrap(b)}a.$factory=["$q","$timeout","$log","sgSettings","Preferences","Card","Gravatar","Resource",function(b,c,d,e,f,g,h,i){return angular.extend(a,{$q:b,$timeout:c,$log:d,$Preferences:f,$Card:g,$gravatar:h,$$resource:new i(e.activeUser("folderURL")+"Calendar",e.activeUser()),timeFormat:"%H:%M",$query:{value:"",search:"title_Category_Location"},$queryEvents:{sort:"start",asc:1,filterpopup:"view_next7"},$queryTasks:{sort:"status",asc:1,filterpopup:"view_incomplete"},$refreshTimeout:null,$ghost:{}}),f.ready().then(function(){f.settings.Calendar.EventsFilterState&&(a.$queryEvents.filterpopup=f.settings.Calendar.EventsFilterState),f.settings.Calendar.TasksFilterState&&(a.$queryTasks.filterpopup=f.settings.Calendar.TasksFilterState),f.settings.Calendar.EventsSortingState&&(a.$queryEvents.sort=f.settings.Calendar.EventsSortingState[0],a.$queryEvents.asc=parseInt(f.settings.Calendar.EventsSortingState[1])),f.settings.Calendar.TasksSortingState&&(a.$queryTasks.sort=f.settings.Calendar.TasksSortingState[0],a.$queryTasks.asc=parseInt(f.settings.Calendar.TasksSortingState[1])),a.$queryTasks.show_completed=parseInt(f.settings.ShowCompletedTasks),a.$categories=f.defaults.SOGoCalendarCategoriesColors,f.defaults.SOGoTimeFormat&&(a.timeFormat=f.defaults.SOGoTimeFormat)}),a}];try{angular.module("SOGo.SchedulerUI")}catch(b){angular.module("SOGo.SchedulerUI",["SOGo.Common"])}angular.module("SOGo.SchedulerUI").factory("Component",a.$factory),a.$selectedCount=function(){var b;return b=0,a.$events&&(b+=_.filter(a.$events,function(a){return a.selected}).length),a.$tasks&&(b+=_.filter(a.$tasks,function(a){return a.selected}).length),b},a.$startRefreshTimeout=function(b){var c=this;a.$refreshTimeout&&a.$timeout.cancel(a.$refreshTimeout),a.$Preferences.ready().then(function(){var d=a.$Preferences.defaults.SOGoRefreshViewCheck;if(d&&"manually"!=d){var e=angular.bind(c,a.$filter,b);a.$refreshTimeout=a.$timeout(e,1e3*d.timeInterval())}})},a.$filter=function(b,c){var d=this,e=new Date,f=e.getDate(),g=e.getMonth()+1,h=e.getFullYear(),i="$query"+b.capitalize(),j={day:""+h+(10>g?"0":"")+g+(10>f?"0":"")+f};return a.$startRefreshTimeout(b),this.$Preferences.ready().then(function(){var e,f,g=!1;return angular.extend(d.$query,j),c&&_.forEach(_.keys(c),function(b){g|=d.$query[b]&&c[b]!=a.$query[b],"reload"==b&&c[b]?g=!0:angular.isDefined(d.$query[b])?d.$query[b]=c[b]:d[i][b]=c[b]}),e=d.$$resource.fetch(null,b+"list",angular.extend(d[i],d.$query)),f="tasks"==b?"$events":"$tasks",g&&(delete a[f],a.$log.debug("force reload of "+f)),d.$unwrapCollection(b,e)})},a.$find=function(b,c,d){var e,f=[b,c];return d&&f.push(d),e=this.$$resource.fetch(f.join("/"),"view"),new a(e)},a.filterCategories=function(b){var c=new RegExp(b,"i");return _.filter(_.keys(a.$categories),function(a){return-1!=a.search(c)})},a.saveSelectedList=function(a){return this.$$resource.post(null,"saveSelectedList",{list:a+"ListView"})},a.$eventsBlocksForView=function(b,c){var d=this;return a.$Preferences.ready().then(function(e){var f,g,h,i;return f=a.$Preferences.defaults.SOGoFirstDayOfWeek,"day"==b?(g="dayView",h=i=c):"multicolumnday"==b?(g="multicolumndayView",h=i=c):"week"==b?(g="weekView",h=c.beginOfWeek(f),i=new Date,i.setTime(h.getTime()),i.addDays(6)):"month"==b&&(g="monthView",h=c,h.setDate(1),h=h.beginOfWeek(f),i=new Date,i.setTime(h.getTime()),i.setMonth(i.getMonth()+1),i.addDays(-1),i=i.endOfWeek(f)),d.$eventsBlocks(g,h,i)})},a.$eventsBlocks=function(b,c,d){var e,f,g,h,i=[],j=a.$q.defer();return e={view:b.toLowerCase(),sd:c.getDayString(),ed:d.getDayString()},a.$log.debug("eventsblocks "+JSON.stringify(e,void 0,2)),f=this.$$resource.fetch(null,"eventsblocks",e),f.then(function(b){var d,e;d=function(b,c,d){var e=_.zipObject(this.eventsFields,c),f=new Date(1e3*e.c_startdate);return e.hour=f.getHourString(),e.blocks=[],b.push(new a(e)),b},e=function(a){this[a.nbr].blocks.push(a),a.component=this[a.nbr]},a.$views=[],a.$timeout(function(){_.forEach(b,function(b){var f,j=[],k={},l={};if(b.eventsFields.splice(_.indexOf(b.eventsFields,"c_folder"),1,"pid"),b.eventsFields.splice(_.indexOf(b.eventsFields,"c_name"),1,"id"),b.eventsFields.splice(_.indexOf(b.eventsFields,"c_recurrence_id"),1,"occurrenceId"),b.eventsFields.splice(_.indexOf(b.eventsFields,"c_title"),1,"summary"),_.reduce(b.events,_.bind(d,b),j),_.forEach(_.flatten(b.blocks),_.bind(e,j)),_.forEach(_.flatten(b.allDayBlocks),_.bind(e,j)),0===i.length)for(g=0;g1||this.repeat.days&&this.repeat.days.length>0||this.repeat.monthdays&&this.repeat.monthdays.length>0||this.repeat.months&&this.repeat.months.length>0);return a},a.prototype.isEditable=function(){return!this.occurrenceId&&!this.isReadOnly},a.prototype.isEditableOccurrence=function(){return this.occurrenceId&&!this.isReadOnly},a.prototype.isInvitation=function(){return!this.occurrenceId&&this.userHasRSVP},a.prototype.isInvitationOccurrence=function(){return this.occurrenceId&&this.userHasRSVP},a.prototype.isReadOnly=function(){return this.isReadOnly&&!this.userHasRSVP},a.prototype.enablePercentComplete=function(){return"task"==this.type&&"not-specified"!=this.status&&"cancelled"!=this.status},a.prototype.coversFreeBusy=function(a,b,c){var d=angular.isDefined(this.freebusy[a])&&angular.isDefined(this.freebusy[a][b])&&1==this.freebusy[a][b][c];return d},a.prototype.updateFreeBusyCoverage=function(){var a=this,b={};if(this.start&&this.end){var c=new Date(this.start.getTime()),d=new Date(this.end.getTime()),e=parseInt(c.getMinutes()/15+.5),f=parseInt(d.getMinutes()/15+.5);return c.setMinutes(15*e),d.setMinutes(15*f),_.forEach(c.daysUpTo(d),function(c,d){var f,g=c.getDate(),h=c.getDayString();if(h==a.start.getDayString())for(f=c.getHours().toString(),b[h]={},b[h][f]=[];e>0;)b[h][f].push(0),e--;else c=c.beginOfDay(),b[h]={};for(;c.getTime()=e;e++)d=e.toString(),a[c][d]?b.freebusy[c][d]=[a[c][d][0],a[c][d][15],a[c][d][30],a[c][d][45]]:b.freebusy[c][d]=[0,0,0,0]})}))},a.prototype.getClassName=function(a){return angular.isUndefined(a)&&(a="fg"),a+"-folder"+(this.destinationCalendar||this.c_folder||this.pid)},a.prototype.addAttendee=function(b){var c,d,e=this;b&&(b.$isList()&&1!==b.isGroup?(d=a.$Card.$find(b.container,b.c_name),d.$id().then(function(b){_.forEach(d.refs,function(b){c={name:b.c_cn,email:b.$preferredEmail(),role:"req-participant",status:"needs-action",uid:b.c_uid},_.find(e.attendees,function(a){return a.email==c.email})||(c.image=a.$gravatar(c.email,32),e.attendees?e.attendees.push(c):e.attendees=[c],e.updateFreeBusyAttendee(c))})})):(c={name:b.c_cn,email:b.$preferredEmail(),role:"req-participant",status:"needs-action",uid:b.c_uid},_.find(this.attendees,function(a){return a.email==c.email})||(c.image=a.$gravatar(c.email,32),this.attendees?this.attendees.push(c):this.attendees=[c],this.updateFreeBusyAttendee(c))))},a.prototype.hasAttendee=function(a){var b=_.find(this.attendees,function(b){return _.find(a.emails,function(a){return a.value==b.email})});return angular.isDefined(b)},a.prototype.deleteAttendee=function(a){var b=_.findIndex(this.attendees,function(b){return b.email==a.email});this.attendees.splice(b,1)},a.prototype.canRemindAttendeesByEmail=function(){return"email"==this.alarm.action&&!this.isReadOnly&&this.attendees&&this.attendees.length>0},a.prototype.addAttachUrl=function(a){if(angular.isUndefined(this.attachUrls))this.attachUrls=[{value:a}];else{for(var b=0;b-1&&this.attachUrls.length>a&&this.attachUrls.splice(a,1)},a.prototype.$addDueDate=function(){this.due=new Date,this.due.setMinutes(15*Math.round(this.due.getMinutes()/15)),this.dueDate=this.due.toISOString()},a.prototype.$deleteDueDate=function(){delete this.due,delete this.dueDate},a.prototype.$addStartDate=function(){this.start=new Date,this.start.setMinutes(15*Math.round(this.start.getMinutes()/15))},a.prototype.$deleteStartDate=function(){delete this.start,delete this.startDate},a.prototype.$reset=function(){var a=this;angular.forEach(this,function(b,c){"constructor"!=c&&"$"!=c[0]&&delete a[c]}),this.init(this.$shadowData),this.$shadowData=this.$omit()},a.prototype.$reply=function(){var b,c=this,d=[this.pid,this.id];return this.occurrenceId&&d.push(this.occurrenceId),b={reply:this.reply,delegatedTo:this.delegatedTo,alarm:this.$hasAlarm?this.alarm:{}},a.$$resource.save(d.join("/"),b,{action:"rsvpAppointment"}).then(function(a){return c.$shadowData=c.$omit(),a})},a.prototype.$adjust=function(b){var c=[this.pid,this.id];return _.every(_.values(b),function(a){return 0===a})?a.$q.when():(this.occurrenceId&&c.push(this.occurrenceId),a.$log.debug("adjust "+c.join("/")+" "+JSON.stringify(b)),a.$$resource.save(c.join("/"),b,{action:"adjust"}))},a.prototype.$save=function(b){var c,d,e,f,g=this;return e=this.$omit(),f=a.$Preferences.constructor.$mdDateLocaleProvider,e.startDate=e.start?e.start.format(f,"%Y-%m-%d"):"",e.startTime=e.start?e.start.format(f,"%H:%M"):"",e.endDate=e.end?e.end.format(f,"%Y-%m-%d"):"",e.endTime=e.end?e.end.format(f,"%H:%M"):"",e.dueDate=e.due?e.due.format(f,"%Y-%m-%d"):"",e.dueTime=e.due?e.due.format(f,"%H:%M"):"",e.completedDate=e.completed?e.completed.format(f,"%Y-%m-%d"):"",this.$hasCustomRepeat?"monthly"==this.repeat.frequency&&this.repeat.month.type&&"byday"==this.repeat.month.type||"yearly"==this.repeat.frequency&&this.repeat.year.byday?(delete e.repeat.monthdays,e.repeat.days=[{day:this.repeat.month.day,occurrence:this.repeat.month.occurrence.toString()}]):this.repeat.month.type&&delete e.repeat.days:this.repeat.frequency&&"never"!=this.repeat.frequency&&(e.repeat={frequency:this.repeat.frequency}),this.repeat.frequency?"until"==this.repeat.end&&this.repeat.until?e.repeat.until=this.repeat.until.stringWithSeparator("-"):"count"==this.repeat.end&&this.repeat.count?e.repeat.count=this.repeat.count:(delete e.repeat.until,delete e.repeat.count):delete e.repeat,"not-specified"==this.status?delete e.status:"completed"!=this.status&&delete e.completedDate,this.$hasAlarm?!this.alarm.action||"email"!=this.alarm.action||this.attendees&&this.attendees.length>0||(e.alarm.attendees=0,e.alarm.organizer=1):e.alarm={},d=[this.pid,this.id],this.isNew&&(c={action:"saveAs"+this.type.capitalize()}),this.occurrenceId&&d.push(this.occurrenceId),angular.extend(e,b),a.$$resource.save(d.join("/"),e,c).then(function(a){return g.$shadowData=g.$omit(),a})},a.prototype.remove=function(b){var c=[this.pid,this.id];return b&&this.occurrenceId&&c.push(this.occurrenceId),a.$$resource.remove(c.join("/"))},a.prototype.$unwrap=function(b){var c=this;this.$futureComponentData=b,this.$futureComponentData.then(function(a){c.init(a),c.$shadowData=c.$omit()},function(b){angular.extend(c,b),c.isError=!0,a.$log.error(c.error)})},a.prototype.$omit=function(){var a={};return angular.forEach(this,function(b,c){"constructor"!=c&&"$"!=c[0]&&"blocks"!=c&&(a[c]=angular.copy(b))}),a},a.prototype.repeatDescription=function(){var a=null;return this.repeat&&(a=l("repeat_"+this.repeat.frequency.toUpperCase())),a},a.prototype.alarmDescription=function(){var a,b=null;return this.alarm&&(a=["reminder"+this.alarm.quantity,this.alarm.unit,this.alarm.reference].join("_"),b=l(a),a===b&&(b=[this.alarm.quantity,l("reminder_"+this.alarm.unit),l("reminder_"+this.alarm.reference)].join(" "))),b},a.prototype.toString=function(){return"[Component "+this.id+"]"}}(),function(){"use strict";function a(a,b,c,d,e,f,g){function h(){f.$eventsBlocksForView(d.view,d.day.asDate()).then(function(a){l.views=a,_.forEach(l.views,function(a){a.id&&(a.calendar=new e({id:a.id,name:a.calendarName}))})})}function i(a){var b=angular.element(a.currentTarget).attr("date");c.go("calendars.view",{day:b})}function j(a){c.go("calendars.view",{view:a})}var k,l=this;l.views=g,l.changeDate=i,l.changeView=j,k=b.$on("calendars:list",h),a.$on("$destroy",k)}a.$inject=["$scope","$rootScope","$state","$stateParams","Calendar","Component","stateEventsBlocks"],angular.module("SOGo.SchedulerUI").controller("CalendarController",a)}(),function(){"use strict";function a(a,b,c,d,e,f,g,h){function i(a,b){(b&&b.reload||A.componentType!=a)&&(angular.isUndefined(h["$"+a])&&h.$filter(a),A.unselectComponents(),A.componentType=a,h.saveSelectedList(a))}function j(){_.forEach(h["$"+A.componentType],function(a){a.selected=!1}),A.mode.multiple=0}function k(){_.forEach(h["$"+A.componentType],function(a){a.selected=!0}),A.mode.multiple=h["$"+A.componentType].length}function m(a,b){b.selected=!b.selected,A.mode.multiple+=b.selected?1:-1,a.preventDefault(),a.stopPropagation()}function n(){e.confirm(l("Warning"),l("Are you sure you want to delete the selected components?"),{ok:l("Delete")}).then(function(){var b=_.filter(h["$"+A.componentType],function(a){return a.selected});g.$deleteComponents(b).then(function(){a.$emit("calendars:list")})})}function o(a,b){q(a,b,"appointment")}function p(a,b){q(a,b,"task")}function q(a,b,c){if(b.viewable){var e="UIx"+c.capitalize()+"ViewTemplate";d.show({parent:angular.element(document.body),targetEvent:a,clickOutsideToClose:!0,escapeToClose:!0,templateUrl:e,controller:"ComponentController",controllerAs:"editor",locals:{stateComponent:b}})}}function r(a,b){var c,e="appointment";b?(c=b,e=b.type):("tasks"==A.componentType&&(e="task"),c=new h({pid:g.$defaultCalendar(),type:e}));var f="UIx"+e.capitalize()+"EditorTemplate";return d.show({parent:angular.element(document.body),targetEvent:a,clickOutsideToClose:!0,escapeToClose:!0,templateUrl:f,controller:"ComponentEditorController",controllerAs:"editor",locals:{stateComponent:c}})}function s(c){function e(a,b,c,d){a.updateThisOccurrence=function(){c.$adjust(d).then(b.hide,function(a){b.cancel().then(function(){f(a,c,d)})})},a.updateAllOccurrences=function(){delete c.occurrenceId,c.$adjust(d).then(b.hide,function(a){b.cancel().then(function(){f(a,c,d)})})}}function f(b,c,e){403==b.status&&b.data&&b.data.message&&angular.isObject(b.data.message)&&d.show({parent:angular.element(document.body),clickOutsideToClose:!1,escapeToClose:!1,templateUrl:"UIxAttendeeConflictDialog",controller:i,controllerAs:"$AttendeeConflictDialogController",locals:{component:c,params:e,conflictError:b.data.message}}).then(function(){a.$emit("calendars:list")})}function i(a,b,c,d,e){function f(){c.$adjust(angular.extend({ignoreConflicts:!0},d)).then(b.hide)}var g=this;g.conflictError=e,g.cancel=b.cancel,g.save=f}var j,k,m,n,o,p,q;j=h.$ghost.component,k=h.$ghost.pointerHandler,j.isNew?(m=k.currentEventCoordinates,j.summary="",j.isAllDay&&(m.duration-=96),j.setDelta(15*m.duration),r(null,j)["finally"](function(){b(function(){h.$resetGhost()})})):(n=k.currentEventCoordinates.getDelta(k.originalEventCoordinates),o={days:n.dayNumber,start:15*n.start,duration:15*n.duration},k.originalCalendar&&0!==n.dayNumber&&(p=k.currentEventCoordinates.dayNumber,q=_.filter(g.$findAll(),{active:1}),o.destination=q[p].id,o.days=0),j.isException||!j.occurrenceId?j.$adjust(o).then(function(){a.$emit("calendars:list")},function(a){f(a,j,o)})["finally"](function(){b(function(){h.$resetGhost()})}):j.occurrenceId&&d.show({clickOutsideToClose:!0,escapeToClose:!0,locals:{component:j,params:o},template:['',' ',"

"+l("editRepeatingItem")+"

","
"," ",' '+l("button_thisOccurrenceOnly")+"",' '+l("button_allOccurrences")+""," ","
"].join(""),controller:e}).then(function(){a.$emit("calendars:list")})["finally"](function(){b(function(){h.$resetGhost()})})),e.$inject=["$scope","$mdDialog","component","params"],i.$inject=["$scope","$mdDialog","component","params","conflictError"]}function t(){return h["$query"+A.componentType.capitalize()].filterpopup}function u(a){h.$filter(A.componentType,{filterpopup:a})}function v(a){return h["$query"+A.componentType.capitalize()].filterpopup==a}function w(a){h.$filter(A.componentType,{sort:a})}function x(a){return h["$query"+A.componentType.capitalize()].sort==a}function y(){a.$emit("calendars:list")}function z(){A.mode.search=!1,h.$filter(A.componentType,{value:""})}var A=this;A.component=h,A.componentType="events",A.selectedList=0,A.selectComponentType=i,A.unselectComponents=j,A.selectAll=k,A.toggleComponentSelection=m,A.confirmDeleteSelectedComponents=n,A.openEvent=o,A.openTask=p,A.newComponent=r,A.filterpopup=t,A.filter=u,A.filteredBy=v,A.sort=w,A.sortedBy=x,A.reload=y,A.cancelSearch=z,A.mode={search:!1,multiple:0},f.ready().then(function(){var a="events";"tasksListView"==f.settings.Calendar.SelectedList&&(A.selectedList=1,a="tasks"),i(a,{reload:!0})}),a.$on("calendars:list",function(){h.$filter(A.componentType,{reload:!0})}),a.$on("calendar:dragend",s)}a.$inject=["$rootScope","$timeout","$state","$mdDialog","Dialog","Preferences","Calendar","Component"],angular.module("SOGo.SchedulerUI").controller("CalendarListController",a)}(),function(){"use strict";function a(a,b,c,d,e,f,g,h,i,j,k,m,n,o){function p(a){i.prompt(l("New calendar"),l("Name of the Calendar")).then(function(a){var b=new m({name:a,isEditable:!0,isRemote:!1,owner:UserLogin});b.$id().then(function(){m.$add(b)})})}function q(){i.prompt(l("Subscribe to a web calendar..."),l("URL of the Calendar"),{inputType:"url"}).then(function(a){m.$addWebCalendar(a)})}function r(a){a.isSubscription?a.$delete()["catch"](function(b,c){i.alert(l('An error occured while deleting the calendar "%{0}".',a.name),l(b.error))}):i.confirm(l("Warning"),l('Are you sure you want to delete the calendar "%{0}"?',a.name),{ok:l("Delete")}).then(function(){a.$delete()["catch"](function(b,c){i.alert(l('An error occured while deleting the calendar "%{0}".',a.name),l(b.error))})})}function s(b,c){function e(b,c,d){function e(a){var b=0===a.type.indexOf("text")||/\.(ics)$/.test(a.name);return b||f.show({template:["",'
',' error_outline'," "+l("Select an iCalendar file (.ics).")+"","
","
"].join(""),position:"top right",hideDelay:3e3}),b}var h=this;h.uploader=new g({url:ApplicationBaseURL+[d.id,"import"].join("/"),autoUpload:!0,queueLimit:1,filters:[{name:e,fn:e}],onSuccessItem:function(b,d,e,g){var h;c.hide(),0===d.imported?h=l("No event was imported."):(h=l("A total of %{0} events were imported in the calendar.",d.imported),a.$emit("calendars:list")),f.show(f.simple().content(h).position("top right").hideDelay(3e3))},onErrorItem:function(a,b,c,d){f.show({template:["",'
',' error_outline'," "+l("An error occurred while importing calendar.")+"","
","
"].join(""),position:"top right",hideDelay:3e3})}}),h.close=function(){c.hide()}}d.show({parent:angular.element(document.body),targetEvent:b,clickOutsideToClose:!0,escapeToClose:!0,templateUrl:"UIxCalendarImportDialog",controller:e,controllerAs:"$CalendarImportDialogController",locals:{folder:c}}),e.$inject=["scope","$mdDialog","folder"]}function t(a){window.location.href=ApplicationBaseURL+"/"+a.id+".ics/export"}function u(a){_.forEach(m.$findAll(),function(b){a.id==b.id?b.active=1:b.active=0})}function v(){_.forEach(m.$findAll(),function(a){a.active=1})}function w(a){function b(a,b){function c(){a.hide()}var d=this;d.calendar=b,d.close=c}d.show({parent:angular.element(document.body),clickOutsideToClose:!0,escapeToClose:!0,templateUrl:a.id+"/links",controller:b,controllerAs:"links",locals:{calendar:a}}),b.$inject=["$mdDialog","calendar"]}function x(a){function b(a,b,c){function d(){f.calendar.$save(),c.init(f.calendar.$omit()),b.hide()}function e(){b.cancel()}var f=this;f.calendar=new m(c.$omit()),f.saveProperties=d,f.close=e,a.$watch("properties.calendar.color",function(){c.color=f.calendar.color})}var c=a.color;d.show({templateUrl:a.id+"/properties",controller:b,controllerAs:"properties",clickOutsideToClose:!0,escapeToClose:!0,locals:{srcCalendar:a}})["catch"](function(){a.color=c}),b.$inject=["$scope","$mdDialog","srcCalendar"]}function y(a){E.calendarName=a.name,E.editMode=a.id,h("calendarName_"+a.id)}function z(a){a.$reset(),E.editMode=!1}function A(a){a.$rename().then(function(a){E.editMode=!1})}function B(a){a.$acl.$users().then(function(){d.show({templateUrl:a.id+"/UIxAclEditor",controller:"AclController",controllerAs:"acl",clickOutsideToClose:!0,escapeToClose:!0,locals:{usersWithACL:a.$acl.users,User:n,folder:a}})})}function C(a){e.debug("subscribeToFolder "+a.owner+a.name),m.$subscribe(a.owner,a.name).then(function(a){f.show(f.simple().content(l("Successfully subscribed to calendar")).position("top right").hideDelay(3e3))})}function D(){var a=c.location.hash.split("/"),b=a[1],d=a[2],e=new Date,f=["#",b,d,e.getDayString()];c.location=f.join("/")}var E=this;E.activeUser=j.activeUser,E.service=m,E.newCalendar=p,E.addWebCalendar=q,E.confirmDelete=r,E.editFolder=y,E.revertEditing=z,E.renameFolder=A,E.share=B,E.importCalendar=s,E.exportCalendar=t,E.showOnly=u,E.showAll=v,E.showLinks=w,E.showProperties=x,E.subscribeToFolder=C,E.today=D,k.ready().then(function(){E.categories=_.map(k.defaults.SOGoCalendarCategories,function(a){return{id:a.asCSSIdentifier(),name:a,color:k.defaults.SOGoCalendarCategoriesColors[a]}})}),b.$watch(function(){return _.union(_.map(m.$calendars,function(a){ return _.pick(a,["id","active","color"])}),_.map(m.$subscriptions,function(a){return _.pick(a,["id","active","color"])}),_.map(m.$webcalendars,function(a){return _.pick(a,["id","active","color"])}))},function(b,c){var d,f,g;d=_.intersectionBy(b,c,"id"),f=_.map(_.filter(d,function(a){var b=_.find(c,{id:a.id});return!_.isEqual(a,b)}),"id"),g=[],f.length>0&&(e.debug(f.join(", ")+" changed"),_.forEach(f,function(a){var b=m.$get(a);g.push(b.$setActivation())})),d.length>0&&m.$q.all(g).then(function(){a.$emit("calendars:list")})},!0)}a.$inject=["$rootScope","$scope","$window","$mdDialog","$log","$mdToast","FileUploader","sgFocus","Dialog","sgSettings","Preferences","Calendar","User","stateCalendars"],angular.module("SOGo.SchedulerUI").controller("CalendarsController",a)}(),function(){"use strict";function a(a,b,c,d,e,f,g){function h(){b.hide()}function i(a){return e.$filterAll(a),e.$cards}function j(){var a="vevent"==s.component.component?"Appointment":"Task";b.hide().then(function(){var c="UIx"+a+"EditorTemplate";b.show({parent:angular.element(document.body),clickOutsideToClose:!0,escapeToClose:!0,templateUrl:c,controller:"ComponentEditorController",controllerAs:"editor",locals:{stateComponent:s.component}})})}function k(){r=c.$get(s.component.pid).$getComponent(s.component.id),r.$futureComponentData.then(function(){s.component=r,j()})}function m(c){var d=c||s.component;d.$reply().then(function(){a.$emit("calendars:list"),b.hide(),f.getAlarms()})}function n(){r=c.$get(s.component.pid).$getComponent(s.component.id),r.$futureComponentData.then(function(){r.reply=s.component.reply,r.delegatedTo=s.component.delegatedTo,r.$hasAlarm=s.component.$hasAlarm,r.alarm=s.component.alarm,m(r)})}function o(){s.component.remove(!0).then(function(){a.$emit("calendars:list"),b.hide()})}function p(){s.component.remove().then(function(){a.$emit("calendars:list"),b.hide()})}function q(a){c.$$resource.post(s.component.pid+"/"+s.component.id,"raw").then(function(c){function d(a,b){a.close=function(){b.hide()}}b.hide(),b.show({parent:angular.element(document.body),targetEvent:a,clickOutsideToClose:!0,escapeToClose:!0,template:['',' ',"
",c,"    
","
"," ",' '+l("Close")+""," ","
"].join(""),controller:d}),d.$inject=["scope","$mdDialog"]})}var r,s=this;s.service=d,s.component=g,s.close=h,s.cardFilter=i,s.edit=j,s.editAllOccurrences=k,s.reply=m,s.replyAllOccurrences=n,s.deleteOccurrence=o,s.deleteAllOccurrences=p,s.toggleRawSource=q,angular.isUndefined(s.component.$futureComponentData)&&(r=c.$get(s.component.pid).$getComponent(s.component.id,s.component.occurrenceId),r.$futureComponentData.then(function(){s.component=r,s.organizer=[s.component.organizer]}))}function b(a,b,c,d,e,f,g,h,i,j,k,l){function m(){var a=I.component.addAttachUrl("");focus("attachUrl_"+a)}function n(){I.showRecurrenceEditor=!I.showRecurrenceEditor,I.component.$hasCustomRepeat=I.showRecurrenceEditor}function o(){I.showAttendeesEditor=!I.showAttendeesEditor}function p(a){return i.$filterAll(a),i.$cards}function q(a){angular.isString(a)?a.isValidEmail()&&(I.component.addAttendee(new j({emails:[{value:a}]})),I.searchText=""):I.component.addAttendee(a)}function r(a){I.component.deleteAttendee(a),0===I.component.attendees.length&&(I.showAttendeesEditor=!1)}function s(b,c){b.$valid&&I.component.$save(c).then(function(b){a.$emit("calendars:list"),e.hide(),k.getAlarms()},function(a){403==a.status&&a.data&&a.data.message&&angular.isObject(a.data.message)&&(I.attendeeConflictError=a.data.message)})}function t(){I.component.$reset(),I.component.isNew&&(I.component=null),e.cancel()}function u(){var a=[];return I.component.start&&I.component.end&&(a=I.component.start.daysUpTo(I.component.end)),_.map(a,function(a){return{stringWithSeparator:a.stringWithSeparator(),getDayString:a.getDayString()}})}function v(){for(var a=[],b=0;23>=b;b++)a.push(b.toString());return a}function w(){I.component.$addStartDate(),F=new Date(I.component.start.getTime())}function x(){I.component.$addDueDate(),H=new Date(I.component.due.getTime())}function y(){I.component.start.addMinutes(60*F.getHours()+F.getMinutes()),z()}function z(){var a;a=F.valueOf()-I.component.start.valueOf(),0!==a&&(F=new Date(I.component.start.getTime()),"appointment"===I.component.type&&(I.component.end=new Date(I.component.start.getTime()),I.component.end.addMinutes(I.component.delta),G=new Date(I.component.end.getTime())),E())}function A(){I.component.end.addMinutes(60*G.getHours()+G.getMinutes()),B()}function B(){var a=G.valueOf()-I.component.end.valueOf();0!==a&&(a=I.component.start.minutesTo(I.component.end),0>a?I.component.end=new Date(G.getTime()):(I.component.delta=a,G=new Date(I.component.end.getTime())),E())}function C(){I.component.due.addMinutes(60*H.getHours()+H.getMinutes()),D()}function D(){H=new Date(I.component.due.getTime())}function E(){I.attendeesEditor.days=u(),I.component.updateFreeBusy()}var F,G,H,I=this;I.service=g,I.component=l,I.categories={},I.showRecurrenceEditor=I.component.$hasCustomRepeat,I.toggleRecurrenceEditor=n,I.showAttendeesEditor=angular.isDefined(I.component.attendees),I.toggleAttendeesEditor=o,I.cardFilter=p,I.addAttendee=q,I.removeAttendee=r,I.addAttachUrl=m,I.cancel=t,I.save=s,I.attendeeConflictError=!1,I.attendeesEditor={days:u(),hours:v()},I.addStartDate=w,I.addDueDate=x,I.updateStartTime=y,I.adjustStartTime=z,I.updateEndTime=A,I.adjustEndTime=B,I.updateDueTime=C,I.adjustDueTime=D,I.component.start&&(F=new Date(I.component.start.getTime())),I.component.end&&(G=new Date(I.component.end.getTime())),I.component.due&&(H=new Date(I.component.due.getTime()))}a.$inject=["$rootScope","$mdDialog","Calendar","Component","AddressBook","Alarm","stateComponent"],b.$inject=["$rootScope","$scope","$log","$timeout","$mdDialog","User","Calendar","Component","AddressBook","Card","Alarm","stateComponent"],angular.module("SOGo.SchedulerUI").controller("ComponentController",a).controller("ComponentEditorController",b)}(),function(){"use strict";function a(){return{restrict:"E",scope:{day:"@sgDay",dayNumber:"@sgDayNumber",dayString:"@sgDayString",calendar:"@sgCalendar"},controller:b}}function b(a,b){this.day=a.day,this.dayNumber=a.dayNumber,this.dayString=a.dayString,this.calendarData=function(){var c,d,e;return a.calendar?(c=a.calendar,e=_.filter(b.$findAll(),{active:1}),d=_.findIndex(e,function(a){return a.id==c}),{pid:c,index:d}):null}}b.$inject=["$scope","Calendar"],angular.module("SOGo.SchedulerUI").directive("sgCalendarDay",a)}(),function(){"use strict";function a(a){function b(a,b,c){var d,e,f;d=100/a.block.siblings,e=a.block.position*d,f=100-(a.block.position+1)*d,100>d&&(e>0&&(e-=2),f>0&&(f-=2)),0===e&&(e=2),0===f&&(f=2),b.css("left",e+"%"),b.css("right",f+"%"),a.block.component&&a.block.component.c_isallday||(b.addClass("starts"+a.block.start),b.addClass("lasts"+a.block.length)),a.block.component&&b.addClass("bg-folder"+a.block.component.pid)}return{restrict:"E",scope:{block:"=sgBlock",clickBlock:"&sgClick"},replace:!0,template:['
",'
','
",'
{{ block.component.summary }}',' ',' ',' ',' ',' '," ",'
'," place {{block.component.c_location}}","
","
","
",'
{{ block.startHour }}
','
{{ block.endHour }}
',"
"].join(""),link:b}}a.$inject=["CalendarSettings"],angular.module("SOGo.SchedulerUI").directive("sgCalendarDayBlock",a)}(),function(){"use strict";function a(){return{restrict:"E",scope:{blocks:"=sgBlocks",day:"@sgDay",clickBlock:"&sgClick"},template:["'].join("")}}angular.module("SOGo.SchedulerUI").directive("sgCalendarDayTable",a)}(),function(){"use strict";function a(a,b,c,d,e){function f(f,g,h,i){function j(){var a,b;f.block=e.$ghost,b=q.calendarData(),b&&(s=b.index,a=b.pid,t=f.block.pointerHandler.originalCalendar.index),a||(a=f.block.component.pid),g.addClass("bg-folder"+a)}function k(){_.forEachRight(p.classList,function(a){/^bg-folder/.test(a)&&g.removeClass(a)}),g.addClass("ng-hide")}function l(){var a,e,h,i,j,k,l,m,p,u;if(a=!1,u=function(){g.removeClass("sg-event--notransition")},d.$view&&d.$view.type==r.type){if(e="multiday-allday"===r.type,h=f.block.pointerHandler.originalEventCoordinates.dayNumber,i=f.block.pointerHandler.currentEventCoordinates.dayNumber,k=f.block.pointerHandler.currentEventCoordinates.start,m=f.block.pointerHandler.currentEventCoordinates.duration,p=c.EventDragDayLength-k,angular.isUndefined(m))return;for(l=m,l>p&&(l=p),i>-1&&(0>s&&i==q.dayNumber||i==s&&(t==s||!f.block.component.isException))&&(a=!0,e||(f.block.startHour=n(k),j=0===parseInt(g.css("top")),j&&g.addClass("sg-event--notransition"),d.$view.quarterHeight?(g.css("top",k*d.$view.quarterHeight+"px"),g.css("height",l*d.$view.quarterHeight+"px")):g.css("top",d.$view.topOffset+"px"),j&&b(u)),g.removeClass("fg-folder"+f.block.component.pid),g.removeClass("sg-event--ghost--last"),g.addClass("sg-event--ghost--first")),m-=l,i++;!a&&m&&i<=q.dayNumber;)l=m,l>c.EventDragDayLength&&(l=c.EventDragDayLength),i>-1&&i==q.dayNumber&&(a=!0,e||(j=0!==parseInt(g.css("top")),j&&g.addClass("sg-event--notransition"),g.css("top",d.$view.topOffset+"px"),d.$view.quarterHeight&&g.css("height",l*d.$view.quarterHeight+"px"),j&&b(u)),g.removeClass("sg-event--ghost--first"),g.removeClass("sg-event--ghost--last"),g.addClass("fg-folder"+f.block.component.pid)),m-=l,i++,k=0;m||(e?g.addClass("sg-event--ghost--last"):f.block.endHour=o(k,l))}a?g.removeClass("ng-hide"):g.addClass("ng-hide")}function m(a){var b,c,d;return b=15*a,c=Math.floor(b/60),10>c&&(c="0"+c),d=b%60,10>d&&(d="0"+d),""+c+":"+d}function n(a){return m(a)}function o(a,b){var d=(a+b)%c.EventDragDayLength;return m(d)}var p,q,r,s,t;p=g[0],q=i[0],r=i[1],s=-1,g.addClass("sg-event--ghost md-whiteframe-3dp ng-hide");var u=a.$on("calendar:dragstart",j),v=a.$on("calendar:drag",l),w=a.$on("calendar:dragend",k);f.$on("$destroy",function(){u(),v(),w()})}return{restrict:"A",require:["^sgCalendarDay","^sgCalendarScrollView"],link:f}}a.$inject=["$rootScope","$timeout","CalendarSettings","Calendar","Component"],angular.module("SOGo.SchedulerUI").directive("sgCalendarGhost",a)}(),function(){"use strict";function a(){return{restrict:"E",scope:{blocks:"=sgBlocks",day:"@sgDay",clickBlock:"&sgClick"},template:["'].join("")}}angular.module("SOGo.SchedulerUI").directive("sgCalendarMonthDay",a)}(),function(){"use strict";function a(){function a(a,b,c){a.block.component&&b.addClass("bg-folder"+a.block.component.pid)}return{restrict:"E",scope:{block:"=sgBlock",clickBlock:"&sgClick"},replace:!0,template:['
',' {{ block.starthour }}'," {{ block.component.summary }}",' ',' ',' ',' ',' '," ","
"].join(""),link:a}}angular.module("SOGo.SchedulerUI").directive("sgCalendarMonthEvent",a)}(),function(){"use strict";function a(a,c,d,e,f,g,h,i,j){return{restrict:"A",scope:{type:"@sgCalendarScrollView"},controller:b,link:function(b,d,e,g){function k(){var a;a=l(),s={type:u,quarterHeight:a,scrollStep:6*a,maxX:n(),element:t},angular.element(c).on("resize",o),o(),"monthly"!=u&&j.ready().then(function(){var b,c,d;j.defaults.SOGoDayStartTime&&(b=j.defaults.SOGoDayStartTime.split(":"),c=document.getElementById("hour"+parseInt(b[0])),d=parseInt(b[1])*a,t.scrollTop=c.offsetTop+d)})}function l(){var a,b,c=null;return a=document.getElementById("hour0"),b=document.getElementById("hour23"),a&&b&&(c=(b.offsetTop-a.offsetTop)/92),c}function m(a){var b,c,d,e,f,g,h;return c=b=d=e=0,f=t.getElementsByClassName("day0"),f.length>0&&(g=f[0].getBoundingClientRect(),c=g.height,b=g.width,d=g.left-a,h=f[0].getElementsByClassName("sg-calendar-tile-header"),h.length>0&&(e=h[0].clientHeight)),{height:c,width:b,offset:{left:d,top:e}}}function n(){var a=0;return a=t.getElementsByClassName("day").length-1}function o(){var a,b;a=t.getBoundingClientRect(),b=m(a.left),angular.extend(s,{coordinates:{x:a.left,y:a.top},dayHeight:b.height,dayWidth:b.width,daysOffset:b.offset.left,topOffset:b.offset.top})}function p(){d.on("mouseover",r),r()}function q(){d.off("mouseover",r),h.$view=null}function r(){var a,b,c,d,e,f,g;a=s.scrollStep,b=i.$ghost.pointerHandler,b&&(c=b.getContainerBasedCoordinates(s),c&&(h.$view=s,d=(new Date).getTime(),(!v||d>v+100)&&(v=d,e=c.y-a,0>e?(f=-t.scrollTop,f>e&&(e=f),t.scrollTop+=e):(e=c.y+a,g=e-t.clientHeight,g>0&&(t.scrollTop+=g)))))}var s,t,u,v,w,x;t=d[0],u=b.type,v=0,w=a.$on("calendar:dragstart",p),x=a.$on("calendar:dragend",q),f(k),b.$on("$destroy",function(){w(),x(),d.off("mouseover",r),angular.element(c).off("resize",o)})}}}function b(a){this.type=a.type}a.$inject=["$rootScope","$window","$document","$q","$timeout","$mdGesture","Calendar","Component","Preferences"],b.$inject=["$scope"],angular.module("SOGo.SchedulerUI").directive("sgCalendarScrollView",a)}(),function(){"use strict";function a(a,b,c,d,e,f,g){function h(h,i,j,k){function m(){var a,b,c,d,e,f,g,j,k,l;a=h.block.component,b=h.block.dayNumber,c=_.findIndex(a.blocks,["dayNumber",b]),d=0===c,e=c===a.blocks.length-1,f=angular.element('
'),f.addClass("bdr-folder"+a.pid),a.c_isallday||"SG-CALENDAR-MONTH-DAY"===i[0].parentNode.tagName?(d&&(g=angular.element('
').append(f),i.append(g)),e&&(j=angular.element('
').append(f.clone()),i.append(j))):(d&&(k=angular.element('
').append(f),i.append(k)),e&&(l=angular.element('
').append(f.clone()),i.append(l)))}function n(a){var b,c;a.stopPropagation(),b="move-event",h.block&&h.block.component?"dragGrip-top"==a.target.className||"dragGrip-left"==a.target.className?b="change-start":"dragGrip-bottom"!=a.target.className&&"dragGrip-right"!=a.target.className||(b="change-end"):b="change-end",c=new t(b),c.initFromEvent(a),g.$ghost.pointerHandler=c,angular.element(document).one("mouseup",q),angular.element(document).on("mousemove",p)}function o(b){var f,j,m,n,o,p,q,r,s;m=i.hasClass("clickableHourCell"),n="SG-CALENDAR-MONTH-DAY"==i[0].parentNode.tagName||i.hasClass("clickableDayCell"),s=k.calendarData(),h.block&&h.block.component?f=h.block:(o=k.dayString.parseDate(d.$mdDateLocaleProvider,"%Y-%m-%e"),p={type:"appointment",pid:s?s.pid:e.$defaultCalendar(),summary:l("New Event"),startDate:o,isAllDay:m?0:1},q=new g(p),f={component:q,dayNumber:k.dayNumber,length:0},f.component.blocks=[f]),j="multiday",n?j="monthly":f.component.c_isallday&&(j="multiday-allday"),_.forEach(f.component.blocks,function(a){a.dragging=!0}),r=g.$ghost.pointerHandler,r.prepareWithEventType(j),r.initFromBlock(f),s&&r.initFromCalendar(s),g.$ghost.component=f.component,c.debug("emit calendar:dragstart "+j),a.$emit("calendar:dragstart")}function p(a){var c=g.$ghost.pointerHandler;b(function(){c.updateFromEvent(a)})}function q(b){var c,d;c=h.block,d=g.$ghost.pointerHandler,angular.element(document).off("mousemove",p),d.dragHasStarted&&(a.$emit("calendar:dragend"),d.dragHasStarted=!1),c&&c.component&&_.forEach(c.component.blocks,function(a){a.dragging=!1})}function r(){}function s(a){this.setEventType(a)}function t(a){this.dragMode=a}if(h.block){if(!h.block.component.editable)return void i.removeClass("sg-draggable-calendar-block");m()}i.on("mousedown",n),h.$on("$destroy",function(){i.off("mousedown",n),i.off("mousemove",p)}),r.prototype={x:-1,y:-1,getDelta:function(a){var b=new r;return b.x=this.x-a.x,b.y=this.y-a.y,b},getDistance:function(a){var b=this.getDelta(a);return Math.sqrt(b.x*b.x+b.y*b.y)},clone:function(){var a=new r;return a.x=this.x,a.y=this.y,a}},s.prototype={dayNumber:-1,start:-1,duration:-1,eventType:null,setEventType:function(a){this.eventType=a},initFromBlock:function(a){"monthly"===this.eventType?(this.start=0,this.duration=96*a.component.blocks.length):(this.start=a.component.blocks[0].start,this.duration=_.sumBy(a.component.blocks,function(a){return a.length})),this.dayNumber=a.component.blocks[0].dayNumber},initFromCalendar:function(a){this.dayNumber=a},getDelta:function(a){var b=new s;return b.dayNumber=this.dayNumber-a.dayNumber,b.start=this.start-a.start,b.duration=this.duration-a.duration,b},_quartersToHM:function(a){var b=15*a,c=Math.floor(b/60);10>c&&(c="0"+c);var d=b%60;return 10>d&&(d="0"+d),""+c+":"+d},getStartTime:function(){return this._quartersToHM(this.start)},getEndTime:function(){var a=(this.start+this.duration)%f.EventDragDayLength;return this._quartersToHM(a)},clone:function(){var a=new s;return a.dayNumber=this.dayNumber,a.start=this.start,a.duration=this.duration,a}},t.prototype={originalCoordinates:null,currentCoordinates:null,originalViewCoordinates:null,currentViewCoordinates:null,originalEventCoordinates:null,currentEventCoordinates:null,originalCalendar:null,dragHasStarted:!1,getEventViewCoordinates:null,initFromBlock:function(a){this.currentEventCoordinates=new s(this.eventType),this.originalEventCoordinates=new s(this.eventType),this.originalEventCoordinates.initFromBlock(a)},initFromEvent:function(a){this.currentCoordinates=new r,this.updateFromEvent(a),this.originalCoordinates=this.currentCoordinates.clone()},initFromCalendar:function(a){this.originalCalendar=a,this.currentEventCoordinates.initFromCalendar(a.index),this.originalEventCoordinates.initFromCalendar(a.index)},updateFromEvent:function(a){if(this.currentCoordinates.x=a.pageX,this.currentCoordinates.y=a.pageY,this.dragHasStarted&&e.$view){var b=this.getEventViewCoordinates(e.$view);this.originalViewCoordinates||(this.originalViewCoordinates=this.getEventViewCoordinates(e.$view,this.originalCoordinates),g.$ghost.component.isNew&&(this.setTimeFromQuarters(g.$ghost.component.start,this.originalViewCoordinates.y),c.debug("new event start date "+g.$ghost.component.start))),this.currentViewCoordinates&&b&&b.x==this.currentViewCoordinates.x&&b.y==this.currentViewCoordinates.y||(this.currentViewCoordinates=b,this.originalViewCoordinates&&(b||(this.currentViewCoordinates=this.originalViewCoordinates.clone()),this.updateEventCoordinates()))}else if(this.originalCoordinates&&this.currentCoordinates&&!this.dragHasStarted){var d=this.getDistance();d>3&&(this.dragHasStarted=!0,o(a))}},updateEventCoordinates:function(){var b,d=this.currentViewCoordinates.getDelta(this.originalViewCoordinates),e=d.x*f.EventDragDayLength+d.y;c.debug("quarters delta "+e),angular.isUndefined(this.originalEventCoordinates.start)&&(this.originalEventCoordinates.dayNumber=this.originalViewCoordinates.x,this.originalEventCoordinates.start=this.originalViewCoordinates.y),this.currentEventCoordinates.dayNumber=this.originalEventCoordinates.dayNumber,"move-event"==this.dragMode?(this.currentEventCoordinates.start=this.originalEventCoordinates.start+e,this.currentEventCoordinates.duration=this.originalEventCoordinates.duration):"change-start"==this.dragMode?(b=this.originalEventCoordinates.duration-e,b>0?(this.currentEventCoordinates.start=this.originalEventCoordinates.start+e,this.currentEventCoordinates.duration=b):0>b&&(this.currentEventCoordinates.start=this.originalEventCoordinates.start+this.originalEventCoordinates.duration,this.currentEventCoordinates.duration=-b)):"change-end"==this.dragMode&&(b=this.originalEventCoordinates.duration+e,b>0?(this.currentEventCoordinates.start=this.originalEventCoordinates.start,this.currentEventCoordinates.duration=b):0>b&&(this.currentEventCoordinates.start=this.originalEventCoordinates.start+b,this.currentEventCoordinates.duration=-b));var g;this.currentEventCoordinates.start<0?(g=Math.ceil(-this.currentEventCoordinates.start/f.EventDragDayLength),this.currentEventCoordinates.start+=g*f.EventDragDayLength,this.currentEventCoordinates.dayNumber-=g):this.currentEventCoordinates.start>=f.EventDragDayLength&&(g=Math.floor(this.currentEventCoordinates.start/f.EventDragDayLength),this.currentEventCoordinates.start-=g*f.EventDragDayLength,this.currentEventCoordinates.dayNumber+=g),c.debug("event coordinates "+JSON.stringify(this.currentEventCoordinates)),a.$emit("calendar:drag")},getContainerBasedCoordinates:function(a,b){var c=b||this.currentCoordinates,d=c.getDelta(a.coordinates),e=a.element;return(d.xe.clientWidth||d.y<0||d.y>e.clientHeight)&&(d=null),d},prepareWithEventType:function(a){var b={multiday:this.getEventMultiDayViewCoordinates,"multiday-allday":this.getEventMultiDayAllDayViewCoordinates,monthly:this.getEventMonthlyViewCoordinates,unknown:null},c=b[a];this.eventType=a,this.getEventViewCoordinates=c},getEventMultiDayViewCoordinates:function(a,b){var c=this.getEventMultiDayAllDayViewCoordinates(a,b);if(c){var d=a.quarterHeight,e=this.getContainerBasedCoordinates(a,b);e.y+=a.element.scrollTop,c.y=Math.floor((e.y-f.EventDragHorizontalOffset)/d);var g=f.EventDragDayLength-1;c.y<0?c.y=0:c.y>g&&(c.y=g)}return c},getEventMultiDayAllDayViewCoordinates:function(a,b){var c,d=this.getContainerBasedCoordinates(a,b);if(d){c=new r;var f=a.dayWidth,g=a.daysOffset;c.x=Math.floor((d.x-g)/f);var h=0,i=e.$view.maxX;if("move-event"!=this.dragMode){var j=k.calendarData();j&&(h=i=j.index)}c.xi&&(c.x=i),c.y=0}else c=null;return c},getEventMonthlyViewCoordinates:function(a,b){var c,d=this.getContainerBasedCoordinates(a,b);if(d){c=new r;var e=0,f=a.dayWidth,g=a.daysOffset,h=a.dayHeight,i=Math.floor((d.y-e)/h);0>i&&(i=0),c.x=Math.floor((d.x-g)/f),c.x<0?c.x=0:c.x>6&&(c.x=6),c.x+=7*i,c.y=0}else c=null;return c},getDistance:function(){return this.currentCoordinates.getDistance(this.originalCoordinates)},setTimeFromQuarters:function(a,b){var c,d;c=Math.floor(b/4),d=b%4*15,a.setHours(c,d)}}}return{restrict:"CA",require:"^sgCalendarDay",link:h}}a.$inject=["$rootScope","$timeout","$log","Preferences","Calendar","CalendarSettings","Component"],angular.module("SOGo.SchedulerUI").directive("sgDraggableCalendarBlock",a)}(); //# sourceMappingURL=Scheduler.services.js.map \ No newline at end of file diff --git a/UI/WebServerResources/js/Scheduler.services.js.map b/UI/WebServerResources/js/Scheduler.services.js.map index 3fefcf27f..13a3d60cd 100644 --- a/UI/WebServerResources/js/Scheduler.services.js.map +++ b/UI/WebServerResources/js/Scheduler.services.js.map @@ -1 +1 @@ -{"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/sgDraggableCalendarBlock.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","factory","$defaultCalendar","calendar","defaultCalendar","defaults","SOGoDefaultCalendar","_","find","$findAll","active","$add","list","sibling","i","isWebCalendar","$webcalendars","isSubscription","$subscriptions","$calendars","o","localeCompare","indexOf","map","splice","data","writable","_this","forEach","push","isUndefined","fetch","then","calendars","union","filter","isOwned","acls","objectCreator","$get","$getIndex","$subscribe","uid","path","userResource","calendarData","$addWebCalendar","url","d","defer","urls","webCalendarURL","reject","post","isEditable","isRemote","owner","login","debug","JSON","stringify","undefined","resolve","promise","$deleteComponents","components","promises","component","isDefined","pid","uids","all","prototype","color","$acl","isSuperUser","$shadowData","$omit","$id","when","$futureCalendarData","getClassName","base","$rename","$save","$delete","remove","$reset","key","save","error","$setActivation","$getComponent","componentId","recurrenceId","$find","isError","isObject","futureComponentData","newComponentData","newguid","isNew","Card","Gravatar","$Card","$gravatar","timeFormat","$query","search","$queryEvents","sort","asc","filterpopup","$queryTasks","$refreshTimeout","$ghost","ready","settings","EventsFilterState","TasksFilterState","EventsSortingState","parseInt","TasksSortingState","show_completed","ShowCompletedTasks","$categories","SOGoCalendarCategoriesColors","SOGoTimeFormat","$selectedCount","count","$events","event","selected","length","$tasks","task","$startRefreshTimeout","type","cancel","refreshViewCheck","SOGoRefreshViewCheck","f","bind","$filter","timeInterval","options","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","dates","deferred","toLowerCase","sd","getDayString","ed","views","reduceComponent","associateComponent","objects","eventData","componentData","zipObject","eventsFields","start","c_startdate","hour","getHourString","blocks","block","nbr","$views","viewData","allDayBlocks","reduce","events","flatten","dayNumber","calendarName","fields","invokeMap","$resetGhost","pointerHandler","startHour","endHour","$parseDate","dateString","time","substring","split","no_time","categories","repeat","alarm","action","quantity","unit","reference","relation","status","delta","classification","isString","setMinutes","Math","round","getMinutes","end","minutesTo","setDelta","dueDate","due","completedDate","completed","c_category","$isRecurrent","days","byDayMask","occurrence","frequency","byday","toString","interval","monthdays","months","until","$hasCustomRepeat","hasCustomRepeat","units","M","H","D","W","match","exec","SOGoCalendarDefaultReminder","$hasAlarm","destinationCalendar","updateFreeBusy","b","isReadOnly","isEditableOccurrence","isInvitation","userHasRSVP","isInvitationOccurrence","enablePercentComplete","coversFreeBusy","quarter","freebusy","updateFreeBusyCoverage","roundedStart","roundedEnd","startQuarter","endQuarter","daysUpTo","index","hourKey","currentDay","dayKey","getHours","beginOfDay","addMinutes","attendees","attendee","image","email","updateFreeBusyAttendee","sday","eday","c_folder","addAttendee","card","$isList","isGroup","container","c_name","listId","refs","ref","c_cn","$preferredEmail","role","c_uid","hasAttendee","emails","deleteAttendee","findIndex","currentAttendee","canRemindAttendeesByEmail","addAttachUrl","attachUrl","attachUrls","deleteAttachUrl","$addDueDate","toISOString","$deleteDueDate","$addStartDate","$deleteStartDate","$reply","reply","delegatedTo","$adjust","every","values","v","extraAttributes","dlp","constructor","$mdDateLocaleProvider","format","startTime","endTime","dueTime","stringWithSeparator","organizer","occurrenceOnly","$futureComponentData","copy","repeatDescription","localizedString","l","toUpperCase","alarmDescription","CalendarController","$scope","$rootScope","$state","$stateParams","stateEventsBlocks","updateView","asDate","vm","changeDate","$event","element","currentTarget","attr","go","changeView","deregisterCalendarsList","$on","$inject","controller","CalendarListController","$mdDialog","Dialog","selectComponentType","reload","unselectComponents","mode","multiple","selectAll","toggleComponentSelection","preventDefault","stopPropagation","confirmDeleteSelectedComponents","confirm","ok","$emit","openEvent","openComponent","openTask","viewable","templateUrl","show","parent","document","body","targetEvent","clickOutsideToClose","escapeToClose","controllerAs","locals","stateComponent","newComponent","baseComponent","updateComponentFromGhost","RecurrentComponentDialogController","updateThisOccurrence","hide","response","onComponentAdjustError","updateAllOccurrences","message","AttendeeConflictDialogController","conflictError","ignoreConflicts","coordinates","calendarNumber","activeCalendars","currentEventCoordinates","summary","isAllDay","duration","getDelta","originalEventCoordinates","originalCalendar","destination","isException","template","filteredBy","field","sortedBy","cancelSearch","selectedList","SelectedList","CalendarsController","$window","$mdToast","FileUploader","focus","User","stateCalendars","newCalendar","ev","prompt","UserLogin","addWebCalendar","inputType","confirmDelete","folder","alert","importCalendar","CalendarImportDialogController","scope","filterByExtension","item","isTextFile","test","position","hideDelay","uploader","ApplicationBaseURL","autoUpload","queueLimit","filters","fn","onSuccessItem","headers","msg","imported","simple","content","onErrorItem","close","exportCalendar","window","location","href","showOnly","showAll","showLinks","LinksDialogController","showProperties","PropertiesDialogController","srcCalendar","saveProperties","$watch","editFolder","editMode","revertEditing","renameFolder","share","$users","usersWithACL","users","subscribeToFolder","today","fragments","hash","state","service","SOGoCalendarCategories","asCSSIdentifier","pick","newList","oldList","commonList","ids","intersectionBy","oldObject","isEqual","ComponentController","AddressBook","Alarm","cardFilter","$filterAll","$cards","edit","editAllOccurrences","c","getAlarms","replyAllOccurrences","deleteOccurrence","deleteAllOccurrences","toggleRawSource","ComponentRawSourceDialogController","ComponentEditorController","toggleRecurrenceEditor","showRecurrenceEditor","toggleAttendeesEditor","showAttendeesEditor","isValidEmail","searchText","removeAttendee","form","$valid","attendeeConflictError","getDays","hours","addStartDate","oldStartDate","addDueDate","oldDueDate","updateStartTime","adjustStartTime","valueOf","oldEndDate","updateEndTime","adjustEndTime","updateDueTime","adjustDueTime","attendeesEditor","sgCalendarDay","restrict","dayString","sgCalendarDayController","directive","sgCalendarDayBlock","CalendarSettings","link","iElement","attrs","pc","left","right","siblings","css","c_isallday","addClass","clickBlock","replace","sgCalendarDayTable","sgCalendarGhost","ctrls","initGhost","calendarDayCtrl","originalCalendarNumber","hideGhost","forEachRight","domElement","classList","removeClass","updateGhost","showGhost","isRelative","originalDay","wasOtherBlock","durationLeft","maxDuration","enableTransition","scrollViewCtrl","getStartTime","quarterHeight","topOffset","getEndTime","quartersToHM","quarters","minutes","mins","floor","deregisterDragStart","deregisterDrag","deregisterDragEnd","require","sgCalendarMonthDay","sgCalendarMonthEvent","sgCalendarScrollView","$document","$mdGesture","sgCalendarScrollViewController","initView","getQuarterHeight","scrollStep","maxX","getMaxColumns","scrollView","on","updateCoordinates","hourCell","quartersOffset","SOGoDayStartTime","getElementById","scrollTop","offsetTop","hour0","hour23","height","getDayDimensions","viewLeft","width","leftOffset","nodes","domRect","tileHeader","getElementsByClassName","getBoundingClientRect","clientHeight","offset","top","max","dayDimensions","x","y","dayHeight","dayWidth","daysOffset","onDragStart","updateFromPointerHandler","onDragEnd","off","pointerCoordinates","scrollY","minY","getContainerBasedCoordinates","lastScroll","deregisterDragStop","sgDraggableCalendarBlock","initGrips","blockIndex","isFirstBlock","isLastBlock","dragGrip","leftGrip","rightGrip","topGrip","bottomGrip","parentNode","tagName","append","clone","onDragDetect","dragMode","target","className","SOGoEventDragPointerHandler","initFromEvent","one","onDrag","dragStart","eventType","isHourCell","isMonthly","newData","hasClass","parseDate","dragging","prepareWithEventType","initFromBlock","initFromCalendar","updateFromEvent","pointer","dragHasStarted","SOGoCoordinates","SOGoEventDragEventCoordinates","setEventType","editable","otherCoordinates","getDistance","sqrt","sumBy","_quartersToHM","originalCoordinates","currentCoordinates","originalViewCoordinates","currentViewCoordinates","getEventViewCoordinates","pageX","pageY","newEventCoordinates","setTimeFromQuarters","updateEventCoordinates","distance","newDuration","deltaQuarters","deltaDays","ceil","clientWidth","methods","multiday","getEventMultiDayViewCoordinates","multiday-allday","getEventMultiDayAllDayViewCoordinates","monthly","getEventMonthlyViewCoordinates","unknown","method","pxCoordinates","maxY","minX","daysTopOffset","daysY","setHours"],"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,EAA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BlO,GAAc,IAGhB,OAAOA,IAGTyR,YAAa,WACX,MAAO9tB,MAAKmuB,mBAAmBL,YAAY9tB,KAAKkuB,sBAGlDQ,oBAAqB,SAAmCjiB,EAAMgb,GAC5D,GAAI1D,GAAO2D,CACX3D,GAAQjT,KAAK8W,MAAMH,EAAW,GAC9BC,EAAWD,EAAW,EAAK,GAC3Bhb,EAAKujB,SAASjM,EAAO2D,KAzjB3B,OACE5C,SAAU,KACVkD,QAAS,iBACT5C,KAAMA,GALViG,EAAyB9R,SAAW,aAAc,WAAY,OAAQ,cAAe,WAAY,mBAAoB,aAikBrHtY,QACGO,OAAO,oBACPyjB,UAAU,2BAA4BoG","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,\n EventDragHorizontalOffset: 3\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, i;\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 = _.find(list, function(o) {\n return (calendar.id == 'personal' ||\n (o.id != 'personal' &&\n o.name.localeCompare(calendar.name) === 1));\n });\n i = sibling ? _.indexOf(_.map(list, 'id'), sibling.id) : 1;\n list.splice(i, 0, calendar);\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 Calendar.$$resource.fetch('calendarslist').then(function(data) {\n 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 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.$add(calendar);\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 });\n d.resolve();\n }, function() {\n d.reject();\n });\n }\n\n return d.promise;\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 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 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 Mailbox.prototype\n * @desc Reset the original state the mailbox'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 $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', 'sgSettings', 'Preferences', 'Card', 'Gravatar', 'Resource', function($q, $timeout, $log, Settings, Preferences, Card, Gravatar, Resource) {\n angular.extend(Component, {\n $q: $q,\n $timeout: $timeout,\n $log: $log,\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 .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 component type, for all calendars\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(_this, Component.$filter, type);\n Component.$refreshTimeout = Component.$timeout(f, refreshViewCheck.timeInterval()*1000);\n }\n });\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 otherType = (type == 'tasks')? '$events' : '$tasks';\n if (dirty) {\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(startDate.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, dates = [],\n deferred = Component.$q.defer();\n\n params = { view: view.toLowerCase(), sd: startDate.getDayString(), ed: endDate.getDayString() };\n Component.$log.debug('eventsblocks ' + JSON.stringify(params, undefined, 2));\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 componentData.hour = start.getHourString();\n componentData.blocks = [];\n objects.push(new Component(componentData));\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 };\n\n Component.$views = [];\n Component.$timeout(function() {\n _.forEach(views, function(data) {\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 (dates.length === 0)\n for (i = 0; i < data.blocks.length; i++) {\n dates.push(startDate.getDayString());\n startDate.addDays(1);\n }\n\n // Convert array of blocks to object with days 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].dayNumber = i;\n blocks[dates[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].dayNumber = i;\n allDayBlocks[dates[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 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);\n components.push(new Component(data));\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 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 Component.$Preferences.ready().then(function() {\n var type = (_this.type == 'appointment')? 'Events' : 'Tasks';\n\n // Set default values from user's defaults\n _this.classification = _this.classification ||\n Component.$Preferences.defaults['SOGoCalendar' + type + 'DefaultClassification'].toLowerCase();\n });\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.month))\n this.repeat.month = { occurrence: '1', day: 'SU', type: 'bymonthday' };\n if (angular.isUndefined(this.repeat.monthdays))\n // TODO: initialize this.repeat.monthdays with month day of start date\n this.repeat.monthdays = [];\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 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 alarm\n Component.$Preferences.ready().then(function() {\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 }\n else {\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 // 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 this.repeat.days && this.repeat.days.length > 0 ||\n this.repeat.monthdays && this.repeat.monthdays.length > 0 ||\n this.repeat.months && this.repeat.months.length > 0);\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 attendee.image = Component.$gravatar(attendee.email, 32);\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 params, url, days;\n if (attendee.uid) {\n params =\n {\n sday: this.start.getDayString(),\n eday: this.end.getDayString()\n };\n url = ['..', '..', attendee.uid, 'freebusy.ifb'];\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 Component.$$resource.fetch(url.join('/'), '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() && card.isGroup !== 1) {\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 status: 'needs-action',\n uid: ref.c_uid\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 name: card.c_cn,\n email: card.$preferredEmail(),\n role: 'req-participant',\n status: 'needs-action',\n uid: card.c_uid\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.constructor.$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.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 (this.repeat.frequency) {\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 (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[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 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 'use strict';\n\n /**\n * @ngInject\n */\n CalendarController.$inject = ['$scope', '$rootScope', '$state', '$stateParams', 'Calendar', 'Component', 'stateEventsBlocks'];\n function CalendarController($scope, $rootScope, $state, $stateParams, Calendar, Component, stateEventsBlocks) {\n var vm = this, deregisterCalendarsList;\n\n vm.views = stateEventsBlocks;\n vm.changeDate = changeDate;\n vm.changeView = changeView;\n\n // Refresh current view when the list of calendars is modified\n deregisterCalendarsList = $rootScope.$on('calendars:list', updateView);\n\n $scope.$on('$destroy', deregisterCalendarsList);\n\n function updateView() {\n // See stateEventsBlocks in Scheduler.app.js\n Component.$eventsBlocksForView($stateParams.view, $stateParams.day.asDate()).then(function(data) {\n vm.views = data;\n _.forEach(vm.views, function(view) {\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 view.calendar = new Calendar({ id: view.id, name: view.calendarName });\n }\n });\n });\n }\n\n // Change calendar's date\n function changeDate($event) {\n var date = angular.element($event.currentTarget).attr('date');\n $state.go('calendars.view', { day: date });\n }\n\n // Change calendar's view\n function changeView(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', '$timeout', '$state', '$mdDialog', 'Dialog', 'Preferences', 'Calendar', 'Component'];\n function CalendarListController($rootScope, $timeout, $state, $mdDialog, Dialog, Preferences, Calendar, Component) {\n var vm = this;\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.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 // 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 });\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 // 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 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 $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, baseComponent) {\n var type = 'appointment', component;\n\n if (baseComponent) {\n component = baseComponent;\n type = baseComponent.type;\n }\n else {\n if (vm.componentType == 'tasks')\n type = 'task';\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, 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 }, 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 '',\n ' ',\n '

' + l('editRepeatingItem') + '

',\n '
',\n ' ',\n ' ' + l('button_thisOccurrenceOnly') + '',\n ' ' + l('button_allOccurrences') + '',\n ' ',\n '
'\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 == 403 &&\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 $rootScope.$emit('calendars:list');\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.exportCalendar = exportCalendar;\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 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, promises;\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 promises = [];\n\n if (ids.length > 0) {\n $log.debug(ids.join(', ') + ' changed');\n _.forEach(ids, function(id) {\n var calendar = Calendar.$get(id);\n promises.push(calendar.$setActivation());\n });\n }\n if (commonList.length > 0)\n Calendar.$q.all(promises).then(function() {\n $rootScope.$emit('calendars:list');\n });\n },\n true // compare for object equality\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);\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 '',\n '
',\n ' error_outline',\n ' ' + l('An error occurred while importing calendar.') + '',\n '
',\n '
'\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 '',\n '
',\n ' error_outline',\n ' ' + l('Select an iCalendar file (.ics).') + '',\n '
',\n '
'\n ].join(''),\n position: 'top right',\n hideDelay: 3000\n });\n\n return isTextFile;\n }\n }\n }\n\n function exportCalendar(calendar) {\n window.location.href = ApplicationBaseURL + '/' + calendar.id + '.ics' + '/export';\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('properties.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', 'stateComponent'];\n function ComponentController($rootScope, $mdDialog, Calendar, Component, AddressBook, Alarm, stateComponent) {\n var vm = this, component;\n\n vm.service = Component;\n vm.component = stateComponent;\n vm.close = close;\n vm.cardFilter = cardFilter;\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\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 AddressBook.$filterAll($query);\n return AddressBook.$cards;\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 $mdDialog.hide();\n Alarm.getAlarms();\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 '',\n ' ',\n '
',\n            data,\n            '    
',\n '
',\n ' ',\n ' ' + l('Close') + '',\n ' ',\n '
'\n ].join(''),\n controller: ComponentRawSourceDialogController\n });\n\n /**\n * @ngInject\n */\n ComponentRawSourceDialogController.$inject = ['scope', '$mdDialog'];\n function ComponentRawSourceDialogController(scope, $mdDialog) {\n scope.close = function() {\n $mdDialog.hide();\n };\n }\n });\n }\n }\n\n /**\n * @ngInject\n */\n ComponentEditorController.$inject = ['$rootScope', '$scope', '$log', '$timeout', '$mdDialog', 'User', 'Calendar', 'Component', 'AddressBook', 'Card', 'Alarm', 'stateComponent'];\n function ComponentEditorController($rootScope, $scope, $log, $timeout, $mdDialog, User, 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.showAttendeesEditor = angular.isDefined(vm.component.attendees);\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.cancel = cancel;\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.updateStartTime = updateStartTime;\n vm.adjustStartTime = adjustStartTime;\n vm.updateEndTime = updateEndTime;\n vm.adjustEndTime = adjustEndTime;\n vm.updateDueTime = updateDueTime;\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 // 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) {\n vm.component.deleteAttendee(attendee);\n if (vm.component.attendees.length === 0)\n vm.showAttendeesEditor = false;\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 $mdDialog.hide();\n Alarm.getAlarms();\n }, function(response) {\n if (response.status == 403 &&\n response.data && response.data.message &&\n angular.isObject(response.data.message))\n vm.attendeeConflictError = response.data.message;\n });\n }\n }\n\n function cancel() {\n vm.component.$reset();\n if (vm.component.isNew) {\n // Cancelling the creation of a component\n vm.component = null;\n }\n $mdDialog.cancel();\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(Component.timeFormat.formatTime(i, 0));\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 updateStartTime() {\n // When using the datepicker, the time is reset to 00:00; restore it\n vm.component.start.addMinutes(oldStartDate.getHours() * 60 + oldStartDate.getMinutes());\n adjustStartTime();\n }\n\n function adjustStartTime() {\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 function updateEndTime() {\n // When using the datepicker, the time is reset to 00:00; restore it\n vm.component.end.addMinutes(oldEndDate.getHours() * 60 + oldEndDate.getMinutes());\n adjustEndTime();\n }\n\n function adjustEndTime() {\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 function updateDueTime() {\n // When using the datepicker, the time is reset to 00:00; restore it\n vm.component.due.addMinutes(oldDueDate.getHours() * 60 + oldDueDate.getMinutes());\n adjustDueTime();\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 \n ..\n \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 \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: [\n '
',\n '
',\n // Categories color stripes\n '
',\n '
{{ block.component.summary }}',\n ' ',\n // Component is reccurent\n ' ',\n // Component has an alarm\n ' ',\n // Component is confidential\n ' ',\n // Component is private\n ' ',\n ' ',\n // Location\n '
',\n ' place {{block.component.c_location}}',\n '
',\n '
',\n '
',\n '
{{ block.startHour }}
',\n '
{{ block.endHour }}
',\n '
'\n ].join(''),\n link: link\n };\n\n function link(scope, iElement, attrs) {\n var pc, left, right;\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 // Set background color\n if (scope.block.component)\n iElement.addClass('bg-folder' + scope.block.component.pid);\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 \n */\n function sgCalendarDayTable() {\n return {\n restrict: 'E',\n scope: {\n blocks: '=sgBlocks',\n day: '@sgDay',\n clickBlock: '&sgClick'\n },\n template: [\n ''\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 /\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;\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 // 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, originalDay, currentDay, wasOtherBlock,\n start, duration, durationLeft, maxDuration, enableTransition;\n\n showGhost = false;\n enableTransition = function() {\n iElement.removeClass('sg-event--notransition');\n };\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 originalDay = scope.block.pointerHandler.originalEventCoordinates.dayNumber;\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\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 // Show start hour and set the vertical position\n scope.block.startHour = getStartTime(start);\n wasOtherBlock = parseInt(iElement.css('top')) === 0;\n if (wasOtherBlock)\n iElement.addClass('sg-event--notransition');\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 if (wasOtherBlock)\n $timeout(enableTransition);\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 }\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 wasOtherBlock = parseInt(iElement.css('top')) !== 0;\n if (wasOtherBlock)\n iElement.addClass('sg-event--notransition');\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 if (wasOtherBlock)\n $timeout(enableTransition);\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 {\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.Common\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 * @ngInject\n * @example:\n\n \n */\n function sgCalendarMonthDay() {\n return {\n restrict: 'E',\n scope: {\n blocks: '=sgBlocks',\n day: '@sgDay',\n clickBlock: '&sgClick'\n },\n template: [\n ''\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 \n */\n function sgCalendarMonthEvent() {\n return {\n restrict: 'E',\n scope: {\n block: '=sgBlock',\n clickBlock: '&sgClick'\n },\n replace: true,\n template: [\n '
',\n ' {{ block.starthour }}',\n ' {{ block.component.summary }}',\n ' ',\n // Component is reccurent\n ' ',\n // Component has an alarm\n ' ',\n // Component is confidential\n ' ',\n // Component is private\n ' ',\n ' ',\n '
'\n ].join(''),\n link: link\n };\n\n function link(scope, iElement, attrs) {\n if (scope.block.component)\n iElement.addClass('bg-folder' + scope.block.component.pid);\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 \n ..\n \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, scrollView, type, lastScroll, deregisterDragStart, deregisterDragStop;\n\n scrollView = element[0];\n type = scope.type; // multiday, multiday-allday, monthly, unknown?\n lastScroll = 0;\n\n // Listen to dragstart and dragend events\n deregisterDragStart = $rootScope.$on('calendar:dragstart', onDragStart);\n deregisterDragStop = $rootScope.$on('calendar:dragend', onDragEnd);\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 deregisterDragStart();\n deregisterDragStop();\n element.off('mouseover', updateFromPointerHandler);\n angular.element($window).off('resize', updateCoordinates);\n });\n\n function initView() {\n var quarterHeight;\n\n // Quarter height doesn't change if window is resize; compute it only once\n quarterHeight = getQuarterHeight();\n\n view = {\n type: type,\n quarterHeight: quarterHeight,\n scrollStep: 6 * quarterHeight,\n maxX: getMaxColumns(),\n\n // Expose a reference of the view element\n element: scrollView\n };\n\n // Compute coordinates of view element; recompute it on window resize\n angular.element($window).on('resize', updateCoordinates);\n updateCoordinates();\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]) * quarterHeight;\n scrollView.scrollTop = hourCell.offsetTop + quartersOffset;\n }\n });\n }\n\n function getQuarterHeight() {\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 function getDayDimensions(viewLeft) {\n var width, height, leftOffset, topOffset, nodes, domRect, tileHeader;\n\n height = width = leftOffset = topOffset = 0;\n nodes = scrollView.getElementsByClassName('day0');\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 function getMaxColumns() {\n var max = 0;\n\n //if (type == 'multiday') {\n max = scrollView.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 function updateCoordinates() {\n var domRect, dayDimensions;\n\n domRect = scrollView.getBoundingClientRect();\n dayDimensions = getDayDimensions(domRect.left);\n\n angular.extend(view, {\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 function onDragStart() {\n element.on('mouseover', updateFromPointerHandler);\n updateFromPointerHandler();\n }\n\n function onDragEnd() {\n element.off('mouseover', updateFromPointerHandler);\n Calendar.$view = null;\n }\n\n // From SOGoScrollController.updateFromPointerHandler\n function updateFromPointerHandler() {\n var scrollStep, pointerHandler, pointerCoordinates, now, scrollY, minY, delta;\n\n scrollStep = view.scrollStep;\n pointerHandler = Component.$ghost.pointerHandler;\n if (pointerHandler) {\n pointerCoordinates = pointerHandler.getContainerBasedCoordinates(view);\n\n if (pointerCoordinates) {\n // Pointer is inside view; Adjust scrollbar if necessary\n Calendar.$view = view;\n now = new Date().getTime();\n if (!lastScroll || now > lastScroll + 100) {\n lastScroll = now;\n scrollY = pointerCoordinates.y - scrollStep;\n if (scrollY < 0) {\n minY = -scrollView.scrollTop;\n if (scrollY < minY)\n scrollY = minY;\n scrollView.scrollTop += scrollY;\n }\n else {\n scrollY = pointerCoordinates.y + scrollStep;\n delta = scrollY - scrollView.clientHeight;\n if (delta > 0) {\n scrollView.scrollTop += delta;\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 sgCalendarDayBlockGhost\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 'use strict';\n\n /*\n * sgDraggableCalendarBlock - Make an element draggable\n * @memberof SOGo.SchedulerUI\n * @restrict class or attribute\n *\n * @example:\n\n
\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) {\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, dayNumber, blockIndex, isFirstBlock, isLastBlock,\n dragGrip, leftGrip, rightGrip, topGrip, bottomGrip;\n\n component = scope.block.component;\n dayNumber = scope.block.dayNumber;\n blockIndex = _.findIndex(component.blocks, ['dayNumber', dayNumber]);\n isFirstBlock = (blockIndex === 0);\n isLastBlock = (blockIndex === component.blocks.length - 1);\n\n dragGrip = angular.element('
');\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('
').append(dragGrip);\n element.append(leftGrip);\n }\n if (isLastBlock) {\n rightGrip = angular.element('
').append(dragGrip.clone());\n element.append(rightGrip);\n }\n }\n else {\n if (isFirstBlock) {\n topGrip = angular.element('
').append(dragGrip);\n element.append(topGrip);\n }\n if (isLastBlock) {\n bottomGrip = angular.element('
').append(dragGrip.clone());\n element.append(bottomGrip);\n }\n }\n }\n\n function onDragDetect(ev) {\n var block, dragMode, eventType, startDate, newData, newComponent, pointerHandler;\n\n ev.stopPropagation();\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 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 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 if (this.eventType === 'monthly') {\n this.start = 0;\n this.duration = block.component.blocks.length * 96;\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 return b.length;\n });\n }\n\n // Get the dayNumber from the event's first block\n this.dayNumber = block.component.blocks[0].dayNumber;\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.x * CalendarSettings.EventDragDayLength + delta.y;\n $log.debug('quarters delta ' + deltaQuarters);\n\n if (angular.isUndefined(this.originalEventCoordinates.start)) {\n this.originalEventCoordinates.dayNumber = this.originalViewCoordinates.x;\n this.originalEventCoordinates.start = this.originalViewCoordinates.y;\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\n // This dayNumber needs to be updated with the calendar number.\n // if (currentView == \"multicolumndayview\")\n // this._updateMulticolumnViewDayNumber_SEDGC();\n this.currentEventCoordinates.dayNumber += deltaDays;\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 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 > 6)\n coordinates.x = 6;\n coordinates.x += 7 * 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"]} \ No newline at end of file +{"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/sgDraggableCalendarBlock.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","factory","$defaultCalendar","calendar","defaultCalendar","defaults","SOGoDefaultCalendar","_","find","$findAll","active","$add","list","sibling","i","isWebCalendar","$webcalendars","isSubscription","$subscriptions","$calendars","o","localeCompare","indexOf","map","splice","data","writable","_this","forEach","push","isUndefined","fetch","then","calendars","union","filter","isOwned","acls","objectCreator","$get","$getIndex","$subscribe","uid","path","userResource","calendarData","$addWebCalendar","url","d","defer","urls","webCalendarURL","reject","post","isEditable","isRemote","owner","login","debug","JSON","stringify","undefined","resolve","promise","$deleteComponents","components","promises","component","isDefined","pid","uids","all","prototype","color","$acl","isSuperUser","$shadowData","$omit","$id","when","$futureCalendarData","getClassName","base","$rename","$save","$delete","remove","$reset","key","save","error","$setActivation","$getComponent","componentId","recurrenceId","$find","isError","isObject","futureComponentData","newComponentData","newguid","isNew","Card","Gravatar","$Card","$gravatar","timeFormat","$query","search","$queryEvents","sort","asc","filterpopup","$queryTasks","$refreshTimeout","$ghost","ready","settings","EventsFilterState","TasksFilterState","EventsSortingState","parseInt","TasksSortingState","show_completed","ShowCompletedTasks","$categories","SOGoCalendarCategoriesColors","SOGoTimeFormat","$selectedCount","count","$events","event","selected","length","$tasks","task","$startRefreshTimeout","type","cancel","refreshViewCheck","SOGoRefreshViewCheck","f","bind","$filter","timeInterval","options","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","dates","deferred","toLowerCase","sd","getDayString","ed","views","reduceComponent","associateComponent","objects","eventData","componentData","zipObject","eventsFields","start","c_startdate","hour","getHourString","blocks","block","nbr","$views","viewData","allDayBlocks","reduce","events","flatten","dayNumber","calendarName","fields","invokeMap","$resetGhost","pointerHandler","startHour","endHour","$parseDate","dateString","time","substring","split","no_time","categories","repeat","alarm","action","quantity","unit","reference","relation","status","delta","classification","isString","setMinutes","Math","round","getMinutes","end","minutesTo","setDelta","dueDate","due","completedDate","completed","c_category","$isRecurrent","days","byDayMask","occurrence","frequency","byday","toString","interval","monthdays","months","until","$hasCustomRepeat","hasCustomRepeat","units","M","H","D","W","match","exec","SOGoCalendarDefaultReminder","$hasAlarm","destinationCalendar","updateFreeBusy","b","isReadOnly","isEditableOccurrence","isInvitation","userHasRSVP","isInvitationOccurrence","enablePercentComplete","coversFreeBusy","quarter","freebusy","updateFreeBusyCoverage","roundedStart","roundedEnd","startQuarter","endQuarter","daysUpTo","index","hourKey","currentDay","dayKey","getHours","beginOfDay","addMinutes","attendees","attendee","image","email","updateFreeBusyAttendee","sday","eday","c_folder","addAttendee","card","$isList","isGroup","container","c_name","listId","refs","ref","c_cn","$preferredEmail","role","c_uid","hasAttendee","emails","deleteAttendee","findIndex","currentAttendee","canRemindAttendeesByEmail","addAttachUrl","attachUrl","attachUrls","deleteAttachUrl","$addDueDate","toISOString","$deleteDueDate","$addStartDate","$deleteStartDate","$reply","reply","delegatedTo","$adjust","every","values","v","extraAttributes","dlp","constructor","$mdDateLocaleProvider","format","startTime","endTime","dueTime","stringWithSeparator","organizer","occurrenceOnly","$futureComponentData","copy","repeatDescription","localizedString","l","toUpperCase","alarmDescription","CalendarController","$scope","$rootScope","$state","$stateParams","stateEventsBlocks","updateView","asDate","vm","changeDate","$event","element","currentTarget","attr","go","changeView","deregisterCalendarsList","$on","$inject","controller","CalendarListController","$mdDialog","Dialog","selectComponentType","reload","unselectComponents","mode","multiple","selectAll","toggleComponentSelection","preventDefault","stopPropagation","confirmDeleteSelectedComponents","confirm","ok","$emit","openEvent","openComponent","openTask","viewable","templateUrl","show","parent","document","body","targetEvent","clickOutsideToClose","escapeToClose","controllerAs","locals","stateComponent","newComponent","baseComponent","updateComponentFromGhost","RecurrentComponentDialogController","updateThisOccurrence","hide","response","onComponentAdjustError","updateAllOccurrences","message","AttendeeConflictDialogController","conflictError","ignoreConflicts","coordinates","calendarNumber","activeCalendars","currentEventCoordinates","summary","isAllDay","duration","getDelta","originalEventCoordinates","originalCalendar","destination","isException","template","filteredBy","field","sortedBy","cancelSearch","selectedList","SelectedList","CalendarsController","$window","$mdToast","FileUploader","focus","User","stateCalendars","newCalendar","ev","prompt","UserLogin","addWebCalendar","inputType","confirmDelete","folder","alert","importCalendar","CalendarImportDialogController","scope","filterByExtension","item","isTextFile","test","position","hideDelay","uploader","ApplicationBaseURL","autoUpload","queueLimit","filters","fn","onSuccessItem","headers","msg","imported","simple","content","onErrorItem","close","exportCalendar","window","location","href","showOnly","showAll","showLinks","LinksDialogController","showProperties","PropertiesDialogController","srcCalendar","saveProperties","$watch","editFolder","editMode","revertEditing","renameFolder","share","$users","usersWithACL","users","subscribeToFolder","today","fragments","hash","state","service","SOGoCalendarCategories","asCSSIdentifier","pick","newList","oldList","commonList","ids","intersectionBy","oldObject","isEqual","ComponentController","AddressBook","Alarm","cardFilter","$filterAll","$cards","edit","editAllOccurrences","c","getAlarms","replyAllOccurrences","deleteOccurrence","deleteAllOccurrences","toggleRawSource","ComponentRawSourceDialogController","ComponentEditorController","toggleRecurrenceEditor","showRecurrenceEditor","toggleAttendeesEditor","showAttendeesEditor","isValidEmail","searchText","removeAttendee","form","$valid","attendeeConflictError","getDays","hours","addStartDate","oldStartDate","addDueDate","oldDueDate","updateStartTime","adjustStartTime","valueOf","oldEndDate","updateEndTime","adjustEndTime","updateDueTime","adjustDueTime","attendeesEditor","sgCalendarDay","restrict","dayString","sgCalendarDayController","directive","sgCalendarDayBlock","CalendarSettings","link","iElement","attrs","pc","left","right","siblings","css","c_isallday","addClass","clickBlock","replace","sgCalendarDayTable","sgCalendarGhost","ctrls","initGhost","calendarDayCtrl","originalCalendarNumber","hideGhost","forEachRight","domElement","classList","removeClass","updateGhost","showGhost","isRelative","originalDay","wasOtherBlock","durationLeft","maxDuration","enableTransition","scrollViewCtrl","getStartTime","quarterHeight","topOffset","getEndTime","quartersToHM","quarters","minutes","mins","floor","deregisterDragStart","deregisterDrag","deregisterDragEnd","require","sgCalendarMonthDay","sgCalendarMonthEvent","sgCalendarScrollView","$document","$mdGesture","sgCalendarScrollViewController","initView","getQuarterHeight","scrollStep","maxX","getMaxColumns","scrollView","on","updateCoordinates","hourCell","quartersOffset","SOGoDayStartTime","getElementById","scrollTop","offsetTop","hour0","hour23","height","getDayDimensions","viewLeft","width","leftOffset","nodes","domRect","tileHeader","getElementsByClassName","getBoundingClientRect","clientHeight","offset","top","max","dayDimensions","x","y","dayHeight","dayWidth","daysOffset","onDragStart","updateFromPointerHandler","onDragEnd","off","pointerCoordinates","scrollY","minY","getContainerBasedCoordinates","lastScroll","deregisterDragStop","sgDraggableCalendarBlock","initGrips","blockIndex","isFirstBlock","isLastBlock","dragGrip","leftGrip","rightGrip","topGrip","bottomGrip","parentNode","tagName","append","clone","onDragDetect","dragMode","target","className","SOGoEventDragPointerHandler","initFromEvent","one","onDrag","dragStart","eventType","isHourCell","isMonthly","newData","hasClass","parseDate","dragging","prepareWithEventType","initFromBlock","initFromCalendar","updateFromEvent","pointer","dragHasStarted","SOGoCoordinates","SOGoEventDragEventCoordinates","setEventType","editable","otherCoordinates","getDistance","sqrt","sumBy","_quartersToHM","originalCoordinates","currentCoordinates","originalViewCoordinates","currentViewCoordinates","getEventViewCoordinates","pageX","pageY","newEventCoordinates","setTimeFromQuarters","updateEventCoordinates","distance","newDuration","deltaQuarters","deltaDays","ceil","clientWidth","methods","multiday","getEventMultiDayViewCoordinates","multiday-allday","getEventMultiDayAllDayViewCoordinates","monthly","getEventMonthlyViewCoordinates","unknown","method","pxCoordinates","maxY","minX","daysTopOffset","daysY","setHours"],"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,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O2D,KAzjB3B,OACE5C,SAAU,KACVkD,QAAS,iBACT5C,KAAMA,GALViG,EAAyB9R,SAAW,aAAc,WAAY,OAAQ,cAAe,WAAY,mBAAoB,aAikBrHtY,QACGO,OAAO,oBACPyjB,UAAU,2BAA4BoG","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,\n EventDragHorizontalOffset: 3\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, i;\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 = _.find(list, function(o) {\n return (calendar.id == 'personal' ||\n (o.id != 'personal' &&\n o.name.localeCompare(calendar.name) === 1));\n });\n i = sibling ? _.indexOf(_.map(list, 'id'), sibling.id) : 1;\n list.splice(i, 0, calendar);\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 Calendar.$$resource.fetch('calendarslist').then(function(data) {\n 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 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.$add(calendar);\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 });\n d.resolve();\n }, function() {\n d.reject();\n });\n }\n\n return d.promise;\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 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 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 Mailbox.prototype\n * @desc Reset the original state the mailbox'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 $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', 'sgSettings', 'Preferences', 'Card', 'Gravatar', 'Resource', function($q, $timeout, $log, Settings, Preferences, Card, Gravatar, Resource) {\n angular.extend(Component, {\n $q: $q,\n $timeout: $timeout,\n $log: $log,\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 .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 component type, for all calendars\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(_this, Component.$filter, type);\n Component.$refreshTimeout = Component.$timeout(f, refreshViewCheck.timeInterval()*1000);\n }\n });\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 otherType = (type == 'tasks')? '$events' : '$tasks';\n if (dirty) {\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(startDate.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, dates = [],\n deferred = Component.$q.defer();\n\n params = { view: view.toLowerCase(), sd: startDate.getDayString(), ed: endDate.getDayString() };\n Component.$log.debug('eventsblocks ' + JSON.stringify(params, undefined, 2));\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 componentData.hour = start.getHourString();\n componentData.blocks = [];\n objects.push(new Component(componentData));\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 };\n\n Component.$views = [];\n Component.$timeout(function() {\n _.forEach(views, function(data) {\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 (dates.length === 0)\n for (i = 0; i < data.blocks.length; i++) {\n dates.push(startDate.getDayString());\n startDate.addDays(1);\n }\n\n // Convert array of blocks to object with days 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].dayNumber = i;\n blocks[dates[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].dayNumber = i;\n allDayBlocks[dates[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 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);\n components.push(new Component(data));\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 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 Component.$Preferences.ready().then(function() {\n var type = (_this.type == 'appointment')? 'Events' : 'Tasks';\n\n // Set default values from user's defaults\n _this.classification = _this.classification ||\n Component.$Preferences.defaults['SOGoCalendar' + type + 'DefaultClassification'].toLowerCase();\n });\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.month))\n this.repeat.month = { occurrence: '1', day: 'SU', type: 'bymonthday' };\n if (angular.isUndefined(this.repeat.monthdays))\n // TODO: initialize this.repeat.monthdays with month day of start date\n this.repeat.monthdays = [];\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 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 alarm\n Component.$Preferences.ready().then(function() {\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 }\n else {\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 // 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 this.repeat.days && this.repeat.days.length > 0 ||\n this.repeat.monthdays && this.repeat.monthdays.length > 0 ||\n this.repeat.months && this.repeat.months.length > 0);\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 attendee.image = Component.$gravatar(attendee.email, 32);\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 params, url, days;\n if (attendee.uid) {\n params =\n {\n sday: this.start.getDayString(),\n eday: this.end.getDayString()\n };\n url = ['..', '..', attendee.uid, 'freebusy.ifb'];\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 Component.$$resource.fetch(url.join('/'), '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() && card.isGroup !== 1) {\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 status: 'needs-action',\n uid: ref.c_uid\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 name: card.c_cn,\n email: card.$preferredEmail(),\n role: 'req-participant',\n status: 'needs-action',\n uid: card.c_uid\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.constructor.$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.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 (this.repeat.frequency) {\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 (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[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 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 'use strict';\n\n /**\n * @ngInject\n */\n CalendarController.$inject = ['$scope', '$rootScope', '$state', '$stateParams', 'Calendar', 'Component', 'stateEventsBlocks'];\n function CalendarController($scope, $rootScope, $state, $stateParams, Calendar, Component, stateEventsBlocks) {\n var vm = this, deregisterCalendarsList;\n\n vm.views = stateEventsBlocks;\n vm.changeDate = changeDate;\n vm.changeView = changeView;\n\n // Refresh current view when the list of calendars is modified\n deregisterCalendarsList = $rootScope.$on('calendars:list', updateView);\n\n $scope.$on('$destroy', deregisterCalendarsList);\n\n function updateView() {\n // See stateEventsBlocks in Scheduler.app.js\n Component.$eventsBlocksForView($stateParams.view, $stateParams.day.asDate()).then(function(data) {\n vm.views = data;\n _.forEach(vm.views, function(view) {\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 view.calendar = new Calendar({ id: view.id, name: view.calendarName });\n }\n });\n });\n }\n\n // Change calendar's date\n function changeDate($event) {\n var date = angular.element($event.currentTarget).attr('date');\n $state.go('calendars.view', { day: date });\n }\n\n // Change calendar's view\n function changeView(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', '$timeout', '$state', '$mdDialog', 'Dialog', 'Preferences', 'Calendar', 'Component'];\n function CalendarListController($rootScope, $timeout, $state, $mdDialog, Dialog, Preferences, Calendar, Component) {\n var vm = this;\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.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 // 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 });\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 // 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 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 $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, baseComponent) {\n var type = 'appointment', component;\n\n if (baseComponent) {\n component = baseComponent;\n type = baseComponent.type;\n }\n else {\n if (vm.componentType == 'tasks')\n type = 'task';\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, 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 }, 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 '',\n ' ',\n '

' + l('editRepeatingItem') + '

',\n '
',\n ' ',\n ' ' + l('button_thisOccurrenceOnly') + '',\n ' ' + l('button_allOccurrences') + '',\n ' ',\n '
'\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 == 403 &&\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 $rootScope.$emit('calendars:list');\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.exportCalendar = exportCalendar;\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 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, promises;\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 promises = [];\n\n if (ids.length > 0) {\n $log.debug(ids.join(', ') + ' changed');\n _.forEach(ids, function(id) {\n var calendar = Calendar.$get(id);\n promises.push(calendar.$setActivation());\n });\n }\n if (commonList.length > 0)\n Calendar.$q.all(promises).then(function() {\n $rootScope.$emit('calendars:list');\n });\n },\n true // compare for object equality\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);\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 '',\n '
',\n ' error_outline',\n ' ' + l('An error occurred while importing calendar.') + '',\n '
',\n '
'\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 '',\n '
',\n ' error_outline',\n ' ' + l('Select an iCalendar file (.ics).') + '',\n '
',\n '
'\n ].join(''),\n position: 'top right',\n hideDelay: 3000\n });\n\n return isTextFile;\n }\n }\n }\n\n function exportCalendar(calendar) {\n window.location.href = ApplicationBaseURL + '/' + calendar.id + '.ics' + '/export';\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('properties.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', 'stateComponent'];\n function ComponentController($rootScope, $mdDialog, Calendar, Component, AddressBook, Alarm, stateComponent) {\n var vm = this, component;\n\n vm.service = Component;\n vm.component = stateComponent;\n vm.close = close;\n vm.cardFilter = cardFilter;\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\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 AddressBook.$filterAll($query);\n return AddressBook.$cards;\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 $mdDialog.hide();\n Alarm.getAlarms();\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 '',\n ' ',\n '
',\n            data,\n            '    
',\n '
',\n ' ',\n ' ' + l('Close') + '',\n ' ',\n '
'\n ].join(''),\n controller: ComponentRawSourceDialogController\n });\n\n /**\n * @ngInject\n */\n ComponentRawSourceDialogController.$inject = ['scope', '$mdDialog'];\n function ComponentRawSourceDialogController(scope, $mdDialog) {\n scope.close = function() {\n $mdDialog.hide();\n };\n }\n });\n }\n }\n\n /**\n * @ngInject\n */\n ComponentEditorController.$inject = ['$rootScope', '$scope', '$log', '$timeout', '$mdDialog', 'User', 'Calendar', 'Component', 'AddressBook', 'Card', 'Alarm', 'stateComponent'];\n function ComponentEditorController($rootScope, $scope, $log, $timeout, $mdDialog, User, 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.showAttendeesEditor = angular.isDefined(vm.component.attendees);\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.cancel = cancel;\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.updateStartTime = updateStartTime;\n vm.adjustStartTime = adjustStartTime;\n vm.updateEndTime = updateEndTime;\n vm.adjustEndTime = adjustEndTime;\n vm.updateDueTime = updateDueTime;\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 // 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) {\n vm.component.deleteAttendee(attendee);\n if (vm.component.attendees.length === 0)\n vm.showAttendeesEditor = false;\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 $mdDialog.hide();\n Alarm.getAlarms();\n }, function(response) {\n if (response.status == 403 &&\n response.data && response.data.message &&\n angular.isObject(response.data.message))\n vm.attendeeConflictError = response.data.message;\n });\n }\n }\n\n function cancel() {\n vm.component.$reset();\n if (vm.component.isNew) {\n // Cancelling the creation of a component\n vm.component = null;\n }\n $mdDialog.cancel();\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(Component.timeFormat.formatTime(i, 0));\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 updateStartTime() {\n // When using the datepicker, the time is reset to 00:00; restore it\n vm.component.start.addMinutes(oldStartDate.getHours() * 60 + oldStartDate.getMinutes());\n adjustStartTime();\n }\n\n function adjustStartTime() {\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 function updateEndTime() {\n // When using the datepicker, the time is reset to 00:00; restore it\n vm.component.end.addMinutes(oldEndDate.getHours() * 60 + oldEndDate.getMinutes());\n adjustEndTime();\n }\n\n function adjustEndTime() {\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 function updateDueTime() {\n // When using the datepicker, the time is reset to 00:00; restore it\n vm.component.due.addMinutes(oldDueDate.getHours() * 60 + oldDueDate.getMinutes());\n adjustDueTime();\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 \n ..\n \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 \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: [\n '
',\n '
',\n // Categories color stripes\n '
',\n '
{{ block.component.summary }}',\n ' ',\n // Component is reccurent\n ' ',\n // Component has an alarm\n ' ',\n // Component is confidential\n ' ',\n // Component is private\n ' ',\n ' ',\n // Location\n '
',\n ' place {{block.component.c_location}}',\n '
',\n '
',\n '
',\n '
{{ block.startHour }}
',\n '
{{ block.endHour }}
',\n '
'\n ].join(''),\n link: link\n };\n\n function link(scope, iElement, attrs) {\n var pc, left, right;\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 // Set background color\n if (scope.block.component)\n iElement.addClass('bg-folder' + scope.block.component.pid);\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 \n */\n function sgCalendarDayTable() {\n return {\n restrict: 'E',\n scope: {\n blocks: '=sgBlocks',\n day: '@sgDay',\n clickBlock: '&sgClick'\n },\n template: [\n ''\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 /\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;\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 // 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, originalDay, currentDay, wasOtherBlock,\n start, duration, durationLeft, maxDuration, enableTransition;\n\n showGhost = false;\n enableTransition = function() {\n iElement.removeClass('sg-event--notransition');\n };\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 originalDay = scope.block.pointerHandler.originalEventCoordinates.dayNumber;\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\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 // Show start hour and set the vertical position\n scope.block.startHour = getStartTime(start);\n wasOtherBlock = parseInt(iElement.css('top')) === 0;\n if (wasOtherBlock)\n iElement.addClass('sg-event--notransition');\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 if (wasOtherBlock)\n $timeout(enableTransition);\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 }\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 wasOtherBlock = parseInt(iElement.css('top')) !== 0;\n if (wasOtherBlock)\n iElement.addClass('sg-event--notransition');\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 if (wasOtherBlock)\n $timeout(enableTransition);\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 {\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.Common\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 * @ngInject\n * @example:\n\n \n */\n function sgCalendarMonthDay() {\n return {\n restrict: 'E',\n scope: {\n blocks: '=sgBlocks',\n day: '@sgDay',\n clickBlock: '&sgClick'\n },\n template: [\n ''\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 \n */\n function sgCalendarMonthEvent() {\n return {\n restrict: 'E',\n scope: {\n block: '=sgBlock',\n clickBlock: '&sgClick'\n },\n replace: true,\n template: [\n '
',\n ' {{ block.starthour }}',\n ' {{ block.component.summary }}',\n ' ',\n // Component is reccurent\n ' ',\n // Component has an alarm\n ' ',\n // Component is confidential\n ' ',\n // Component is private\n ' ',\n ' ',\n '
'\n ].join(''),\n link: link\n };\n\n function link(scope, iElement, attrs) {\n if (scope.block.component)\n iElement.addClass('bg-folder' + scope.block.component.pid);\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 \n ..\n \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, scrollView, type, lastScroll, deregisterDragStart, deregisterDragStop;\n\n scrollView = element[0];\n type = scope.type; // multiday, multiday-allday, monthly, unknown?\n lastScroll = 0;\n\n // Listen to dragstart and dragend events\n deregisterDragStart = $rootScope.$on('calendar:dragstart', onDragStart);\n deregisterDragStop = $rootScope.$on('calendar:dragend', onDragEnd);\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 deregisterDragStart();\n deregisterDragStop();\n element.off('mouseover', updateFromPointerHandler);\n angular.element($window).off('resize', updateCoordinates);\n });\n\n function initView() {\n var quarterHeight;\n\n // Quarter height doesn't change if window is resize; compute it only once\n quarterHeight = getQuarterHeight();\n\n view = {\n type: type,\n quarterHeight: quarterHeight,\n scrollStep: 6 * quarterHeight,\n maxX: getMaxColumns(),\n\n // Expose a reference of the view element\n element: scrollView\n };\n\n // Compute coordinates of view element; recompute it on window resize\n angular.element($window).on('resize', updateCoordinates);\n updateCoordinates();\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]) * quarterHeight;\n scrollView.scrollTop = hourCell.offsetTop + quartersOffset;\n }\n });\n }\n\n function getQuarterHeight() {\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 function getDayDimensions(viewLeft) {\n var width, height, leftOffset, topOffset, nodes, domRect, tileHeader;\n\n height = width = leftOffset = topOffset = 0;\n nodes = scrollView.getElementsByClassName('day0');\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 function getMaxColumns() {\n var max = 0;\n\n //if (type == 'multiday') {\n max = scrollView.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 function updateCoordinates() {\n var domRect, dayDimensions;\n\n domRect = scrollView.getBoundingClientRect();\n dayDimensions = getDayDimensions(domRect.left);\n\n angular.extend(view, {\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 function onDragStart() {\n element.on('mouseover', updateFromPointerHandler);\n updateFromPointerHandler();\n }\n\n function onDragEnd() {\n element.off('mouseover', updateFromPointerHandler);\n Calendar.$view = null;\n }\n\n // From SOGoScrollController.updateFromPointerHandler\n function updateFromPointerHandler() {\n var scrollStep, pointerHandler, pointerCoordinates, now, scrollY, minY, delta;\n\n scrollStep = view.scrollStep;\n pointerHandler = Component.$ghost.pointerHandler;\n if (pointerHandler) {\n pointerCoordinates = pointerHandler.getContainerBasedCoordinates(view);\n\n if (pointerCoordinates) {\n // Pointer is inside view; Adjust scrollbar if necessary\n Calendar.$view = view;\n now = new Date().getTime();\n if (!lastScroll || now > lastScroll + 100) {\n lastScroll = now;\n scrollY = pointerCoordinates.y - scrollStep;\n if (scrollY < 0) {\n minY = -scrollView.scrollTop;\n if (scrollY < minY)\n scrollY = minY;\n scrollView.scrollTop += scrollY;\n }\n else {\n scrollY = pointerCoordinates.y + scrollStep;\n delta = scrollY - scrollView.clientHeight;\n if (delta > 0) {\n scrollView.scrollTop += delta;\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 sgCalendarDayBlockGhost\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 'use strict';\n\n /*\n * sgDraggableCalendarBlock - Make an element draggable\n * @memberof SOGo.SchedulerUI\n * @restrict class or attribute\n *\n * @example:\n\n
\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) {\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, dayNumber, blockIndex, isFirstBlock, isLastBlock,\n dragGrip, leftGrip, rightGrip, topGrip, bottomGrip;\n\n component = scope.block.component;\n dayNumber = scope.block.dayNumber;\n blockIndex = _.findIndex(component.blocks, ['dayNumber', dayNumber]);\n isFirstBlock = (blockIndex === 0);\n isLastBlock = (blockIndex === component.blocks.length - 1);\n\n dragGrip = angular.element('
');\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('
').append(dragGrip);\n element.append(leftGrip);\n }\n if (isLastBlock) {\n rightGrip = angular.element('
').append(dragGrip.clone());\n element.append(rightGrip);\n }\n }\n else {\n if (isFirstBlock) {\n topGrip = angular.element('
').append(dragGrip);\n element.append(topGrip);\n }\n if (isLastBlock) {\n bottomGrip = angular.element('
').append(dragGrip.clone());\n element.append(bottomGrip);\n }\n }\n }\n\n function onDragDetect(ev) {\n var block, dragMode, eventType, startDate, newData, newComponent, pointerHandler;\n\n ev.stopPropagation();\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 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 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 if (this.eventType === 'monthly') {\n this.start = 0;\n this.duration = block.component.blocks.length * 96;\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 return b.length;\n });\n }\n\n // Get the dayNumber from the event's first block\n this.dayNumber = block.component.blocks[0].dayNumber;\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.x * CalendarSettings.EventDragDayLength + delta.y;\n $log.debug('quarters delta ' + deltaQuarters);\n\n if (angular.isUndefined(this.originalEventCoordinates.start)) {\n this.originalEventCoordinates.dayNumber = this.originalViewCoordinates.x;\n this.originalEventCoordinates.start = this.originalViewCoordinates.y;\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\n // This dayNumber needs to be updated with the calendar number.\n // if (currentView == \"multicolumndayview\")\n // this._updateMulticolumnViewDayNumber_SEDGC();\n this.currentEventCoordinates.dayNumber += deltaDays;\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 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 > 6)\n coordinates.x = 6;\n coordinates.x += 7 * 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"]} \ No newline at end of file