sogo/UI/WebServerResources/js/Common.js

4 lines
76 KiB
JavaScript
Raw Normal View History

2017-03-09 07:26:19 +01:00
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,e){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:"fafafa",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"}),DebugEnabled||(a.debugEnabled(!1),b.debugInfoEnabled(!1),e.disableWarnings(),d.generateThemesOnDemand(!0)),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)&&/^[\n\r ]*<!DOCTYPE html>/.test(c.data)?(a.location.reload(!0),b.reject()):c}}}function c(a,b,c){return{responseError:function(d){var e,f;if(/^application\/json/.test(d.config.headers.Accept)){if(d.status==-1)return e=b.defer(),f=angular.element('<iframe class="ng-hide" src="'+UserFolderURL+'recover"></iframe>'),f.on("load",function(){c.get("$http")(d.config).then(e.resolve,e.reject),f.remove()}),document.body.appendChild(f[0]),e.promise;a.$broadcast("http:Error",d)}return b.reject(d)}}}angular.module("SOGo.Common",["ngAnimate","ngMessages","ngSanitize","ngMaterial","mdColors"]).value("sgSettings",{isPopup:document.body.classList.contains("popup"),baseURL:function(){return ApplicationBaseURL||null},resourcesURL:function(){return ResourcesURL||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,help:HelpURL||null,logoff:UserLogoffPath||null}};return a?b[a]:b},minimumSearchLength:function(){return angular.isNumber(minimumSearchLength)?minimumSearchLength:2}}).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","#33FF
2017-03-02 07:27:34 +01:00
;return!this.$confirmation&&(_.some(_.values(this.rights))&&("anonymous"==this.uid?"AddressBook"==a.constructor.name?b=l('Potentially anyone on the Internet will be able to access your address book "%{0}", even if they do not have an account on this system. Is this information suitable for the public Internet?',a.name):"Calendar"==a.constructor.name&&(b=l('Potentially anyone on the Internet will be able to access your calendar "%{0}", even if they do not have an account on this system. Is this information suitable for the public Internet?',a.name)):"anyone"!=this.uid&&"<default>"!=this.uid||("AddressBook"==a.constructor.name?b=l('Any user with an account on this system will be able to access your address book "%{0}". Are you certain you trust them all?',a.name):"Calendar"==a.constructor.name?b=l('Any user with an account on this system will be able to access your calendar "%{0}". Are you certain you trust them all?',a.name):"Mailbox"==a.constructor.name&&(b=l('Any user with an account on this system will be able to access your mailbox "%{0}". Are you certain you trust them all?',a.name)))),this.$confirmation=b,b)},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.$shadowRights&&(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){function b(a,b,c,d){var e,f=b.find("img"),g=b.find("md-icon"),h=angular.element(g[0]),i=angular.element(g[1]);c.size&&(f.attr("width",c.size),f.attr("height",c.size),h.css("font-size",c.size+"px"),i.css("font-size",parseInt(.4*c.size)+"px")),angular.isDefined(c.ngDisabled)&&(e=a.$watch(c.ngDisabled,function(a){c.disabled&&i.css({display:"block"}),e()})),d.img=f,d.genericImg=h}return{restrict:"AE",scope:{},bindToController:{size:"@",email:"=sgEmail",src:"=sgSrc"},transclude:!0,template:['<div class="sg-icon-badge-container">'," <md-icon ng-transclude></md-icon>",' <md-icon class="md-warn sg-icon--badge sg-icon--badge-bottom"',' style="display: none">not_interested</md-icon>',' <img class="ng-hide" ng-src="{{vm.url}}">',"</div>"].join(""),link:b,controller:"sgAvatarImageController",controllerAs:"vm"}}function b(a,b,c,d,e,f){function g(a){var b=f(a,k.size,e.defaults.SOGoAlternateAvatar);c({method:"GET",url:b,cache:!0,headers:{Accept:"image/*"}}).then(function(){k.url||(k.url=b,k.urlEmail=a,i())},function(){h()})}function h(){k.url=null,k.urlEmail=null,k.img.addClass("ng-hide"),k.genericImg.removeClass("ng-hide")}function i(){k.genericImg.addClass("ng-hide"),k.img.removeClass("ng-hide")}function j(){b.addClass("sg-avatar-image--zoomable"),l=function(){b.toggleClass("sg-avatar-image--zoom")},b.on("click",l)}var k,l;k=this,a.$on("$destroy",function(){l&&b.off("click",l)}),e.ready().then(function(){a.$watch(function(){return k.email},function(a,b){a&&k.urlEmail!=a?(h(),e.defaults.SOGoGravatarEnabled&&g(a)):a||h()})}),"sg-src"in b[0].attributes&&a.$watch(function(){return k.src},function(a){a&&(k.url=a,k.urlEmail=""+k.email,j(),i())})}a.$inject=["$parse"],b.$inject=["$scope","$element","$http","$q","Preferences","Gravatar"],angular.module("SOGo.Common").directive("sgAvatarImage",a).controller("sgAvatarImageController",b)}(),function(){"use strict";function a(a,b,c,d){function e(e,f){return e.on("click",function(a){this.hasAttribute("disabled")&&a.stopImmediatePropagation()}),function(e,f,g,h){function i(a,b,c,d,e){var f;if(angular.isDefined(d)){if(f=a(d),!f.constant)throw Error("Expected constant expression for
2017-03-24 06:24:52 +01:00
b.prototype.detachTimePane=function(){this.$element.removeClass("sg-timepicker-open"),angular.element(document.body).removeClass("md-datepicker-is-showing"),this.timePane.classList.remove("md-pane-open"),this.timePane.classList.remove("md-timepicker-pos-adjusted"),this.isTimeOpen&&this.$mdUtil.enableScrolling(),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.$mdUtil.disableScrollAround(this.timePane),this.attachTimePane(),this.evalAttr("ngFocus");var b=this;this.$mdUtil.nextTick(function(){b.documentElement.on("click touchstart",b.bodyClickHandler)},!1),window.addEventListener(this.windowEventName,this.windowEventHandler)}},b.prototype.closeTimePane=function(){if(this.isTimeOpen){var a=this;a.detachTimePane(),a.ngModelCtrl.$setTouched(),a.evalAttr("ngBlur"),a.documentElement.off("click touchstart",a.bodyClickHandler),window.removeEventListener(a.windowEventName,a.windowEventHandler),a.timePaneOpenedFrom.focus(),a.timePaneOpenedFrom=null,a.isTimeOpen=!1}},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){a||this.ngModelCtrl.$setTouched(),this.evalAttr(a?"ngFocus":"ngBlur"),this.isFocused=a},b.prototype.handleBodyClick=function(a){if(this.isTimeOpen){this.$mdUtil.getClosest(a.target,"sg-time-pane")||this.closeTimePane(),this.$scope.$digest()}},b.prototype.handleWindowBlur=function(){this.inputFocusedOnWindowBlur=document.activeElement===this.inputElement},b.prototype.evalAttr=function(a){this.$attrs[a]&&this.$scope.$parent.$eval(this.$attrs[a])}}(),function(){"use strict";function a(a,b,c){function d(a,d){return function(e,f,g,h){function i(){var a=m.$viewValue;r=m.$viewValue,d.sgToggleGridAttr&&(o=d.sgToggleGridAttr,a=_.map(m.$viewValue,d.sgToggleGridAttr)),_.forEach(q,function(b){var c=angular.element(b);_.includes(a,c.attr("value"))&&c.addClass("sg-active")}),m.$validate(),j(m.$invalid)}function j(a){var b=f.parent().children()[0];a?(f.addClass("sg-toggle-grid-invalid"),"LABEL"==b.tagName&&(b.style.color=c.getThemeColor("warn"))):(f.removeClass("sg-toggle-grid-invalid"),"LABEL"==b.tagName&&(b.style.color=""))}function k(a){var b=_.findIndex(r,function(b){return o?b[o]==a:b==a});if(b<0)if(o){var c={};c[o]=a,r.push(c)}else r.push(a);else r.splice(b,1);e.$apply(function(){m.$setViewValue(r),m.$setDirty(),m.$validate(),j(m.$invalid)})}var l,m,n,o,p,q=a.find("md-grid-tile"),r=[];for(m=h[1]||b.fakeNgModel(),m.$render=i,m.$isEmpty=function(a){return!a||0===a.length},p=function(){var a=angular.element(this),b=a.attr("value");a.toggleClass("sg-active"),k(b)},n=0;n<q.length;n++)l=angular.element(q[n]),l.addClass("sg-icon-button"),l.find("figure").addClass("md-icon"),l.on("click",p)}}return{restrict:"A",require:["mdGridList","?ngModel"],compile:d}}a.$inject=["$parse","$mdUtil","$mdColors"],angular.module("SOGo.Common").directive("sgToggleGrid",a)}(),String.prototype.endsWith=function(a){return this.indexOf(a,this.length-a.length)!==-1},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.indexO
//# sourceMappingURL=Common.js.map