Files
sogo/UI/WebServerResources/js/Preferences.services.js
T
2018-03-07 11:09:20 -05:00

2 lines
7.0 KiB
JavaScript

!function(){"use strict";function a(){var b,c,d,e=this;if(this.defaults={},this.settings={},b=a.$document[0].getElementById("UserDefaults")){try{d=angular.fromJson(b.textContent||b.innerHTML)}catch(b){a.$log.error("Can't parse user's defaults: "+b.message),d={}}d.SOGoMailLabelsColorsKeys=[],d.SOGoMailLabelsColorsValues=[],_.forEach(d.SOGoMailLabelsColors,function(a,b){d.SOGoMailLabelsColorsKeys.push(b),d.SOGoMailLabelsColorsValues.push(a)}),_.forEach(d.SOGoSieveFilters,function(a){_.forEach(a.actions,function(a){"addflag"==a.method&&"$"==a.argument.charAt(0)&&(a.argument="_"+a.argument)})}),d.SOGoRememberLastModule&&(d.SOGoLoginModule="Last"),d.SOGoMailAutoSave=parseInt(d.SOGoMailAutoSave)||0,d.SOGoMailComposeWindowEnabled=angular.isDefined(d.SOGoMailComposeWindow),d.SOGoMailComposeFontSizeEnabled=parseInt(d.SOGoMailComposeFontSize)>0,window.CKEDITOR&&d.SOGoMailComposeFontSizeEnabled&&(window.CKEDITOR.config.fontSize_defaultLabel=d.SOGoMailComposeFontSize,window.CKEDITOR.addCss(".cke_editable { font-size: "+d.SOGoMailComposeFontSize+"px; }")),_.forEach(d.AuxiliaryMailAccounts,function(a){isNaN(parseInt(a.port))&&(a.port=null)}),d.Vacation?(d.Vacation.startDate?d.Vacation.startDate=new Date(1e3*parseInt(d.Vacation.startDate)):(d.Vacation.startDateEnabled=0,d.Vacation.startDate=new Date,d.Vacation.startDate=d.Vacation.startDate.beginOfDay(),d.Vacation.startDate.addDays(1)),d.Vacation.endDate?d.Vacation.endDate=new Date(1e3*parseInt(d.Vacation.endDate)):(d.Vacation.endDateEnabled=0,d.Vacation.endDate=new Date(d.Vacation.startDate.getTime()),d.Vacation.endDate.addDays(1)),d.Vacation.autoReplyEmailAddresses&&d.Vacation.autoReplyEmailAddresses.length?d.Vacation.autoReplyEmailAddresses=d.Vacation.autoReplyEmailAddresses.join(","):delete d.Vacation.autoReplyEmailAddresses):d.Vacation={},angular.isUndefined(d.Vacation.autoReplyEmailAddresses)&&angular.isDefined(window.defaultEmailAddresses)&&(d.Vacation.autoReplyEmailAddresses=window.defaultEmailAddresses),angular.isUndefined(d.Vacation.daysBetweenResponse)&&(d.Vacation.daysBetweenResponse=7),angular.isUndefined(d.Vacation.startDate)&&(d.Vacation.startDateEnabled=0,d.Vacation.startDate=new Date),angular.isUndefined(d.Vacation.endDate)&&(d.Vacation.endDateEnabled=0,d.Vacation.endDate=new Date),d.Forward&&d.Forward.forwardAddress&&(d.Forward.forwardAddress=d.Forward.forwardAddress.join(",")),angular.isUndefined(d.SOGoCalendarCategoriesColors)&&(d.SOGoCalendarCategoriesColors={},d.SOGoCalendarCategories=[]),angular.isUndefined(d.SOGoContactsCategories)?d.SOGoContactsCategories=[]:d.SOGoContactsCategories=_.compact(d.SOGoContactsCategories),angular.extend(e.defaults,d),e.$mdDateLocaleProvider=a.$mdDateLocaleProvider,angular.extend(e.$mdDateLocaleProvider,d.locale),angular.extend(e.$mdDateLocaleProvider,{firstDayOfWeek:d.SOGoFirstDayOfWeek,firstWeekOfYear:d.SOGoFirstWeekOfYear}),e.$mdDateLocaleProvider.firstDayOfWeek=parseInt(d.SOGoFirstDayOfWeek),e.$mdDateLocaleProvider.weekNumberFormatter=function(a){return l("Week %d",a)},e.$mdDateLocaleProvider.msgCalendar=l("Calender"),e.$mdDateLocaleProvider.msgOpenCalendar=l("Open Calendar"),e.$mdDateLocaleProvider.parseDate=function(a){return a?a.parseDate(e.$mdDateLocaleProvider,e.defaults.SOGoShortDateFormat):new Date(NaN)},e.$mdDateLocaleProvider.formatDate=function(a){return a?a.format(e.$mdDateLocaleProvider,a.$dateFormat||e.defaults.SOGoShortDateFormat):""},e.$mdDateLocaleProvider.parseTime=function(a){return a?a.parseDate(e.$mdDateLocaleProvider,e.defaults.SOGoTimeFormat):new Date(NaN)},e.$mdDateLocaleProvider.formatTime=function(a){return a?a.format(e.$mdDateLocaleProvider,e.defaults.SOGoTimeFormat):""}}if(c=a.$document[0].getElementById("UserSettings")){try{d=angular.fromJson(c.textContent||c.innerHTML)}catch(b){a.$log.error("Can't parse user's settings: "+b.message),d={}}d.Calendar&&(d.Calendar.PreventInvitationsWhitelist?d.Calendar.PreventInvitationsWhitelist=_.map(d.Calendar.PreventInvitationsWhitelist,function(b,c){var d=/^(.+)\s<(\S+)>$/.exec(b),f=new a.$User({uid:c,cn:d[1],c_email:d[2]});return f.$$image||(f.$$image=e.avatar(f.c_email,32,{no_404:!0})),f}):d.Calendar.PreventInvitationsWhitelist=[]),angular.extend(e.settings,d)}}a.$factory=["$document","$q","$timeout","$log","$mdDateLocale","sgSettings","Gravatar","Resource","User",function(b,c,d,e,f,g,h,i,j){return angular.extend(a,{$document:b,$q:c,$timeout:d,$log:e,$mdDateLocaleProvider:f,$gravatar:h,$$resource:new i(g.activeUser("folderURL"),g.activeUser()),$resourcesURL:g.resourcesURL(),$User:j}),new a}];try{angular.module("SOGo.PreferencesUI")}catch(a){angular.module("SOGo.PreferencesUI",["SOGo.Common"])}angular.module("SOGo.PreferencesUI").factory("Preferences",a.$factory),a.prototype.ready=function(){return a.$log.warn("Preferences.ready is deprecated -- access settings/defaults directly."),a.$q.when(!0)},a.prototype.avatar=function(b,c,d){var e,f=this,g=f.defaults.SOGoAlternateAvatar;return e=f.defaults.SOGoGravatarEnabled?a.$gravatar(b,c,g,d):[a.$resourcesURL,"img","ic_person_grey_24px.svg"].join("/"),d&&d.dstObject&&d.dstAttr&&(d.dstObject[d.dstAttr]=e),e},a.prototype.$save=function(){return a.$$resource.save("Preferences",this.$omit(!0)).then(function(a){return a})},a.prototype.$omit=function(a){var b,c;return b={},c={},angular.forEach(this,function(c,d){"constructor"!=d&&"$"!=d[0]&&(a?b[d]=angular.copy(c):b[d]=c)}),b.defaults.SOGoMailLabelsColors={},_.forEach(b.defaults.SOGoMailLabelsColorsKeys,function(a,c){b.defaults.SOGoMailLabelsColors[a]=b.defaults.SOGoMailLabelsColorsValues[c]}),delete b.defaults.SOGoMailLabelsColorsKeys,delete b.defaults.SOGoMailLabelsColorsValues,_.forEach(b.defaults.SOGoSieveFilters,function(a){_.forEach(a.actions,function(a){"addflag"==a.method&&"_"==a.argument.charAt(0)&&"$"==a.argument.charAt(1)&&(a.argument=a.argument.substring(1))})}),b.defaults.SOGoMailComposeWindowEnabled||delete b.defaults.SOGoMailComposeWindow,delete b.defaults.SOGoMailComposeWindowEnabled,b.defaults.SOGoMailComposeFontSizeEnabled||(b.defaults.SOGoMailComposeFontSize=0),delete b.defaults.SOGoMailComposeFontSizeEnabled,b.defaults.Vacation&&(b.defaults.Vacation.startDateEnabled?b.defaults.Vacation.startDate=b.defaults.Vacation.startDate.getTime()/1e3:(delete b.defaults.Vacation.startDateEnabled,b.defaults.Vacation.startDate=0),b.defaults.Vacation.endDateEnabled?b.defaults.Vacation.endDate=b.defaults.Vacation.endDate.getTime()/1e3:(delete b.defaults.Vacation.endDateEnabled,b.defaults.Vacation.endDate=0),b.defaults.Vacation.autoReplyEmailAddresses?b.defaults.Vacation.autoReplyEmailAddresses=_.filter(b.defaults.Vacation.autoReplyEmailAddresses.split(","),function(a){return a.length}):b.defaults.Vacation.autoReplyEmailAddresses=[]),b.defaults.Forward&&b.defaults.Forward.forwardAddress&&(b.defaults.Forward.forwardAddress=b.defaults.Forward.forwardAddress.split(",")),b.settings.Calendar&&b.settings.Calendar.PreventInvitationsWhitelist&&(_.forEach(b.settings.Calendar.PreventInvitationsWhitelist,function(a){c[a.uid]=a.$shortFormat()}),b.settings.Calendar.PreventInvitationsWhitelist=c),b}}();
//# sourceMappingURL=Preferences.services.js.map