3 lines
56 KiB
JavaScript
3 lines
56 KiB
JavaScript
function l(){var a,b,c=arguments[0],d=c,e=arguments;for(labels[c]?d=labels[c]:clabels[c]&&(d=clabels[c]),a=1,b=0;a<e.length;a++,b++)d=d.replace("%{"+b+"}",e[a]);return a=1,e.length>1&&(d=d.replace(/%((%)|s|d)/g,function(b){var c=null;if(b[2])c=b[2];else{switch(c=e[a],b){case"%d":c=parseFloat(c),isNaN(c)&&(c=0)}a++}return c})),d}function hexToRgb(a){var b=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(a);return b?{r:parseInt(b[1],16),g:parseInt(b[2],16),b:parseInt(b[3],16)}:null}function contrast(a){var b,c,d=1;if(b=hexToRgb(a)){c=[b.r/255,b.g/255,b.b/255];for(var e=0;e<c.length;++e)c[e]<=.03928?c[e]=c[e]/12.92:c[e]=Math.pow((c[e]+.055)/1.055,2.4);d=.2126*c[0]+.7152*c[1]+.0722*c[2]}return d>.179?"black":"white"}function guid(){function a(){return(65536*(1+Math.random())|0).toString(16).substring(1)}return(a()+a()+"-"+a()+"-4"+a().substr(0,3)+"-"+a()+"-"+a()+a()+a()).toLowerCase()}!function(){"use strict";function a(a,b,c,d){d.definePalette("sogo-green",{50:"eaf5e9",100:"cbe5c8",200:"aad6a5",300:"88c781",400:"66b86a",500:"56b04c",600:"4da143",700:"388e3c",800:"367d2e",900:"225e1b",A100:"ffffff",A200:"69f0ae",A400:"00e676",A700:"00c853",contrastDefaultColor:"dark",contrastLightColors:["300","400","500","600","700","800","900"]}),d.definePalette("sogo-blue",{50:"f0faf9",100:"e1f5f3",200:"ceebe8",300:"bfe0dd",400:"b2d6d3",500:"a1ccc8",600:"8ebfbb",700:"7db3b0",800:"639997",900:"4d8080",A100:"d4f7fa",A200:"c3f5fa",A400:"53e3f0",A700:"00b0c0",contrastDefaultColor:"light",contrastDarkColors:["50","100","200"]}),d.definePalette("sogo-paper",{50:"fcf7f8",100:"f7f1dc",200:"ede5ca",300:"e6d8ba",400:"e2d2a3",500:"d6c48d",600:"baa870",700:"857545",800:"524517",900:"433809",1000:"000000",A100:"ffffff",A200:"eeeeee",A400:"bdbdbd",A700:"616161",contrastDefaultColor:"dark",contrastLightColors:["800","900"]}),d.theme("default").primaryPalette("sogo-blue",{"default":"900","hue-1":"400","hue-2":"800","hue-3":"A700"}).accentPalette("sogo-green",{"default":"500","hue-1":"A100","hue-2":"300","hue-3":"A700"}).backgroundPalette("grey",{"default":"A100","hue-1":"200","hue-2":"300","hue-3":"500"}),DebugEnabled||(a.debugEnabled(!1),b.debugInfoEnabled(!1)),c.interceptors.push("AuthInterceptor"),c.interceptors.push("ErrorInterceptor")}function b(a,b){return{response:function(c){return c&&/^application\/json/.test(c.config.headers.Accept)&&/^<!DOCTYPE html>/.test(c.data)?(a.location.reload(!0),b.reject()):c}}}function c(a,b){return{responseError:function(c){return/^application\/json/.test(c.config.headers.Accept)&&a.$broadcast("http:Error",c),b.reject(c)}}}angular.module("SOGo.Common",["ngAnimate","ngSanitize","ngMaterial","mdColors"]).value("sgSettings",{isPopup:document.body.classList.contains("popup"),baseURL:function(){return ApplicationBaseURL||null},activeUser:function(a){var b={login:UserLogin||null,identification:UserIdentification||null,email:UserEmail||null,language:UserLanguage||null,folderURL:UserFolderURL||null,isSuperUser:IsSuperUser||null,path:{calendar:UserCalendarPath||null,contacts:UserContactsPath||null,mail:UserMailPath||null,preferences:UserPreferencesPath||null,administration:IsSuperUser?UserAdministrationPath:null,logoff:UserLogoffPath||null}};return a?b[a]:b}}).constant("sgColors",{selection:["#FFFFFF","#330033","#C0C0C0","#999999","#666666","#333333","#000000","#FFCCCC","#FF6666","#FF0000","#CC0000","#990000","#660000","#330000","#FFCC99","#FF9966","#FF9900","#FF6600","#CC6600","#993300","#663300","#FFFF99","#FFFF66","#FFCC66","#FFCC33","#CC9933","#996633","#663333","#FFFFCC","#FFFF33","#FFFF00","#FFCC00","#999900","#666600","#333300","#CCCCCC","#66FF99","#33FF33","#33CC00","#009900","#006600","#003300","#99FFFF","#33FFFF","#66CCCC","#00CCCC","#339999","#336666","#003333","#CCFFFF","#66FFFF","#33CCFF","#3366FF","#3333FF","#000099","#000066","#CCCCFF","#9999FF","#6666CC","#6633FF","#6600CC","#333399","#330099","#FFCCFF","#FF99FF","#CC66CC","#CC33CC","#993399","#663366","#99FF99"]}).constant("sgConstant",{xs:"(max-width: 599px)","gt-xs":"(min-width: 600px)",sm:"(min-width: 600px) and (max-width: 959px)","gt-sm":"(min-width: 960px)",md:"(min-width: 960px) and (max-width: 1279px)","gt-md":"(min-width: 1280px)",lg:"(min-width: 1280px) and (max-width: 1919px)","gt-lg":"(min-width: 1920px)",xl:"(min-width: 1920px)"}).config(a).factory("AuthInterceptor",b).factory("ErrorInterceptor",c),a.$inject=["$logProvider","$compileProvider","$httpProvider","$mdThemingProvider"],b.$inject=["$window","$q"],c.$inject=["$rootScope","$q"]}(),function(){"use strict";function a(a){c=a}function b(a,b,d){function e(a){var b=a.join("");return b}function f(a,b,c,d,e,f){if(e){var g="rgb("+e.value[0]+","+e.value[1]+","+e.value[2]+")",h="rgb("+e.contrast[0]+","+e.contrast[1]+","+e.contrast[2]+")",i={theme:c,palette:d,value:g,contrast:h,hue:f};s.insertRule(a(i),t),t+=1,s.insertRule(b(i),t),t+=1}}function g(a,b,c,d,e){if(d){var f="rgb("+d.value[0]+","+d.value[1]+","+d.value[2]+")";s.insertRule(a({theme:b,palette:c,value:f,hue:e}),t),t+=1}}function h(){var a=b[0].head.querySelector('style[title="Dynamic-Generated-by-mdColors"]');return null===a&&(a=b[0].createElement("style"),a.title="Dynamic-Generated-by-mdColors",a.appendChild(b[0].createTextNode("")),b[0].head.appendChild(a)),a.sheet}for(var i=a(e([".md-{{theme}}-theme",".md-fg"])+" { color:{{value}};}"),j=a(e([".md-{{theme}}-theme",".md-bg"])+" { background-color:{{value}};}"),k=a(e([".md-{{theme}}-theme",".md-bdr"])+" { border-color:{{value}};}"),l=a(e([".md-{{theme}}-theme",".md-{{hue}}",".md-fg"])+" { color:{{value}};}"),m=a(e([".md-{{theme}}-theme",".md-{{hue}}",".md-bg"])+" { background-color:{{value}};}"),n=a(e([".md-{{theme}}-theme",".md-{{palette}}",".md-fg"])+" { color:{{value}};}"),o=a(e([".md-{{theme}}-theme",".md-{{palette}}",".md-bg"])+" { background-color:{{value}}; color:{{contrast}}; }"),p=a(e([".md-{{theme}}-theme",".md-{{palette}}",".md-bdr"])+" { border-color:{{value}};}"),q=a(e([".md-{{theme}}-theme",".md-{{palette}}.md-{{hue}}",".md-fg"])+" { color:{{value}};}"),r=a(e([".md-{{theme}}-theme",".md-{{palette}}.md-{{hue}}",".md-bg"])+" { background-color:{{value}};}"),s=h(),t=0;s.cssRules.length>0;)s.deleteRule(0);angular.forEach(c._THEMES,function(a,b){f(i,j,b,"primary",c._PALETTES[a.colors.primary.name][a.colors.primary.hues["default"]]),f(l,m,b,"primary",c._PALETTES[a.colors.primary.name][a.colors.primary.hues["hue-2"]],"hue-2"),f(l,m,b,"primary",c._PALETTES[a.colors.primary.name][a.colors.primary.hues["hue-3"]],"hue-3"),f(l,m,b,"primary",c._PALETTES[a.colors.primary.name][a.colors.primary.hues["hue-1"]],"hue-1"),g(k,b,"primary",c._PALETTES[a.colors.primary.name][a.colors.primary.hues["default"]]),angular.forEach(a.colors,function(a,d){f(n,o,b,d,c._PALETTES[a.name][a.hues["default"]]),g(p,b,d,c._PALETTES[a.name][a.hues["default"]]),f(q,r,b,d,c._PALETTES[a.name][a.hues["hue-2"]],"hue-2"),f(q,r,b,d,c._PALETTES[a.name][a.hues["hue-3"]],"hue-3"),f(q,r,b,d,c._PALETTES[a.name][a.hues["hue-1"]],"hue-1")})})}var c;angular.module("mdColors",["ngMaterial"]).config(a).run(b),a.$inject=["$mdThemingProvider"],b.$inject=["$interpolate","$document","$log"]}(),function(){"use strict";function a(a){return a.decodeURIComponent}a.$inject=["$window"],angular.module("SOGo.Common").filter("decodeUri",a)}(),function(){"use strict";function a(a){return a.encodeURIComponent}a.$inject=["$window"],angular.module("SOGo.Common").filter("encodeUri",a)}(),function(){"use strict";function a(a){return function(b){var c=angular.element("<div>"+b+"</div>");return c.find("a").attr("target","_blank"),a.trustAs("html",c.html())}}a.$inject=["$sce"],angular.module("SOGo.Common").filter("ensureTarget",a)}(),function(){"use strict";function a(){return l}angular.module("SOGo.Common").filter("loc",a)}(),function(){"use strict";function a(){return function(a){for(var b=[],c=0;c<parseInt(a);c++)b.push(c);return b}}angular.module("SOGo.Common").filter("range",a)}(),function(){"use strict";function a(a,b,c,d,e){function f(a){return d.$filter(a,e.$acl.users)}function g(){e.$acl.$resetUsersRights(),a.hide()}function h(){e.$acl.$saveUsersRights().then(function(){a.hide()},function(a,c){b.alert(l("Warning"),l("An error occured please try again."))})}function i(a){var b=a.$confirmRights();b&&(n.confirmation.showing=!0,n.confirmation.message=b)}function j(a){e.$acl.$removeUser(a.uid)}function k(a){a&&e.$acl.$addUser(a).then(function(a){n.userToAdd="",n.searchText="",n.selectedUid=null,a&&m(a)},function(a){b.alert(l("Warning"),a)})}function m(a){n.selectedUid==a.uid?n.selectedUid=null:(n.selectedUid=a.uid,n.selectedUser=a,n.selectedUser.$rights())}var n=this;n.users=c,n.folder=e,n.selectedUser=null,n.selectedUid=null,n.userToAdd="",n.searchText="",n.userFilter=f,n.closeModal=g,n.saveModal=h,n.confirmChange=i,n.removeUser=j,n.addUser=k,n.selectUser=m,n.confirmation={showing:!1,message:""}}a.$inject=["$mdDialog","Dialog","usersWithACL","User","folder"],angular.module("SOGo.Common").controller("AclController",a)}(),function(){"use strict";function a(a,b,c,d,e,f,g,h,i,j,k,m){function n(){return!f("left").isOpen()}function o(a,b){var c;b.data&&b.data.message?c=b.data.message:b.status&&(c=b.statusText),c?g.show({template:["<md-toast>",' <div class="md-toast-content">',' <md-icon class="md-warn md-hue-1">error_outline</md-icon>'," <span flex>"+l(c)+"</span>"," </div>","</md-toast>"].join(""),hideDelay:5e3,position:"top right"}):console.debug("untrap error")}b.isPopup=k.isPopup,b.activeUser=k.activeUser(),b.baseURL=k.baseURL(),b.leftIsClose=h(j.xs),b.currentDay=window.currentDay,c(function(){d(function(){e.get("../date").then(function(a){b.currentDay=a})},864e5)},1e3*window.currentDay.secondsBeforeTomorrow),b.toggleLeft=function(){b.leftIsClose=n(),f("left").toggle().then(function(){i.debug("toggle left is done")})},b.toggleRight=function(){f("right").toggle().then(function(){i.debug("toggle right is done")})},b.$watch(function(){return h(j["gt-sm"])},function(a){b.isGtMedium=a,a&&(b.leftIsClose=!1)}),a.$on("http:Error",o),m.getAlarms()}a.$inject=["$rootScope","$scope","$timeout","$interval","$http","$mdSidenav","$mdToast","$mdMedia","$log","sgConstant","sgSettings","Alarm"],angular.module("SOGo.Common").controller("navController",a)}(),function(){"use strict";function a(a){this.folderId=a}a.factory=["$q","$timeout","sgSettings","Resource","User",function(b,c,d,e,f){return angular.extend(a,{$q:b,$timeout:c,$$resource:new e(d.activeUser("folderURL"),d.activeUser()),$User:f}),a}],angular.module("SOGo.Common").factory("Acl",a.factory),a.prototype.$users=function(b){var c,d=this,e=a.$q.defer();if(!this.users){var f;return f=angular.isDefined(b)?a.$$resource.userResource(b).fetch(this.folderId,"acls"):a.$$resource.fetch(this.folderId,"acls"),f.then(function(f){return d.users=[],angular.forEach(f.users,function(e){c=new a.$User(e),c.canSubscribeUser=c.isSubscribed,c.wasSubscribed=c.isSubscribed,c.$rights=angular.bind(c,c.$acl,d.folderId,b),d.users.push(c)}),e.resolve(d.users),d.users})}return e.resolve(this.users),e.promise},a.prototype.$addUser=function(b,c){var d=this,e=a.$q.defer(),f={uid:b.uid};if(!b.uid||_.indexOf(_.pluck(this.users,"uid"),b.uid)>-1)e.resolve();else{var g;g=angular.isDefined(c)?a.$$resource.userResource(c).fetch(this.folderId,"addUserInAcls",f):a.$$resource.fetch(this.folderId,"addUserInAcls",f),g.then(function(){b.wasSubscribed=!1,b.userClass=b.isGroup?"normal-group":"normal-user",b.$rights=angular.bind(b,b.$acl,d.folderId),d.users.push(b),e.resolve(b)},function(a,b){e.reject(l("An error occured please try again."))})}return e.promise},a.prototype.$removeUser=function(b){var c=this,d={uid:b};return a.$$resource.fetch(this.folderId,"removeUserFromAcls",d).then(function(){var a=_.indexOf(_.pluck(c.users,"uid"),b);a>=0&&c.users.splice(a,1)})},a.prototype.$resetUsersRights=function(){angular.forEach(this.users,function(a){a.$resetRights()})},a.prototype.$saveUsersRights=function(b){var c=this,d=a.$q.defer(),e=a.$q.defer(),f={action:"saveUserRights"},g=[];if(angular.forEach(this.users,function(a){a.$rightsAreDirty()&&g.push(a.$omit())}),g.length){var h;h=angular.isDefined(b)?a.$$resource.userResource(b).save(this.folderId,g,f):a.$$resource.save(this.folderId,g,f),h.then(function(){angular.forEach(c.users,function(a){a.$rightsAreDirty()&&(a.$shadowRights=angular.copy(a.rights))}),d.resolve()},d.reject)}else d.resolve();return g=[],angular.forEach(this.users,function(a){!a.wasSubscribed&&a.isSubscribed&&g.push(a.uid)}),g.length?(f={uids:g.join(",")},a.$$resource.fetch(this.folderId,"subscribeUsers",f).then(function(){angular.forEach(c.users,function(a){a.wasSubscribed=a.isSubscribed}),e.resolve()},e.reject)):e.resolve(),a.$q.all([d.promise,e.promise])}}(),function(){"use strict";function a(){this.currentAlarm=null}function b(b,c,d,e){return angular.extend(a,{$timeout:b,$$resource:new d(c.activeUser("folderURL")+"Calendar",c.activeUser()),$toast:e}),a}a.getAlarms=function(){var b=this,c=new Date,d=Math.floor(c.getTime()/1e3);this.$$resource.fetch("","alarmslist?browserTime="+d).then(function(c){var d=c.alarms.sort(function(a,b){var c=parseInt(a[2]),d=parseInt(b[2]);return d-c});if(d.length>0){var e=d.pop(),f=new Date,g=Math.floor(f.getTime()/1e3),h=e[0]+"/"+e[1],i=parseInt(e[2]),j=i;i>0&&(j-=g);var k=(new Date(1e3*i),angular.bind(b,a.showAlarm,h));b.currentAlarm&&b.$timeout.cancel(b.currentAlarm),b.currentAlarm=b.$timeout(k,1e3*j)}})},a.showAlarm=function(a){var b=this;this.$$resource.fetch(a,"?resetAlarm=yes").then(function(c){function d(a,c,d){a.reminder="10",a.cancel=function(){c.hide()},a.ok=function(){b.$$resource.fetch(d,"view?snoozeAlarm="+a.reminder),c.hide()}}b.$toast.show({position:"top right",hideDelay:0,template:["<md-toast>",' <div class="md-toast-content">'," <md-input-container>",' <label style="color: white;">'+c.summary+"</label>",' <md-select ng-model="reminder">'," <md-option value=5>",l("5 minutes")," </md-option>"," <md-option value=10>",l("10 minutes")," </md-option>"," <md-option value=15>",l("15 minutes")," </md-option>"," <md-option value=30>",l("30 minutes")," </md-option>"," <md-option value=45>",l("45 minutes")," </md-option>"," <md-option value=60>",l("1 hour")," </md-option>"," <md-option value=1440>",l("1 day")," </md-option>"," </md-select>"," </md-input-container>",' <md-button ng-click="cancel()">',l("Cancel")," </md-button>",' <md-button ng-click="ok()">',l("Ok")," </md-button>"," </div>","</md-toast>"].join(""),locals:{url:a},controller:d}),d.$inject=["scope","$mdToast","url"]})},b.$inject=["$timeout","sgSettings","Resource","$mdToast"],angular.module("SOGo.Common").factory("Alarm",b)}(),function(){"use strict";function a(){function a(a){var b,c,d,e,f,g;for(b=null,c=a+"=",d=document.cookie.split(";"),e=0;!b&&e<d.length;e++){for(f=d[e],g=0;" "==f.charAt(g);)g++;g>0&&(f=f.substr(g)),0===f.indexOf(c)&&(b=f.substr(c.length))}return b}function b(){var b,c=null,d=a("0xHIGHFLYxSOGo");return d&&d.length>8&&(b=decodeURIComponent(d.substr(8)),c=b.base64decode().split(":")),c}function c(a,b){var c,d,e,f,g,h,i,j;return c=a,b&&(c+="@"+b.value),d=""+window.location.href,e=ApplicationBaseURL+"/"+encodeURIComponent(c),"/"==e[0]&&(g=d.split("/"),h=g[2],i=g[0],e=i+"//"+h+e),g=e.split("/"),g.splice(0,3),f=g.join("/"),j=!d.startsWith(e)&&!d.startsWith(f)||d.endsWith("/logoff")?e:d}function d(a,d,e){var f,g=this;return f={login:function(f){var g,h=a.defer(),i=f.username,j=f.password,k=f.domain,m=f.rememberLogin?1:0;return f.loginSuffix&&!i.endsWith(f.loginSuffix)&&(i+=loginSuffix,k=!1),f.language&&"WONoSelectionString"!=f.language&&(g=f.language),d({method:"POST",url:"/SOGo/connect",data:{userName:i,password:j,domain:k,language:g,rememberLogin:m}}).then(function(a){var d=a.data,e=b();e?"undefined"!=typeof d.expire&&"undefined"!=typeof d.grace?d.expire<0&&d.grace>0?h.reject({grace:d.grace}):d.expire>0&&-1==d.grace?h.reject({expire:d.expire}):h.resolve(c(i,k)):h.resolve(c(i,k)):h.reject(l("cookiesNotEnabled"))},function(a){var b,c,d=a.data;d&&d.LDAPPasswordPolicyError?(c=d.LDAPPasswordPolicyError,b=c==e.PolicyNoError?l("Wrong username or password."):c==e.PolicyAccountLocked?l("Your account was locked due to too many failed attempts."):l("Login failed due to unhandled error case: ")+c):b=l("Unhandled error response"),h.reject({error:b})}),h.promise},changePassword:function(b){var c=a.defer(),f=g.readLoginCookie();return d({method:"POST",url:"/SOGo/so/changePassword",data:{userName:f[0],password:f[1],newPassword:b}}).then(c.resolve,function(a){var b,d=a.data,f=d.LDAPPasswordPolicyError;f?f==e.PolicyNoError?b=l("Password change failed"):f==e.PolicyPasswordModNotAllowed?b=l("Password change failed - Permission denied"):f==e.PolicyInsufficientPasswordQuality?b=l("Password change failed - Insufficient password quality"):f==e.PolicyPasswordTooShort?b=l("Password change failed - Password is too short"):f==e.PolicyPasswordTooYoung?b=l("Password change failed - Password is too young"):f==e.PolicyPasswordInHistory?b=l("Password change failed - Password is in history"):(b=l("Unhandled policy error: %{0}").formatted(f),f=e.PolicyPasswordUnknown):(f=e.PolicyPasswordSystemUnknown,b=_("Unhandled error response")),c.reject(b)}),c.promise}}}this.$get=d,d.$inject=["$q","$http","passwordPolicyConfig"]}angular.module("SOGo.Authentication",[]).constant("passwordPolicyConfig",{PolicyPasswordChangeUnsupported:-3,PolicyPasswordSystemUnknown:-2,PolicyPasswordUnknown:-1,PolicyPasswordExpired:0,PolicyAccountLocked:1,PolicyChangeAfterReset:2,PolicyPasswordModNotAllowed:3,PolicyMustSupplyOldPassword:4,PolicyInsufficientPasswordQuality:5,PolicyPasswordTooShort:6,PolicyPasswordTooYoung:7,PolicyPasswordInHistory:8,PolicyNoError:65535}).provider("Authentication",a)}(),function(){"use strict";function a(){}function b(b,c){return angular.extend(a,{$q:b,$modal:c}),a}a.alert=function(a,b){var c=this.$modal.alert().title(a).htmlContent(b).ok(l("OK"));this.$modal.show(c)},a.confirm=function(a,b,c){var d=this.$modal.confirm().title(a).htmlContent(b).ok(c&&c.ok?c.ok:l("OK")).cancel(c&&c.cancel?c.cancel:l("Cancel"));return this.$modal.show(d)},a.prompt=function(a,b,c){function d(b,c){b.title=a,b.name="",b.cancel=function(){f.reject(),c.hide()},b.ok=function(){f.resolve(b.name),c.hide()}}var e=c||{},f=this.$q.defer();return this.$modal.show({parent:angular.element(document.body),clickOutsideToClose:!0,escapeToClose:!0,template:['<md-dialog flex="50" flex-xs="90">',' <md-dialog-content class="md-dialog-content" layout="column">',' <h2 class="md-title" ng-bind="title"></h2>'," <md-input-container>"," <label>"+b+"</label>",' <input type="'+(e.inputType||"text")+'"',' aria-label="'+a+'"',' ng-model="name" md-autofocus="true" required="required"/>'," </md-input-container>"," </md-dialog-content>"," <md-dialog-actions>",' <md-button ng-click="cancel()">'," "+l("Cancel")," </md-button>",' <md-button class="md-primary" ng-click="ok()" ng-disabled="!name.length">'," "+l("OK")," </md-button>"," </md-dialog-actions>","</md-dialog>"].join(""),controller:d}),d.$inject=["scope","$mdDialog"],f.promise},b.$inject=["$q","$mdDialog"],angular.module("SOGo.Common").factory("Dialog",b)}(),function(){"use strict";function a(){return function(a,b,c,d){var e,f,g,h=b,i=c;return a?(e=a.indexOf("<"),e>=0&&(f=a.indexOf(">",e),f>e&&(a=a.substring(e+1,f))),b||(h=48),g=a.md5(),i&&"none"!=i||(c=d&&d.no_404?"mm":"404"),"https://www.gravatar.com/avatar/"+g+"?s="+h+"&d="+c):""}}angular.module("SOGo.Common").factory("Gravatar",a)}(),function(){"use strict";function a(a,b,c,d,e){angular.extend(this,{_http:a,_q:b,_path:c,_activeUser:d}),angular.extend(this,e),this._path=this._path.replace(/\/$/,"")}a.$factory=["$http","$q",function(b,c){return function(d,e,f){return new a(b,c,d,e,f)}}],angular.module("SOGo.Common").factory("Resource",a.$factory),a.prototype.userResource=function(b){var c=_.compact(this._activeUser.folderURL.split("/"));return c.splice(c.length-1,1,escape(b)),new a(this._http,this._q,"/"+c.join("/"),this._activeUser)},a.prototype.fetch=function(a,b,c){var d=this._q.defer(),e=[this._path];return a&&e.push(a.split("/")),b&&e.push(b),e=_.compact(_.flatten(e)).join("/"),this._http({method:"GET",url:e,params:c}).then(function(a){return d.resolve(a.data)},function(a){return 404==a.status?d.reject():void 0}),d.promise},a.prototype.newguid=function(a){var b=this._q.defer(),c=this._path+"/"+a+"/newguid";return this._http.get(c).then(function(a){return b.resolve(a.data)},b.reject),b.promise},a.prototype.create=function(a,b){var c=this._q.defer(),d=this._path+"/"+a;return this._http.post(d,{name:b}).then(function(a){return c.resolve(a.data)},c.reject),c.promise},a.prototype.post=function(a,b,c){var d=this._q.defer(),e=[this._path];return a&&e.push(a),b&&e.push(b),e=_.compact(_.flatten(e)).join("/"),this._http.post(e,c).then(function(a){return d.resolve(a.data)},d.reject),d.promise},a.prototype.save=function(a,b,c){var d=(this._q.defer(),c&&c.action?c.action:"save");return this.post(a,d,b)},a.prototype.remove=function(a){var b=this._q.defer(),c=this._path+"/"+a+"/delete";return this._http.get(c).then(function(a){return b.resolve(a.data)},b.reject),b.promise}}(),function(){"use strict";function a(a){a&&this.init(a)}a.factory=["$q","$log","sgSettings","Resource","Gravatar",function(b,c,d,e,f){return angular.extend(a,{$q:b,$log:c,$$resource:new e(d.activeUser("folderURL"),d.activeUser()),$gravatar:f,$query:"",$users:[]}),a}],angular.module("SOGo.Common").factory("User",a.factory),a.$filter=function(b,c,d){var e={search:b};if(!d||!d.dry){if(!b)return a.$users.splice(0,a.$users.length),a.$q.when(a.$users);if(a.$query==b)return a.$q.when(a.$users);a.$query=b}return a.$$resource.fetch(null,"usersSearch",e).then(function(b){var e,f,g,h,i=function(a){return this.uid==a.uid};for(h=d&&d.dry?[]:a.$users,e=c?_.filter(b.users,function(a){return!_.find(c,i,a)}):b.users,f=h.length-1;f>=0;f--)g=h[f],_.find(e,i,g)||h.splice(f,1);return _.each(e,function(b,c){if(_.isUndefined(_.find(h,i,b))){var d=new a(b);h.splice(c,0,d)}}),a.$log.debug(h),h})},a.prototype.init=function(b){angular.extend(this,b),this.$$shortFormat||(this.$$shortFormat=this.$shortFormat()),this.$$image||(this.$$image=this.image||a.$gravatar(this.c_email,32,a.$alternateAvatar,{no_404:!0})),this.empty=" "},a.prototype.$shortFormat=function(a){var b=this.cn||this.c_email,c=this.c_email,d=a&&a.email===!1;return!d&&c&&b!=c&&(b+=" <"+c+">"),b},a.prototype.$acl=function(b,c){var d=this,e=a.$q.defer(),f={uid:this.uid};if(this.$shadowRights)e.resolve(this.rights);else{var g;g=angular.isDefined(c)?a.$$resource.userResource(c).fetch(b,"userRights",f):a.$$resource.fetch(b,"userRights",f),g.then(function(a){return d.rights=a,d.$shadowRights=angular.copy(a),e.resolve(a),a})}return e.promise},a.prototype.$isAnonymous=function(){return"anonymous"==this.uid},a.prototype.$isSpecial=function(){return this.userClass&&"public-user"==this.userClass},a.prototype.$confirmRights=function(){var a=!1;return this.$confirmation?!1:(_.some(_.values(this.rights))&&("anonymous"==this.uid?a=l("Potentially anyone on the Internet will be able to access your folder, even if they do not have an account on this system. Is this information suitable for the public Internet?"):"<default>"==this.uid&&(a=l("Any user with an account on this system will be able to access your folder. Are you certain you trust them all?"))),this.$confirmation=a,a)},a.prototype.$rightsAreDirty=function(){return this.rights&&!_.isEqual(this.rights,this.$shadowRights)},a.prototype.$resetRights=function(a){var b=this;a?_.map(_.keys(this.rights),function(a){angular.isString(b.rights[a])?b.rights[a]="None":b.rights[a]=0}):this.rights=angular.copy(this.$shadowRights)},a.prototype.$folders=function(b){var c=this,d=a.$q.defer(),e={type:b};return this.$$folders?d.resolve(this.$$folders):a.$$resource.userResource(this.uid).fetch(null,"foldersSearch",e).then(function(a){c.$$folders=a.folders,d.resolve(a.folders)}),d.promise},a.prototype.$omit=function(){var a={};return angular.forEach(this,function(b,c){"constructor"!=c&&"$"!=c[0]&&(a[c]=b)}),a},a.prototype.toString=function(){return"[User "+this.c_email+"]"}}(),function(){"use strict";function a(a,b){return function(c){b(function(){a.$broadcast("sgFocusOn",c)})}}a.$inject=["$rootScope","$timeout"],angular.module("SOGo.Common").factory("sgFocus",a)}(),function(){"use strict";function a(){return{restrict:"AE",scope:{},bindToController:{size:"@",email:"=sgEmail",src:"=sgSrc"},template:["<md-icon>person</md-icon>",'<img class="ng-hide" ng-src="{{vm.url}}" />'].join(""),link:b,controller:"sgAvatarImageController",controllerAs:"vm"}}function b(a,b,c,d){var e=b.find("img"),f=b.find("md-icon");c.size&&(e.attr("width",c.size),e.attr("height",c.size)),d.img=e,d.genericImg=f}function c(a,b,c,d,e,f){function g(a){var b=f(a,j.size,e.defaults.SOGoAlternateAvatar);c({method:"GET",url:b,cache:!0,headers:{Accept:"image/*"}}).then(function(){j.url||(j.url=b,j.urlEmail=a,i())},function(){h()})}function h(){j.url=null,j.urlEmail=null,j.img.addClass("ng-hide"),j.genericImg.removeClass("ng-hide")}function i(){j.genericImg.addClass("ng-hide"),j.img.removeClass("ng-hide")}var j;j=this,e.ready().then(function(){a.$watch("vm.email",function(a,b){a&&j.urlEmail!=a?(h(),g(a)):a||h()})}),"sg-src"in b[0].attributes&&a.$watch("vm.src",function(a){a&&(j.url=a,j.urlEmail=""+j.email,i())})}c.$inject=["$scope","$element","$http","$q","Preferences","Gravatar"],angular.module("SOGo.Common").directive("sgAvatarImage",a).controller("sgAvatarImageController",c)}(),function(){"use strict";function a(){function a(a,b,c,d){d.$render=function(){a.sgColor=d.$viewValue,a.sgIconColor=contrast(d.$viewValue)}}return{restrict:"E",require:"ngModel",template:["<md-menu>",' <md-button class="md-icon-button"',' label:aria-label="Options"'," ng-style=\"{ 'background-color': sgColor }\"",' ng-click="$mdOpenMenu()"',' md-menu-origin="md-menu-origin">',' <md-icon ng-style="{ color: sgIconColor }">color_lens</md-icon>'," </md-button>",' <md-menu-content width="3">',' <md-content class="md-padding">',' <md-grid-list class="sg-color-picker" md-cols="7" md-row-height="1:1" md-gutter="0.5em">',' <md-grid-tile ng-repeat="color in ::sgColors track by $index"'," ng-style=\"{ 'background-color': color }\"",' ng-class="{ selected: color == sgColor }"',' ng-click="setColor(color)"><md-icon ng-style="{ color: color }">check_box</md-icon></md-grid-tile>'," </md-grid-list>"," </md-content>"," </md-menu-content>","</md-menu>"].join(""),replace:!0,controller:b,link:a}}function b(a,b,c){var d=b.controller("ngModel");a.sgColors=c.selection,a.setColor=function(b){a.sgColor=b,a.sgIconColor=contrast(b),d.$setViewValue(b)}}b.$inject=["$scope","$element","sgColors"],angular.module("SOGo.Common").directive("sgColorPicker",a)}(),function(){"use strict";function a(a){function b(b,c,d){var e=b.$watch(function(a){return a.$eval(d.sgCompile)},function(d){c.html(d),a(c.contents())(b),e()})}return{restrict:"A",link:b}}a.$inject=["$compile"],angular.module("SOGo.Common").directive("sgCompile",a)}(),function(){"use strict";function a(){var a=13;return function(b,c,d){c.bind("keydown keypress",function(c){c.which===a&&(b.$apply(d.sgEnter),c.preventDefault())})}}angular.module("SOGo.Common").directive("sgEnter",a)}(),function(){"use strict";function a(){var a=27;return function(b,c,d){c.bind("keydown",function(c){c.keyCode===a&&b.$apply(d.sgEscape)})}}angular.module("SOGo.Common").directive("sgEscape",a)}(),function(){"use strict";function a(){return function(a,b,c){a.$on("sgFocusOn",function(a,d){d===c.sgFocusOn&&(b[0].focus(),b[0].select())})}}angular.module("SOGo.Common").directive("sgFocusOn",a)}(),function(){"use strict";function a(){function a(){var a=this;a.contrast=contrast}return{restrict:"E",require:"ngModel",scope:{ngModel:"="},replace:!0,bindToController:!0,controller:a,controllerAs:"cssCtrl",template:['<style type="text/css">'," .bg-folder{{ cssCtrl.ngModel.id }},"," .bg-folder{{ cssCtrl.ngModel.id }} label,"," .bg-folder{{ cssCtrl.ngModel.id }} .md-input {"," background-color: {{ cssCtrl.ngModel.color }} !important;"," color: {{ cssCtrl.contrast(cssCtrl.ngModel.color) }} !important;"," }"," .sg-event.bg-folder{{ cssCtrl.ngModel.id }} md-icon {"," color: {{ cssCtrl.contrast(cssCtrl.ngModel.color) }} !important;"," }"," md-toolbar.bg-folder{{ cssCtrl.ngModel.id }} md-icon:not(.sg-icon-toolbar-bg) {"," color: {{ cssCtrl.contrast(cssCtrl.ngModel.color) }} !important;"," }"," .bg-folder{{ cssCtrl.ngModel.id }} label {"," color: {{ cssCtrl.contrast(cssCtrl.ngModel.color) }} !important;"," opacity: 0.8;"," }"," .fg-folder{{ cssCtrl.ngModel.id }},"," .sg-event.fg-folder{{ cssCtrl.ngModel.id }} md-icon {"," color: {{ cssCtrl.ngModel.color }} !important;"," }"," .bdr-folder{{ cssCtrl.ngModel.id }} {"," border-color: {{ cssCtrl.ngModel.color }} !important;"," }"," .checkbox-folder{{ cssCtrl.ngModel.id }} .md-icon {"," background-color: {{ cssCtrl.ngModel.color }} !important;"," }"," .checkbox-folder{{ cssCtrl.ngModel.id }}.md-checked .md-icon:after {"," border-color: {{ cssCtrl.contrast(cssCtrl.ngModel.color) }} !important;"," }","</style>"].join("")}}angular.module("SOGo.Common").directive("sgFolderStylesheet",a)}(),function(){"use strict";function a(){return{restrict:"A",scope:{placeholder:"=sgPlaceholder"},link:function(a,b,c){a.$watch("placeholder",function(){b[0].placeholder=a.placeholder})}}}angular.module("SOGo.Common").directive("sgPlaceholder",a)}(),function(){"use strict";function a(a){function b(b,c){var d=(b.find("md-input-container"),b.find("input")),e=b.find("md-select"),f=b.find("md-button");return d.attr("ng-model","$sgSearchController.searchText"),d.attr("ng-model-options","$sgSearchController.searchTextOptions"),d.attr("ng-change","$sgSearchController.onChange()"),e&&(e.attr("ng-model","$sgSearchController.searchField"),e.attr("ng-change","$sgSearchController.onChange()")),f&&f.attr("sg-search-cancel")?(f.attr("ng-click",f.attr("sg-search-cancel")),f.removeAttr("sg-search-cancel")):f=null,function(b,c,d,e){var g=c.find("button");e.doSearch=a(c.attr("sg-search")),f&&g&&g.on("click",e.cancelSearch)}}return{restrict:"A",controller:"sgSearchController",controllerAs:"$sgSearchController",priority:1001,compile:b}}function b(){function a(a,b){return function(a,b,c,d,e){e(function(a){b.append(a)})}}return{restrict:"A",priority:1e3,transclude:!0,compile:a}}function c(a,b,c){var d,e=this;d=angular.isNumber(a.minimumSearchLength)?a.minimumSearchLength:2,e.previous={searchText:"",searchField:""},e.searchText=null,e.searchTextOptions={updateOn:"default blur",debounce:{"default":300,blur:0}},e.onChange=function(){"undefined"!=typeof e.searchText&&null!==e.searchText&&(e.searchText!=e.previous.searchText||e.searchField!=e.previous.searchField)&&((e.searchText.length>d||0===e.searchText.length||"."==e.searchText)&&e.doSearch(b,{searchText:e.searchText,searchField:e.searchField}),e.previous={searchText:e.searchText,searchField:e.searchField})},e.cancelSearch=function(){e.previous={searchText:"",searchField:""},e.searchText=null}}a.$inject=["$parse"],c.$inject=["$window","$scope","$element"],angular.module("SOGo.Common").controller("sgSearchController",c).directive("sgSearch",a).directive("sgSearch",b)}(),function(){"use strict";function a(a){return{restrict:"A",scope:{folderType:"@sgSubscribe",onFolderSelect:"&sgSubscribeOnSelect"},replace:!1,bindToController:!0,controller:c,controllerAs:"$sgSubscribeDialogController",link:b}}function b(a,b,c,d){b.find("input");b.on("click",d.showDialog)}function c(a){var b=this;b.showDialog=function(){a.show({templateUrl:"../Contacts/UIxContactsUserFolders",clickOutsideToClose:!0,locals:{folderType:b.folderType,
|
|
onFolderSelect:b.onFolderSelect},controller:d,controllerAs:"subscribe"})}}function d(a,b,c,d){var e=this;e.selectedUser=null,e.users=d.$users,e.searchTextOptions={updateOn:"default blur",debounce:{"default":300,blur:0}},e.onChange=function(){d.$filter(e.searchText).then(function(){e.selectedUser&&_.isUndefined(_.find(d.$users,function(a){return a.uid==e.selectedUser.uid}))&&(e.selectedUser=null)})},e.selectUser=function(a){e.selectedUser==e.users[a]?e.selectedUser=null:e.users[a].$folders(b).then(function(){e.selectedUser=e.users[a]})},e.selectFolder=function(a){c({folderData:a})},e.close=function(){a.hide()}}a.$inject=["User"],c.$inject=["$mdDialog"],d.$inject=["$mdDialog","folderType","onFolderSelect","User"],angular.module("SOGo.Common").directive("sgSubscribe",a)}(),function(){"use strict";function a(){return{template:['<div class="sg-time-pane">',' <div class="hours-pane">',' <div ng-repeat="hoursBigLine in hours" layout="row" layout-sm="column">',' <div ng-repeat="hoursLine in hoursBigLine" layout="row" class="hours">',' <md-button class="hourBtn md-fab md-mini" ng-repeat="hour in hoursLine" id="{{hour.id}}"',' ng-click="hourClickHandler(hour.displayName)">{{hour.displayName}}</md-button>'," </div>"," </div>"," </div>",' <div class="min5" ng-show="is5min()">',' <div layout="row" layout-sm="column">',' <div ng-repeat="minutesLine in min5" layout="row">',' <md-button class="minuteBtn md-fab md-mini" ng-repeat="minute in minutesLine" id="{{minute.id}}"',' ng-click="minuteClickHandler(minute.displayName)">{{minute.displayName}}</md-button>'," </div>"," </div>"," </div>",' <div class="sg-time-scroll-mask" ng-hide="is5min()">',' <div class="min1" layout="row" layout-sm="column" layout-wrap>',' <div ng-repeat="minutesLine in min1" layout="row" layout-align="space-around center" flex="50">',' <md-button class="minuteBtn md-fab md-mini" ng-repeat="minute in minutesLine" id="{{minute.id}}"',' ng-click="minuteClickHandler(minute.displayName)">{{minute.displayName}}</md-button>'," </div>"," </div>"," </div>",' <div flex layout="row" layout-align="center center" class="toggle-pane">',' <md-button class="toggleBtn md-fab md-mini" ng-bind="getToggleBtnLbl()" ng-click="toggleManual5min()"></md-button>'," </div>","</div>"].join(""),scope:{},require:["ngModel","sgTimePane"],controller:b,controllerAs:"ctrl",bindToController:!0,link:function(a,b,c,d){var e=d[0],f=d[1],g=b;f.configureNgModel(e,f,g)}}}function b(a,b,c,d,f,g,h,i,j,k,l){var m;this.$scope=c,this.$element=a,this.timePaneElement=a[0].querySelector(".sg-time-pane"),this.$animate=d,this.$q=f,this.$mdInkRipple=k,this.$mdUtil=l,this.keyCode=g.KEY_CODE,this.dateUtil=i,this.id=e++,this.ngModelCtrl=null,this.selectedTime=null,this.displayTime=null,this.isInitialized=!1,c.hours=[],c.hours[0]=[],c.hours[0][0]=[],c.hours[0][1]=[],c.hours[1]=[],c.hours[1][0]=[],c.hours[1][1]=[];for(var n=0;6>n;n++)c.hours[0][0][n]={id:"tp-"+this.id+"-hour-"+n,displayName:10>n?"0"+n:""+n,selected:!1},c.hours[0][1][n]={id:"tp-"+this.id+"-hour-"+(n+6),displayName:10>n+6?"0"+(n+6):""+(n+6),selected:!1},c.hours[1][0][n]={id:"tp-"+this.id+"-hour-"+(n+12),displayName:""+(n+12),selected:!1},c.hours[1][1][n]={id:"tp-"+this.id+"-hour-"+(n+18),displayName:""+(n+18),selected:!1};for(c.min5=[],c.min5[0]=[],c.min5[1]=[],n=0;6>n;n++)m=5*n,c.min5[0][n]={id:"tp-"+this.id+"-minute5-"+m,displayName:10>m?":0"+m:":"+m,selected:!0},c.min5[1][n]={id:"tp-"+this.id+"-minute5-"+(m+30),displayName:":"+(m+30),selected:!1};for(c.min1=[],n=0;12>n;n++){c.min1[n]=[];for(var o=0;5>o;o++)m=5*n+o,c.min1[n][o]={id:"tp-"+this.id+"-minute-"+m,displayName:10>m?":0"+m:":"+m,selected:!0}}c.show5min=!0,c.getToggleBtnLbl=function(){return c.is5min()?">>":"<<"},c.toggleManual5min=function(){c.manual5min=!c.is5min()},c.is5min=function(){return c.manual5min===!0||c.manual5min===!1?c.manual5min:c.show5min},b.tabindex||a.attr("tabindex","-1");var p=this;this.hourClickHandler=function(a){var b=new Date(p.displayTime);b.setHours(Number(a)),p.setNgModelValue(b,"hours")},c.hourClickHandler=this.hourClickHandler,this.minuteClickHandler=function(a){var b=a.substr(1),c=new Date(p.displayTime);c.setMinutes(Number(b)),p.setNgModelValue(c,"minutes")},c.minuteClickHandler=this.minuteClickHandler,this.attachTimePaneEventListeners()}angular.module("SOGo.Common").directive("sgTimePane",a);var c="md-bg",d="md-focus",e=0;b.$inject=["$element","$attrs","$scope","$animate","$q","$mdConstant","$mdTheming","$$mdDateUtil","$mdDateLocale","$mdInkRipple","$mdUtil"],b.prototype.configureNgModel=function(a,b,c){this.ngModelCtrl=a;var d=this;a.$render=function(){d.changeSelectedTime(d.ngModelCtrl.$viewValue,b,c)}},b.prototype.changeSelectedTime=function(a,b,d){var e=this.selectedTime;this.selectedTime=a,this.changeDisplayTime(a).then(function(){if(e){var d=e.getHours(),f=document.getElementById("tp-"+b.id+"-hour-"+d);f&&(f.classList.remove(c),f.setAttribute("aria-selected","false"));var g=e.getMinutes(),h=document.getElementById("tp-"+b.id+"-minute-"+g);h&&(h.classList.remove(c),h.setAttribute("aria-selected","false"));var i=document.getElementById("tp-"+b.id+"-minute5-"+g);i&&(i.classList.remove(c),i.setAttribute("aria-selected","false"))}if(a){var j,k=a.getHours(),l=document.getElementById("tp-"+b.id+"-hour-"+k);l&&(l.classList.add(c),l.setAttribute("aria-selected","true"));var m=a.getMinutes();m%5===0?(b.$scope.show5min=!0,j=document.getElementById("tp-"+b.id+"-minute5-"+m),j&&(j.classList.add(c),j.setAttribute("aria-selected","true"))):b.$scope.show5min=!1,j=document.getElementById("tp-"+b.id+"-minute-"+m),j&&(j.classList.add(c),j.setAttribute("aria-selected","true"))}})},b.prototype.changeDisplayTime=function(a){var b=new Date(a);return this.isInitialized?this.dateUtil.isValidDate(b)?(this.displayTime=b,this.$q.when()):this.$q.when():(this.buildInitialTimePaneDisplay(),this.$q.when())},b.prototype.buildInitialTimePaneDisplay=function(){this.displayTime=this.selectedTime||this.today,this.isInitialized=!0},b.prototype.attachTimePaneEventListeners=function(){this.$element.on("keydown",angular.bind(this,this.handleKeyEvent))},b.prototype.handleKeyEvent=function(a){var b=this;this.$scope.$apply(function(){return a.which==b.keyCode.ESCAPE||a.which==b.keyCode.TAB?(b.$scope.$emit("md-time-pane-close"),void(a.which==b.keyCode.TAB&&a.preventDefault())):a.which===b.keyCode.ENTER?(b.setNgModelValue(b.displayTime,"enter"),void a.preventDefault()):void 0})},b.prototype.setNgModelValue=function(a,b){this.$scope.$emit("sg-time-pane-change",{date:a,changed:b}),this.ngModelCtrl.$setViewValue(a),this.ngModelCtrl.$render()},b.prototype.focus=function(a,b){var c=a||this.selectedTime||this.today,e=this.timePaneElement.querySelector(".md-focus");if(e&&e.classList.remove(d),c){var f=c.getHours(),g=document.getElementById("tp-"+b.id+"-hour-"+f);g&&(g.classList.add(d),g.focus())}}}(),function(){"use strict";function a(){return{template:['<md-button class="sg-timepicker-button md-icon-button" type="button" ',' tabindex="-1" aria-hidden="true" ',' ng-click="ctrl.openTimePane($event)">'," <md-icon>access_time</md-icon>","</md-button>",'<div class="md-default-theme sg-timepicker-input-container" '," ng-class=\"{'sg-timepicker-focused': ctrl.isFocused,"," 'md-bdr': ctrl.isFocused}\">",' <input class="sg-timepicker-input" aria-haspopup="true" ',' ng-focus="ctrl.setFocused(true)" ng-blur="ctrl.setFocused(false)">',' <md-button type="button" md-no-ink ',' class="sg-timepicker-triangle-button md-icon-button" ',' ng-click="ctrl.openTimePane($event)" ',' aria-label="{{::ctrl.dateLocale.msgOpenCalendar}}">',' <div class="sg-timepicker-expand-triangle"></div>'," </md-button>","</div>",'<div class="sg-timepicker-time-pane md-whiteframe-z1">',' <div class="sg-timepicker-input-mask">',' <div class="sg-timepicker-input-mask-opaque',' md-default-theme md-background md-bg"></div>'," </div>",' <div class="sg-timepicker-time md-default-theme md-bg md-background">',' <sg-time-pane role="dialog" aria-label="{{::ctrl.dateLocale.msgCalendar}}" ',' ng-model="ctrl.time" ng-if="ctrl.isTimeOpen"></sg-time-pane>'," </div>","</div>"].join(""),require:["ngModel","sgTimepicker"],scope:{placeholder:"@mdPlaceholder"},controller:b,controllerAs:"ctrl",bindToController:!0,link:function(a,b,c,d){var e=d[0],f=d[1];f.configureNgModel(e)}}}function b(a,b,c,d,e,f,g,h,i,j,k,l,m){this.$compile=d,this.$timeout=e,this.$window=f,this.dateLocale=k,this.dateUtil=l,this.$mdConstant=g,this.$mdMedia=h,this.$mdUtil=j,this.$$rAF=m,this.ngModelCtrl=null,this.inputElement=b[0].querySelector("input"),this.inputContainer=b[0].querySelector(".sg-timepicker-input-container"),this.ngInputElement=angular.element(this.inputElement),this.timePane=b[0].querySelector(".sg-timepicker-time-pane"),this.timeButton=b[0].querySelector(".sg-timepicker-button"),this.inputMask=b[0].querySelector(".sg-timepicker-input-mask-opaque"),this.$element=b,this.$attrs=c,this.$scope=a,this.date=null,this.isFocused=!1,this.isDisabled=!1,this.setDisabled(b[0].disabled||angular.isString(c.disabled)),this.isTimeOpen=!1,this.timePaneOpenedFrom=null,this.timePane.id="sg-time-pane"+j.nextUid(),i(b),this.bodyClickHandler=angular.bind(this,this.handleBodyClick),this.windowResizeHandler=j.debounce(angular.bind(this,this.closeTimePane),100),c.tabindex||b.attr("tabindex","-1"),this.installPropertyInterceptors(),this.attachChangeListeners(),this.attachInteractionListeners();var n=this;a.$on("$destroy",function(){n.detachTimePane()})}angular.module("SOGo.Common").directive("sgTimepicker",a);var c=3,d="sg-timepicker-invalid",e=500,f={MIN5:{GTSM:192,SM:312},MIN1:{GTSM:384,SM:474}},g={GTSM:530,SM:292};b.$inject=["$scope","$element","$attrs","$compile","$timeout","$window","$mdConstant","$mdMedia","$mdTheming","$mdUtil","$mdDateLocale","$$mdDateUtil","$$rAF"],b.prototype.configureNgModel=function(a){this.ngModelCtrl=a;var b=this;a.$render=function(){var a=b.ngModelCtrl.$viewValue;if(a&&!(a instanceof Date))throw Error("The ng-model for sg-timepicker must be a Date instance. Currently the model is a: "+typeof a);b.time=a,b.inputElement.value=b.dateLocale.formatTime(a),b.resizeInputElement(),b.updateErrorState()}},b.prototype.attachChangeListeners=function(){var a=this;a.$scope.$on("sg-time-pane-change",function(b,c){var e=new Date(c.date);a.ngModelCtrl.$setViewValue(e),a.time=e,a.inputElement.value=a.dateLocale.formatTime(e),"minutes"==c.changed&&a.closeTimePane(),a.resizeInputElement(),a.inputContainer.classList.remove(d)}),a.ngInputElement.on("input",angular.bind(a,a.resizeInputElement)),a.ngInputElement.on("input",a.$mdUtil.debounce(a.handleInputEvent,e,a))},b.prototype.attachInteractionListeners=function(){var a=this,b=this.$scope,c=this.$mdConstant.KEY_CODE;a.ngInputElement.on("keydown",function(d){d.altKey&&d.keyCode==c.DOWN_ARROW&&(a.openTimePane(d),b.$digest())}),b.$on("md-time-close",function(){a.closeTimePane()})},b.prototype.installPropertyInterceptors=function(){var a=this;if(this.$attrs.ngDisabled){var b=this.$mdUtil.validateScope(this.$element)?this.$element.scope():null;b&&b.$watch(this.$attrs.ngDisabled,function(b){a.setDisabled(b)})}Object.defineProperty(this,"placeholder",{get:function(){return a.inputElement.placeholder},set:function(b){a.inputElement.placeholder=b||""}})},b.prototype.setDisabled=function(a){this.isDisabled=a,this.inputElement.disabled=a,this.timeButton.disabled=a},b.prototype.updateErrorState=function(a){var b=a||this.date;this.clearErrorState(),this.dateUtil.isValidDate(b)||this.ngModelCtrl.$setValidity("valid",null===b),this.ngModelCtrl.$valid||this.inputContainer.classList.add(d)},b.prototype.clearErrorState=function(){this.inputContainer.classList.remove(d),["valid"].forEach(function(a){this.ngModelCtrl.$setValidity(a,!0)},this)},b.prototype.resizeInputElement=function(){this.inputElement.size=this.inputElement.value.length+c},b.prototype.handleInputEvent=function(a){var b=this.inputElement.value,c=b.split(/[\.:]/);if(""===b)this.ngModelCtrl.$setViewValue(null),this.time=null,this.inputContainer.classList.remove(d);else if(c.length<2)this.inputContainer.classList.toggle(d,b);else{var e=Number(c[0]),f=Number(c[1]),g=new Date(this.time);e&&e>=0&&23>=e&&f&&f>=0&&59>=f&&angular.isDate(g)?(g.setHours(e),g.setMinutes(f),this.ngModelCtrl.$setViewValue(g),this.time=g,this.inputContainer.classList.remove(d)):this.inputContainer.classList.toggle(d,b)}},b.prototype.attachTimePane=function(){var a=this.timePane;this.$element.addClass("sg-timepicker-open"),this.$element.find("button").addClass("md-primary");var b=this.inputContainer.getBoundingClientRect(),c=document.body.getBoundingClientRect(),d=b.top-c.top,e=b.left-c.left,h=this.$mdMedia("sm")?g.SM:g.GTSM;e+h>c.right&&c.right-h>0&&(e=c.right-h,a.classList.add("sg-timepicker-pos-adjusted")),a.style.left=e+"px";var i="object"==typeof this.time&&this.time.getMinutes()%5===0?"MIN5":"MIN1",j=this.$mdMedia("sm")?f[i].SM:f[i].GTSM;d+j>c.bottom&&c.bottom-j>0&&(d=c.bottom-j,a.classList.add("sg-timepicker-pos-adjusted")),a.style.top=d+"px",document.body.appendChild(a),this.inputMask.style.left=b.width+"px",this.$$rAF(function(){a.classList.add("md-pane-open")})},b.prototype.detachTimePane=function(){this.$element.removeClass("sg-timepicker-open"),this.$element.find("button").removeClass("md-primary"),this.timePane.classList.remove("md-pane-open"),this.timePane.classList.remove("md-timepicker-pos-adjusted"),this.timePane.parentNode&&this.timePane.parentNode.removeChild(this.timePane)},b.prototype.openTimePane=function(a){if(!this.isTimeOpen&&!this.isDisabled){this.isTimeOpen=!0,this.timePaneOpenedFrom=a.target,this.attachTimePane(),this.$mdUtil.disableScrollAround(this.timePane);var b=this;this.$mdUtil.nextTick(function(){document.body.addEventListener("click",b.bodyClickHandler)},!1),window.addEventListener("resize",this.windowResizeHandler)}},b.prototype.closeTimePane=function(){this.isTimeOpen&&(this.isTimeOpen=!1,this.detachTimePane(),this.timePaneOpenedFrom.focus(),this.timePaneOpenedFrom=null,this.$mdUtil.enableScrolling(),document.body.removeEventListener("click",this.bodyClickHandler),window.removeEventListener("resize",this.windowResizeHandler))},b.prototype.getTimePaneCtrl=function(){return angular.element(this.timePane.querySelector("sg-time-pane")).controller("sgTimePane")},b.prototype.focusTime=function(){var a=this;this.$mdUtil.nextTick(function(){var b=a.getTimePaneCtrl();a.getTimePaneCtrl().focus(null,b)},!1)},b.prototype.setFocused=function(a){this.isFocused=a},b.prototype.handleBodyClick=function(a){if(this.isTimeOpen){var b=this.$mdUtil.getClosest(a.target,"sg-time-pane");b||this.closeTimePane(),this.$scope.$digest()}}}(),function(){"use strict";function a(a){function b(b,c,d,e){function f(a){var b=_.findIndex(i,function(b){return j?b[j]==a:b==a});if(0>b)if(j){var c={};c[j]=a,i.push(c)}else i.push(a);else i.splice(b,1)}var g,h,i,j,k,l,m=c.find("md-grid-tile");for(k=b.$watch(function(){return a(d.sgToggleGrid)(b)},function(a){if(angular.isDefined(a)){var b=a;i=a,d.sgToggleGridAttr&&(j=d.sgToggleGridAttr,b=_.pluck(a,d.sgToggleGridAttr)),_.each(m,function(a){var c=angular.element(a);_.contains(b,c.attr("value"))&&c.addClass("sg-active")}),k()}}),l=function(){var a=angular.element(this),b=a.attr("value");a.toggleClass("sg-active"),f(b)},h=0;h<m.length;h++)g=angular.element(m[h]),g.addClass("sg-icon-button"),g.find("figure").addClass("md-icon"),g.on("click",l)}return{restrict:"A",link:b}}a.$inject=["$parse"],angular.module("SOGo.Common").directive("sgToggleGrid",a)}(),String.prototype.endsWith=function(a){return-1!==this.indexOf(a,this.length-a.length)},String.prototype.startsWith=function(a,b){return b=angular.isNumber(b)?b:0,this.lastIndexOf(a,b)===b},String.prototype._base64_keyStr="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",String.prototype.base64encode=function(){for(var a,b,c,d,e,f,g,h="",i=0,j=this.utf8encode();i<j.length;)a=j.charCodeAt(i++),b=j.charCodeAt(i++),c=j.charCodeAt(i++),d=a>>2,e=(3&a)<<4|b>>4,f=(15&b)<<2|c>>6,g=63&c,isNaN(b)?f=g=64:isNaN(c)&&(g=64),h=h+this._base64_keyStr.charAt(d)+this._base64_keyStr.charAt(e)+this._base64_keyStr.charAt(f)+this._base64_keyStr.charAt(g);return h},String.prototype.base64decode=function(){for(var a,b,c,d,e,f,g,h="",i=0,j=""+this;i<j.length;)d=this._base64_keyStr.indexOf(j.charAt(i++)),e=this._base64_keyStr.indexOf(j.charAt(i++)),f=this._base64_keyStr.indexOf(j.charAt(i++)),g=this._base64_keyStr.indexOf(j.charAt(i++)),a=d<<2|e>>4,b=(15&e)<<4|f>>2,c=(3&f)<<6|g,h+=String.fromCharCode(a),64!=f&&(h+=String.fromCharCode(b)),64!=g&&(h+=String.fromCharCode(c));return h},String.prototype.md5=function(){if(this.length){var a=function(a){function b(a,b){return a<<b|a>>>32-b}function c(a,b){var c,d,e,f,g;return e=2147483648&a,f=2147483648&b,c=1073741824&a,d=1073741824&b,g=(1073741823&a)+(1073741823&b),c&d?2147483648^g^e^f:c|d?1073741824&g?3221225472^g^e^f:1073741824^g^e^f:g^e^f}function d(a,b,c){return a&b|~a&c}function e(a,b,c){return a&c|b&~c}function f(a,b,c){return a^b^c}function g(a,b,c){return b^(a|~c)}function h(a,e,f,g,h,i,j){return a=c(a,c(c(d(e,f,g),h),j)),c(b(a,i),e)}function i(a,d,f,g,h,i,j){return a=c(a,c(c(e(d,f,g),h),j)),c(b(a,i),d)}function j(a,d,e,g,h,i,j){return a=c(a,c(c(f(d,e,g),h),j)),c(b(a,i),d)}function k(a,d,e,f,h,i,j){return a=c(a,c(c(g(d,e,f),h),j)),c(b(a,i),d)}function l(a){for(var b,c=a.length,d=c+8,e=(d-d%64)/64,f=16*(e+1),g=Array(f-1),h=0,i=0;c>i;)b=(i-i%4)/4,h=i%4*8,g[b]=g[b]|a.charCodeAt(i)<<h,i++;return b=(i-i%4)/4,h=i%4*8,g[b]=g[b]|128<<h,g[f-2]=c<<3,g[f-1]=c>>>29,g}function m(a){var b,c,d="",e="";for(c=0;3>=c;c++)b=a>>>8*c&255,e="0"+b.toString(16),d+=e.substr(e.length-2,2);return d}function n(a){a=a.replace(/rn/g,"n");for(var b="",c=0;c<a.length;c++){var d=a.charCodeAt(c);128>d?b+=String.fromCharCode(d):d>127&&2048>d?(b+=String.fromCharCode(d>>6|192),b+=String.fromCharCode(63&d|128)):(b+=String.fromCharCode(d>>12|224),b+=String.fromCharCode(d>>6&63|128),b+=String.fromCharCode(63&d|128))}return b}var o,p,q,r,s,t,u,v,w,x=Array(),y=7,z=12,A=17,B=22,C=5,D=9,E=14,F=20,G=4,H=11,I=16,J=23,K=6,L=10,M=15,N=21;for(a=n(a),x=l(a),t=1732584193,u=4023233417,v=2562383102,w=271733878,o=0;o<x.length;o+=16)p=t,q=u,r=v,s=w,t=h(t,u,v,w,x[o+0],y,3614090360),w=h(w,t,u,v,x[o+1],z,3905402710),v=h(v,w,t,u,x[o+2],A,606105819),u=h(u,v,w,t,x[o+3],B,3250441966),t=h(t,u,v,w,x[o+4],y,4118548399),w=h(w,t,u,v,x[o+5],z,1200080426),v=h(v,w,t,u,x[o+6],A,2821735955),u=h(u,v,w,t,x[o+7],B,4249261313),t=h(t,u,v,w,x[o+8],y,1770035416),w=h(w,t,u,v,x[o+9],z,2336552879),v=h(v,w,t,u,x[o+10],A,4294925233),u=h(u,v,w,t,x[o+11],B,2304563134),t=h(t,u,v,w,x[o+12],y,1804603682),w=h(w,t,u,v,x[o+13],z,4254626195),v=h(v,w,t,u,x[o+14],A,2792965006),u=h(u,v,w,t,x[o+15],B,1236535329),t=i(t,u,v,w,x[o+1],C,4129170786),w=i(w,t,u,v,x[o+6],D,3225465664),v=i(v,w,t,u,x[o+11],E,643717713),u=i(u,v,w,t,x[o+0],F,3921069994),t=i(t,u,v,w,x[o+5],C,3593408605),w=i(w,t,u,v,x[o+10],D,38016083),v=i(v,w,t,u,x[o+15],E,3634488961),u=i(u,v,w,t,x[o+4],F,3889429448),t=i(t,u,v,w,x[o+9],C,568446438),w=i(w,t,u,v,x[o+14],D,3275163606),v=i(v,w,t,u,x[o+3],E,4107603335),u=i(u,v,w,t,x[o+8],F,1163531501),t=i(t,u,v,w,x[o+13],C,2850285829),w=i(w,t,u,v,x[o+2],D,4243563512),v=i(v,w,t,u,x[o+7],E,1735328473),u=i(u,v,w,t,x[o+12],F,2368359562),t=j(t,u,v,w,x[o+5],G,4294588738),w=j(w,t,u,v,x[o+8],H,2272392833),v=j(v,w,t,u,x[o+11],I,1839030562),u=j(u,v,w,t,x[o+14],J,4259657740),t=j(t,u,v,w,x[o+1],G,2763975236),w=j(w,t,u,v,x[o+4],H,1272893353),v=j(v,w,t,u,x[o+7],I,4139469664),u=j(u,v,w,t,x[o+10],J,3200236656),t=j(t,u,v,w,x[o+13],G,681279174),w=j(w,t,u,v,x[o+0],H,3936430074),v=j(v,w,t,u,x[o+3],I,3572445317),u=j(u,v,w,t,x[o+6],J,76029189),t=j(t,u,v,w,x[o+9],G,3654602809),w=j(w,t,u,v,x[o+12],H,3873151461),v=j(v,w,t,u,x[o+15],I,530742520),u=j(u,v,w,t,x[o+2],J,3299628645),t=k(t,u,v,w,x[o+0],K,4096336452),w=k(w,t,u,v,x[o+7],L,1126891415),v=k(v,w,t,u,x[o+14],M,2878612391),u=k(u,v,w,t,x[o+5],N,4237533241),t=k(t,u,v,w,x[o+12],K,1700485571),w=k(w,t,u,v,x[o+3],L,2399980690),v=k(v,w,t,u,x[o+10],M,4293915773),u=k(u,v,w,t,x[o+1],N,2240044497),t=k(t,u,v,w,x[o+8],K,1873313359),w=k(w,t,u,v,x[o+15],L,4264355552),v=k(v,w,t,u,x[o+6],M,2734768916),u=k(u,v,w,t,x[o+13],N,1309151649),t=k(t,u,v,w,x[o+4],K,4149444226),w=k(w,t,u,v,x[o+11],L,3174756917),v=k(v,w,t,u,x[o+2],M,718787259),u=k(u,v,w,t,x[o+9],N,3951481745),t=c(t,p),u=c(u,q),v=c(v,r),w=c(w,s);var O=m(t)+m(u)+m(v)+m(w);return O.toLowerCase()};return a(this.toLowerCase())}},String.prototype.capitalize=function(){return this.charAt(0).toUpperCase()+this.slice(1)},String.prototype.asDate=function(){var a,b=this.split("/");return 3==b.length?a=new Date(b[2],b[1]-1,b[0]):(b=this.split("-"),3==b.length?a=new Date(b[0],b[1]-1,b[2]):8==this.length&&(a=new Date(this.substring(0,4),this.substring(4,6)-1,this.substring(6,8)))),a},String.prototype.formatted=function(){for(var a=this,b=0;b<arguments.length;b++)a=a.replace("%{"+b+"}",arguments[b],"g");return a},String.prototype.formatTime=function(a,b){var c=this,d="am",e=a,f=b;return a>12&&(d="pm",e=a%12),10>b&&(f="0"+b),c=c.replace("%H",10>a?"0"+a:a),c=c.replace("%I",10>e?"0"+e:e),c=c.replace("%M",f),c=c.replace("%p",d)},String.prototype.isValidEmail=function(){var a=/^([\w\!\#$\%\&\'\*\+\-\/\=\?\^\`{\|\}\~]+\.)*[\w\!\#$\%\&\'\*\+\-\/\=\?\^\`{\|\}\~]+@((((([a-z0-9]{1}[a-z0-9\-]{0,62}[a-z0-9]{1})|[a-z])\.)+[a-z]{2,})|(\d{1,3}\.){3}\d{1,3}(\:\d{1,5})?)$/i;return a.test(this)},String.prototype.asCSSIdentifier=function(){for(var a=["_","\\.","#","@","\\*",":",","," ","'","&","\\+"],b=["_U_","_D_","_H_","_A_","_S_","_C_","_CO_","_SP_","_SQ_","_AM_","_P_"],c=this,d=0;d<a.length;d++){var e=new RegExp(a[d],"g");c=c.replace(e,b[d])}return/^\d+/.test(c)&&(c="_"+c),c},String.prototype.timeInterval=function(){var a;return a="once_per_hour"==this?3600:"every_minute"==this?60:60*parseInt(this.substr(6))},String.prototype.parseDate=function(a,b){var c,d,e,f,g,h,i,j,k,l;for(c=""+this,d=/%[dembByY]/g,g=new Date,h={year:-1,month:-1,day:-1},i={"%d":[/\d\d/,function(a){return h.day=parseInt(a),h.day<32}],"%e":[/ ?\d?\d/,function(a){return h.day=parseInt(a),h.day<32}],"%m":[/\d\d/,function(a){return h.month=parseInt(a)-1,h.month<12}],"%b":[/[^\d\s\.\/\-]{2,}/,function(b){var c=_.indexOf(a.shortMonths,b);return c>=0&&(h.month=c),c>=0}],"%B":[/[^\d\s\.\/\-]{2,}/,function(b){var c=_.indexOf(a.months,b);return c>=0&&(h.month=c),c>=0}],"%y":[/\d\d/,function(a){var b=parseInt(g.getFullYear().toString().substring(2))+5;return h.year=parseInt(a),h.year<b?h.year+=2e3:h.year+=1900,!0}],"%Y":[/[12]\d\d\d/,function(a){return h.year=parseInt(a),!0}]},e=b.match(d)||[],l=0,j=0;j<e.length;j++)f=e[j],k=(c.match(i[f][0])||[])[0],k&&(c=c.slice(c.indexOf(k)+k.length),i[f][1](k)&&l++);return e.length===l?new Date(h.year,h.month,h.day):new Date(NaN)},Date.prototype.daysUpTo=function(a){var b=[],c=this.getTime(),d=a.getTime();if(c>d){var e=c;c=d,d=e}for(var f=Math.round((d-c)/864e5)+1,g=0;f>g;g++){var h=new Date;h.setTime(c+864e5*g),b.push(h)}return b},Date.prototype.minutesTo=function(a){var b,c;return b=Math.floor(a.valueOf()-this.valueOf())/1e3/60,c=a.getTimezoneOffset()-this.getTimezoneOffset(),b-c},Date.prototype.stringWithSeparator=function(a){var b=""+(this.getMonth()+1),c=""+this.getDate(),d=this.getYear();return 1e3>d&&(d=""+(d+1900)),1==b.length&&(b="0"+b),1==c.length&&(c="0"+c),"-"==a?str=d+"-"+b+"-"+c:str=c+"/"+b+"/"+d,str},Date.prototype.addDays=function(a){var b,c,d;c=this.getTime(),b=new Date(c),c+=864e5*a,this.setTime(c),d=this.getTimezoneOffset()-b.getTimezoneOffset(),0!==d&&(c=this.getTime()+60*d*1e3,this.setTime(c))},Date.prototype.addHours=function(a){var b=this.getTime();b+=36e5*a,this.setTime(b)},Date.prototype.addMinutes=function(a){var b=this.getTime();b+=6e4*a,this.setTime(b)},Date.prototype.beginOfDay=function(){var a=new Date(this.getTime());return a.setHours(0),a.setMinutes(0),a.setSeconds(0),a.setMilliseconds(0),a},Date.prototype.beginOfWeek=function(a){var b=a-this.getDay();b>0&&(b-=7);var c=this.beginOfDay();return c.setHours(12),c.addDays(b),c},Date.prototype.endOfWeek=function(a){var b=this.beginOfWeek(a);return b.addDays(6),b.setHours(23),b.setMinutes(59),b.setSeconds(59),b.setMilliseconds(999),b},Date.prototype.getDayString=function(){var a=this.getYear();1e3>a&&(a+=1900);var b=""+(this.getMonth()+1);1==b.length&&(b="0"+b),a+=b;var c=""+this.getDate();return 1==c.length&&(c="0"+c),a+=c},Date.prototype.getHourString=function(){var a=this.getHours()+"00";return 3==a.length&&(a="0"+a),a},Date.prototype.format=function(a,b){var c,d,e,f,g=[],h=/%[daAmbByYHIMp]/g,i={"%d":this.getUTCDate(),"%e":this.getUTCDate(),"%a":a.shortDays[this.getUTCDay()],"%A":a.days[this.getUTCDay()],"%m":this.getUTCMonth()+1,"%b":a.shortMonths[this.getUTCMonth()],"%B":a.months[this.getUTCMonth()],"%y":this.getUTCFullYear().toString().substring(2),"%Y":this.getUTCFullYear(),"%H":this.getHours(),"%M":this.getMinutes()};for(i["%I"]=i["%H"]>12?i["%H"]%12:i["%H"],i["%p"]=l(i["%H"]<12?"AM":"PM"),i["%d"]=(i["%d"]<10?"0":"")+i["%d"],i["%e"]=(i["%e"]<10?" ":"")+i["%e"],i["%m"]=(i["%m"]<10?"0":"")+i["%m"],i["%H"]=(i["%H"]<10?"0":"")+i["%H"],i["%I"]=(i["%I"]<10?"0":"")+i["%I"],i["%M"]=(i["%M"]<10?"0":"")+i["%M"],c=b.replace(h,"\x00").split("\x00"),d=b.match(h),e=0,f=d.length;f>=e;e++)c.length&&g.push(c.shift()),g.push(i[d[e]]);return g.join("")};
|
|
//# sourceMappingURL=Common.js.map
|