sogo/UI/WebServerResources/js/Preferences.services.js
2017-05-13 01:24:30 -04:00

2 lines
6.3 KiB
JavaScript

!function(){"use strict";function e(){var a=this;this.defaults={},this.settings={},this.defaultsPromise=e.$$resource.fetch("jsonDefaults").then(function(t){var r=t||{},o=_.fromPairs(_.map(r.SOGoMailLabelsColors,function(e,a){return"$"==a.charAt(0)?["_"+a,e]:[a,e]}));return r.SOGoMailLabelsColors=o,_.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(a.defaults,r),a.$mdDateLocaleProvider=e.$mdDateLocaleProvider,angular.extend(a.$mdDateLocaleProvider,r.locale),angular.extend(a.$mdDateLocaleProvider,{firstDayOfWeek:r.SOGoFirstDayOfWeek,firstWeekOfYear:r.SOGoFirstWeekOfYear}),a.$mdDateLocaleProvider.firstDayOfWeek=parseInt(r.SOGoFirstDayOfWeek),a.$mdDateLocaleProvider.weekNumberFormatter=function(e){return l("Week %d",e)},a.$mdDateLocaleProvider.msgCalendar=l("Calender"),a.$mdDateLocaleProvider.msgOpenCalendar=l("Open Calendar"),a.$mdDateLocaleProvider.parseDate=function(e){return e?e.parseDate(a.$mdDateLocaleProvider,r.SOGoShortDateFormat):new Date(NaN)},a.$mdDateLocaleProvider.formatDate=function(e){return e?e.format(a.$mdDateLocaleProvider,e.$dateFormat||r.SOGoShortDateFormat):""},a.$mdDateLocaleProvider.parseTime=function(e){return e?e.parseDate(a.$mdDateLocaleProvider,r.SOGoTimeFormat):new Date(NaN)},a.$mdDateLocaleProvider.formatTime=function(e){return e?e.format(a.$mdDateLocaleProvider,r.SOGoTimeFormat):""},a.defaults}),this.settingsPromise=e.$$resource.fetch("jsonSettings").then(function(t){return t.Calendar&&(t.Calendar.PreventInvitationsWhitelist?t.Calendar.PreventInvitationsWhitelist=_.map(t.Calendar.PreventInvitationsWhitelist,function(t,r){var o=/^(.+)\s<(\S+)>$/.exec(t),n=new e.$User({uid:r,cn:o[1],c_email:o[2]});return n.$$image||a.avatar(n.c_email,32,{no_404:!0}).then(function(e){n.$$image=e}),n}):t.Calendar.PreventInvitationsWhitelist=[]),angular.extend(a.settings,t),a.settings})}e.$factory=["$q","$timeout","$log","$mdDateLocale","sgSettings","Gravatar","Resource","User",function(a,t,r,o,n,s,i,d){return angular.extend(e,{$q:a,$timeout:t,$log:r,$mdDateLocaleProvider:o,$gravatar:s,$$resource:new i(n.activeUser("folderURL"),n.activeUser()),$resourcesURL:n.resourcesURL(),$User:d}),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.$q.all([this.defaultsPromise,this.settingsPromise])},e.prototype.avatar=function(a,t,r){var o=this;return this.ready().then(function(){var n,s=o.defaults.SOGoAlternateAvatar;return n=o.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]=n),n})},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:a.defaults.Vacation.startDate=0,a.defaults.Vacation.endDateEnabled?a.defaults.Vacation.endDate=a.defaults.Vacation.endDate.getTime()/1e3: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