2 lines
68 KiB
JavaScript
2 lines
68 KiB
JavaScript
!function(){"use strict";function e(t){"function"!=typeof t.then&&(angular.extend(this,t),_.forEach(this.identities,function(e){e.fullName?e.full=e.fullName+" <"+e.email+">":e.full="<"+e.email+">"}),e.$log.debug("Account: "+JSON.stringify(t,void 0,2)))}e.$factory=["$q","$timeout","$log","sgSettings","Resource","Preferences","Mailbox","Message",function(t,n,s,o,i,a,r,l){return angular.extend(e,{$q:t,$timeout:n,$log:s,$$resource:new i(o.activeUser("folderURL")+"Mail",o.activeUser()),$Preferences:a,$Mailbox:r,$Message:l}),e}];try{angular.module("SOGo.MailerUI")}catch(e){angular.module("SOGo.MailerUI",["SOGo.Common"])}angular.module("SOGo.MailerUI").factory("Account",e.$factory),e.$findAll=function(t){return t?e.$unwrapCollection(t):e.$$resource.fetch("","mailAccounts").then(function(t){return e.$unwrapCollection(t)})},e.$unwrapCollection=function(t){var n=[];return angular.forEach(t,function(t,s){t.id=s,n[s]=new e(t)}),e.$accounts=n,n},e.prototype.getLength=function(){return this.$flattenMailboxes().length},e.prototype.getItemAtIndex=function(e){var t;return t=this.$flattenMailboxes(),e>=0&&e<t.length?t[e]:null},e.prototype.$getMailboxes=function(t){var n=this;return!this.$mailboxes||t&&t.reload?e.$Mailbox.$find(this,t).then(function(t){n.$mailboxes=t,n.$expanded=!1;var s,o=function(e){_.forEach(e,function(e){e.$expanded=s.indexOf("/"+e.id)>=0,e.children&&e.children.length>0&&o(e.children)})};return e.$Preferences.settings.Mail.ExpandedFolders&&(s=angular.isString(e.$Preferences.settings.Mail.ExpandedFolders)?angular.fromJson(e.$Preferences.settings.Mail.ExpandedFolders):e.$Preferences.settings.Mail.ExpandedFolders,n.$expanded=s.indexOf("/"+n.id)>=0,s.length>0&&o(n.$mailboxes)),e.$accounts&&(n.$expanded|=1==e.$accounts.length),n.$flattenMailboxes({reload:!0}),n.$mailboxes}):e.$q.when(this.$mailboxes)},e.prototype.$flattenMailboxes=function(t){var n=this,s=[],o=[],i=function(e){_.forEach(e,function(e){s.push(e),(t&&t.all||e.$expanded)&&e.children&&e.children.length>0&&i(e.children)})};return!this.$$flattenMailboxes||t&&(t.reload||t.all)?(i(this.$mailboxes),t&&t.all||(n.$$flattenMailboxes=s,t&&t.saveState&&(_.forEach(e.$accounts,function(e){e.$expanded&&o.push("/"+e.id),_.reduce(e.$$flattenMailboxes,function(e,t){return t.$expanded&&e.push("/"+t.id),e},o)}),e.$$resource.post(null,"saveFoldersState",o)))):s=this.$$flattenMailboxes,s},e.prototype.$getMailboxByType=function(e){var t=function(n){var s=_.find(n,function(t){return t.type==e});return s||angular.forEach(n,function(e){!s&&e.children&&e.children.length>0&&(s=t(e.children))}),s};return t(this.$mailboxes)},e.prototype.$getMailboxByPath=function(e){var t=function(n){var s=_.find(n,function(t){return t.path==e});return s||angular.forEach(n,function(e){!s&&e.children&&e.children.length>0&&(s=t(e.children))}),s};return t(this.$mailboxes)},e.prototype.$newMailbox=function(t,n){var s=this;return e.$$resource.post(t.toString(),"createFolder",{name:n}).then(function(){s.$getMailboxes({reload:!0})})},e.prototype.updateQuota=function(e){var t,n;t=Math.round(1e4*e.usedSpace/e.maxQuota)/100,n=l("quotasFormat").formatted(t,Math.round(e.maxQuota/10.24)/100),this.$quota={percent:t,description:n}},e.prototype.$newMessage=function(){var t=this;return e.$$resource.fetch(this.id.toString(),"compose").then(function(n){return e.$log.debug("New message (compose): "+JSON.stringify(n,void 0,2)),new e.$Message(n.accountId,t.$getMailboxByPath(n.mailboxPath),n)}).then(function(t){return e.$$resource.fetch(t.$absolutePath({asDraft:!0}),"edit").then(function(n){return e.$log.debug("New message (edit): "+JSON.stringify(n,void 0,2)),angular.extend(t.editable,n),t.isNew=!0,t})})},e.prototype.$addDelegate=function(t){var n=this,s=e.$q.defer(),o={uid:t.uid};return!t.uid||_.indexOf(_.map(this.delegates,"uid"),t.uid)>-1?s.resolve():e.$$resource.fetch(this.id.toString(),"addDelegate",o).then(function(){n.delegates.push(t),s.resolve(n.users)},function(e,t){s.reject(l("An error occured please try again."))}),s.promise},e.prototype.$removeDelegate=function(t){var n=this,s={uid:t};return e.$$resource.fetch(this.id.toString(),"removeDelegate",s).then(function(){var e=_.indexOf(_.map(n.delegates,"uid"),t);e>=0&&n.delegates.splice(e,1)})}}(),function(){"use strict";function e(t,n){if(this.$account=t,"function"!=typeof n.then){if(this.init(n),this.name&&!this.path){var s=e.$$resource.create("createFolder",this.name);this.$unwrap(s)}}else this.$unwrap(n)}e.$factory=["$q","$timeout","$log","sgSettings","Resource","Message","Acl","Preferences","sgMailbox_PRELOAD",function(t,n,s,o,i,a,r,l,c){return angular.extend(e,{$q:t,$timeout:n,$log:s,$$resource:new i(o.activeUser("folderURL")+"Mail",o.activeUser()),$Message:a,$$Acl:r,$Preferences:l,$query:{sort:"arrival",asc:0},selectedFolder:null,$refreshTimeout:null,$virtualMode:!1,$virtualPath:!1,PRELOAD:c}),l.settings.Mail.SortingState&&(e.$query.sort=l.settings.Mail.SortingState[0],e.$query.asc=parseInt(l.settings.Mail.SortingState[1])),e}];try{angular.module("SOGo.MailerUI")}catch(e){angular.module("SOGo.MailerUI",["SOGo.Common"])}angular.module("SOGo.MailerUI").constant("sgMailbox_PRELOAD",{LOOKAHEAD:50,SIZE:100}).factory("Mailbox",e.$factory),e.$find=function(t,n){var s;return s=n&&n.all?this.$$resource.fetch(t.id.toString(),"viewAll"):this.$$resource.fetch(t.id.toString(),"view"),e.$unwrapCollection(t,s)},e.$unwrapCollection=function(t,n){var s=[],o=function(n,s){for(var i=0;i<s.children.length;i++)s.children[i].level=n,s.children[i]=new e(t,s.children[i]),o(n+1,s.children[i])};return n.then(function(n){return e.$timeout(function(){return angular.forEach(n.mailboxes,function(n,i){n.level=0;var a=new e(t,n);o(1,a),s.push(a)}),n.quotas&&t.updateQuota(n.quotas),s})})},e.$absolutePath=function(e,t){var n=[];return t&&(n=_.map(t.split("/"),function(e){return"folder"+e.asCSSIdentifier()})),n.splice(0,0,e),n.join("/")},e.prototype.init=function(t){(angular.isUndefined(this.uidsMap)||t.headers)&&(this.$isLoading=!0,this.$messages=[],this.uidsMap={}),angular.extend(this,t),this.path&&(this.id=this.$id(),this.$acl=new e.$$Acl("Mail/"+this.id)),this.$displayName=this.name,this.type&&(this.$isEditable=this.isEditable(),this.$isSpecial=!0,"inbox"==this.type?(this.$displayName=l("InboxFolderName"),this.$icon="inbox"):"draft"==this.type?(this.$displayName=l("DraftsFolderName"),this.$icon="drafts"):"sent"==this.type?(this.$displayName=l("SentFolderName"),this.$icon="send"):"trash"==this.type?(this.$displayName=l("TrashFolderName"),this.$icon="delete"):"junk"==this.type?(this.$displayName=l("JunkFolderName"),this.$icon="thumb_down"):"additional"==this.type?this.$icon="folder_shared":(this.$isSpecial=!1,this.$icon="folder_open")),this.$isNoInferiors=this.isNoInferiors(),angular.isUndefined(this.$shadowData)&&(this.$shadowData=this.$omit())},e.prototype.selectFolder=function(){e.$virtualMode||(e.selectedFolder=this)},e.prototype.getLength=function(){return this.$messages.length},e.prototype.getItemAtIndex=function(e){var t;return e>=0&&e<this.$messages.length&&(t=this.$messages[e],this.$lastVisibleIndex=Math.max(0,e-3),this.$loadMessage(t.uid))?t:null},e.prototype.$id=function(){return e.$absolutePath(this.$account.id,this.path)},e.prototype.$selectedMessages=function(){return _.filter(this.$messages,function(e){return e.selected})},e.prototype.$selectedCount=function(){return this.$selectedMessages().length},e.prototype.isSelectedMessage=function(e){return this.selectedMessage==e},e.prototype.$selectedMessage=function(){var e=this;return _.find(this.$messages,function(t){return t.uid==e.selectedMessage})},e.prototype.$selectedMessageIndex=function(){return this.uidsMap[this.selectedMessage]},e.prototype.hasSelectedMessage=function(){return angular.isDefined(this.selectedMessage)},e.prototype.$filter=function(t,n){var s=this,o={};if(angular.isDefined(this.unseenCount)||(this.unseenCount=0),e.$timeout(function(){s.$isLoading=!0}),e.$refreshTimeout&&e.$timeout.cancel(e.$refreshTimeout),t&&angular.extend(e.$query,t),angular.extend(o,{sortingAttributes:e.$query}),angular.isDefined(n)&&(o.filters=_.reject(n,function(e){return!e.searchInput||0===e.searchInput.length}),_.forEach(o.filters,function(e){var t,n=e.searchBy.match(/(\w+)_or_(\w+)/);n&&(o.sortingAttributes.match="OR",e.searchBy=n[1],(t=angular.copy(e)).searchBy=n[2],o.filters.push(t))})),!e.$virtualMode){var i=e.$Preferences.defaults.SOGoRefreshViewCheck;if(i&&"manually"!=i){var a=angular.bind(this,e.prototype.$filter,null,n);e.$refreshTimeout=e.$timeout(a,1e3*i.timeInterval())}}var r=e.$$resource.post(this.id,"view",o);return this.$unwrap(r)},e.prototype.$loadMessage=function(t){var n,s,o,i,a=this.uidsMap[t],r=this.$messages.length,l=!1;if(angular.isDefined(this.uidsMap[t])&&a<this.$messages.length&&(angular.isDefined(this.$messages[a].subject)&&(l=!0),n=Math.min(a+e.PRELOAD.LOOKAHEAD,r-1),angular.isDefined(this.$messages[n].subject)||angular.isDefined(this.$messages[n].loading)?(s=Math.max(a-e.PRELOAD.LOOKAHEAD,0),angular.isDefined(this.$messages[s].subject)||angular.isDefined(this.$messages[s].loading)||(n=a,a=Math.max(a-e.PRELOAD.SIZE,0))):n=Math.min(a+e.PRELOAD.SIZE,r-1),!angular.isDefined(this.$messages[a].subject)&&!angular.isDefined(this.$messages[a].loading)||!angular.isDefined(this.$messages[n].subject)&&!angular.isDefined(this.$messages[n].loading))){for(o=[];a<n&&a<r;a++)angular.isDefined(this.$messages[a].subject)||this.$messages[a].loading?n++:(o.push(this.$messages[a].uid),this.$messages[a].loading=!0);e.$log.debug("Loading UIDs "+o.join(" ")),i=e.$$resource.post(this.id,"headers",{uids:o}),this.$unwrapHeaders(i)}return l},e.prototype.isEditable=function(){return"folder"==this.type},e.prototype.isNoInferiors=function(){return this.flags.indexOf("noinferiors")>=0},e.prototype.isNoSelect=function(){return this.flags.indexOf("noselect")>=0},e.prototype.getClassName=function(e){return!1},e.prototype.$rename=function(){var t,n,s,o,i=this;return this.name==this.$shadowData.name?e.$q.when():(t=function(e,n){var s=null;return _.find(n,function(e){return e.path==i.path})?s=e:angular.forEach(n,function(e){!s&&e.children&&e.children.length>0&&(s=t(e,e.children))}),s},n=t(null,this.$account.$mailboxes),s=null===n?this.$account.$mailboxes:n.children,o=_.indexOf(_.map(s,"id"),this.id),this.$save().then(function(t){var n,a=i.path;i.init(t),s.splice(o,1),n=_.find(s,function(t){return e.$log.debug(t.name+" ? "+i.name),"folder"==t.type&&t.name.localeCompare(i.name)>0}),o=n?_.indexOf(_.map(s,"id"),n.id):s.length,s.splice(o,0,i);var r=new RegExp("^"+a),l=function(e){_.forEach(e.children,function(e){e.path=e.path.replace(r,i.path),e.id=e.$id(),l(e)})};l(i)}))},e.prototype.$compact=function(){var t=this;return e.$$resource.post(this.id,"expunge").then(function(e){e.quotas&&t.$account.updateQuota(e.quotas)})},e.prototype.$canFolderAs=function(){return"folder"==this.type&&0===this.level},e.prototype.$setFolderAs=function(t){return e.$$resource.post(this.id,"setAs"+t+"Folder")},e.prototype.$emptyTrash=function(){var t=this;return e.$$resource.post(this.id,"emptyTrash").then(function(e){t.$messages=[],t.uidsMap={},t.unseenCount=0,angular.isDefined(t.children)&&t.children.length&&t.$account.$getMailboxes({reload:!0}),e.quotas&&t.$account.updateQuota(e.quotas)})},e.prototype.$markAsRead=function(){var t=this;return e.$$resource.post(this.id,"markRead").then(function(){t.unseenCount=0,_.forEach(t.$messages,function(e){e.isread=!0})})},e.prototype.$flagMessages=function(t,n,s){var o={msgUIDs:_.map(t,"uid"),flags:n,operation:s};return e.$$resource.post(this.id,"addOrRemoveLabel",o).then(function(){return t})},e.prototype.saveSelectedMessages=function(){var t,n;return t=_.filter(this.$messages,function(e){return e.selected}),n=_.map(t,"uid"),{uids:n},{filename:l("Saved Messages.zip")},e.$$resource.download(this.id,"saveMessages",{uids:n})},e.prototype.exportFolder=function(){var t;return t={filename:this.name+".zip"},e.$$resource.download(this.id,"exportFolder",null,t)},e.prototype.$delete=function(t){var n=this;return e.$$resource.post(this.id,"delete",t).then(function(){return n.$account.$getMailboxes({reload:!0}),!0})},e.prototype.$_deleteMessages=function(e,t){var n,s=this,o=this.$messages.length;return n=_.filter(t,function(e,t){return!e.isread}),this.unseenCount-=n.length,_.forEachRight(this.$messages,function(t,n){var i=_.findIndex(e,function(e){return t.uid==e});i>-1?(e.splice(i,1),delete s.uidsMap[t.uid],t.uid==s.selectedMessage&&delete s.selectedMessage,s.$messages.splice(n,1),n<o&&(o=n)):s.uidsMap[t.uid]-=e.length}),o},e.prototype.$deleteMessages=function(t,n){var s,o,i=this;return s=_.map(t,"uid"),o={uids:s},n&&angular.extend(o,n),e.$$resource.post(this.id,"batchDelete",o).then(function(e){return e.quotas&&i.$account.updateQuota(e.quotas),i.$_deleteMessages(s,t)})},e.prototype.$markOrUnMarkMessagesAsJunk=function(t){var n=_.map(t,"uid"),s="junk"==this.type?"markMessagesAsNotJunk":"markMessagesAsJunk";return e.$$resource.post(this.id,s,{uids:n})},e.prototype.$copyMessages=function(t,n){var s=this,o=_.map(t,"uid");return e.$$resource.post(this.id,"copyMessages",{uids:o,folder:n}).then(function(e){e.quotas&&s.$account.updateQuota(e.quotas)})},e.prototype.$moveMessages=function(t,n){var s,o=this;return s=_.map(t,"uid"),e.$$resource.post(this.id,"moveMessages",{uids:s,folder:n}).then(function(){return o.$_deleteMessages(s,t)})},e.prototype.$reset=function(){var e=this;angular.forEach(this.$shadowData,function(t,n){delete e[n]}),angular.extend(this,this.$shadowData),this.$shadowData=this.$omit()},e.prototype.$save=function(){var t=this;return e.$$resource.save(this.id,this.$omit()).then(function(n){return t.$shadowData=t.$omit(),e.$log.debug(JSON.stringify(n,void 0,2)),n},function(n){return e.$log.error(JSON.stringify(n.data,void 0,2)),t.$reset(),n.data})},e.prototype.$newMailbox=function(e,t){return this.$account.$newMailbox(e,t)},e.prototype.$omit=function(){var e={};return angular.forEach(this,function(t,n){"constructor"!=n&&"children"!=n&&"headers"!=n&&"uids"!=n&&"uidsMap"!=n&&"$"!=n[0]&&(e[n]=t)}),e},e.prototype.$unwrap=function(t){var n=this,s=e.$q.defer();return this.$futureMailboxData=t,this.$futureMailboxData.then(function(t){e.$timeout(function(){var o,i;(!t.uids||n.$topIndex>t.uids.length-1)&&(n.$topIndex=0),n.init(t),n.uids&&(e.$log.debug("unwrapping "+n.uids.length+" messages"),i=_.invokeMap(n.headers[0],"toLowerCase"),n.headers.splice(0,1),n.threaded&&(o=n.uids[0],n.uids.splice(0,1)),_.reduce(n.uids,function(t,s,i){var a;return a=n.threaded?_.zipObject(o,s):{uid:s.toString()},n.uidsMap[a.uid]=i,t.push(new e.$Message(n.$account.id,n,a,!0)),t},n.$messages),_.forEach(n.headers,function(e){var t=_.zipObject(i,e),s=n.uidsMap[t.uid.toString()];_.extend(n.$messages[s],t)})),e.$log.debug("mailbox "+n.id+" ready"),n.$isLoading=!1,s.resolve(n.$messages)})},function(e){angular.extend(n,e),n.isError=!0,n.$isLoading=!1,s.reject()}),s.promise},e.prototype.$unwrapHeaders=function(t){var n=this;t.then(function(t){e.$timeout(function(){var e,s;t.length>0&&(e=_.invokeMap(t[0],"toLowerCase"),t.splice(0,1),_.forEach(t,function(t){t=_.zipObject(e,t),s=n.uidsMap[t.uid.toString()],angular.isDefined(s)&&_.extend(n.$messages[s],t)}))})})},e.prototype.$updateSubscribe=function(){var t=this.subscribed?"subscribe":"unsubscribe";e.$$resource.post(this.id,t)}}(),function(){"use strict";function e(e,t,n,s){this.accountId=e,this.$mailbox=t,this.$hasUnsafeContent=!1,this.$loadUnsafeContent=!1,this.editable={to:[],cc:[],bcc:[]},this.selected=!1,"function"!=typeof n.then?(!angular.isUndefined(s)&&s||(angular.extend(this,n),this.$formatFullAddresses()),this.uid=parseInt(n.uid)):this.$unwrap(n)}e.$factory=["$q","$timeout","$log","sgSettings","sgMessage_STATUS","Resource","Preferences",function(t,n,s,o,i,a,r){return angular.extend(e,{STATUS:i,$q:t,$timeout:n,$log:s,$$resource:new a(o.activeUser("folderURL")+"Mail",o.activeUser()),$avatar:angular.bind(r,r.avatar)}),r.defaults.SOGoMailLabelsColors&&(e.$tags=r.defaults.SOGoMailLabelsColors),r.defaults.SOGoMailDisplayRemoteInlineImages&&"always"==r.defaults.SOGoMailDisplayRemoteInlineImages&&(e.$displayRemoteInlineImages=!0),e}];try{angular.module("SOGo.MailerUI")}catch(e){angular.module("SOGo.MailerUI",["SOGo.Common"])}angular.module("SOGo.MailerUI").constant("sgMessage_STATUS",{NOT_LOADED:0,DELAYED_LOADING:1,LOADING:2,LOADED:3,DELAYED_MS:300}).factory("Message",e.$factory),e.filterTags=function(t,n){var s=new RegExp(t,"i"),o=[];return _.forEach(_.keys(e.$tags),function(t){var i=e.$tags[t];-1!=i[0].search(s)&&(_.includes(n,t)||o.push({name:t,description:i[0],color:i[1]}))}),o},e.prototype.$absolutePath=function(t){function n(){var e;return(e=_.map(s.$mailbox.path.split("/"),function(e){return"folder"+e.asCSSIdentifier()})).splice(0,0,s.accountId),e.join("/")}var s=this,o=this.id;return(angular.isUndefined(this.id)||t&&t.nocache)&&(this.id=n()+"/"+this.uid,o=this.id),t&&t.asDraft&&this.draftId&&(o=n()+"/"+this.draftId),t&&t.withResourcePath&&(o=e.$$resource.path(o)),o},e.prototype.$setUID=function(e){var t,n=this.uid||-1,s=this;n!=parseInt(e)&&(this.uid=parseInt(e),this.$absolutePath({nocache:!0}),n>-1?(n=n.toString(),angular.isDefined(this.$mailbox.uidsMap[n])&&(t=this.$mailbox.uidsMap[n],this.$mailbox.uidsMap[e]=t,delete this.$mailbox.uidsMap[n],_.forEach(["from","to","subject"],function(e){s.$mailbox.$messages[t][e]=s[e]}))):this.$mailbox.constructor.selectedFolder&&"draft"==this.$mailbox.constructor.selectedFolder.type&&this.$mailbox.constructor.selectedFolder.$filter())},e.prototype.$formatFullAddresses=function(){var t=this,n=_.map(t.$mailbox.$account.identities,"email");_.forEach(["from","to","cc","bcc","reply-to"],function(s){_.forEach(t[s],function(t){t.name&&t.name!=t.email?(t.full=t.name+" <"+t.email+">",t.name.length<10?t.shortname=t.name:t.name.split(" ").length&&(t.shortname=_.first(_.last(t.name.split(/, */)).split(/ +/)).replace("'",""))):t.email&&(t.full="<"+t.email+">",t.shortname=t.email.split("@")[0]),t.image=e.$avatar(t.email,32),_.indexOf(n,t.email)>=0&&(t.shortname=l("me"))})})},e.prototype.$shortRecipients=function(e){var t=this,n=[],s=0,o=0;return _.forEach(["to","cc","bcc"],function(i){o+=t[i]?t[i].length:0,_.forEach(t[i],function(t,o){s<e&&n.push(t.shortname),s++})}),o>e&&n.push(l("and %{0} more...",o-e)),n.join(", ")},e.prototype.$shortAddress=function(e){var t="";return this[e]&&this[e].length>0&&(t=this[e][0].name||this[e][0].email||""),t},e.prototype.allowReplyAll=function(){var e=0;return e=_.reduce(["to","cc"],_.bind(function(e,t){return this[t]?e+this[t].length:e},this),e),!this.isDraft&&e>1},e.prototype.loadUnsafeContent=function(){this.$loadUnsafeContent=!0},e.prototype.$content=function(){var t=this,n=[],s=function(o){if(o.msgclass="msg-attachment-other","UIxMailPartAlternativeViewer"==o.type)s(_.find(o.content,function(e){return o.preferredPart==e.contentType}));else if(angular.isArray(o.content)){if("UIxMailPartSignedViewer"==o.type&&1===o["supports-smime"]){var i="<p>"+o.error.replace(/\n/,'</p><p class="md-caption">');i=i.replace(/\n/g,'</p><p class="md-caption">')+"</p>",t.$smime={validSignature:o.valid,message:i}}_.forEach(o.content,function(e){s(e)})}else angular.isUndefined(o.safeContent)&&(o.safeContent=o.content,t.$hasUnsafeContent|=o.safeContent.indexOf(" unsafe-")>-1),"UIxMailPartHTMLViewer"==o.type?(o.html=!0,t.$loadUnsafeContent||e.$displayRemoteInlineImages?(angular.isUndefined(o.unsafeContent)&&(o.unsafeContent=document.createElement("div"),o.unsafeContent.innerHTML=o.safeContent,angular.forEach(["src","data","classid","background","style"],function(e){var t,n,s,i=o.unsafeContent.querySelectorAll("[unsafe-"+e+"]");for(s=0;s<i.length;s++)n=(t=angular.element(i[s])).attr("unsafe-"+e),t.attr(e,n),t.removeAttr("unsafe-"+e)}),t.$hasUnsafeContent=!1),o.content=o.unsafeContent.innerHTML):o.content=o.safeContent,n.push(o)):"UIxMailPartICalViewer"==o.type||"UIxMailPartImageViewer"==o.type||"UIxMailPartLinkViewer"==o.type?("UIxMailPartImageViewer"==o.type?o.msgclass="msg-attachment-image":"UIxMailPartLinkViewer"==o.type&&(o.msgclass="msg-attachment-link"),o.compile=!0,n.push(o)):(o.html=!0,o.content=o.safeContent,n.push(o))};return this.parts&&s(this.parts),n},e.prototype.$editableContent=function(){var t=this;return e.$$resource.fetch(this.$absolutePath(),"edit").then(function(n){return angular.extend(t,n),e.$$resource.fetch(t.$absolutePath({asDraft:!0}),"edit").then(function(n){var s=_.find(t.$mailbox.$account.identities,function(e){return-1!==n.from.toLowerCase().indexOf(e.email)});return s&&(n.from=s.full),e.$log.debug("editable = "+JSON.stringify(n,void 0,2)),angular.extend(t.editable,n),n.text})})},e.prototype.$plainContent=function(){return e.$$resource.fetch(this.$absolutePath(),"viewplain")},e.prototype.addTag=function(e){return this.$addOrRemoveTag("add",e)},e.prototype.removeTag=function(e){return this.$addOrRemoveTag("remove",e)},e.prototype.$addOrRemoveTag=function(t,n){var s={operation:t,msgUIDs:[this.uid],flags:n};if(n)return e.$$resource.post(this.$mailbox.$id(),"addOrRemoveLabel",s)},e.prototype.$imipAction=function(t,n,s){var o=this;e.$$resource.post([this.$absolutePath(),t].join("/"),n,s).then(function(t){e.$timeout(function(){o.$reload()})})},e.prototype.$sendMDN=function(){return this.shouldAskReceipt=0,e.$$resource.post(this.$absolutePath(),"sendMDN")},e.prototype.$deleteAttachment=function(t){var n={filename:t},s=this;e.$$resource.fetch(this.$absolutePath({asDraft:!0}),"deleteAttachment",n).then(function(n){e.$timeout(function(){s.editable.attachmentAttrs=_.filter(s.editable.attachmentAttrs,function(e){return e.filename!=t})})})},e.prototype.toggleFlag=function(){var t=this,n="markMessageFlagged";return this.isflagged&&(n="markMessageUnflagged"),e.$$resource.post(this.$absolutePath(),n).then(function(n){e.$timeout(function(){t.isflagged=!t.isflagged})})},e.prototype.$isLoading=function(){return this.$loaded==e.STATUS.LOADING},e.prototype.$reload=function(t){var n,s=this;return t&&t.useCache&&this.$futureMessageData?(this.isread||e.$$resource.fetch(this.$absolutePath(),"markMessageRead").then(function(){e.$timeout(function(){s.isread=!0,s.$mailbox.unseenCount--})}),this):(n=e.$$resource.fetch(this.$absolutePath(t),"view"),this.$unwrap(n))},e.prototype.$reply=function(){return this.$newDraft("reply")},e.prototype.$replyAll=function(){return this.$newDraft("replyall")},e.prototype.$forward=function(){return this.$newDraft("forward")},e.prototype.$newDraft=function(t){var n=this;return e.$$resource.fetch(this.$absolutePath(),t).then(function(s){var o,i;return e.$log.debug("New "+t+": "+JSON.stringify(s,void 0,2)),o=n.$mailbox.$account.$getMailboxByPath(s.mailboxPath),i=new e(s.accountId,o,s),e.$$resource.fetch(i.$absolutePath({asDraft:!0}),"edit").then(function(s){return e.$log.debug("New "+t+": "+JSON.stringify(s,void 0,2)+" original UID: "+n.uid),angular.extend(i.editable,s),i.origin={message:n,action:t},i})})},e.prototype.$save=function(){var t=this,n=this.editable;return e.$log.debug("save = "+JSON.stringify(n,void 0,2)),e.$$resource.save(this.$absolutePath({asDraft:!0}),n).then(function(n){e.$log.debug("save = "+JSON.stringify(n,void 0,2)),t.$setUID(n.uid),t.$reload(),t.isNew=!1})},e.prototype.$send=function(){var t=this,n=angular.copy(this.editable);return e.$log.debug("send = "+JSON.stringify(n,void 0,2)),e.$$resource.post(this.$absolutePath({asDraft:!0}),"send",n).then(function(n){return"success"==n.status?(angular.isDefined(t.origin)&&(t.origin.action.startsWith("reply")?t.origin.message.isanswered=!0:"forward"==t.origin.action&&(t.origin.message.isforwarded=!0)),n):e.$q.reject(n.data)})},e.prototype.$unwrap=function(t){var n=this;return this.$loaded=e.STATUS.DELAYED_LOADING,e.$timeout(function(){n.$loaded!=e.STATUS.LOADED&&(n.$loaded=e.STATUS.LOADING)},e.STATUS.DELAYED_MS),this.$futureMessageData=t.then(function(t){return 0===n.isread&&(n.isread=!0,n.$mailbox.unseenCount--),e.$timeout(function(){return angular.extend(n,t),n.$formatFullAddresses(),n.$loadUnsafeContent=!1,n.$loaded=e.STATUS.LOADED,n})}),this.$futureMessageData},e.prototype.$omit=function(e){var t={},n=e&&e.privateAttributes;return angular.forEach(this,function(e,s){("constructor"!=s&&"$"!=s[0]||n)&&(t[s]=e)}),t},e.prototype.download=function(){var t,n;return t={uids:[this.uid]},n={filename:this.subject+".zip"},e.$$resource.download(this.$mailbox.id,"saveMessages",t,n)},e.prototype.downloadAttachments=function(){var t;return t={filename:l("attachments")+"-"+this.uid+".zip"},e.$$resource.download(this.$absolutePath(),"archiveAttachments",null,t)}}(),function(){"use strict";function e(){this.show=!1,this.message=null,this.elements=[]}e.$factory=["$document","$timeout","$mdPanel","sgHotkeys",function(t,n,s,o){return angular.extend(e,{$document:t,$timeout:n,$mdPanel:s,sgHotkeys:o}),new e}],e.prototype.setMessage=function(e){this.message=e},e.prototype.registerImage=function(e){this.elements.push(e)},e.prototype.registerHotkeys=function(t){this.keys=[e.sgHotkeys.createHotkey({key:"left",description:l("View previous item"),callback:angular.bind(t,t.previousImage)}),e.sgHotkeys.createHotkey({key:"right",description:l("View next item"),callback:angular.bind(t,t.nextImage)})],_.forEach(this.keys,function(t){e.sgHotkeys.registerHotkey(t)})},e.prototype.showGallery=function(t,n){function s(e){e.$ctrl=this,this.close=function(){e.close()},this.selectImage=function(e){this.selectedIndex=e,this.selectedImage=this.images[e]},this.nextImage=function(){this.selectedIndex!=this.lastIndex&&this.selectImage(this.selectedIndex+1)},this.previousImage=function(){this.selectedIndex>0&&this.selectImage(this.selectedIndex-1)}}var o=this,i=e.$mdPanel,a=angular.element(this.message.parts.content[n].content).find("img")[0].src,r=_.filter(this.message.attachmentAttrs,function(e){return 0===e.mimetype.indexOf("image/")}),c=_.findIndex(r,function(e){return e.url.indexOf(a)>=0});angular.element(e.$document[0].body).addClass("sg-image-gallery-backdrop");var u=i.newPanelPosition().absolute(),d=i.newPanelAnimation().openFrom(t.target).duration(100).withAnimation(i.animation.FADE),h={attachTo:angular.element(document.body),locals:{lastIndex:r.length-1,images:r,selectedIndex:c,selectedImage:r[c]},bindToController:!0,controller:s,controllerAs:"$panelCtrl",position:u,animation:d,targetEvent:t,fullscreen:!0,hasBackdrop:!0,template:['<sg-image-gallery layout="column">',' <div class="md-toolbar-tools" layout="row" layout-align="space-between center">',' <md-button class="md-icon-button"',' aria-label="'+l("Close")+'"',' ng-click="$panelCtrl.close()">'," <md-icon>arrow_back</md-icon>"," </md-button>",' <md-icon class="md-primary">image</md-icon>',' <div md-truncate class="md-flex" ng-bind="$panelCtrl.selectedImage.filename"></div>',' <md-button class="md-icon-button"',' aria-label="'+l("Save Attachment")+'"',' ng-href="{{$panelCtrl.selectedImage.urlAsAttachment}}">'," <md-icon>file_download</md-icon>"," </md-button>"," </div>",' <div class="md-flex" layout="row" layout-align="space-between center">',' <md-button class="md-icon-button" ng-click="$panelCtrl.previousImage()"',' ng-disabled="$panelCtrl.selectedIndex == 0">'," <md-icon>navigate_before</md-icon>"," </md-button>",' <img class="sg-image" ng-src="{{$panelCtrl.selectedImage.url}}">',' <md-button class="md-icon-button" ng-click="$panelCtrl.nextImage()"',' ng-disabled="$panelCtrl.selectedIndex == $panelCtrl.lastIndex">'," <md-icon>navigate_next</md-icon>"," </md-button>"," </div>",' <div class="sg-image-thumbnails">',' <div class="sg-image-thumbnail" ng-repeat="image in ::$panelCtrl.images">',' <img class="sg-hide" ng-src="{{::image.url}}" ng-click="$panelCtrl.selectImage($index)">'," </div>"," </div>","</sg-image-gallery>"].join(""),trapFocus:!0,clickOutsideToClose:!0,escapeToClose:!0,focusOnOpen:!0,onOpenComplete:function(){o.show=!0,_.forEach(e.$document.find("sg-image-gallery")[0].getElementsByClassName("sg-image-thumbnail"),function(t){var n=t.children[0];angular.element(n).one("load",function(){n.naturalWidth<n.naturalHeight&&n.classList.add("portrait")}),e.$timeout(function(){n.classList.remove("sg-hide")},1e3)})},onDomRemoved:function(){angular.element(e.$document[0].body).removeClass("sg-image-gallery-backdrop"),o.show=!1,_.forEach(o.hotkeys,function(t){e.sgHotkeys.deregisterHotkey(t)})}};i.open(h).then(function(e){o.registerHotkeys(e.$ctrl)}),s.$inject=["mdPanelRef"]},angular.module("SOGo.MailerUI").factory("ImageGallery",e.$factory)}(),function(){"use strict";function e(e){this.$account=e}e.$factory=["$q","$timeout","$log","sgSettings","Resource","Message","Mailbox","sgMailbox_PRELOAD",function(t,n,s,o,i,a,r,l){return angular.extend(e,{$q:t,$timeout:n,$log:s,$$resource:new i(o.activeUser("folderURL")+"Mail",o.activeUser()),$Message:r,selectedFolder:null,PRELOAD:l}),e}];try{angular.module("SOGo.MailerUI")}catch(e){angular.module("SOGo.MailerUI",["SOGo.Common"])}angular.module("SOGo.MailerUI").constant("sgMailbox_PRELOAD",{LOOKAHEAD:50,SIZE:100}).factory("VirtualMailbox",e.$factory),e.$absolutePath=function(e){return[e,"virtual"].join("/")},e.prototype.init=function(e){this.$isLoading=!1,this.$mailboxes=[],this.uidsMap={},angular.extend(this,e),this.id=this.$id()},e.prototype.setMailboxes=function(e){this.$mailboxes=e,_.forEach(this.$mailboxes,function(e){e.$messages=[],e.uidsMap={}})},e.prototype.startSearch=function(t,n){var s=this,o=e.$q.when();this.$isLoading=!0,_.forEach(this.$mailboxes,function(i){o=o.then(function(){if(s.$isLoading)return e.$log.debug("searching mailbox "+i.path),i.$filter({sort:"date",asc:!1,match:t},n)})}),o.finally(function(){s.$isLoading=!1})},e.prototype.stopSearch=function(){e.$log.debug("stopping search..."),this.$isLoading=!1},e.prototype.selectFolder=function(){},e.prototype.resetSelectedMessage=function(){_.forEach(this.$mailboxes,function(e){delete e.selectedMessage})},e.prototype.hasSelectedMessage=function(){return angular.isDefined(_.find(this.$mailboxes,function(e){return angular.isDefined(e.selectedMessage)}))},e.prototype.isSelectedMessage=function(e,t){return angular.isDefined(_.find(this.$mailboxes,function(n){return n.path==t&&n.selectedMessage==e}))},e.prototype.getLength=function(){var e=0;return angular.isDefined(this.$mailboxes)?(_.forEach(this.$mailboxes,function(t){e+=t.$messages.length}),e):e},e.prototype.getItemAtIndex=function(e){var t,n,s,o,i;if(angular.isDefined(this.$mailboxes)&&e>=0)for(t=0,n=0;n<this.$mailboxes.length;n++)for(o=this.$mailboxes[n],s=0;s<o.$messages.length;t++,s++)if(i=o.$messages[s],t==e&&o.$loadMessage(i.uid))return i;return null},e.prototype.$id=function(){return e.$absolutePath(this.$account.id)},e.prototype.$selectedMessages=function(){return _.transform(this.$mailboxes,function(e,t){e[t.id]=t.$selectedMessages()},{})},e.prototype.$selectedCount=function(){return _.sum(_.invokeMap(this.$mailboxes,"$selectedCount"))},e.prototype.$flagMessages=function(t,n,s){var o={flags:n,operation:s},i=[],a=[];return _.forEach(t,function(t,n){if(t.length>0){var s=_.map(t,"uid");i.push(t);var r=e.$$resource.post(n,"addOrRemoveLabel",_.assign(o,{msgUIDs:s}));a.push(r)}}),e.$q.all(a).then(function(){return _.flatten(i)})},e.prototype.$deleteMessages=function(t){var n=[];return _.forEach(t,function(e,t){if(e.length>0){var s=e[0].$mailbox.$deleteMessages(e);n.push(s)}}),e.$q.all(n)},e.prototype.$markOrUnMarkMessagesAsJunk=function(t){var n=[];return _.forEach(t,function(e,t){if(e.length>0){var s=e[0].$mailbox.$markOrUnMarkMessagesAsJunk(e);n.push(s)}}),e.$q.all(n)},e.prototype.$copyMessages=function(t,n){var s=[];return _.forEach(t,function(e,t){if(e.length>0){var o=e[0].$mailbox.$copyMessages(e,n);s.push(o)}}),e.$q.all(s)},e.prototype.$moveMessages=function(t,n){var s=[];return _.forEach(t,function(e,t){if(e.length>0){var o=e[0].$mailbox.$moveMessages(e,n);s.push(o)}}),e.$q.all(s)}}(),function(){"use strict";function e(e,t,n,s,o,i,a,r,c,u,d,h,g,f,m,p,$){function b(e){e.push(d.createHotkey({key:l("hotkey_search"),description:l("Search"),callback:S.searchMode})),e.push(d.createHotkey({key:l("hotkey_compose"),description:l("Write a new message"),callback:function(e){null===S.messageDialog&&S.newMessage(e)}})),e.push(d.createHotkey({key:l("hotkey_junk"),description:l("Mark the selected messages as junk"),callback:S.markOrUnMarkMessagesAsJunk})),e.push(d.createHotkey({key:"space",description:l("Toggle item"),callback:S.toggleMessageSelection})),e.push(d.createHotkey({key:"shift+space",description:l("Toggle range of items"),callback:S.toggleMessageSelection})),e.push(d.createHotkey({key:"up",description:l("View next item"),callback:M,preventInClass:["sg-mail-part"]})),e.push(d.createHotkey({key:"down",description:l("View previous item"),callback:x,preventInClass:["sg-mail-part"]})),e.push(d.createHotkey({key:"shift+up",description:l("Add next item to selection"),callback:C,preventInClass:["sg-mail-part"]})),e.push(d.createHotkey({key:"shift+down",description:l("Add previous item to selection"),callback:w,preventInClass:["sg-mail-part"]})),_.forEach(["backspace","delete"],function(t){e.push(d.createHotkey({key:t,description:l("Delete selected message or folder"),callback:S.confirmDeleteSelectedMessages}))}),_.forEach(e,function(e){d.registerHotkey(e)})}function v(e){return S.selectedFolder.$compact()}function y(){var t=[g.baseURL(),"UIxMailPopupView#!/Mail",S.account.id,h(h(S.selectedFolder.path)),"new"].join("/"),n=S.selectedFolder.$id()+"/"+Math.random(0,1e3);console.debug(t),e.open(t,n,["width=680","height=520","resizable=1","scrollbars=1","toolbar=0","location=0","directories=0","status=0","menubar=0","copyhistory=0"].join(","))}function M(e){var t=S.selectedFolder.$selectedMessageIndex();return angular.isDefined(t)?(t--,S.selectedFolder.$topIndex>0&&S.selectedFolder.$topIndex--):(t=S.selectedFolder.getLength()-1,S.selectedFolder.$topIndex=S.selectedFolder.getLength()),t>-1&&S.selectMessage(S.selectedFolder.$messages[t]),e.preventDefault(),t}function x(e){var t=S.selectedFolder.$selectedMessageIndex();return angular.isDefined(t)?(t++,S.selectedFolder.$topIndex<S.selectedFolder.getLength()&&S.selectedFolder.$topIndex++):t=0,t<S.selectedFolder.getLength()?S.selectMessage(S.selectedFolder.$messages[t]):t=-1,e.preventDefault(),t}function C(e){var t;S.selectedFolder.hasSelectedMessage()&&(t=M(e))>=0&&S.toggleMessageSelection(e,S.selectedFolder.$messages[t])}function w(e){var t;S.selectedFolder.hasSelectedMessage()&&(t=x(e))>=0&&S.toggleMessageSelection(e,S.selectedFolder.$messages[t])}function I(){return $.$virtualMode?S.selectedFolder.$mailboxes:[S.selectedFolder]}function E(e,t){var s,i,a=t;S.mode.multiple=S.selectedFolder.$selectedCount(),e?(t>0&&(a-=1,s=S.selectedFolder.$messages[a]),t<S.selectedFolder.$messages.length&&(i=S.selectedFolder.$messages[t]),s?s.isread&&i&&!i.isread&&(a=t,s=i):i&&(a=t,s=i),s?(S.selectedFolder.$topIndex=a,o.go("mail.account.mailbox.message",{messageId:s.uid})):o.go("mail.account.mailbox")):n(function(){console.warn("go to mailbox"),o.go("mail.account.mailbox")})}var S=this,F=angular.element(e.document).find("title").attr("sg-default")||"SOGo",k=[];this.$onInit=function(){e.$mailboxController=S,this.service=$,this.accounts=r,this.account=c,this.selectedFolder=u,this.messageDialog=null,this.mode={search:!1,multiple:0},b(k),angular.element(e).on("beforeunload",v),t.$on("$destroy",function(){angular.element(e).off("beforeunload",v),_.forEach(k,function(e){d.deregisterHotkey(e)})}),t.$watch(function(){return S.selectedFolder.unseenCount},function(t){var n=F+" - ";t&&(n+="("+t+") "),n+=S.selectedFolder.$displayName,e.document.title=n})},this.sort=function(e){S.selectedFolder.$filter({sort:e})},this.sortedBy=function(e){return $.$query.sort==e},this.searchMode=function(){S.mode.search=!0,f("search")},this.cancelSearch=function(){S.mode.search=!1,S.selectedFolder.$filter().then(function(){S.selectedFolder.selectedMessage&&n(function(){S.selectedFolder.$topIndex=S.selectedFolder.uidsMap[S.selectedFolder.selectedMessage]})})},this.newMessage=function(e,t){var n;null===S.messageDialog&&(t?y():(n=S.account.$newMessage(),S.messageDialog=i.show({parent:angular.element(document.body),targetEvent:e,clickOutsideToClose:!1,escapeToClose:!1,templateUrl:"UIxMailEditor",controller:"MessageEditorController",controllerAs:"editor",locals:{stateAccount:S.account,stateMessage:n}}).finally(function(){S.messageDialog=null})))},this.selectMessage=function(e){$.$virtualMode?o.go("mail.account.virtualMailbox.message",{mailboxId:h(e.$mailbox.path),messageId:e.uid}):o.go("mail.account.mailbox.message",{messageId:e.uid})},this.toggleMessageSelection=function(e,t){var n,s,o,i=S.selectedFolder;if(t||(t=i.$selectedMessage()),!t)return!0;if(t.selected=!t.selected,S.mode.multiple+=t.selected?1:-1,e.shiftKey&&i.$selectedCount()>1){for(s=(n=i.uidsMap[t.uid])-2;s>=0&&!i.$messages[s].selected;)s--;if(s<0)for(s=n+2;s<i.getLength()&&!i.$messages[s].selected;)s++;if(s>=0&&s<i.getLength())for(o=Math.min(n,s);o<=Math.max(n,s);o++)i.$messages[o].selected=!0}e.preventDefault(),e.stopPropagation()},this.confirmDeleteSelectedMessages=function(e){var t=S.selectedFolder.$selectedMessages();null===S.messageDialog&&_.size(t)>0&&(S.messageDialog=m.confirm(l("Confirmation"),l("Are you sure you want to delete the selected messages?"),{ok:l("Delete")}).then(function(){var e=S.selectedFolder.hasSelectedMessage();S.selectedFolder.$deleteMessages(t).then(function(t){$.$virtualMode?e&&o.go("mail.account.virtualMailbox"):E(e,t)},function(n){S.messageDialog=m.confirm(l("Warning"),l("The messages could not be moved to the trash folder. Would you like to delete them immediately?"),{ok:l("Delete")}).then(function(){S.selectedFolder.$deleteMessages(t,{withoutTrash:!0}).then(function(t){$.$virtualMode?e&&o.go("mail.account.virtualMailbox"):E(e,t)})})})}).finally(function(){S.messageDialog=null})),e.preventDefault()},this.markOrUnMarkMessagesAsJunk=function(){var e=S.selectedFolder.hasSelectedMessage(),t=S.selectedFolder.$selectedMessages();0===_.size(t)&&e&&(t=[S.selectedFolder.$selectedMessage()]),_.size(t)>0&&S.selectedFolder.$markOrUnMarkMessagesAsJunk(t).then(function(){var n="/"+S.account.id+"/folderINBOX";"junk"!=S.selectedFolder.type&&(n="/"+S.account.$getMailboxByType("junk").id),S.selectedFolder.$moveMessages(t,n).then(function(t){$.$virtualMode?e&&o.go("mail.account.virtualMailbox"):E(e,t)})})},this.copySelectedMessages=function(e){var t=S.selectedFolder.$selectedMessages();_.size(t)>0&&S.selectedFolder.$copyMessages(t,"/"+e).then(function(){a.show(a.simple().content(l("%{0} message(s) copied",S.selectedFolder.$selectedCount())).position("top right").hideDelay(2e3))})},this.moveSelectedMessages=function(e){var t=S.selectedFolder.hasSelectedMessage(),n=S.selectedFolder.$selectedMessages(),s=S.selectedFolder.$selectedCount();_.size(n)>0&&S.selectedFolder.$moveMessages(n,"/"+e).then(function(e){a.show(a.simple().content(l("%{0} message(s) moved",s)).position("top right").hideDelay(2e3)),$.$virtualMode?t&&o.go("mail.account.virtualMailbox"):E(t,e)})},this.selectAll=function(){var e=0;_.forEach(I(),function(t){for(var n=0,s=t.$messages.length;n<s;n++)t.$messages[n].selected=!0;e+=s}),S.mode.multiple=e},this.unselectMessages=function(){_.forEach(I(),function(e){_.forEach(e.$messages,function(e){e.selected=!1})}),S.mode.multiple=0},this.markSelectedMessagesAsFlagged=function(){var e=S.selectedFolder.$selectedMessages();_.size(e)>0&&S.selectedFolder.$flagMessages(e,"\\Flagged","add").then(function(e){_.forEach(e,function(e){e.isflagged=!0})})},this.markSelectedMessagesAsUnread=function(){var e=S.selectedFolder.$selectedMessages();_.size(e)>0&&S.selectedFolder.$flagMessages(e,"seen","remove").then(function(e){_.forEach(e,function(e){e.isread&&e.$mailbox.unseenCount++,e.isread=!1})})},this.markSelectedMessagesAsRead=function(){var e=S.selectedFolder.$selectedMessages();_.size(e)>0&&S.selectedFolder.$flagMessages(e,"seen","add").then(function(e){_.forEach(e,function(e){e.isread||e.$mailbox.unseenCount--,e.isread=!0})})}}function t(e){return e[0].controller.prototype.resetScroll=function(){"messagesList"==this.$element.parent().attr("id")?this.updateSize():this.scrollTo(0)},e}e.$inject=["$window","$scope","$timeout","$q","$state","$mdDialog","$mdToast","stateAccounts","stateAccount","stateMailbox","sgHotkeys","encodeUriFilter","sgSettings","sgFocus","Dialog","Account","Mailbox"],angular.module("SOGo.MailerUI").controller("MailboxController",e),t.$inject=["$delegate"],angular.module("material.components.virtualRepeat").decorator("mdVirtualRepeatContainerDirective",t)}(),function(){"use strict";function e(e,t,n,s,o,i,a,r,c,u,d,h,g,f,m,p,$,b){function v(e){_.forEach(["backspace","delete"],function(t){e.push(h.createHotkey({key:t,description:l("Delete selected message or folder"),callback:function(){f.selectedFolderController&&f.selectedFolder&&!f.selectedFolder.hasSelectedMessage()&&f.selectedFolderController.confirmDelete(f.selectedFolder)}}))}),_.forEach(e,function(e){h.registerHotkey(e)})}var y,M,x=this,C=[];this.$onInit=function(){this.service=f,this.accounts=b,this.currentSearchParam="",this.search={options:{"":"",subject:l("Enter Subject"),from:l("Enter From"),to:l("Enter To"),cc:l("Enter Cc"),body:l("Enter Body")},subfolders:1,match:"AND",params:[]},this.showSubscribedOnly=$.defaults.SOGoMailShowSubscribedFoldersOnly,this.refreshUnseenCount(),v(C),e.$on("$destroy",function(){_.forEach(C,function(e){h.deregisterHotkey(e)})})},this.hideAdvancedSearch=function(){x.service.$virtualPath=!1,x.service.$virtualMode=!1,y=x.accounts[0],M=x.searchPreviousMailbox,t.go("mail.account.mailbox",{accountId:y.id,mailboxId:c(M.path)})},this.toggleAdvancedSearch=function(){if(f.selectedFolder.$isLoading)x.virtualMailbox.stopSearch();else{var e,n=[],s=function(e){_.forEach(e,function(e){n.push(e),e.children&&e.children.length>0&&s(e.children)})};x.virtualMailbox=new m(x.accounts[0]),f.$virtualMode||(x.searchPreviousMailbox=f.selectedFolder),f.selectedFolder=x.virtualMailbox,f.$virtualMode=!0,angular.isDefined(f.$virtualPath)?(e=x.accounts[0].$getMailboxByPath(f.$virtualPath),n.push(e),x.search.subfolders&&e.children.length&&s(e.children)):n=x.accounts[0].$flattenMailboxes(),x.virtualMailbox.setMailboxes(n),x.virtualMailbox.startSearch(x.search.match,x.search.params),"mail.account.virtualMailbox"!=t.$current.name&&t.go("mail.account.virtualMailbox",{accountId:x.accounts[0].id})}},this.addSearchParam=function(e){return x.currentSearchParam=e,r("advancedSearch"),!1},this.newSearchParam=function(e){if(e.length&&x.currentSearchParam.length){var t=0,n=x.currentSearchParam;return e.startsWith("!")&&(t=1,e=e.substring(1).trim()),x.currentSearchParam="",{searchBy:n,searchInput:e,negative:t}}},this.toggleAccountState=function(e){e.$expanded=!e.$expanded,e.$flattenMailboxes({reload:!0,saveState:!0}),s(function(){angular.element(o).triggerHandler("resize")},150)},this.subscribe=function(e){function t(e,t,n){function s(){t.hide()}var o=this;o.loading=!0,o.filter={name:""},o.account=new g({id:n.id,name:n.name}),o.close=s,o.account.$getMailboxes({reload:!0,all:!0}).then(function(){o.loading=!1})}i.show({templateUrl:e.id+"/subscribe",controller:t,controllerAs:"subscriptions",clickOutsideToClose:!0,escapeToClose:!0,locals:{srcAccount:e}}).finally(function(){e.$getMailboxes({reload:!0})}),t.$inject=["$scope","$mdDialog","srcAccount"]},this.newFolder=function(e){u.prompt(l("New Folder..."),l("Enter the new name of your folder")).then(function(t){e.$newMailbox(e.id,t).then(function(){},function(e,n){u.alert(l('An error occured while creating the mailbox "%{0}".',t),l(e.error))})})},this.delegate=function(e){function t(e,t,n,s){function o(e){return n.$filter(e,s.delegates)}function i(){t.hide()}function a(e){s.$removeDelegate(e.uid).catch(function(e,t){u.alert(l("Warning"),l("An error occured please try again."))})}function r(e){e&&s.$addDelegate(e).then(function(){c.userToAdd="",c.searchText=""},function(e){u.alert(l("Warning"),e)})}var c=this;c.users=s.delegates,c.account=s,c.userToAdd="",c.searchText="",c.userFilter=o,c.closeModal=i,c.removeUser=a,c.addUser=r}i.show({templateUrl:e.id+"/delegation",controller:t,controllerAs:"delegate",clickOutsideToClose:!0,escapeToClose:!0,locals:{User:p,account:e}}),t.$inject=["$scope","$mdDialog","User","account"]},this.refreshUnseenCount=function(){var e,t=o.unseenCountFolders;_.forEach(x.accounts,function(e){_.includes(t,e.id+"/folderINBOX")||t.push(e.id+"/folderINBOX"),_.forEach(e.$$flattenMailboxes,function(e){angular.isDefined(e.unseenCount)&&!_.includes(t,e.id)&&t.push(e.id)})}),g.$$resource.post("","unseenCount",{mailboxes:t}).then(function(e){_.forEach(x.accounts,function(t){_.forEach(t.$$flattenMailboxes,function(t){e[t.id]&&(t.unseenCount=e[t.id])})})}),(e=$.defaults.SOGoRefreshViewCheck)&&"manually"!=e&&s(x.refreshUnseenCount,1e3*e.timeInterval())},this.isDroppableFolder=function(e,t){return t.id!=e.id&&!t.isNoSelect()},this.dragSelectedMessages=function(e,n,s){var o,i,r,c,u,d;o="/"+n.id,0===(i=e.$selectedMessages()).length&&(i=[e.$selectedMessage()]),r=_.map(i,"uid"),c=e.selectedMessage&&r.indexOf(e.selectedMessage)>=0,"copy"==s?(u=e.$copyMessages(i,o),d=l("%{0} message(s) copied",i.length)):(u=e.$moveMessages(i,o),d=l("%{0} message(s) moved",i.length)),u.then(function(){c&&t.go("mail.account.mailbox"),a.show(a.simple().content(d).position("top right").hideDelay(2e3))})}}e.$inject=["$scope","$state","$transitions","$timeout","$window","$mdDialog","$mdToast","sgFocus","encodeUriFilter","Dialog","sgSettings","sgHotkeys","Account","Mailbox","VirtualMailbox","User","Preferences","stateAccounts"],angular.module("SOGo.MailerUI").controller("MailboxesController",e)}(),function(){"use strict";function e(e,t,n,s,o,i,a,r,c,u,d,h,g,f,m,p,$,b,v,y,M){function x(){return t.mailbox?(arguments.length>0&&(t.mailbox.messageDialog=arguments[0]),t.mailbox.messageDialog):null}function C(e){return function(){if(null===x())return e.apply(F,arguments)}}function w(e){e.push(d.createHotkey({key:l("hotkey_reply"),description:l("Reply to the message"),callback:C(angular.bind(F,F.reply))})),e.push(d.createHotkey({key:l("hotkey_replyall"),description:l("Reply to sender and all recipients"),callback:C(angular.bind(F,F.replyAll))})),e.push(d.createHotkey({key:l("hotkey_forward"),description:l("Forward selected message"),callback:C(angular.bind(F,F.forward))})),e.push(d.createHotkey({key:l("hotkey_flag"),description:l("Flagged"),callback:C(angular.bind(u,u.toggleFlag))})),_.forEach(["backspace","delete"],function(t){e.push(d.createHotkey({key:t,callback:C(function(e){0===F.mailbox.$selectedCount()&&F.deleteMessage(),e.preventDefault()})}))}),_.forEach(e,function(e){d.registerHotkey(e)})}function I(){var t,n,s={};return e.opener&&e.opener.$mailboxController&&e.opener.$mailboxController.selectedFolder.$id()==c.$id()&&(n=e.opener.$mailboxController,s.mailboxCtrl=n,e.opener.$messageController&&e.opener.$messageController.message.uid==u.uid&&(t=e.opener.$messageController,s.messageCtrl=t)),s}function E(e,t){null===x()&&x(o.show({parent:angular.element(document.body),targetEvent:e,clickOutsideToClose:!1,escapeToClose:!1,templateUrl:"UIxMailEditor",controller:"MessageEditorController",controllerAs:"editor",locals:{stateAccount:F.account,stateMessage:t}}).finally(function(){x(null),F.closePopup()}))}function S(e,t){F.message.$plainContent().then(function(n){var s={pid:$.$defaultCalendar(),type:t,summary:n.subject,comment:n.content},i=new b(s),a=[g.activeUser("folderURL"),"Calendar","UIx"+t.capitalize()+"EditorTemplate"].join("/");return o.show({parent:angular.element(document.body),targetEvent:e,clickOutsideToClose:!0,escapeToClose:!0,templateUrl:a,controller:"ComponentEditorController",controllerAs:"editor",locals:{stateComponent:i}})})}var F=this,k=null,D=[];this.$onInit=function(){e.$messageController=F,f.setMessage(u),this.$state=n,this.accounts=a,this.account=r,this.mailbox=c,this.message=u,this.service=M,this.tags={searchText:"",selected:""},this.showFlags=u.flags&&u.flags.length>0,this.$showDetailedRecipients=!1,F.showRawSource=!1,w(D),e.opener?(t.$watchCollection(function(){return F.message.flags},function(e,t){var n;(e||t)&&(n=I()).messageCtrl&&n.messageCtrl.service.$timeout(function(){n.messageCtrl.showFlags=!0,n.messageCtrl.message.flags=e})}),t.$watch(function(){return F.message.isflagged},function(e,t){var n=I();n.mailboxCtrl&&n.mailboxCtrl.service.$timeout(function(){_.find(n.mailboxCtrl.selectedFolder.$messages,{uid:F.message.uid}).isflagged=e})})):t.$watchCollection(function(){return F.message.flags},function(e,t){var n,s,o;(e||t)&&(n=e||[],s=t||[],_.forEach(n,function(e,t){angular.isObject(e)&&(n[t]=e.name)}),n.length>s.length?(o=_.difference(n,s),_.forEach(o,function(e){F.message.addTag(e)})):n.length<s.length&&(o=_.difference(s,n),_.forEach(o,function(e){F.message.removeTag(e)})))}),t.$on("$destroy",function(){_.forEach(D,function(e){d.deregisterHotkey(e)})})},this.addFlags=function(e){this.showFlags=!0,m("flags")},this.toggleDetailedRecipients=function(e){this.$showDetailedRecipients=!this.$showDetailedRecipients,e.stopPropagation(),e.preventDefault()},this.filterMailtoLinks=function(e){var t,n,s,o;"A"==e.target.tagName&&"href"in e.target.attributes&&(t=e.target.attributes.href.value,(n=/^mailto:([^\?]+)/.exec(t))&&(s=_.map(decodeURIComponent(n[1]).split(","),function(e){return"<"+e+">"}),o={to:s},_.forEach(["subject","body"],function(e){var s=new RegExp(e+"=([^&]+)");e="body"==e?"text":e,(n=s.exec(t))&&(o[e]=[decodeURIComponent(n[1])])}),_.forEach(["cc","bcc"],function(e){var s=new RegExp(e+"=([^&]+)");(n=s.exec(t))&&(o[e]=[decodeURIComponent(n[1])])}),this.newMessage(e,o)))},this.deleteMessage=function(){var e,t,o,a,r,l=I();l.messageCtrl?(e=l.mailboxCtrl.selectedFolder,t=l.messageCtrl.message,o=l.messageCtrl.$state):(e=c,t=u,o=n),e.$deleteMessages([t]).then(function(n){var l=n;if(t=null,angular.isDefined(o)){n>0&&(l-=1,a=e.$messages[l]),n<e.$messages.length&&(r=e.$messages[n]),a?a.isread&&r&&!r.isread&&(l=n,a=r):r&&(l=n,a=r);try{a&&s(i["gt-md"])?(o.go("mail.account.mailbox.message",{messageId:a.uid}),l<e.$topIndex?e.$topIndex=l:l>e.$lastVisibleIndex&&(e.$topIndex=l-(e.$lastVisibleIndex-e.$topIndex))):o.go("mail.account.mailbox").then(function(){t=null,delete e.selectedMessage})}catch(e){}}F.closePopup()})},this.close=function(){n.go("mail.account.mailbox").then(function(){F.message=null,delete c.selectedMessage})},this.reply=function(e){E(e,this.message.$reply())},this.replyAll=function(e){E(e,this.message.$replyAll())},this.forward=function(e){E(e,this.message.$forward())},this.edit=function(e){this.message.$editableContent().then(function(){E(e,F.message)})},this.openPopup=function(){var t=[g.baseURL(),"UIxMailPopupView#!/Mail",this.message.accountId,h(h(this.message.$mailbox.path)),this.message.uid].join("/"),n=this.message.$absolutePath();k=e.open(t,n,["width=680","height=520","resizable=1","scrollbars=1","toolbar=0","location=0","directories=0","status=0","menubar=0","copyhistory=0"].join(","))},this.closePopup=function(){e.opener&&e.close()},this.newMessage=function(e,t){this.account.$newMessage().then(function(n){angular.extend(n.editable,t),E(e,n)}),e.stopPropagation(),e.preventDefault()},this.toggleRawSource=function(e){this.showRawSource||this.message.$rawSource?this.showRawSource=!this.showRawSource:M.$$resource.post(this.message.id,"viewsource").then(function(e){F.message.$rawSource=e,F.showRawSource=!0})},this.print=function(t){e.print()},this.convertToEvent=function(e){return S(e,"appointment")},this.convertToTask=function(e){return S(e,"task")}}e.$inject=["$window","$scope","$state","$mdMedia","$mdDialog","sgConstant","stateAccounts","stateAccount","stateMailbox","stateMessage","sgHotkeys","encodeUriFilter","sgSettings","ImageGallery","sgFocus","Dialog","Calendar","Component","Account","Mailbox","Message"],angular.module("SOGo.MailerUI").controller("MessageController",e)}(),function(){"use strict";function e(e,t,n,s,o,i,a,r,c,u,d,h,g,f,m){function p(){var e,n={};try{t.opener&&"$mailboxController"in t.opener&&"selectedFolder"in t.opener.$mailboxController&&("draft"==t.opener.$mailboxController.selectedFolder.type?(n.draftMailboxCtrl=t.opener.$mailboxController,"$messageController"in t.opener&&t.opener.$messageController.message.uid==c.uid&&(n.draftMessageCtrl=t.opener.$messageController)):c.origin&&(e=c.origin.message,t.opener.$mailboxController.selectedFolder.$id()==e.$mailbox.$id()&&(n.originMailboxCtrl=t.opener.$mailboxController)))}catch(e){}return n}function $(){var e,t,n,s=E.message.editable.attachmentAttrs;if(s)for(e=0;e<s.length;e++)t={name:s[e].filename,type:s[e].mimetype,size:parseInt(s[e].size)},(n=new a.FileItem(E.uploader,t)).progress=100,n.isUploaded=!0,n.isSuccess=!0,n.inlineUrl=s[e].url,E.uploader.queue.push(n)}function b(e,n){e.isUploading?E.uploader.cancelItem(e):(E.message.$deleteAttachment(e.file.name),e.remove());var s=t.document.getElementById(n);s&&angular.element(s).prop("value",null)}function v(){E.autosave&&d.cancel(E.autosave),E.message.isNew&&E.message.attachmentAttrs&&E.message.$mailbox.$deleteMessages([E.message]),o.cancel()}function y(){var e=p();E.message.$save().then(function(t){E.message.$rawSource=null,e.draftMailboxCtrl&&e.draftMailboxCtrl.selectedFolder.$filter().then(function(){e.draftMessageCtrl&&e.draftMessageCtrl.$state.go("mail.account.mailbox.message",{messageId:E.message.uid})}),i.show(i.simple().content(l("Your email has been saved")).position("top right").hideDelay(3e3))})}function M(){var e=p();E.sendState="sending",E.autosave&&d.cancel(E.autosave),E.message.$send().then(function(t){E.sendState="sent",e.draftMailboxCtrl&&e.draftMailboxCtrl.selectedFolder.$filter().then(function(){e.draftMessageCtrl&&e.draftMessageCtrl.close()}),e.originMailboxCtrl&&e.originMailboxCtrl.selectedFolder.$filter(),i.show(i.simple().content(l("Your email has been sent")).position("top right").hideDelay(3e3)),d(o.hide,1e3)},function(e){E.sendState="error",E.errorMessage=e.data?e.data.message:e.statusText})}function x(){E.isFullscreen=!E.isFullscreen}function C(e){return g.$filterAll(e).then(function(e){var t=[];return _.forEach(_.invokeMap(e,"explode"),function(e){_.forEach(e,function(e){t.push(e)})}),_.uniqBy(t,function(e){return e.$$fullname+" "+e.$$email})})}function w(e,t){var n,s,o;return n=E.message.editable[t],angular.isString(e)?(_.forEach(e.split(/[,;]/),function(e){n.push(e)}),null):(e.$isList({expandable:!0})?angular.isDefined(e.refs)&&e.refs.length?_.forEach(e.refs,function(e){e.email.length&&n.push(e.$shortFormat())}):(o=f.$find(e.container,e.c_name)).$id().then(function(e){_.forEach(o.refs,function(e){e.email.length&&n.push(e.$shortFormat())})}):s=e.$shortFormat(),s||null)}function I(){E.message.$save(),m.defaults.SOGoMailAutoSave&&(E.autosave=d(E.autosaveDrafts,1e3*m.defaults.SOGoMailAutoSave*60))}var E=this;E.addRecipient=w,E.autocomplete={to:{},cc:{},bcc:{}},E.autosave=null,E.autosaveDrafts=I,E.cancel=v,E.contactFilter=C,E.isFullscreen=!1,E.hideBcc=0===c.editable.bcc.length,E.hideCc=0===c.editable.cc.length,E.identities=_.map(r.identities,"full"),E.message=c,E.recipientSeparatorKeys=[s.KEY_CODE.ENTER,s.KEY_CODE.TAB,s.KEY_CODE.COMMA,s.KEY_CODE.SEMICOLON],E.removeAttachment=b,E.save=y,E.send=M,E.sendState=!1,E.toggleFullscreen=x,E.uploader=new a({url:c.$absolutePath({asDraft:!0,withResourcePath:!0})+"/save",autoUpload:!0,alias:"attachments",removeAfterUpload:!1,onSuccessItem:function(e,t,n,s){c.$setUID(t.uid),c.$reload({asDraft:!1}),e.inlineUrl=t.lastAttachmentAttrs[0].url},onCancelItem:function(e,t,n,s){c.$deleteAttachment(e.file.name),this.removeFromQueue(e)},onErrorItem:function(e,t,n,s){i.show(i.simple().content(l('Error while uploading the file "%{0}":',e.file.name)+" "+(t.message?l(t.message):"")).position("top right").action(l("OK")).hideDelay(!1)),this.removeFromQueue(e)}}),m.defaults.SOGoMailAutoSave&&(E.autosave=d(E.autosaveDrafts,1e3*m.defaults.SOGoMailAutoSave*60)),E.localeCode=m.defaults.LocaleCode,e.$on("$destroy",function(){E.uploader.destroy()}),"reply"==n.actionName?c.$reply().then(function(e){E.message=e,E.hideCc=!e.editable.cc||0===e.editable.cc.length,E.hideBcc=!e.editable.bcc||0===e.editable.bcc.length}):"replyall"==n.actionName?c.$replyAll().then(function(e){E.message=e,E.hideCc=!e.editable.cc||0===e.editable.cc.length,E.hideBcc=!e.editable.bcc||0===e.editable.bcc.length}):"forward"==n.actionName?c.$forward().then(function(e){E.message=e,$()}):angular.isDefined(c)&&(E.message=c,$())}function t(e,t){e.closeToast=function(){t.hide()}}e.$inject=["$scope","$window","$stateParams","$mdConstant","$mdDialog","$mdToast","FileUploader","stateAccount","stateMessage","encodeUriFilter","$timeout","Dialog","AddressBook","Card","Preferences"],t.$inject=["$scope","$mdToast"],angular.module("SOGo.MailerUI").controller("SendMessageToastController",t).controller("MessageEditorController",e)}(),function(){function e(){return{restrict:"C",scope:{},controller:"sgAccountController"}}function t(e,t,n,s,o,i,a,r){var l=[];this.$postLink=function(){this.quotaElement=_.find(e.find("div"),function(e){return e.classList.contains("sg-quota")})},this.addMailboxController=function(e){l.push(e)},this.selectFolder=function(e){if(a.selectedFolderController=e,null!==a.selectedFolder){var t=_.find(l,function(e){return e.mailbox.id==a.selectedFolder.id});t&&t.unselectFolder()}s(i["gt-md"])||o("left").close()}}t.$inject=["$element","$transitions","$state","$mdMedia","$mdSidenav","sgConstant","Mailbox","encodeUriFilter"],angular.module("SOGo.MailerUI").controller("sgAccountController",t).directive("sgAccountSection",e)}(),function(){"use strict";function e(){function e(e,t,n,s){s.pathToAttachment=n.sgImipPath}return{restrict:"A",link:e,controller:"sgImipController"}}function t(e,t){var n=this;e.delegateInvitation=!1,e.delegatedTo="",e.searchText="",e.userFilter=function(e){return t.$filter(e)},e.iCalendarAction=function(t){var s;"delegate"==t&&(s={receiveUpdates:!1,delegatedTo:e.delegatedTo.c_email}),e.viewer.message.$imipAction(n.pathToAttachment,t,s)}}t.$inject=["$scope","User"],angular.module("SOGo.MailerUI").controller("sgImipController",t).directive("sgImip",e)}(),function(){function e(){return{restrict:"C",require:{accountController:"^^sgAccountSection"},scope:{},bindToController:{mailbox:"=sgMailbox"},template:[' <div class="sg-child-level-0"',' ng-class="$ctrl.childLevel()">',' <md-checkbox class="sg-folder"',' ng-class="$ctrl.mailbox.$icon"',' aria-label="'+l("Expanded")+'"',' ng-model="$ctrl.mailbox.$expanded"',' ng-disabled="$ctrl.mailbox.children.length == 0"',' ng-change="$ctrl.mailbox.$account.$flattenMailboxes({ reload: true, saveState: true })">'," <md-icon>{{$ctrl.mailbox.$icon}}</md-icon></md-checkbox>"," </div>",' <p class="sg-item-name"',' ng-click="$ctrl.selectFolder($event)"',' ng-dblclick="$ctrl.editFolder($event)">',' <span ng-bind="$ctrl.mailbox.$displayName"></span>',' <span class="sg-counter-badge ng-hide"',' ng-show="$ctrl.mailbox.unseenCount"',' ng-bind="$ctrl.mailbox.unseenCount"></span>'," </p>",' <md-input-container class="md-flex ng-hide">',' <input class="sg-item-name" type="text"',' aria-label="'+l("Enter the new name of your folder")+'"',' ng-blur="$ctrl.saveFolder($event)"',' sg-enter="$ctrl.saveFolder($event)"',' sg-escape="$ctrl.revertEditing()" />'," </md-input-container>",' <md-icon class="md-menu" ng-click="$ctrl.showMenu($event)" aria-label="'+l("Options")+'">more_vert</md-icon>'].join(""),controller:"sgMailboxListItemController",controllerAs:"$ctrl"}}function t(e,t,n,s,o,i,a,r,c,u,d){var h=this;this.$onInit=function(){this.$element=t,this.service=u,this.editMode=!1,this.accountController.addMailboxController(this)},this.$postLink=function(){this.selectableElement=t.find("div")[0],this.clickableElement=t.find("p")[0],this.inputContainer=t.find("md-input-container")[0],this.inputElement=t.find("input")[0],this.moreOptionsButton=_.last(t.find("md-icon")),null!==u.selectedFolder&&u.selectedFolder.id==this.mailbox.id&&this.accountController.selectFolder(this)},this.childLevel=function(){return"sg-child-level-"+this.mailbox.level},this.selectFolder=function(e){this.editMode||this.mailbox==u.selectedFolder||(u.$virtualPath=!1,u.$virtualMode=!1,this.accountController.selectFolder(this),e&&(n.go("mail.account.mailbox",{accountId:this.mailbox.$account.id,mailboxId:d(this.mailbox.path)}),e.stopPropagation(),e.preventDefault()))},this.unselectFolder=function(){t[0].classList.remove("md-bg")},this.editFolder=function(e){this.editMode=!0,this.inputElement.value=this.mailbox.name,this.clickableElement.classList.add("ng-hide"),this.inputContainer.classList.remove("ng-hide"),this.inputElement.focus(),this.inputElement.select(),e&&(e.stopPropagation(),e.preventDefault())},this.saveFolder=function(e){this.inputElement.disabled||(this.mailbox.name=this.inputElement.value,this.inputElement.disabled=!0,this.mailbox.$rename().then(function(e){h.editMode=!1,h.inputContainer.classList.add("ng-hide"),h.clickableElement.classList.remove("ng-hide")}).finally(function(){h.inputElement.disabled=!1}))},this.revertEditing=function(){this.editMode=!1,this.clickableElement.classList.remove("ng-hide"),this.inputContainer.classList.add("ng-hide"),this.inputElement.value=this.mailbox.name},this.confirmDelete=function(){c.confirm(l("Warning"),l("Do you really want to move this folder into the trash ?"),{ok:l("Delete")}).then(function(){h.mailbox.$delete().then(function(){n.go("mail.account.inbox")},function(e){c.confirm(l("Warning"),l("The mailbox could not be moved to the trash folder. Would you like to delete it immediately?"),{ok:l("Delete")}).then(function(){h.mailbox.$delete({withoutTrash:!0}).then(function(){n.go("mail.account.inbox")},function(e){c.alert(l('An error occured while deleting the mailbox "%{0}".',h.mailbox.name),l(e.error))})})})})},this.showMenu=function(e){function t(e,t,n,o){var d=this;this.markFolderRead=function(){this.folder.$markAsRead()},this.newFolder=function(){c.prompt(l("New Folder..."),l("Enter the new name of your folder")).then(function(e){d.folder.$newMailbox(d.folder.id,e).then(function(){},function(t,n){c.alert(l('An error occured while creating the mailbox "%{0}".',e),l(t.error))})})},this.editFolder=function(){this.itemCtrl.editFolder()},this.compactFolder=function(){this.folder.$compact().then(function(){s.show(s.simple().content(l("Folder compacted")).position("top right").hideDelay(3e3))})},this.emptyTrashFolder=function(){this.folder.$emptyTrash().then(function(){s.show(s.simple().content(l("Trash emptied")).position("top right").hideDelay(3e3))})},this.showAdvancedSearch=function(){u.$virtualPath=this.folder.path,i(r["gt-md"])||a("left").close()},this.share=function(){this.folder.$acl.$users().then(function(){n.show({templateUrl:d.folder.id+"/UIxAclEditor",controller:"AclController",controllerAs:"acl",clickOutsideToClose:!0,escapeToClose:!0,locals:{usersWithACL:d.folder.$acl.users,User:o,folder:d.folder}})})},this.setFolderAs=function(e){this.folder.$setFolderAs(e).then(function(){d.folder.$account.$getMailboxes({reload:!0})})}}var n=o.newPanelPosition().relativeTo(this.moreOptionsButton).addPanelPosition(o.xPosition.ALIGN_START,o.yPosition.ALIGN_TOPS),d=o.newPanelAnimation().openFrom(this.moreOptionsButton).duration(100).withAnimation(o.animation.FADE),h={attachTo:angular.element(document.body),locals:{itemCtrl:this,folder:this.mailbox,confirmDelete:this.confirmDelete},bindToController:!0,controller:t,controllerAs:"$menuCtrl",position:n,animation:d,targetEvent:e,templateUrl:"UIxMailFolderMenu",trapFocus:!0,clickOutsideToClose:!0,escapeToClose:!0,focusOnOpen:!0};o.open(h).then(function(e){e.panelEl.one("click",function(){e.close()})}),t.$inject=["mdPanelRef","$state","$mdDialog","User"]}}t.$inject=["$scope","$element","$state","$mdToast","$mdPanel","$mdMedia","$mdSidenav","sgConstant","Dialog","Mailbox","encodeUriFilter"],angular.module("SOGo.MailerUI").controller("sgMailboxListItemController",t).directive("sgMailboxListItem",e)}(),function(){function e(){return{restrict:"C",scope:{},bindToController:{message:"=sgMessage"},controller:"sgMessageListItemController"}}function t(e,t,n){var s=this;this.$onInit=function(){this.MailboxService=n,e.$watch(function(){return s.message?[_.pick(s.message,["uid","isread","isflagged"])]:null},function(e,t){s.message&&s.onUpdate()},!0)},this.onUpdate=function(){this.message.isread?t.removeClass("unread"):t.addClass("unread"),n.selectedFolder.isSelectedMessage(this.message.uid,this.message.$mailbox.path)?t.addClass("md-default-theme md-accent md-bg md-hue-2"):t.removeClass("md-default-theme md-accent md-bg md-hue-2")},this.setVisibility=function(e,t){t?e.classList.remove("ng-hide"):e.classList.add("ng-hide")}}t.$inject=["$scope","$element","Mailbox"],angular.module("SOGo.MailerUI").controller("sgMessageListItemController",t).directive("sgMessageListItem",e)}(),function(){function e(){function e(e,t,n,s){e.parentController=s}return{restrict:"C",require:"^^sgMessageListItem",scope:{},template:['<div class="sg-tile-content">',' <div class="sg-md-subhead">'," <div>",' <span class="sg-label-outline ng-hide">\x3c!-- mailbox --\x3e</span>',' <md-icon class="ng-hide">error</md-icon>'," <span>\x3c!-- sender or recipient --\x3e</span>"," </div>",' <div class="sg-tile-date">\x3c!-- date --\x3e</div>'," </div>",' <div class="sg-md-body">',' <div class="sg-tile-subject">\x3c!-- subject --\x3e</div>',' <div class="sg-tile-size">\x3c!-- size --\x3e</div>'," </div>","</div>",'<div class="sg-tile-icons">',' <md-icon class="ng-hide">star</md-icon>',' <md-icon class="ng-hide">reply</md-icon>',' <md-icon class="ng-hide">forward</md-icon>',' <md-icon class="ng-hide">attach_file</md-icon>',"</div>",'<div class="sg-progress-linear-bottom">',' <md-progress-linear class="md-accent"',' md-mode="indeterminate"',' ng-disabled="!$ctrl.message.$isLoading()">\x3c!-- message loading progress --\x3e</md-progress-linear>',"</div>"].join(""),link:e,controller:"sgMessageListItemMainController",controllerAs:"$ctrl"}}function t(e,t,n,s,o,i,a,r,l){var c=this;this.$postLink=function(){var n,s,i,l;this.parentController=e.parentController,i=this.parentController.onUpdate,l=this.parentController.setVisibility,_.forEach(t.find("div"),function(e){e.classList.contains("sg-tile-content")?n=angular.element(e):e.classList.contains("sg-tile-icons")&&(s=angular.element(e))}),this.priorityIconElement=n.find("md-icon")[0],a.$virtualMode&&(this.mailboxNameElement=n.find("span")[0],this.mailboxNameElement.classList.remove("ng-hide")),this.senderElement=n.find("span")[1],_.forEach(n.find("div"),function(e){e.classList.contains("sg-tile-subject")?c.subjectElement=e:e.classList.contains("sg-tile-size")?c.sizeElement=e:e.classList.contains("sg-tile-date")&&(c.dateElement=e)}),_.forEach(s.find("md-icon"),function(e){"star"==e.textContent?c.flagIconElement=e:"reply"==e.textContent?c.answerIconElement=e:"forward"==e.textContent?c.forwardIconElement=e:"attach_file"==e.textContent&&(c.attachmentIconElement=e)}),this.parentController.onUpdate=function(){var e;c.message=c.parentController.message;var n=o.nodesToArray(t[0].querySelectorAll(".sg-category"));for(_.forEach(n,function(e){t[0].removeChild(e)}),e=0;e<c.message.flags.length&&e<5;e++){var s=c.message.flags[e];if(c.service.$tags[s]){var a=angular.element('<div class="sg-category"></div>');a.css("left",3*e+"px"),a.css("background-color",c.service.$tags[s][1]),t.prepend(a)}}c.mailboxNameElement&&(c.mailboxNameElement.innerHTML=c.message.$mailbox.$displayName),"sent"==c.MailboxService.selectedFolder.type?c.senderElement.innerHTML=c.message.$shortAddress("to").encodeEntities():c.senderElement.innerHTML=c.message.$shortAddress("from").encodeEntities(),c.message.priority&&c.message.priority.level<3?(c.priorityIconElement.classList.remove("ng-hide"),c.message.priority.level<2?c.priorityIconElement.classList.add("md-warn"):c.priorityIconElement.classList.remove("md-warn")):c.priorityIconElement.classList.add("ng-hide"),c.subjectElement.innerHTML=c.message.subject.encodeEntities(),c.sizeElement.innerHTML=c.message.size,c.dateElement.innerHTML=c.message.relativedate,l(c.flagIconElement,c.message.isflagged),l(c.answerIconElement,c.message.isanswered),l(c.forwardIconElement,c.message.isforwarded),l(c.attachmentIconElement,c.message.hasattachment),angular.bind(c.parentController,i)()},this.service=r,this.MailboxService=a}}t.$inject=["$scope","$element","$parse","$state","$mdUtil","$mdToast","Mailbox","Message","encodeUriFilter"],angular.module("SOGo.MailerUI").controller("sgMessageListItemMainController",t).directive("sgMessageListItemMain",e)}(),function(){"use strict";function e(){return{restrict:"A",bindToController:{partIndex:"=sgZoomableImage"},controller:t}}function t(e,t){var n=this;this.$postLink=function(){t.registerImage(e),e.on("click",this.showImage)},this.showImage=function(e){"IMG"==e.target.tagName&&t.showGallery(e,n.partIndex)}}t.$inject=["$element","ImageGallery"],angular.module("SOGo.MailerUI").directive("sgZoomableImage",e)}();
|
|
//# sourceMappingURL=Mailer.services.js.map
|