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

3 lines
39 KiB
JavaScript
Raw Normal View History

2016-02-08 18:54:12 +01:00
!function(){"use strict";function a(b){"function"!=typeof b.then&&(angular.extend(this,b),_.each(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(b){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)}),c},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,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,b.length>0&&d(c.$mailboxes)),c.$flattenMailboxes({reload:!0})}),c.$mailboxes}):a.$q.when(this.$mailboxes)},a.prototype.$flattenMailboxes=function(b){var c=this,d=[],e=[],f=function(a){_.each(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&&(_.reduce(d,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};b=c(this.$mailboxes),console.debug(b),console.debug(this.specialMailboxes)},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(_.pluck(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.$removeDelegate=function(b){var c=this,d={uid:b};return a.$$resource.fetch(this.id.toString(),"removeDelegate",d).then(function(){var a=_.indexOf(_.pluck(c.delegates,"uid"),b);a>=0&&c.delegates.splice(a,1)})}}(),function(){"use strict";function a(b,c){if(this.$account=b,"function"!=typeof c.then){if(this.init(c),this.name&&!this.path){var d=a.$$r
a.stopPropagation(),a.preventDefault()}function r(){var a,b,d,e,f,i=p();i.messageCtrl?(a=i.mailboxCtrl.selectedFolder,b=i.messageCtrl.message,d=i.messageCtrl.$state):(a=g,b=h,d=c),a.$deleteMessages([b]).then(function(c){var g=c;if(b=null,angular.isDefined(d)){c>0&&(g-=1,e=a.$messages[g]),c<a.$messages.length&&(f=a.$messages[c]),e?e.isread&&f&&!f.isread&&(g=c,e=f):f&&(g=c,e=f);try{e?(d.go("mail.account.mailbox.message",{messageId:e.uid}),g<a.$topIndex?a.$topIndex=g:g>a.$lastVisibleIndex&&(a.$topIndex=g-(a.$lastVisibleIndex-a.$topIndex))):d.go("mail.account.mailbox")}catch(h){}}z()})}function s(a,b,c){null===E&&(angular.isDefined(c)||(c=[]),E=d.show({parent:angular.element(document.body),targetEvent:a,clickOutsideToClose:!1,escapeToClose:!1,templateUrl:"UIxMailEditor",controller:"MessageEditorController",controllerAs:"editor",locals:{stateAccounts:D.accounts,stateAccount:D.account,stateMessage:b,stateRecipients:c}})["finally"](function(){E=null,z()}))}function t(){c.go("mail.account.mailbox").then(function(){D.message=null,delete g.selectedMessage})}function u(a){var b=D.message.$reply();s(a,b)}function v(a){var b=D.message.$replyAll();s(a,b)}function w(a){var b=D.message.$forward();s(a,b)}function x(a){D.message.$editableContent().then(function(){s(a,D.message)})}function y(){var b=[j.baseURL(),"UIxMailPopupView#/Mail",D.message.accountId,i(i(D.message.$mailbox.path)),D.message.uid].join("/"),c=D.message.$absolutePath();F=a.open(b,c,["width=680","height=520","resizable=1","scrollbars=1","toolbar=0","location=0","directories=0","status=0","menubar=0","copyhistory=0"].join(","))}function z(){a.opener&&a.close()}function A(a,b){var c=D.account.$newMessage();s(a,c,[b]),a.stopPropagation(),a.preventDefault()}function B(){window.location.href=ApplicationBaseURL+"/"+D.mailbox.id+"/saveMessages?uid="+D.message.uid}function C(a){D.showRawSource||D.rawSource?D.showRawSource=!D.showRawSource:o.$$resource.post(D.message.id,"viewsource").then(function(a){D.rawSource=a,D.showRawSource=!0})}var D=this,E=null,F=null;a.$messageController=D,D.$state=c,D.accounts=e,D.account=f,D.mailbox=g,D.message=h,D.service=o,D.tags={searchText:"",selected:""},D.showFlags=h.flags&&h.flags.length>0,D.$showDetailedRecipients=!1,D.showDetailedRecipients=q,D.doDelete=r,D.close=t,D.reply=u,D.replyAll=v,D.forward=w,D.edit=x,D.openPopup=y,D.closePopup=z,D.newMessage=A,D.saveMessage=B,D.toggleRawSource=C,D.showRawSource=!1,a.opener&&(b.$watchCollection("viewer.message.flags",function(a,b){var c;(a||b)&&(c=p(),c.messageCtrl&&c.messageCtrl.service.$timeout(function(){c.messageCtrl.message.flags=a}))}),b.$watch("viewer.message.isflagged",function(a,b){var c=p();c.mailboxCtrl&&c.mailboxCtrl.service.$timeout(function(){var b=_.find(c.mailboxCtrl.selectedFolder.$messages,{uid:D.message.uid});b.isflagged=a})}))}a.$inject=["$window","$scope","$state","$mdDialog","stateAccounts","stateAccount","stateMailbox","stateMessage","encodeUriFilter","sgSettings","sgFocus","Dialog","Account","Mailbox","Message"],angular.module("SOGo.MailerUI").controller("MessageController",a)}(),function(){"use strict";function a(a,b,c,d,e,f,g,h,i,j,k,m,n,o,p){function q(){var b,c={};return a.opener&&a.opener.$mailboxController&&("draft"==a.opener.$mailboxController.selectedFolder.type?(c.draftMailboxCtrl=a.opener.$mailboxController,a.opener.$messageController&&a.opener.$messageController.message.uid==h.uid&&(c.draftMessageCtrl=a.opener.$messageController)):h.origin&&(b=h.origin.message,a.opener.$mailboxController.selectedFolder.$id()==b.$mailbox.$id()&&(c.originMailboxCtrl=a.opener.$mailboxController))),c}function r(){var a,b,c;if(z.message.attachmentAttrs)for(a=0;a<z.message.attachmentAttrs.length;a++)b={name:z.message.attachmentAttrs[a].filename,type:z.message.attachmentAttrs[a].mimetype,size:parseInt(z.message.attachmentAttrs[a].size)},c=new f.FileItem(z.uploader,b),c.progress=100,c.isUploaded=!0,c.isSuccess=!0,c.inlineUrl=z.message.attachmentAttrs[a].url,z.uploader.queue.push(c)}function s(a){a.isUploading?z.uploader.cancelItem(a):(z.message.$deleteAttachment(a.file.name),a.remove())}functi
//# sourceMappingURL=Mailer.services.js.map