sogo/UI/WebServerResources/js/Common.js

4 lines
66 KiB
JavaScript
Raw Normal View History

2016-08-05 07:33:14 +02: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){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"}).backgroundPalette("grey",{default:"50","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","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}}).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: 600
this.helper.removeClass("ng-hide"),this.count&&this.count(f)>1?c.text(this.count(f)).removeClass("ng-hide"):c.addClass("ng-hide"),e.debug("emit folder:dragstart"),b.$emit("folder:dragstart",this.folder)):this.startPosition={clientX:a.clientX,clientY:a.clientY},this.dragHasStarted&&(a.shiftKey?this.helper.addClass("sg-draggable-helper--copy"):this.helper.removeClass("sg-draggable-helper--copy"),this.helper.css({top:a.pageY+5+"px",left:a.pageX+5+"px"}))},onDragEnd:function(a){this.startPosition=null,c.off("mousemove",this.bindedOnDrag),this.dragHasStarted&&(e.debug("emit folder:dragend"),b.$emit("folder:dragend",this.folder,a.shiftKey?"copy":"move"),this.dragHasStarted=!1,this.helper.addClass("ng-hide"))}}}return{restrict:"A",link:f}}a.$inject=["$parse","$rootScope","$document","$timeout","$log"],angular.module("SOGo.Common").directive("sgDraggable",a)}(),function(){"use strict";function a(a,b,c,d,e){function f(c,d,e){function f(a){l=!0,d.addClass("sg-droppable-over")}function g(a){l=!1,this.classList.remove("sg-droppable-over"),d.off("mousemove")}var h,i,j,k,l=!1;if(!e.sgDrop)throw Error("sg-droppable requires a sg-drop action.");l=!1,i=a(e.sgDroppable),h=a(e.sgDrop),j=b.$on("folder:dragstart",function(a,b){i(c,{dragFolder:b})&&(d.on("mouseenter",f),d.on("mouseleave",g))}),k=b.$on("folder:dragend",function(a,b,e){d.off("mouseenter"),d.off("mouseleave"),l&&(angular.bind(d[0],g)(a),h(c,{dragFolder:b,dragMode:e}))}),c.$on("destroy",function(){j(),k()})}return{restrict:"A",link:f}}a.$inject=["$parse","$rootScope","$document","$timeout","$log"],angular.module("SOGo.Common").directive("sgDroppable",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 }} {"," 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,"," .bg-folder{{ cssCtrl.ngModel.id }} .md-input {"," 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;"," }"," .contrast-bdr-folder{{ cssCtrl.ngModel.id }} {"," border-color: {{ cssCtrl.contrast(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.pla
m=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)&&m++);return e.length===m?new Date(h.year,h.month,h.day,h.hour,h.minute):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;g<f;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 d<1e3&&(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;return 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)),this},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.firstWeekOfYearForDate=function(a){var b,c,d,e;return b=a.firstWeekOfYear,d=new Date(this.getTime()),d.setMonth(0),d.setDate(1),c=d.getDay(),e="First4DayWeek"==b?(c+a.firstDayOfWeek)%7<4?d.beginOfWeek(a.firstDayOfWeek):d.addDays(7).beginOfWeek(a.firstDayOfWeek):"FirstFullWeek"==b?0===c?d.beginOfWeek(a.firstDayOfWeek):d.addDays(7).beginOfWeek(a.firstDayOfWeek):d.beginOfWeek(a.firstDayOfWeek)},Date.prototype.getWeek=function(a){var b,c,d;return b=this.firstWeekOfYearForDate(a),b.getTime()<this.getTime()?d=1+Math.floor((this.getTime()-b.getTime())/6048e5):(c=new Date(this.getTime()),c.addDays(-7),b=c.firstWeekOfYearForDate(a),d=2+Math.floor((c.getTime()-b.getTime())/6048e5)),d},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();a<1e3&&(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=/%[deaAmbByYUHIMp]/g,i={"%d":this.getDate(),"%e":this.getDate(),"%a":a.shortDays[this.getDay()],"%A":a.days[this.getDay()],"%m":this.getMonth()+1,"%b":a.shortMonths[this.getMonth()],"%B":a.months[this.getMonth()],"%y":this.getFullYear().toString().substring(2),"%Y":this.getFullYear(),"%U":this.getWeek(a),"%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,"\0").split("\0"),d=b.match(h),e=0,f=d.length;e<=f;e++)c.length&&g.push(c.shift()),g.push(i[d[e]]);return g.join("")};
//# sourceMappingURL=Common.js.map