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

3 lines
36 KiB
JavaScript
Raw Normal View History

2015-12-11 21:44:55 +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.$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.create("createFolder",this.name);this.$unwrap(d)}}else this.$unwrap(c)}a.$factory=["$q","$timeout","$log","sgSettings","Resource","Message","Acl","Preferences","sgMailbox_PRELOAD",function(b,c,d,e,f,g,h,
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){function m(){var a,b,c;if(u.message.attachmentAttrs)for(a=0;a<u.message.attachmentAttrs.length;a++)b={name:u.message.attachmentAttrs[a].filename,type:u.message.attachmentAttrs[a].mimetype,size:parseInt(u.message.attachmentAttrs[a].size)},c=new d.FileItem(u.uploader,b),c.progress=100,c.isUploaded=!0,c.isSuccess=!0,c.inlineUrl=u.message.attachmentAttrs[a].url,u.uploader.queue.push(c)}function n(a){a.isUploading?u.uploader.cancelItem(a):(u.message.$deleteAttachment(a.file.name),a.remove())}function o(){u.autosave&&h.cancel(u.autosave),b.cancel()}function p(){u.message.$save().then(function(a){c.show(c.simple().content(l("Your email has been saved")).position("top right").hideDelay(3e3))})}function q(){u.autosave&&h.cancel(u.autosave),u.message.$send().then(function(a){c.show(c.simple().content(l("Your email has been sent")).position("top right").hideDelay(3e3)),b.hide()})}function r(a){return j.$filterAll(a)}function s(a){var b=[];return angular.isString(a)?a:(a.$$fullname&&b.push(a.$$fullname),a.$$email&&b.push("<"+a.$$email+">"),b.join(" "))}function t(){u.message.$save(),k.defaults.SOGoMailAutoSave&&(u.autosave=h(u.autosaveDrafts,1e3*k.defaults.SOGoMailAutoSave*60))}var u=this;u.addRecipient=s,u.autocomplete={to:{},cc:{},bcc:{}},u.autosave=null,u.autosaveDrafts=t,u.hideCc=!0,u.hideBcc=!0,u.cancel=o,u.save=p,u.send=q,u.removeAttachment=n,u.contactFilter=r,u.identities=_.pluck(_.flatten(_.pluck(e,"identities")),"full"),u.uploader=new d({url:f.$absolutePath({asDraft:!0})+"/save",autoUpload:!0,alias:"attachments",removeAfterUpload:!1,onSuccessItem:function(a,b,c,d){f.$setUID(b.uid),f.$reload({asDraft:!1}),a.inlineUrl=b.lastAttachmentAttrs[0].url},onCancelItem:function(a,b,c,d){f.$deleteAttachment(a.file.name),this.removeFromQueue(a)},onErrorItem:function(a,b,c,d){}}),"reply"==a.actionName?f.$reply().then(function(a){u.message=a,u.hideCc=!a.editable.cc||0===a.editable.cc.length,u.hideBcc=!a.editable.bcc||0===a.editable.bcc.length}):"replyall"==a.actionName?f.$replyAll().then(function(a){u.message=a,u.hideCc=!a.editable.cc||0===a.editable.cc.length,u.hideBcc=!a.editable.bcc||0===a.editable.bcc.length}):"forward"==a.actionName?f.$forward().then(function(a){u.message=a,m()}):angular.isDefined(f)&&(u.message=f,m()),angular.isDefined(g)&&(u.message.editable.to=_.union(u.message.editable.to,_.pluck(g,"full"))),k.ready().then(function(){k.defaults.SOGoMailAutoSave&&(u.autosave=h(u.autosaveDrafts,1e3*k.defaults.SOGoMailAutoSave*60)),u.localeCode=k.defaults.LocaleCode})}function b(a,b){a.closeToast=function(){b.hide()}}a.$inject=["$stateParams","$mdDialog","$mdToast","FileUploader","stateAccounts","stateMessage","stateRecipients","$timeout","Dialog","AddressBook","Preferences"],b.$inject=["$scope","$mdToast"],angular.module("SOGo.MailerUI").controller("SendMessageToastController",b).controller("MessageEditorController",a)}(),function(){"use strict";function a(){function a(a,b,c,d){d.pathToAttachment=c.sgImipPath}return{restrict:"A",link:a,controller:"sgImipController"}}function b(a,b){var c=this;a.delegateInvitation=!1,a.delegatedTo="",a.searchText="",a.userFilter=function(a){return b.$filter(a)},a.iCalendarAction=function(b){var d;"delegate"==b&&(d={receiveUpdates:!1,delegatedTo:a.delegatedTo.c_email}),a.viewer.message.$imipAction(c.pathToAttachment,b,d)}}b.$inject=["$scope","User"],angular.module("SOGo.MailerUI").controller("sgImipController",b).directive("sgImip",a)}(),function(){"
//# sourceMappingURL=Mailer.services.js.map