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

3 lines
36 KiB
JavaScript
Raw Normal View History

2016-01-04 21:59:01 +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})})},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.$$resource.cre
a.preventDefault()}function A(){window.location.href=ApplicationBaseURL+"/"+C.mailbox.id+"/saveMessages?uid="+C.message.uid}function B(a){C.showRawSource||C.rawSource?C.showRawSource=!C.showRawSource:o.$$resource.post(C.message.id,"viewsource").then(function(a){C.rawSource=a,C.showRawSource=!0})}var C=this,D=null,E=null;C.accounts=e,C.account=f,C.mailbox=g,C.message=h,C.service=o,C.tags={searchText:"",selected:""},C.showFlags=h.flags&&h.flags.length>0,C.$showDetailedRecipients=!1,C.showDetailedRecipients=p,C.doDelete=q,C.close=s,C.reply=t,C.replyAll=u,C.forward=v,C.edit=w,C.openPopup=x,C.closePopup=y,C.newMessage=z,C.saveMessage=A,C.toggleRawSource=B,C.showRawSource=!1,b.$watchCollection("viewer.message.flags",function(a,b){_.each(_.difference(b,a),function(a){C.message.removeTag(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){function o(){var a,b,c;if(w.message.attachmentAttrs)for(a=0;a<w.message.attachmentAttrs.length;a++)b={name:w.message.attachmentAttrs[a].filename,type:w.message.attachmentAttrs[a].mimetype,size:parseInt(w.message.attachmentAttrs[a].size)},c=new e.FileItem(w.uploader,b),c.progress=100,c.isUploaded=!0,c.isSuccess=!0,c.inlineUrl=w.message.attachmentAttrs[a].url,w.uploader.queue.push(c)}function p(a){a.isUploading?w.uploader.cancelItem(a):(w.message.$deleteAttachment(a.file.name),a.remove())}function q(){w.autosave&&i.cancel(w.autosave),c.cancel()}function r(){w.message.$save().then(function(a){d.show(d.simple().content(l("Your email has been saved")).position("top right").hideDelay(3e3))})}function s(){w.autosave&&i.cancel(w.autosave),w.message.$send().then(function(a){d.show(d.simple().content(l("Your email has been sent")).position("top right").hideDelay(3e3)),c.hide()})}function t(a){return k.$filterAll(a),k.$cards}function u(a,b){var c,d,e;return angular.isString(a)?a:(c=w.message.editable[b],"vlist"==a.c_component?angular.isDefined(a.refs)&&a.refs.length?_.each(a.refs,function(a){a.email.length&&c.push(a.$shortFormat())}):(e=m.$find(a.container,a.c_name),e.$id().then(function(a){_.forEach(e.refs,function(a){a.email.length&&c.push(a.$shortFormat())})})):d=a.$shortFormat(),d?d:null)}function v(){w.message.$save(),n.defaults.SOGoMailAutoSave&&(w.autosave=i(w.autosaveDrafts,1e3*n.defaults.SOGoMailAutoSave*60))}var w=this,x=186;w.addRecipient=u,w.autocomplete={to:{},cc:{},bcc:{}},w.autosave=null,w.autosaveDrafts=v,w.hideCc=!0,w.hideBcc=!0,w.cancel=q,w.save=r,w.send=s,w.removeAttachment=p,w.contactFilter=t,w.identities=_.pluck(_.flatten(_.pluck(f,"identities")),"full"),w.recipientSeparatorKeys=[b.KEY_CODE.ENTER,b.KEY_CODE.COMMA,x],w.uploader=new e({url:g.$absolutePath({asDraft:!0})+"/save",autoUpload:!0,alias:"attachments",removeAfterUpload:!1,onSuccessItem:function(a,b,c,d){g.$setUID(b.uid),g.$reload({asDraft:!1}),a.inlineUrl=b.lastAttachmentAttrs[0].url},onCancelItem:function(a,b,c,d){g.$deleteAttachment(a.file.name),this.removeFromQueue(a)},onErrorItem:function(a,b,c,d){}}),"reply"==a.actionName?g.$reply().then(function(a){w.message=a,w.hideCc=!a.editable.cc||0===a.editable.cc.length,w.hideBcc=!a.editable.bcc||0===a.editable.bcc.length}):"replyall"==a.actionName?g.$replyAll().then(function(a){w.message=a,w.hideCc=!a.editable.cc||0===a.editable.cc.length,w.hideBcc=!a.editable.bcc||0===a.editable.bcc.length}):"forward"==a.actionName?g.$forward().then(function(a){w.message=a,o()}):angular.isDefined(g)&&(w.message=g,o()),angular.isDefined(h)&&(w.message.editable.to=_.union(w.message.editable.to,_.pluck(h,"full"))),n.ready().then(function(){n.defaults.SOGoMailAutoSave&&(w.autosave=i(w.autosaveDrafts,1e3*n.defaults.SOGoMailAutoSave*60)),w.localeCode=n.defaults.LocaleCode})}function b(a,b){a.closeToast=function(){b.hide()}}a.$inject=["$stateParams","$mdConstant","$mdDialog","$mdToast","FileUploader","stateAccounts","stateMessage
//# sourceMappingURL=Mailer.services.js.map