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

3 lines
51 KiB
JavaScript
Raw Normal View History

2016-10-18 07:17:31 +02:00
!function(){"use strict";function a(b){"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)))}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.reject(l("An error occured please try again."))}),d.promise},a.prototype.$removeDeleg
var a=O.selectedFolder.$selectedMessages();_.size(a)>0&&O.selectedFolder.$flagMessages(a,"\\Flagged","add").then(function(a){_.forEach(a,function(a){a.isflagged=!0})})}function N(){var a=O.selectedFolder.$selectedMessages();_.size(a)>0&&O.selectedFolder.$flagMessages(a,"seen","remove").then(function(a){_.forEach(a,function(a){a.isread=!1,a.$mailbox.unseenCount++})})}var O=this,P=null,Q=angular.element(a.document).find("title").attr("sg-default")||"SOGo",R=[];a.$mailboxController=O,O.service=q,O.accounts=h,O.account=i,O.selectedFolder=j,O.selectMessage=C,O.toggleMessageSelection=D,O.sort=t,O.sortedBy=u,O.searchMode=v,O.cancelSearch=w,O.newMessage=x,O.mode={search:!1,multiple:0},O.confirmDeleteSelectedMessages=G,O.markOrUnMarkMessagesAsJunk=H,O.copySelectedMessages=I,O.moveSelectedMessages=J,O.markSelectedMessagesAsFlagged=M,O.markSelectedMessagesAsUnread=N,O.selectAll=K,O.unselectMessages=L,j.selectFolder(),r(R),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})}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,t,u){function v(a){a.push(o.createHotkey({key:"backspace",description:l("Delete selected message or folder"),callback:function(){q.selectedFolder&&!q.selectedFolder.hasSelectedMessage()&&L(q.selectedFolder)}})),_.forEach(a,function(a){o.registerHotkey(a)})}function w(a){V.showingAdvancedSearch=!0,V.search.mailbox=a,g(i["gt-md"])||h("left").close()}function x(){V.showingAdvancedSearch=!1,V.service.$virtualMode=!1,T=V.accounts[0],U=V.searchPreviousMailbox,b.go("mail.account.mailbox",{accountId:T.id,mailboxId:k(U.path)})}function y(){if(q.selectedFolder.$isLoading)V.virtualMailbox.stopSearch();else{var a,c=[],d=function(a){_.forEach(a,function(a){c.push(a),a.children&&a.children.length>0&&d(a.children)})};V.virtualMailbox=new r(V.accounts[0]),q.$virtualMode||(V.searchPreviousMailbox=q.selectedFolder),q.selectedFolder=V.virtualMailbox,q.$virtualMode=!0,angular.isDefined(V.search.mailbox)?(a=V.accounts[0].$getMailboxByPath(V.search.mailbox),c.push(a),V.search.subfolders&&a.children.length&&d(a.children)):c=V.accounts[0].$flattenMailboxes(),V.virtualMailbox.setMailboxes(c),V.virtualMailbox.startSearch(V.search.match,V.search.params),b.go("mail.account.virtualMailbox",{accountId:V.accounts[0].id})}}function z(a){return V.currentSearchParam=a,j("advancedSearch"),!1}function A(a){if(a.length&&V.currentSearchParam.length){var b=0,c=V.currentSearchParam;return a.startsWith("!")&&(b=1,a=a.substring(1).trim()),V.currentSearchParam="",{searchBy:c,searchInput:a,negative:b}}}function B(a){a.$expanded=!a.$expanded,a.$flattenMailboxes({reload:!0,saveState:!0}),c(function(){angular.element(d).triggerHandler("resize")},150)}function C(a){function b(a,b,c,d){function e(){b.cancel()}var f=this;f.loading=!0,f.filter={name:""},f.metadataForFolder=c,f.account=new p({id:d.id,name:d.name}),f.close=e,f.account.$getMailboxes().then(function(){f.loading=!1})}e.show({templateUrl:a.id+"/subscribe",controller:b,controllerAs:"subscriptions",clickOutsideToClose:!0,escapeToClose:!0,locals:{metadataForFolder:O,srcAccount:a}}).finally(function(){a.$getMailboxes({reload:!0})}),b.$inject=["$scope","$mdDialog","metadataForFolder","srcAccount"]}function D(a){m.prompt(l("New folder"),l("Enter the new name of your folder :")).then(function(b){a.$newM
//# sourceMappingURL=Mailer.services.js.map