sogo/UI/WebServerResources/js/Mailer.services.js

3 lines
49 KiB
JavaScript
Raw Normal View History

2016-09-27 07:34:10 +02:00
!function(){"use strict";function a(b,c){"function"!=typeof b.then&&(angular.extend(this,b),_.forEach(this.identities,function(a){a.fullName?a.full=a.fullName+" <"+a.email+">":a.full="<"+a.email+">"}),a.$log.debug("Account: "+JSON.stringify(b,void 0,2))),this.fetchAll=!1,angular.isDefined(c)&&c&&(this.fetchAll=!0,this.$getMailboxes())}a.$factory=["$q","$timeout","$log","sgSettings","Resource","Preferences","Mailbox","Message",function(b,c,d,e,f,g,h,i){return angular.extend(a,{$q:b,$timeout:c,$log:d,$$resource:new f(e.activeUser("folderURL")+"Mail",e.activeUser()),$Preferences:g,$Mailbox:h,$Message:i}),a}];try{angular.module("SOGo.MailerUI")}catch(a){angular.module("SOGo.MailerUI",["SOGo.Common"])}angular.module("SOGo.MailerUI").factory("Account",a.$factory),a.$findAll=function(b){return b?a.$unwrapCollection(b):a.$$resource.fetch("","mailAccounts").then(function(b){return a.$unwrapCollection(b)})},a.$unwrapCollection=function(b){var c=[];return angular.forEach(b,function(b,d){b.id=d,c[d]=new a(b)}),a.$accounts=c,c},a.prototype.getLength=function(){return this.$flattenMailboxes().length},a.prototype.getItemAtIndex=function(a){var b;return b=this.$flattenMailboxes(),a>=0&&a<b.length?b[a]:null},a.prototype.$getMailboxes=function(b){var c=this;return!this.$mailboxes||b&&b.reload?a.$Mailbox.$find(this).then(function(b){return c.$mailboxes=b,c.$expanded=!1,a.$Preferences.ready().then(function(){var b,d=function(a){_.forEach(a,function(a){a.$expanded=b.indexOf("/"+a.id)>=0,a.children&&a.children.length>0&&d(a.children)})};a.$Preferences.settings.Mail.ExpandedFolders&&(b=angular.isString(a.$Preferences.settings.Mail.ExpandedFolders)?angular.fromJson(a.$Preferences.settings.Mail.ExpandedFolders):a.$Preferences.settings.Mail.ExpandedFolders,c.$expanded=b.indexOf("/"+c.id)>=0,b.length>0&&d(c.$mailboxes)),a.$accounts&&(c.$expanded|=1==a.$accounts.length),c.$flattenMailboxes({reload:!0})}),c.$mailboxes}):a.$q.when(this.$mailboxes)},a.prototype.$flattenMailboxes=function(b){var c=this,d=[],e=[],f=function(a){_.forEach(a,function(a){d.push(a),(b&&b.all||a.$expanded)&&a.children&&a.children.length>0&&f(a.children)})};return!this.$$flattenMailboxes||b&&(b.reload||b.all)?(f(this.$mailboxes),b&&b.all||(c.$$flattenMailboxes=d,b&&b.saveState&&(_.forEach(a.$accounts,function(a){a.$expanded&&e.push("/"+a.id),_.reduce(a.$$flattenMailboxes,function(a,b){return b.$expanded&&a.push("/"+b.id),a},e)}),a.$$resource.post(null,"saveFoldersState",e)))):d=this.$$flattenMailboxes,d},a.prototype.$getMailboxByType=function(a){var b,c=function(b){var d=_.find(b,function(b){return b.type==a});return d||angular.forEach(b,function(a){!d&&a.children&&a.children.length>0&&(d=c(a.children))}),d};return b=c(this.$mailboxes)},a.prototype.$getMailboxByPath=function(a){var b=null,c=function(b){var d=_.find(b,function(b){return b.path==a});return d||angular.forEach(b,function(a){!d&&a.children&&a.children.length>0&&(d=c(a.children))}),d};return b=c(this.$mailboxes)},a.prototype.$newMailbox=function(b,c){var d=this;return a.$$resource.post(b.toString(),"createFolder",{name:c}).then(function(){d.$getMailboxes({reload:!0})})},a.prototype.updateQuota=function(a){var b,c,d;b=Math.round(1e4*a.usedSpace/a.maxQuota)/100,c=l("quotasFormat"),d=c.formatted(b,Math.round(a.maxQuota/10.24)/100),this.$quota={percent:b,description:d}},a.prototype.$newMessage=function(){var b=this;return a.$$resource.fetch(this.id.toString(),"compose").then(function(c){a.$log.debug("New message (compose): "+JSON.stringify(c,void 0,2));var d=new a.$Message(c.accountId,b.$getMailboxByPath(c.mailboxPath),c);return d}).then(function(b){return a.$$resource.fetch(b.$absolutePath({asDraft:!0}),"edit").then(function(c){return a.$log.debug("New message (edit): "+JSON.stringify(c,void 0,2)),angular.extend(b.editable,c),b.isNew=!0,b})})},a.prototype.$addDelegate=function(b){var c=this,d=a.$q.defer(),e={uid:b.uid};return!b.uid||_.indexOf(_.map(this.delegates,"uid"),b.uid)>-1?d.resolve():a.$$resource.fetch(this.id.toString(),"addDelegate",e).then(function(){c.delegates.push(b),d.resolve(c.users)},function(a,b){d.r
O.markOrUnMarkMessagesAsJunk=H,O.copySelectedMessages=I,O.moveSelectedMessages=J,O.markSelectedMessagesAsFlagged=M,O.markSelectedMessagesAsUnread=N,O.selectAll=K,O.unselectMessages=L,angular.element(a).on("beforeunload",s),b.$on("$destroy",function(){angular.element(a).off("beforeunload",s),_.forEach(R,function(a){k.deregisterHotkey(a)})}),b.$watch(function(){return O.selectedFolder.unseenCount},function(b){var c=Q+" - ";b&&(c+="("+b+") "),c+=O.selectedFolder.name,a.document.title=c}),r(R)}function b(a){return a[0].controller.prototype.resetScroll=function(){"messagesList"==this.$element.parent().attr("id")?this.updateSize():this.scrollTo(0)},a}a.$inject=["$window","$scope","$timeout","$q","$state","$mdDialog","$mdToast","stateAccounts","stateAccount","stateMailbox","sgHotkeys","encodeUriFilter","sgFocus","Dialog","Account","Mailbox"],angular.module("material.components.virtualRepeat").decorator("mdVirtualRepeatContainerDirective",b),b.$inject=["$delegate"],angular.module("SOGo.MailerUI").controller("MailboxController",a)}(),function(){"use strict";function a(a,b,c,d,e,f,g,h,i,j,k,m,n,o,p,q,r,s){function t(a){S.showingAdvancedSearch=!0,S.search.mailbox=a,f(h["gt-md"])||g("left").close()}function u(){S.showingAdvancedSearch=!1,S.service.$virtualMode=!1,Q=S.accounts[0],R=S.searchPreviousMailbox,a.go("mail.account.mailbox",{accountId:Q.id,mailboxId:j(R.path)})}function v(){if(o.selectedFolder.$isLoading)S.virtualMailbox.stopSearch();else{var b,c=[],d=function(a){_.forEach(a,function(a){c.push(a),a.children&&a.children.length>0&&d(a.children)})};S.virtualMailbox=new p(S.accounts[0]),o.$virtualMode||(S.searchPreviousMailbox=o.selectedFolder),o.selectedFolder=S.virtualMailbox,o.$virtualMode=!0,angular.isDefined(S.search.mailbox)?(b=S.accounts[0].$getMailboxByPath(S.search.mailbox),c.push(b),S.search.subfolders&&b.children.length&&d(b.children)):c=S.accounts[0].$flattenMailboxes(),S.virtualMailbox.setMailboxes(c),S.virtualMailbox.startSearch(S.search.match,S.search.params),a.go("mail.account.virtualMailbox",{accountId:S.accounts[0].id})}}function w(a){return S.currentSearchParam=a,i("advancedSearch"),!1}function x(a){if(a.length&&S.currentSearchParam.length){var b=0,c=S.currentSearchParam;return a.startsWith("!")&&(b=1,a=a.substring(1).trim()),S.currentSearchParam="",{searchBy:c,searchInput:a,negative:b}}}function y(a){a.$expanded=!a.$expanded,a.$flattenMailboxes({reload:!0,saveState:!0}),b(function(){angular.element(c).triggerHandler("resize")},150)}function z(a){function b(a,b,c,d){function e(){b.cancel()}var f=this;f.app=c,f.account=new n({id:d.id,name:d.name},(!0)),f.close=e}d.show({templateUrl:a.id+"/subscribe",controller:b,controllerAs:"subscriptions",clickOutsideToClose:!0,escapeToClose:!0,locals:{srcApp:S,srcAccount:a}}).finally(function(){a.$getMailboxes({reload:!0})}),b.$inject=["$scope","$mdDialog","srcApp","srcAccount"]}function A(a){k.prompt(l("New folder"),l("Enter the new name of your folder :")).then(function(b){a.$newMailbox(a.id,b).then(function(){},function(a,c){k.alert(l('An error occured while creating the mailbox "%{0}".',b),l(a.error))})})}function B(a){function b(a,b,c,d){function e(a){return c.$filter(a,d.delegates)}function f(){b.hide()}function g(a){d.$removeDelegate(a.uid).catch(function(a,b){k.alert(l("Warning"),l("An error occured please try again."))})}function h(a){a&&d.$addDelegate(a).then(function(){i.userToAdd="",i.searchText=""},function(a){k.alert(l("Warning"),a)})}var i=this;i.users=d.delegates,i.account=d,i.userToAdd="",i.searchText="",i.userFilter=e,i.closeModal=f,i.removeUser=g,i.addUser=h}d.show({templateUrl:a.id+"/delegation",controller:b,controllerAs:"delegate",clickOutsideToClose:!0,escapeToClose:!0,locals:{User:q,account:a}}),b.$inject=["$scope","$mdDialog","User","account"]}function C(a){S.editMode=a.path,i("mailboxName_"+a.path)}function D(a){a.$reset(),S.editMode=!1}function E(b,c,d){S.editMode!=d.path&&(S.editMode=!1,S.showingAdvancedSearch=!1,S.service.$virtualMode=!1,f(h["gt-md"])||g("left").close(),a.go("mail.account.mailbox",{accountId:c.id,mailboxId:j(d.path)}),b.stopPropa
//# sourceMappingURL=Mailer.services.js.map