sogo/UI/WebServerResources/js/Common.js

4 lines
76 KiB
JavaScript
Raw Normal View History

2017-03-01 15:49:36 +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){if(-1!=d.status)return/^application\/json/.test(d.config.headers.Accept)&&a.$broadcast("http:Error",d),b.reject(d);var e=angular.element('<iframe type="hidden" src="'+UserFolderURL+'recover"></iframe>');e.on("load",function(){var a=c.get("$http");return"GET"==d.config.method?a({method:"GET",url:d.config.url}):"POST"==d.config.method?a({method:"POST",url:d.config.url,data:d.data}):void 0}),document.body.appendChild(e[0])}}}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
this._cheatSheet?(g.$modal.hide(),this._cheatSheet=null):this._cheatSheet=g.$modal.show({clickOutsideToClose:!0,escapeToClose:!0,template:["<md-dialog>"," <md-dialog-content>"," <md-list>",' <md-list-item ng-repeat="(hotkey, keys) in hotkeys">',' <div class="sg-hotkey-container">'," <sg-hotkey>{{keys[0].lkey || hotkey}}</sg-hotkey>"," </div>"," {{keys[0].description}}"," </md-list-item>"," </md-list>"," </md-dialog-content>","</md-dialog>"].join(""),controller:a,locals:{hotkeys:b._hotkeys}})["finally"](function(){b._cheatSheet=null}),a.$inject=["$scope","hotkeys"]},g}var b={8:"backspace",9:"tab",13:"enter",16:"shift",17:"ctrl",18:"alt",19:"pause",20:"caps",27:"escape",32:"space",33:"pageup",34:"pagedown",35:"end",36:"home",37:"left",38:"up",39:"right",40:"down",45:"insert",46:"delete",96:"0",97:"1",98:"2",99:"3",100:"4",101:"5",102:"6",103:"7",104:"8",105:"9",106:"*",107:"+",109:"-",110:".",111:"/",112:"f1",113:"f2",114:"f3",115:"f4",116:"f5",117:"f6",118:"f7",119:"f8",120:"f9",121:"f10",122:"f11",123:"f12"},c={42:"*",63:"?"};this.$get=a,a.$inject=["$rootScope","$window"]}function b(a,b){return angular.extend(b,{$modal:a}),new b}b.$inject=["$mdDialog","$sgHotkeys"],angular.module("SOGo.Common").service("sgHotkeys",b).provider("$sgHotkeys",a)}(),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,g){return e.on("click",function(a){this.hasAttribute("disabled")&&a.stopImmediatePropagation()}),function(e,g,h,i){function j(a,b,c,d,e){var f;if(angular.isDefined(d)){if(f=a(d),!f.constant)throw Error("Expected constant expression for `"+c+"`, but saw `"+d+"`.");return f(b)}return e}function k(a){g[0].hasAttribute("disabled")||e.$apply(function(){var b=i.$viewValue==m?n:m;i.$setViewValue(b,a&&a.type),i.$render()})}function l(){i.$viewValue==m?g.addClass(f):g.removeClass(f)}var m=j(a,e,"sgTrueValue",h.sgTrueValue,!0),n=j(a,e,"sgFalseValue",h.sgFalseValue,!1);i=i||d.fakeNgModel(),c(g),b.expectWithText(g,"aria-label"),g.on("click",k),i.$render=l}}var f="sg-checked";return{restrict:"E",replace:!0,transclude:!0,require:"?ngModel",template:['<button class="md-button sg-checkmark" type="button">'," <md-icon>check</md-ic
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){var b=this.$mdUtil.getClosest(a.target,"sg-time-pane");b||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;o=m.$viewValue,d.sgToggleGridAttr&&(p=d.sgToggleGridAttr,a=_.map(m.$viewValue,d.sgToggleGridAttr)),_.forEach(r,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(o,function(b){return p?b[p]==a:b==a});if(0>b)if(p){var c={};c[p]=a,o.push(c)}else o.push(a);else o.splice(b,1);e.$apply(function(){m.$setViewValue(o),m.$setDirty(),m.$validate(),j(m.$invalid)})}var l,m,n,o,p,q,r=a.find("md-grid-tile");for(m=h[1]||b.fakeNgModel(),m.$render=i,m.$isEmpty=function(a){return!a||0===a.length},q=function(){var a=angular.element(this),b=a.attr("value");a.toggleClass("sg-active"),k(b)},n=0;n<r.length;n++)l=angular.element(r[n]),l.addClass("sg-icon-button"),l.find("figure").addClass("md-icon"),l.on("click",q)}}return{restrict:"A",require:["mdGridList","?ngModel"],compile:d}}a.$inject=["$parse","$mdUtil","$mdColors"],angular.module("SOGo.Common").directive("sgToggleGrid",a)}(),function(){"use strict";function a(a,b){function c(c,d,e,f){var g=[];f.onInputBlur=function(){var c;this.inputHasFocus=!1,c=function(){var a=this.getChipBuffer().trim();this.validateModel();var b=this.ngModelCtrl.$valid;this.userInputNgModelCtrl&&(b&=this.userInputNgModelCtrl.$valid),a&&b&&(this.appendChip(a),this.resetChipBuffer())}.bind(this),this.autocompleteCtrl?(g.push(c),a.addEventListener("click",function(a){for(;g.length>0;){var c=g.splice(0,1)[0];b(function(){b(c)})}},!1)):c()}}return{link:c,require:"mdChips",restrict:"A"}}a.$inject=["$window","$timeout"],angular.module("SOGo.Common").directive("sgTransformOnBlur",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
//# sourceMappingURL=Common.js.map