sogo/UI/WebServerResources/js/Preferences.services.js
2017-06-02 02:16:11 -04:00

2 lines
6.6 KiB
JavaScript

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