1 line
258 KiB
Plaintext
1 line
258 KiB
Plaintext
{"version":3,"sources":["Mailer/Account.service.js","Mailer/Mailbox.service.js","Mailer/Message.service.js","Mailer/sgImageGallery.service.js","Mailer/VirtualMailbox.service.js","Mailer/MailboxController.js","Mailer/MailboxesController.js","Mailer/MessageController.js","Mailer/MessageEditorController.js","Mailer/sgAccountSection.directive.js","Mailer/sgImageGallery.directive.js","Mailer/sgIMIP.directive.js","Mailer/sgMailboxListItem.directive.js","Mailer/sgMessageListItem.directive.js","Mailer/sgMessageListItemMain.directive.js","Mailer/sgZoomableImage.directive.js"],"names":["Account","futureAccountData","then","angular","extend","this","_","forEach","identities","identity","fullName","full","email","$log","debug","JSON","stringify","undefined","$factory","$q","$timeout","Settings","Resource","Preferences","Mailbox","Message","$$resource","activeUser","$Preferences","$Mailbox","$Message","module","e","factory","$findAll","data","$unwrapCollection","fetch","o","collection","i","id","$accounts","prototype","getLength","$flattenMailboxes","length","getItemAtIndex","index","expandedMailboxes","$getMailboxes","options","_this","$mailboxes","reload","$find","$expanded","expandedFolders","_visit","mailboxes","indexOf","children","settings","Mail","ExpandedFolders","isString","fromJson","warn","when","allMailboxes","push","all","$$flattenMailboxes","saveState","account","reduce","mailbox","post","$getMailboxByType","type","_find","find","$getMailboxByPath","path","$newMailbox","name","toString","$certificate","security","hasCertificate","$$certificate","reject","$removeCertificate","updateQuota","percent","format","description","Math","round","usedSpace","maxQuota","l","formatted","$quota","$newMessage","message","accountId","mailboxPath","$absolutePath","asDraft","accountDefaults","defaults","AuxiliaryMailAccounts","alwaysSign","sign","alwaysEncrypt","encrypt","editable","isNew","mailto","isObject","$parseMailto","$addDelegate","user","deferred","defer","param","uid","map","delegates","resolve","users","status","promise","$removeDelegate","splice","futureMailboxData","$account","init","newMailboxData","create","$unwrap","Acl","PRELOAD","$$Acl","$query","sort","asc","selectedFolder","$refreshTimeout","$virtualMode","$virtualPath","SortingState","parseInt","constant","LOOKAHEAD","SIZE","createMailboxes","level","quotas","split","component","asCSSIdentifier","join","isUndefined","uidsMap","headers","$isLoading","$messages","$id","$acl","$displayName","$isEditable","isEditable","$isSpecial","$icon","$isNoInferiors","isNoInferiors","$shadowData","$omit","selectFolder","$lastVisibleIndex","max","$loadMessage","$selectedMessages","filter","selected","$selectedCount","isSelectedMessage","messageId","selectedMessage","$selectedMessage","$selectedMessageIndex","hasSelectedMessage","isDefined","$filter","sortingAttributes","filters","unseenCount","cancel","searchInput","secondFilter","match","searchBy","copy","refreshViewCheck","SOGoRefreshViewCheck","f","bind","timeInterval","endIndex","uids","futureHeadersData","startIndex","loaded","subject","min","loading","$unwrapHeaders","flags","isNoSelect","getClassName","base","$rename","findParent","parent","parentMailbox","$save","sibling","oldPath","localeCompare","pathRE","RegExp","_updateChildren","child","replace","$compact","$canFolderAs","$setFolderAs","$emptyTrash","$markAsRead","isread","$flagMessages","messages","operation","msgUIDs","saveSelectedMessages","selectedMessages","selectedUIDs","filename","download","exportFolder","$delete","$_deleteMessages","unseen","firstIndex","forEachRight","selectedIndex","findIndex","$deleteMessages","$markOrUnMarkMessagesAsJunk","method","$copyMessages","folder","$moveMessages","$reset","value","key","save","response","error","$futureMailboxData","$topIndex","invokeMap","threaded","msgs","msg","msgObject","zipObject","isError","j","messageHeaders","$updateSubscribe","action","subscribed","futureMessageData","lazy","$mailbox","$hasUnsafeContent","$loadUnsafeContent","to","cc","bcc","$formatFullAddresses","Message_STATUS","STATUS","$avatar","avatar","SOGoMailLabelsColors","$tags","SOGoMailDisplayRemoteInlineImages","$displayRemoteInlineImages","NOT_LOADED","DELAYED_LOADING","LOADING","LOADED","DELAYED_MS","filterTags","query","excludedTags","re","results","keys","tag","pair","search","includes","color","buildPath","nocache","draftId","withResourcePath","$setUID","oldUID","attr","constructor","shortname","first","last","image","$shortRecipients","result","count","total","$shortAddress","address","allowReplyAll","recipientsCount","isDraft","loadUnsafeContent","$parts","$content","parts","part","msgclass","content","alternatePart","preferredPart","contentType","isArray","signed","valid","certificate","certificates","encrypted","mixedPart","safeContent","html","unsafeContent","document","createElement","innerHTML","suffix","element","elements","querySelectorAll","removeAttr","compile","$editableContent","from","toLowerCase","text","$plainContent","addTag","$addOrRemoveTag","removeTag","$imipAction","$reload","$sendMDN","shouldAskReceipt","$deleteAttachment","attachmentAttrs","attachment","toggleFlag","isflagged","$loaded","useCache","$futureMessageData","exec","decodeURIComponent","trim","$reply","$newDraft","$replyAll","$forward","origin","$send","startsWith","isanswered","isforwarded","privateAttributes","downloadAttachments","ImageGallery","show","$document","$mdPanel","sgHotkeys","setMessage","registerImage","registerHotkeys","$ctrl","createHotkey","callback","previousImage","nextImage","registerHotkey","showGallery","$event","partIndex","PanelController","mdPanelRef","close","selectImage","selectedImage","images","lastIndex","partSrc","src","attrs","mimetype","url","body","addClass","panelPosition","newPanelPosition","absolute","panelAnimation","newPanelAnimation","openFrom","target","duration","withAnimation","animation","FADE","config","attachTo","locals","bindToController","controller","controllerAs","position","targetEvent","fullscreen","hasBackdrop","template","trapFocus","clickOutsideToClose","escapeToClose","focusOnOpen","onOpenComplete","getElementsByClassName","imgContainer","imgEl","one","naturalWidth","naturalHeight","classList","add","remove","onDomRemoved","removeClass","hotkeys","deregisterHotkey","open","$inject","VirtualMailbox","setMailboxes","startSearch","params","finally","stopSearch","resetSelectedMessage","len","k","transform","messagesMap","sum","allMessages","promises","assign","flatten","MailboxController","$window","$scope","$state","$mdDialog","$mdToast","stateAccounts","stateAccount","stateMailbox","encodeUriFilter","sgSettings","focus","Dialog","_registerHotkeys","vm","searchMode","messageDialog","newMessage","markOrUnMarkMessagesAsJunk","toggleMessageSelection","_nextMessage","preventInClass","_previousMessage","_addNextMessageToSelection","_addPreviousMessageToSelection","hotkey","confirmDeleteSelectedMessages","_compactBeforeUnload","event","_newMessageInPopup","baseURL","wId","random","console","selectMessage","preventDefault","_currentMailboxes","_unselectMessage","nextMessage","previousMessage","nextIndex","mode","multiple","go","defaultWindowTitle","$onInit","$mailboxController","service","accounts","on","$on","off","$watch","title","centerIsClose","navController_centerIsClose","field","sortedBy","cancelSearch","composeWindowEnabled","SOGoMailComposeWindowEnabled","inPopup","SOGoMailComposeWindow","templateUrl","stateMessage","catch","noop","mailboxId","nextSelectedIndex","shiftKey","stopPropagation","size","confirm","ok","deleteSelectedMessage","withoutTrash","moveSelectedMessage","dstFolder","copySelectedMessages","simple","hideDelay","moveSelectedMessages","selectAll","unselectMessages","markSelectedMessagesAsFlagged","markSelectedMessagesAsUnread","markSelectedMessagesAsRead","mdVirtualRepeatContainerDirectiveDecorator","$delegate","resetScroll","$element","updateSize","scrollTo","decorator","MailboxesController","$transitions","User","selectedFolderController","confirmDelete","currentSearchParam","","subfolders","showSubscribedOnly","SOGoMailShowSubscribedFoldersOnly","refreshUnseenCount","hideAdvancedSearch","searchPreviousMailbox","toggleAdvancedSearch","virtualMailbox","root","folders","$current","addSearchParam","v","newSearchParam","pattern","n","searchParam","substring","negative","toggleAccountState","triggerHandler","subscribe","SubscriptionsDialogController","srcAccount","hide","newFolder","parentFolder","prompt","alert","delegate","MailboxDelegationController","userFilter","closeModal","removeUser","addUser","userToAdd","searchText","unseenCountFolders","isDroppableFolder","srcFolder","dragSelectedMessages","dstId","clearMessageView","success","MessageController","$mdMedia","sgConstant","Calendar","Component","_messageDialog","arguments","_unlessInDialog","apply","reply","replyAll","forward","deleteMessage","$parentControllers","ctrls","opener","mailboxCtrl","$messageController","messageCtrl","_showMailEditor","closePopup","_convertToComponent","componentData","pid","$defaultCalendar","summary","comment","capitalize","stateComponent","popupWindow","tags","showFlags","$showDetailedRecipients","showRawSource","$watchCollection","newTags","oldTags","wasflagged","_newTags","_oldTags","difference","addFlags","toggleDetailedRecipients","filterMailtoLinks","href","tagName","attributes","state","parentCtrls","_showMailEditorInPopup","isPopup","openInPopup","edit","contains","toggleRawSource","$rawSource","print","convertToEvent","convertToTask","MessageEditorController","$stateParams","$mdConstant","$mdUtil","FileUploader","AddressBook","Card","originMessage","draftMailboxCtrl","draftMessageCtrl","originMailboxCtrl","_initFileUploader","uploader","autoUpload","alias","removeAfterUpload","onSuccessItem","item","inlineUrl","lastAttachmentAttrs","onCancelItem","file","removeFromQueue","onErrorItem","_updateFileUploader","_addAttachments","fileItem","FileItem","progress","isUploaded","isSuccess","queue","removeAttachment","isUploading","cancelItem","getElementById","prop","autosave","send","sendState","errorMessage","statusText","toggleFullscreen","isFullscreen","contactFilter","$filterAll","cards","explodedCards","manyCards","card","uniqBy","$$fullname","$$email","addRecipient","contact","recipients","recipient","list","emailRE","charCodeAt","test","charAt","$isList","expandable","refs","ref","$shortFormat","container","c_name","listId","autosaveDrafts","SOGoMailAutoSave","autocomplete","hideBcc","hideCc","uniq","recipientSeparatorKeys","KEY_CODE","ENTER","TAB","COMMA","SEMICOLON","localeCode","LocaleCode","destroy","actionName","SendMessageToastController","closeToast","sgAccountSection","restrict","scope","sgAccountController","$mdSidenav","$postLink","quotaElement","div","addMailboxController","mailboxController","selectedMailboxCtrl","ctrl","unselectFolder","directive","sgImageGalleryController","addImage","imgSrc","relativeTo","addPanelPosition","xPosition","ALIGN_START","yPosition","ALIGN_TOPS","panelRef","panelEl","sgImip","link","iElement","pathToAttachment","sgImipPath","sgImipController","delegateInvitation","delegatedTo","iCalendarAction","receiveUpdates","c_email","viewer","sgMailboxListItem","require","accountController","sgMailboxListItemController","editMode","selectableElement","clickableElement","inputContainer","inputElement","moreOptionsButton","childLevel","editFolder","select","saveFolder","disabled","revertEditing","showMenu","MenuController","$menuCtrl","markFolderRead","itemCtrl","compactFolder","emptyTrashFolder","showAdvancedSearch","share","$users","usersWithACL","setFolderAs","sgMessageListItem","sgMessageListItemController","watchedAttrs","MailboxService","pick","newId","oldId","onUpdate","setVisibility","visible","sgMessageListItemMain","postLink","parentController","sgMessageListItemMainController","$parse","contentDivElement","iconsDivElement","parentControllerOnUpdate","priorityIconElement","mailboxNameElement","senderElement","subjectElement","sizeElement","dateElement","textContent","flagIconElement","answerIconElement","forwardIconElement","attachmentIconElement","flagElements","nodesToArray","flagElement","removeChild","css","prepend","encodeEntities","priority","relativedate","hasattachment","sgZoomableImage","sgZoomableImageController","showImage"],"mappings":"CAEA,WACE,YAOE,SAASA,GAAQC,GAEqB,kBAA3BA,GAAkBC,OAC3BC,QAAQC,OAAOC,KAAMJ,GACrBK,EAAEC,QAAQF,KAAKG,WAAY,SAASC,GAC9BA,EAASC,SACXD,EAASE,KAAOF,EAASC,SAAW,KAAOD,EAASG,MAAQ,IAE5DH,EAASE,KAAO,IAAMF,EAASG,MAAQ,MAE3CZ,EAAQa,KAAKC,MAAM,YAAcC,KAAKC,UAAUf,EAAmBgB,OAAW,KAalFjB,EAAQkB,UAAY,KAAM,WAAY,OAAQ,aAAc,WAAY,cAAe,UAAW,UAAW,SAASC,EAAIC,EAAUP,EAAMQ,EAAUC,EAAUC,EAAaC,EAASC,GAWlL,MAVAtB,SAAQC,OAAOJ,GACbmB,GAAIA,EACJC,SAAUA,EACVP,KAAMA,EACNa,WAAY,GAAIJ,GAASD,EAASM,WAAW,aAAe,OAAQN,EAASM,cAC7EC,aAAcL,EACdM,SAAUL,EACVM,SAAUL,IAGLzB,GAOT,KACEG,QAAQ4B,OAAO,iBAEjB,MAAMC,GACJ7B,QAAQ4B,OAAO,iBAAkB,gBAEnC5B,QAAQ4B,OAAO,iBACZE,QAAQ,UAAWjC,EAAQkB,UAQ9BlB,EAAQkC,SAAW,SAASC,GAC1B,MAAKA,GAKEnC,EAAQoC,kBAAkBD,GAJxBnC,EAAQ0B,WAAWW,MAAM,GAAI,gBAAgBnC,KAAK,SAASoC,GAChE,MAAOtC,GAAQoC,kBAAkBE,MAYvCtC,EAAQoC,kBAAoB,SAASD,GACnC,GAAII,KAQJ,OANApC,SAAQI,QAAQ4B,EAAM,SAASG,EAAGE,GAChCF,EAAEG,GAAKD,EACPD,EAAWC,GAAK,GAAIxC,GAAQsC,KAE9BtC,EAAQ0C,UAAYH,EAEbA,GASTvC,EAAQ2C,UAAUC,UAAY,WAC5B,MAAOvC,MAAKwC,oBAAoBC,Q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jT,QAAQsS,aAC7Byc,EAAc9b,EAAMkd,sBACLld,EAAMjT,QAAQ6wB,eAG7Bn3B,QAAQ6M,KAAK0M,EAAMkc,iBAAkBK,MAGvC51B,KAAKqhB,QAAUjgB,EACfpB,KAAK80B,eAAiB3zB,GApH1Bq0B,EAAgCnY,SAAW,SAAU,WAAY,SAAU,SAAU,UAAW,WAAY,UAAW,UAAW,mBA0HlIvd,QACG4B,OAAO,iBACPia,WAAW,kCAAmC6Z,GAC9CjE,UAAU,wBAAyB8D,MCnLxC,WAEE,YAeA,SAAS6B,KACP,OACEvG,SAAU,IACVjV,kBACE7B,UAAW,oBAEb8B,WAAYwb,GA8BhB,QAASA,GAA0BnT,EAAUnL,GAC3C,GAAIQ,GAAQrZ,IAEZA,MAAK+wB,UAAY,WACflY,EAAaM,cAAc6K,GAC3BA,EAASzC,GAAG,QAASvhB,KAAKo3B,YAG5Bp3B,KAAKo3B,UAAY,SAASxd,GACK,OAAzBA,EAAOsB,OAAOkP,SAChBvR,EAAac,YAAYC,EAAQP,EAAMQ,YAX7Csd,EAA0B9Z,SAAW,WAAY,gBAejDvd,QACG4B,OAAO,iBACP6vB,UAAU,kBAAmB2F","file":"Mailer.services.js","sourcesContent":["/* -*- Mode: javascript; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n\n(function() {\n 'use strict';\n\n /**\n * @name Account\n * @constructor\n * @param {object} futureAccountData\n */\n function Account(futureAccountData) {\n // Data is immediately available\n if (typeof futureAccountData.then !== 'function') {\n angular.extend(this, futureAccountData);\n _.forEach(this.identities, function(identity) {\n if (identity.fullName)\n identity.full = identity.fullName + ' <' + identity.email + '>';\n else\n identity.full = '<' + identity.email + '>';\n });\n Account.$log.debug('Account: ' + JSON.stringify(futureAccountData, undefined, 2));\n }\n else {\n // The promise will be unwrapped first\n //this.$unwrap(futureAccountData);\n }\n }\n\n /**\n * @memberof Account\n * @desc The factory we'll use to register with Angular\n * @returns the Account constructor\n */\n Account.$factory = ['$q', '$timeout', '$log', 'sgSettings', 'Resource', 'Preferences', 'Mailbox', 'Message', function($q, $timeout, $log, Settings, Resource, Preferences, Mailbox, Message) {\n angular.extend(Account, {\n $q: $q,\n $timeout: $timeout,\n $log: $log,\n $$resource: new Resource(Settings.activeUser('folderURL') + 'Mail', Settings.activeUser()),\n $Preferences: Preferences,\n $Mailbox: Mailbox,\n $Message: Message\n });\n\n return Account; // return constructor\n }];\n\n /**\n * @module SOGo.MailerUI\n * @desc Factory registration of Account in Angular module.\n */\n try {\n angular.module('SOGo.MailerUI');\n }\n catch(e) {\n angular.module('SOGo.MailerUI', ['SOGo.Common']);\n }\n angular.module('SOGo.MailerUI')\n .factory('Account', Account.$factory);\n\n /**\n * @memberof Account\n * @desc Set the list of accounts and instanciate a new Account object for each item.\n * @param {array} [data] - the metadata of the accounts\n * @returns the list of accounts\n */\n Account.$findAll = function(data) {\n if (!data) {\n return Account.$$resource.fetch('', 'mailAccounts').then(function(o) {\n return Account.$unwrapCollection(o);\n });\n }\n return Account.$unwrapCollection(data);\n };\n\n /**\n * @memberof Account\n * @desc Unwrap to a collection of Account instances.\n * @param {object} data - the accounts information\n * @returns a collection of Account objects\n */\n Account.$unwrapCollection = function(data) {\n var collection = [];\n\n angular.forEach(data, function(o, i) {\n o.id = i;\n collection[i] = new Account(o);\n });\n Account.$accounts = collection;\n\n return collection;\n };\n\n /**\n * @function getLength\n * @memberof Account.prototype\n * @desc Used by md-virtual-repeat / md-on-demand\n * @returns the number of mailboxes in the account\n */\n Account.prototype.getLength = function() {\n return this.$flattenMailboxes().length;\n };\n\n /**\n * @function getItemAtIndex\n * @memberof Account.prototype\n * @desc Used by md-virtual-repeat / md-on-demand\n * @returns the mailbox at the specified index\n */\n Account.prototype.getItemAtIndex = function(index) {\n var expandedMailboxes;\n\n expandedMailboxes = this.$flattenMailboxes();\n if (index >= 0 && index < expandedMailboxes.length)\n return expandedMailboxes[index];\n\n return null;\n };\n\n /**\n * @function $getMailboxes\n * @memberof Account.prototype\n * @desc Fetch the list of mailboxes for the current account.\n * @param {object} [options] - force a reload by setting 'reload' to true\n * @returns a promise of the HTTP operation\n */\n Account.prototype.$getMailboxes = function(options) {\n var _this = this;\n\n if (this.$mailboxes && !(options && options.reload)) {\n return Account.$q.when(this.$mailboxes);\n }\n else {\n return Account.$Mailbox.$find(this, options).then(function(data) {\n _this.$mailboxes = data;\n _this.$expanded = false;\n\n // Set expanded folders from user's settings\n var expandedFolders,\n _visit = function(mailboxes) {\n _.forEach(mailboxes, function(o) {\n o.$expanded = (expandedFolders.indexOf('/' + o.id) >= 0);\n if (o.children && o.children.length > 0) {\n _visit(o.children);\n }\n });\n };\n if (Account.$Preferences.settings.Mail.ExpandedFolders) {\n if (angular.isString(Account.$Preferences.settings.Mail.ExpandedFolders)) {\n // Backward compatibility support\n try {\n expandedFolders = angular.fromJson(Account.$Preferences.settings.Mail.ExpandedFolders);\n }\n catch (e) {\n Account.$log.warn(\"Can't parse list of expanded folders. String was: \" +\n Account.$Preferences.settings.Mail.ExpandedFolders);\n expandedFolders = [];\n }\n }\n else {\n expandedFolders = Account.$Preferences.settings.Mail.ExpandedFolders;\n }\n _this.$expanded = (expandedFolders.indexOf('/' + _this.id) >= 0);\n if (expandedFolders.length > 0) {\n _visit(_this.$mailboxes);\n }\n }\n if (Account.$accounts)\n _this.$expanded |= (Account.$accounts.length == 1); // Always expand single account\n _this.$flattenMailboxes({reload: true});\n\n return _this.$mailboxes;\n });\n }\n };\n\n /**\n * @function $flattenMailboxes\n * @memberof Account.prototype\n * @desc Get a flatten array of the mailboxes.\n * @param {object} [options] - the following boolean attributes are available:\n * - reload: rebuild the flatten array of mailboxes from the original tree representation (this.$mailboxes)\n * - all: return all mailboxes, ignoring their expanstion state\n * - saveState: save expansion state of mailboxes to the server\n * @returns an array of Mailbox instances\n */\n Account.prototype.$flattenMailboxes = function(options) {\n var _this = this,\n allMailboxes = [],\n expandedMailboxes = [],\n _visit = function(mailboxes) {\n _.forEach(mailboxes, function(o) {\n allMailboxes.push(o);\n if ((options && options.all || o.$expanded) && o.children && o.children.length > 0) {\n _visit(o.children);\n }\n });\n };\n\n if (this.$$flattenMailboxes && !(options && (options.reload || options.all))) {\n allMailboxes = this.$$flattenMailboxes;\n }\n else {\n _visit(this.$mailboxes);\n if (!options || !options.all) {\n _this.$$flattenMailboxes = allMailboxes;\n if (options && options.saveState) {\n // Save expansion state of mailboxes to the server\n _.forEach(Account.$accounts, function(account) {\n if (account.$expanded) {\n expandedMailboxes.push('/' + account.id);\n }\n _.reduce(account.$$flattenMailboxes, function(expandedFolders, mailbox) {\n if (mailbox.$expanded) {\n expandedFolders.push('/' + mailbox.id);\n }\n return expandedFolders;\n }, expandedMailboxes);\n });\n Account.$$resource.post(null, 'saveFoldersState', expandedMailboxes);\n }\n }\n }\n\n return allMailboxes;\n };\n\n Account.prototype.$getMailboxByType = function(type) {\n var mailbox,\n // Recursive find function\n _find = function(mailboxes) {\n var mailbox = _.find(mailboxes, function(o) {\n return o.type == type;\n });\n if (!mailbox) {\n angular.forEach(mailboxes, function(o) {\n if (!mailbox && o.children && o.children.length > 0) {\n mailbox = _find(o.children);\n }\n });\n }\n return mailbox;\n };\n mailbox = _find(this.$mailboxes);\n\n return mailbox;\n };\n\n /**\n * @function $getMailboxByPath\n * @memberof Account.prototype\n * @desc Recursively find a mailbox using its path\n * @returns a promise of the HTTP operation\n */\n Account.prototype.$getMailboxByPath = function(path) {\n var mailbox = null,\n // Recursive find function\n _find = function(mailboxes) {\n var mailbox = _.find(mailboxes, function(o) {\n return o.path == path;\n });\n if (!mailbox) {\n angular.forEach(mailboxes, function(o) {\n if (!mailbox && o.children && o.children.length > 0) {\n mailbox = _find(o.children);\n }\n });\n }\n return mailbox;\n };\n mailbox = _find(this.$mailboxes);\n\n return mailbox;\n };\n\n /**\n * @function $newMailbox\n * @memberof Account.prototype\n * @desc Create a new mailbox on the server and refresh the list of mailboxes.\n * @returns a promise of the HTTP operations\n */\n Account.prototype.$newMailbox = function(path, name) {\n var _this = this;\n\n return Account.$$resource.post(path.toString(), 'createFolder', {name: name}).then(function() {\n _this.$getMailboxes({reload: true});\n });\n };\n\n /**\n * @function $certificate\n * @memberof Account.prototype\n * @desc View the S/MIME certificate details associated to the account.\n * @returns a promise of the HTTP operation\n */\n Account.prototype.$certificate = function() {\n var _this = this;\n\n if (this.security && this.security.hasCertificate) {\n if (this.$$certificate)\n return Account.$q.when(this.$$certificate);\n else {\n return Account.$$resource.fetch(this.id.toString(), 'certificate').then(function(data) {\n _this.$$certificate = data;\n return data;\n });\n }\n }\n else {\n return Account.$q.reject();\n }\n };\n\n /**\n * @function $removeCertificate\n * @memberof Account.prototype\n * @desc Remove any S/MIME certificate associated with the account.\n * @returns a promise of the HTTP operation\n */\n Account.prototype.$removeCertificate = function() {\n var _this = this;\n\n return Account.$$resource.fetch(this.id.toString(), 'removeCertificate').then(function() {\n _this.security.hasCertificate = false;\n });\n };\n\n /**\n * @function updateQuota\n * @memberof Account.prototype\n * @param {Object} data - the inbox quota information returned by the server\n * @desc Update the quota definition associated to the account\n */\n Account.prototype.updateQuota = function(data) {\n var percent, format, description;\n\n percent = (Math.round(data.usedSpace * 10000 / data.maxQuota) / 100);\n format = l(\"quotasFormat\");\n description = format.formatted(percent, Math.round(data.maxQuota/10.24)/100);\n\n this.$quota = { percent: percent, description: description };\n };\n\n /**\n * @function $newMessage\n * @memberof Account.prototype\n * @desc Prepare a new Message object associated to the appropriate mailbox.\n * @returns a promise of the HTTP operations\n */\n Account.prototype.$newMessage = function(options) {\n var _this = this;\n\n // Query account for draft folder and draft UID\n return Account.$$resource.fetch(this.id.toString(), 'compose').then(function(data) {\n Account.$log.debug('New message (compose): ' + JSON.stringify(data, undefined, 2));\n var message = new Account.$Message(data.accountId, _this.$getMailboxByPath(data.mailboxPath), data);\n return message;\n }).then(function(message) {\n // Fetch draft initial data\n return Account.$$resource.fetch(message.$absolutePath({asDraft: true}), 'edit').then(function(data) {\n var accountDefaults = Account.$Preferences.defaults.AuxiliaryMailAccounts[_this.id];\n if (accountDefaults.security) {\n if (accountDefaults.security.alwaysSign)\n data.sign = true;\n if (accountDefaults.security.alwaysEncrypt)\n data.encrypt = true;\n }\n Account.$log.debug('New message (edit): ' + JSON.stringify(data, undefined, 2));\n angular.extend(message.editable, data);\n message.isNew = true;\n if (options && options.mailto) {\n if (angular.isObject(options.mailto))\n angular.extend(message.editable, options.mailto);\n else\n message.$parseMailto(options.mailto);\n }\n return message;\n });\n });\n };\n\n /**\n * @function $addDelegate\n * @memberof Account.prototype\n * @param {Object} user - a User object with minimal set of attributes (uid, isGroup, cn, c_email)\n * @desc Remove a user from the account's delegates\n * @see {@link User.$filter}\n */\n Account.prototype.$addDelegate = function(user) {\n var _this = this,\n deferred = Account.$q.defer(),\n param = {uid: user.uid};\n if (!user.uid || _.indexOf(_.map(this.delegates, 'uid'), user.uid) > -1) {\n // No UID specified or user already in delegates\n deferred.resolve();\n }\n else {\n Account.$$resource.fetch(this.id.toString(), 'addDelegate', param).then(function() {\n _this.delegates.push(user);\n deferred.resolve(_this.users);\n }, function(data, status) {\n deferred.reject(l('An error occured please try again.'));\n });\n }\n return deferred.promise;\n };\n\n /**\n * @function $removeDelegate\n * @memberof Account.prototype\n * @param {Object} user - a User object with minimal set of attributes (uid, isGroup, cn, c_email)\n * @desc Remove a user from the account's delegates\n * @return a promise of the server call to remove the user from the account's delegates\n */\n Account.prototype.$removeDelegate = function(uid) {\n var _this = this,\n param = {uid: uid};\n return Account.$$resource.fetch(this.id.toString(), 'removeDelegate', param).then(function() {\n var i = _.indexOf(_.map(_this.delegates, 'uid'), uid);\n if (i >= 0) {\n _this.delegates.splice(i, 1);\n }\n });\n };\n \n})();\n","/* -*- Mode: javascript; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n\n(function() {\n 'use strict';\n\n /**\n * @name Mailbox\n * @constructor\n * @param {object} futureMailboxData - either an object literal or a promise\n */\n function Mailbox(account, futureMailboxData) {\n this.$account = account;\n // Data is immediately available\n if (typeof futureMailboxData.then !== 'function') {\n this.init(futureMailboxData);\n if (this.name && !this.path) {\n // Create a new mailbox on the server\n var newMailboxData = Mailbox.$$resource.create('createFolder', this.name);\n this.$unwrap(newMailboxData);\n }\n }\n else {\n // The promise will be unwrapped first\n // NOTE: this condition never happen for the moment\n this.$unwrap(futureMailboxData);\n }\n }\n\n /**\n * @memberof Mailbox\n * @desc The factory we'll use to register with Angular\n * @returns the Mailbox constructor\n */\n Mailbox.$factory = ['$q', '$timeout', '$log', 'sgSettings', 'Resource', 'Message', 'Acl', 'Preferences', 'sgMailbox_PRELOAD', function($q, $timeout, $log, Settings, Resource, Message, Acl, Preferences, PRELOAD) {\n angular.extend(Mailbox, {\n $q: $q,\n $timeout: $timeout,\n $log: $log,\n $$resource: new Resource(Settings.activeUser('folderURL') + 'Mail', Settings.activeUser()),\n $Message: Message,\n $$Acl: Acl,\n $Preferences: Preferences,\n $query: { sort: 'arrival', asc: 0 }, // The default sort must match [UIxMailListActions defaultSortKey]\n selectedFolder: null,\n $refreshTimeout: null,\n $virtualMode: false,\n $virtualPath: false,\n PRELOAD: PRELOAD\n });\n // Initialize sort parameters from user's settings\n if (Preferences.settings.Mail.SortingState) {\n Mailbox.$query.sort = Preferences.settings.Mail.SortingState[0];\n Mailbox.$query.asc = parseInt(Preferences.settings.Mail.SortingState[1]);\n }\n\n return Mailbox; // return constructor\n }];\n\n /**\n * @module SOGo.MailerUI\n * @desc Factory registration of Mailbox in Angular module.\n */\n try {\n angular.module('SOGo.MailerUI');\n }\n catch(e) {\n angular.module('SOGo.MailerUI', ['SOGo.Common']);\n }\n angular.module('SOGo.MailerUI')\n .constant('sgMailbox_PRELOAD', {\n LOOKAHEAD: 50,\n SIZE: 100\n })\n .factory('Mailbox', Mailbox.$factory);\n\n /**\n * @memberof Mailbox\n * @desc Fetch list of mailboxes of a specific account\n * @param {string} accountId - the account\n * @return a promise of the HTTP operation\n * @see {@link Account.$getMailboxes}\n */\n Mailbox.$find = function(account, options) {\n var path, futureMailboxData;\n\n if (options && options.all)\n futureMailboxData = this.$$resource.fetch(account.id.toString(), 'viewAll');\n else\n futureMailboxData = this.$$resource.fetch(account.id.toString(), 'view');\n\n return Mailbox.$unwrapCollection(account, futureMailboxData); // a collection of mailboxes\n };\n\n /**\n * @memberof Mailbox\n * @desc Unwrap to a collection of Mailbox instances.\n * @param {string} account - the account\n * @param {promise} futureMailboxData - a promise of the mailboxes metadata\n * @returns a promise of a collection of Mailbox objects\n */\n Mailbox.$unwrapCollection = function(account, futureMailboxData) {\n var collection = [],\n // Local recursive function\n createMailboxes = function(level, mailbox) {\n for (var i = 0; i < mailbox.children.length; i++) {\n mailbox.children[i].level = level;\n mailbox.children[i] = new Mailbox(account, mailbox.children[i]);\n createMailboxes(level+1, mailbox.children[i]);\n }\n };\n //collection.$futureMailboxData = futureMailboxData;\n\n return futureMailboxData.then(function(data) {\n return Mailbox.$timeout(function() {\n // Each entry is spun up as a Mailbox instance\n angular.forEach(data.mailboxes, function(data, index) {\n data.level = 0;\n var mailbox = new Mailbox(account, data);\n createMailboxes(1, mailbox); // recursively create all sub-mailboxes\n collection.push(mailbox);\n });\n // Update inbox quota\n if (data.quotas)\n account.updateQuota(data.quotas);\n return collection;\n });\n });\n };\n\n /**\n * @memberof Mailbox\n * @desc Build the path of the mailbox (or account only).\n * @param {string} accountId - the account ID\n * @param {string} [mailboxPath] - the mailbox path\n * @returns a string representing the path relative to the mail module\n */\n Mailbox.$absolutePath = function(accountId, mailboxPath) {\n var path = [];\n\n if (mailboxPath) {\n path = _.map(mailboxPath.split('/'), function(component) {\n return 'folder' + component.asCSSIdentifier();\n });\n }\n\n path.splice(0, 0, accountId); // insert account ID\n\n return path.join('/');\n };\n\n /**\n * @function init\n * @memberof Mailbox.prototype\n * @desc Extend instance with new data and compute additional attributes.\n * @param {object} data - attributes of mailbox\n */\n Mailbox.prototype.init = function(data) {\n var _this = this;\n if (angular.isUndefined(this.uidsMap) || data.headers) {\n this.$isLoading = true;\n this.$messages = [];\n this.uidsMap = {};\n }\n angular.extend(this, data);\n if (this.path) {\n this.id = this.$id();\n this.$acl = new Mailbox.$$Acl('Mail/' + this.id);\n }\n this.$displayName = this.name;\n if (this.type) {\n this.$isEditable = this.isEditable();\n this.$isSpecial = true;\n if (this.type == 'inbox') {\n this.$displayName = l('InboxFolderName');\n this.$icon = 'inbox';\n }\n else if (this.type == 'draft') {\n this.$displayName = l('DraftsFolderName');\n this.$icon = 'drafts';\n }\n else if (this.type == 'sent') {\n this.$displayName = l('SentFolderName');\n this.$icon = 'send';\n }\n else if (this.type == 'trash') {\n this.$displayName = l('TrashFolderName');\n this.$icon = 'delete';\n }\n else if (this.type == 'junk') {\n this.$displayName = l('JunkFolderName');\n this.$icon = 'thumb_down';\n }\n else if (this.type == 'additional') {\n this.$icon = 'folder_shared';\n }\n else {\n this.$isSpecial = false;\n this.$icon = 'folder_open';\n }\n }\n this.$isNoInferiors = this.isNoInferiors();\n if (angular.isUndefined(this.$shadowData)) {\n // Make a copy of the data for an eventual reset\n this.$shadowData = this.$omit();\n }\n };\n\n /**\n * @function selectFolder\n * @memberof Mailbox.prototype\n * @desc Mark the folder as selected in the constructor unless virtual mode is active\n */\n Mailbox.prototype.selectFolder = function() {\n if (!Mailbox.$virtualMode)\n Mailbox.selectedFolder = this;\n };\n\n /**\n * @function getLength\n * @memberof Mailbox.prototype\n * @desc Used by md-virtual-repeat / md-on-demand\n * @returns the number of messages in the mailbox\n */\n Mailbox.prototype.getLength = function() {\n return this.$messages.length;\n };\n\n /**\n * @function getItemAtIndex\n * @memberof Mailbox.prototype\n * @desc Used by md-virtual-repeat / md-on-demand\n * @returns the message at the specified index\n */\n Mailbox.prototype.getItemAtIndex = function(index) {\n var message;\n\n if (index >= 0 && index < this.$messages.length) {\n message = this.$messages[index];\n this.$lastVisibleIndex = Math.max(0, index - 3); // Magic number is NUM_EXTRA from virtual-repeater.js\n\n if (this.$loadMessage(message.uid))\n return message;\n }\n return null;\n };\n\n /**\n * @function $id\n * @memberof Mailbox.prototype\n * @desc Build the unique ID to identified the mailbox.\n * @returns a string representing the path relative to the mail module\n */\n Mailbox.prototype.$id = function() {\n return Mailbox.$absolutePath(this.$account.id, this.path);\n };\n\n /**\n * @function $selectedMessages\n * @memberof Mailbox.prototype\n * @desc Return the messages selected by the user.\n * @returns Message instances\n */\n Mailbox.prototype.$selectedMessages = function() {\n return _.filter(this.$messages, function(message) { return message.selected; });\n };\n\n /**\n * @function $selectedCount\n * @memberof Mailbox.prototype\n * @desc Return the number of messages selected by the user.\n * @returns the number of selected messages\n */\n Mailbox.prototype.$selectedCount = function() {\n return this.$selectedMessages().length;\n };\n\n /**\n * @function isSelectedMessage\n * @memberof Mailbox.prototype\n * @desc Check if the specified message is displayed in the detailed view.\n * @param {string} messageId\n * @returns true if the specified message is displayed\n */\n Mailbox.prototype.isSelectedMessage = function(messageId) {\n return this.selectedMessage == messageId;\n };\n\n /**\n * @function $selectedMessage\n * @memberof Mailbox.prototype\n * @desc Return the currently visible message.\n * @returns a Message instance or undefined if no message is displayed\n */\n Mailbox.prototype.$selectedMessage = function() {\n var _this = this;\n\n return _.find(this.$messages, function(message) { return message.uid == _this.selectedMessage; });\n };\n\n /**\n * @function $selectedMessageIndex\n * @memberof Mailbox.prototype\n * @desc Return the index of the currently visible message.\n * @returns a number or undefined if no message is selected\n */\n Mailbox.prototype.$selectedMessageIndex = function() {\n return this.uidsMap[this.selectedMessage];\n };\n\n /**\n * @function hasSelectedMessage\n * @memberof Mailbox.prototype\n * @desc Check if a message is selected.\n * @returns true if the a message is selected\n */\n Mailbox.prototype.hasSelectedMessage = function() {\n return angular.isDefined(this.selectedMessage);\n };\n\n /**\n * @function $filter\n * @memberof Mailbox.prototype\n * @desc Fetch the messages metadata of the mailbox\n * @param {object} [sort] - sort preferences. Defaults to descendent by date.\n * @param {string} sort.match - either AND or OR\n * @param {string} sort.sort - either arrival, subject, from, to, date, or size\n * @param {boolean} sort.asc - sort is ascendant if true\n * @param {object[]} [filters] - list of filters for the query\n * @param {string} filters.searchBy - either subject, from, to, cc, or body\n * @param {string} filters.searchInput - the search string to match\n * @param {boolean} filters.negative - negate the condition\n * @returns a promise of the HTTP operation\n */\n Mailbox.prototype.$filter = function(sortingAttributes, filters) {\n var _this = this, options = {};\n\n if (!angular.isDefined(this.unseenCount))\n this.unseenCount = 0;\n\n Mailbox.$timeout(function() {\n _this.$isLoading = true;\n });\n\n if (Mailbox.$refreshTimeout)\n Mailbox.$timeout.cancel(Mailbox.$refreshTimeout);\n\n if (sortingAttributes)\n // Sorting preferences are common to all mailboxes\n angular.extend(Mailbox.$query, sortingAttributes);\n\n angular.extend(options, { sortingAttributes: Mailbox.$query });\n if (angular.isDefined(filters)) {\n options.filters = _.reject(filters, function(filter) {\n return !filter.searchInput || filter.searchInput.length === 0;\n });\n // Decompose filters that match two fields\n _.forEach(options.filters, function(filter) {\n var secondFilter,\n match = filter.searchBy.match(/(\\w+)_or_(\\w+)/);\n if (match) {\n options.sortingAttributes.match = 'OR';\n filter.searchBy = match[1];\n secondFilter = angular.copy(filter);\n secondFilter.searchBy = match[2];\n options.filters.push(secondFilter);\n }\n });\n }\n\n // Restart the refresh timer, if needed\n if (!Mailbox.$virtualMode) {\n var refreshViewCheck = Mailbox.$Preferences.defaults.SOGoRefreshViewCheck;\n if (refreshViewCheck && refreshViewCheck != 'manually') {\n var f = angular.bind(this, Mailbox.prototype.$filter, null, filters);\n Mailbox.$refreshTimeout = Mailbox.$timeout(f, refreshViewCheck.timeInterval()*1000);\n }\n }\n\n var futureMailboxData = Mailbox.$$resource.post(this.id, 'view', options);\n return this.$unwrap(futureMailboxData);\n };\n\n /**\n * @function $loadMessage\n * @memberof Mailbox.prototype\n * @desc Check if the message is loaded and in any case, fetch more messages headers from the server.\n * @returns true if the message metadata are already fetched\n */\n Mailbox.prototype.$loadMessage = function(messageId) {\n var startIndex = this.uidsMap[messageId],\n endIndex,\n index,\n max = this.$messages.length,\n loaded = false,\n uids,\n futureHeadersData;\n if (angular.isDefined(this.uidsMap[messageId]) && startIndex < this.$messages.length) {\n // Index is valid\n if (angular.isDefined(this.$messages[startIndex].subject)) {// || this.$messages[startIndex].loading) {\n // Message headers are loaded or data is coming\n loaded = true;\n }\n\n // Preload more headers if possible\n endIndex = Math.min(startIndex + Mailbox.PRELOAD.LOOKAHEAD, max - 1);\n if (angular.isDefined(this.$messages[endIndex].subject) ||\n angular.isDefined(this.$messages[endIndex].loading)) {\n index = Math.max(startIndex - Mailbox.PRELOAD.LOOKAHEAD, 0);\n if (!angular.isDefined(this.$messages[index].subject) &&\n !angular.isDefined(this.$messages[index].loading)) {\n // Previous messages not loaded; preload more headers further up\n endIndex = startIndex;\n startIndex = Math.max(startIndex - Mailbox.PRELOAD.SIZE, 0);\n }\n }\n else\n // Next messages not load; preload more headers further down\n endIndex = Math.min(startIndex + Mailbox.PRELOAD.SIZE, max - 1);\n\n if (!angular.isDefined(this.$messages[startIndex].subject) &&\n !angular.isDefined(this.$messages[startIndex].loading) ||\n !angular.isDefined(this.$messages[endIndex].subject) &&\n !angular.isDefined(this.$messages[endIndex].loading)) {\n\n for (uids = []; startIndex < endIndex && startIndex < max; startIndex++) {\n if (angular.isDefined(this.$messages[startIndex].subject) || this.$messages[startIndex].loading) {\n // Message at this index is already loaded; increase the end index\n endIndex++;\n }\n else {\n // Message at this index will be loaded\n uids.push(this.$messages[startIndex].uid);\n this.$messages[startIndex].loading = true;\n }\n }\n\n Mailbox.$log.debug('Loading UIDs ' + uids.join(' '));\n futureHeadersData = Mailbox.$$resource.post(this.id, 'headers', {uids: uids});\n this.$unwrapHeaders(futureHeadersData);\n }\n }\n return loaded;\n };\n\n /**\n * @function isEditable\n * @memberof Mailbox.prototype\n * @desc Checks if the mailbox is editable based on its type.\n * @returns true if the mailbox is not a special folder.\n */\n Mailbox.prototype.isEditable = function() {\n return this.type == 'folder';\n };\n\n /**\n * @function isNoInferiors\n * @memberof Mailbox.prototype\n * @desc Checks if the mailbox can contain submailboxes\n * @returns true if the mailbox can not contain submailboxes\n */\n Mailbox.prototype.isNoInferiors = function() {\n return this.flags.indexOf('noinferiors') >= 0;\n };\n\n /**\n * @function isNoSelect\n * @memberof Mailbox.prototype\n * @desc Checks if the mailbox can be selected\n * @returns true if the mailbox can not be selected\n */\n Mailbox.prototype.isNoSelect = function() {\n return this.flags.indexOf('noselect') >= 0;\n };\n\n /**\n * @function getClassName\n * @memberof Mailbox.prototype\n * @desc Not used but defined because it is called from UIxAclEditor.wox.\n * @returns a string representing the foreground CSS class name\n */\n Mailbox.prototype.getClassName = function(base) {\n return false;\n };\n\n /**\n * @function $rename\n * @memberof AddressBook.prototype\n * @desc Rename the addressbook and keep the list sorted\n * @param {string} name - the new name\n * @returns a promise of the HTTP operation\n */\n Mailbox.prototype.$rename = function() {\n var _this = this,\n findParent,\n parent,\n children,\n i;\n\n if (this.name == this.$shadowData.name) {\n // Name hasn't changed\n return Mailbox.$q.when();\n }\n\n // Local recursive function\n findParent = function(parent, children) {\n var parentMailbox = null,\n mailbox = _.find(children, function(o) {\n return o.path == _this.path;\n });\n if (mailbox) {\n parentMailbox = parent;\n }\n else {\n angular.forEach(children, function(o) {\n if (!parentMailbox && o.children && o.children.length > 0) {\n parentMailbox = findParent(o, o.children);\n }\n });\n }\n return parentMailbox;\n };\n\n // Find mailbox parent\n parent = findParent(null, this.$account.$mailboxes);\n if (parent === null)\n children = this.$account.$mailboxes;\n else\n children = parent.children;\n\n // Find index of mailbox among siblings\n i = _.indexOf(_.map(children, 'id'), this.id);\n\n return this.$save().then(function(data) {\n var sibling, oldPath = _this.path;\n _this.init(data); // update the path and id\n\n // Move mailbox among its siblings according to its new name\n children.splice(i, 1);\n sibling = _.find(children, function(o) {\n return (o.type == 'folder' && o.name.localeCompare(_this.name) > 0);\n });\n if (sibling) {\n i = _.indexOf(_.map(children, 'id'), sibling.id);\n }\n else {\n i = children.length;\n }\n children.splice(i, 0, _this);\n\n // Update the path and id of children\n var pathRE = new RegExp('^' + oldPath);\n var _updateChildren = function(mailbox) {\n _.forEach(mailbox.children, function(child) {\n child.path = child.path.replace(pathRE, _this.path);\n child.id = child.$id();\n _updateChildren(child);\n });\n };\n _updateChildren(_this);\n });\n };\n\n /**\n * @function $compact\n * @memberof Mailbox.prototype\n * @desc Compact the mailbox\n * @returns a promise of the HTTP operation\n */\n Mailbox.prototype.$compact = function() {\n var _this = this;\n return Mailbox.$$resource.post(this.id, 'expunge')\n .then(function(data) {\n // Update inbox quota\n if (data.quotas)\n _this.$account.updateQuota(data.quotas);\n });\n };\n\n /**\n * @function $canFolderAs\n * @memberof Mailbox.prototype\n * @desc Check if the folder can be set as Drafts/Sent/Trash\n * @returns true if folder is eligible\n */\n Mailbox.prototype.$canFolderAs = function() {\n return this.type == 'folder' && this.level === 0;\n };\n\n /**\n * @function $setFolderAs\n * @memberof Mailbox.prototype\n * @desc Set a folder as Drafts/Sent/Trash\n * @returns a promise of the HTTP operation\n */\n Mailbox.prototype.$setFolderAs = function(type) {\n return Mailbox.$$resource.post(this.id, 'setAs' + type + 'Folder');\n };\n\n /**\n * @function $emptyTrash\n * @memberof Mailbox.prototype\n * @desc Empty the Trash folder.\n * @returns a promise of the HTTP operation\n */\n Mailbox.prototype.$emptyTrash = function() {\n var _this = this;\n\n return Mailbox.$$resource.post(this.id, 'emptyTrash').then(function(data) {\n // Remove all messages from the mailbox\n _this.$messages = [];\n _this.uidsMap = {};\n _this.unseenCount = 0;\n\n // If we had any submailboxes, lets do a refresh of the mailboxes list\n if (angular.isDefined(_this.children) && _this.children.length)\n _this.$account.$getMailboxes({reload: true});\n\n // Update inbox quota\n if (data.quotas)\n _this.$account.updateQuota(data.quotas);\n });\n };\n\n /**\n * @function $markAsRead\n * @memberof Mailbox.prototype\n * @desc Mark all messages from folder as read\n * @returns a promise of the HTTP operation\n */\n Mailbox.prototype.$markAsRead = function() {\n var _this = this;\n\n return Mailbox.$$resource.post(this.id, 'markRead').then(function() {\n _this.unseenCount = 0;\n _.forEach(_this.$messages, function(message) {\n message.isread = true;\n });\n });\n };\n\n /**\n * @function $flagMessages\n * @memberof Mailbox.prototype\n * @desc Add or remove a flag on a message set\n * @returns a promise of the HTTP operation\n */\n Mailbox.prototype.$flagMessages = function(messages, flags, operation) {\n var data = {msgUIDs: _.map(messages, 'uid'),\n flags: flags,\n operation: operation};\n\n return Mailbox.$$resource.post(this.id, 'addOrRemoveLabel', data).then(function() {\n return messages;\n });\n };\n\n /**\n * @function saveSelectedMessages\n * @memberof Mailbox.prototype\n * @desc Download the selected messages\n * @returns a promise of the HTTP operation\n */\n Mailbox.prototype.saveSelectedMessages = function() {\n var data, options, selectedMessages, selectedUIDs;\n\n selectedMessages = _.filter(this.$messages, function(message) { return message.selected; });\n selectedUIDs = _.map(selectedMessages, 'uid');\n data = { uids: selectedUIDs };\n options = { filename: l('Saved Messages.zip') };\n\n return Mailbox.$$resource.download(this.id, 'saveMessages', {uids: selectedUIDs});\n };\n\n /**\n * @function exportFolder\n * @memberof Mailbox.prototype\n * @desc Export this mailbox\n * @returns a promise of the HTTP operation\n */\n Mailbox.prototype.exportFolder = function() {\n var options;\n\n options = { filename: this.name + '.zip' };\n\n return Mailbox.$$resource.download(this.id, 'exportFolder', null, options);\n };\n\n /**\n * @function $delete\n * @memberof Mailbox.prototype\n * @desc Delete the mailbox from the server\n * @param {object} [options] - additional options (use {withoutTrash: true} to delete immediately)\n * @returns a promise of the HTTP operation\n */\n Mailbox.prototype.$delete = function(options) {\n var _this = this;\n\n return Mailbox.$$resource.post(this.id, 'delete', options)\n .then(function() {\n _this.$account.$getMailboxes({reload: true});\n return true;\n });\n };\n\n /**\n * @function $_deleteMessages\n * @memberof Mailbox.prototype\n * @desc Delete multiple messages from Mailbox object.\n * @param {string[]} uids - the messages uids\n * @param {object[]} messages - the Message instances\n * @return the index of the first deleted message\n */\n Mailbox.prototype.$_deleteMessages = function(uids, messages) {\n var _this = this, selectedUIDs, _$messages, unseen, firstIndex = this.$messages.length;\n\n // Decrement the unseen count\n unseen = _.filter(messages, function(message, i) { return !message.isread; });\n this.unseenCount -= unseen.length;\n\n // Remove messages from $messages and uidsMap\n _.forEachRight(this.$messages, function(message, index) {\n var selectedIndex = _.findIndex(uids, function(uid) {\n return message.uid == uid;\n });\n if (selectedIndex > -1) {\n uids.splice(selectedIndex, 1);\n delete _this.uidsMap[message.uid];\n if (message.uid == _this.selectedMessage)\n delete _this.selectedMessage;\n _this.$messages.splice(index, 1);\n if (index < firstIndex)\n firstIndex = index;\n }\n else {\n _this.uidsMap[message.uid] -= uids.length;\n }\n });\n\n // Return the index of the first deleted message\n return firstIndex;\n };\n\n /**\n * @function $deleteMessages\n * @memberof Mailbox.prototype\n * @desc Delete multiple messages from mailbox.\n * @param {object} [options] - additional options (use {withoutTrash: true} to delete immediately)\n * @return a promise of the HTTP operation\n */\n Mailbox.prototype.$deleteMessages = function(messages, options) {\n var _this = this, uids, data;\n\n uids = _.map(messages, 'uid');\n data = { uids: uids };\n if (options) angular.extend(data, options);\n\n return Mailbox.$$resource.post(this.id, 'batchDelete', data)\n .then(function(data) {\n // Update inbox quota\n if (data.quotas)\n _this.$account.updateQuota(data.quotas);\n\n return _this.$_deleteMessages(uids, messages);\n });\n };\n\n /**\n * @function $markOrUnMarkMessagesAsJunk\n * @memberof Mailbox.prototype\n * @desc Mark messages as junk/not junk\n * @return a promise of the HTTP operation\n */\n Mailbox.prototype.$markOrUnMarkMessagesAsJunk = function(messages) {\n var _this = this,\n uids = _.map(messages, 'uid'),\n method = (this.type == 'junk' ? 'markMessagesAsNotJunk' : 'markMessagesAsJunk');\n\n return Mailbox.$$resource.post(this.id, method, {uids: uids});\n };\n\n /**\n * @function $copyMessages\n * @memberof Mailbox.prototype\n * @desc Copy multiple messages from the current mailbox to a target one\n * @return a promise of the HTTP operation\n */\n Mailbox.prototype.$copyMessages = function(messages, folder) {\n var _this = this,\n uids = _.map(messages, 'uid');\n\n return Mailbox.$$resource.post(this.id, 'copyMessages', {uids: uids, folder: folder})\n .then(function(data) {\n // Update inbox quota\n if (data.quotas)\n _this.$account.updateQuota(data.quotas);\n });\n };\n\n /**\n * @function $moveMessages\n * @memberof Mailbox.prototype\n * @desc Move multiple messages from the current mailbox to a target one\n * @return a promise of the HTTP operation\n */\n Mailbox.prototype.$moveMessages = function(messages, folder) {\n var _this = this, uids;\n\n uids = _.map(messages, 'uid');\n return Mailbox.$$resource.post(this.id, 'moveMessages', {uids: uids, folder: folder})\n .then(function() {\n return _this.$_deleteMessages(uids, messages);\n });\n };\n\n /**\n * @function $reset\n * @memberof Mailbox.prototype\n * @desc Reset the original state the mailbox's data.\n */\n Mailbox.prototype.$reset = function() {\n var _this = this;\n angular.forEach(this.$shadowData, function(value, key) {\n delete _this[key];\n });\n angular.extend(this, this.$shadowData);\n this.$shadowData = this.$omit();\n };\n\n /**\n * @function $save\n * @memberof Mailbox.prototype\n * @desc Save the mailbox to the server. This currently can only affect the name of the mailbox.\n * @returns a promise of the HTTP operation\n */\n Mailbox.prototype.$save = function() {\n var _this = this;\n\n return Mailbox.$$resource.save(this.id, this.$omit()).then(function(data) {\n // Make a copy of the data for an eventual reset\n _this.$shadowData = _this.$omit();\n Mailbox.$log.debug(JSON.stringify(data, undefined, 2));\n return data;\n }, function(response) {\n Mailbox.$log.error(JSON.stringify(response.data, undefined, 2));\n // Restore previous version\n _this.$reset();\n return response.data;\n });\n };\n\n /**\n * @function $newMailbox\n * @memberof Mailbox.prototype\n * @desc Create a new mailbox on the server and refresh the list of mailboxes.\n * @returns a promise of the HTTP operations\n */\n Mailbox.prototype.$newMailbox = function(path, name) {\n return this.$account.$newMailbox(path, name);\n };\n\n /**\n * @function $omit\n * @memberof Mailbox.prototype\n * @desc Return a sanitized object used to send to the server.\n * @return an object literal copy of the Mailbox instance\n */\n Mailbox.prototype.$omit = function() {\n var mailbox = {};\n angular.forEach(this, function(value, key) {\n if (key != 'constructor' &&\n key != 'children' &&\n key != 'headers' &&\n key != 'uids' &&\n key != 'uidsMap' &&\n key[0] != '$') {\n mailbox[key] = value;\n }\n });\n return mailbox;\n };\n\n /**\n * @function $unwrap\n * @memberof Mailbox.prototype\n * @desc Unwrap a promise and instanciate new Message objects using received data.\n * @param {promise} futureMailboxData - a promise of the Mailbox's metadata\n * @returns a promise of the HTTP operation\n */\n Mailbox.prototype.$unwrap = function(futureMailboxData) {\n var _this = this,\n deferred = Mailbox.$q.defer();\n\n this.$futureMailboxData = futureMailboxData;\n this.$futureMailboxData.then(function(data) {\n var selectedMessages = _.map(_this.$selectedMessages(), 'uid');\n Mailbox.$timeout(function() {\n var uids, headers;\n\n if (!data.uids || _this.$topIndex > data.uids.length - 1)\n _this.$topIndex = 0;\n\n _this.init(data);\n\n if (_this.uids) {\n Mailbox.$log.debug('unwrapping ' + _this.uids.length + ' messages');\n\n // First entry of 'headers' are keys\n headers = _.invokeMap(_this.headers[0], 'toLowerCase');\n _this.headers.splice(0, 1);\n\n // First entry of 'uids' are keys when threaded view is enabled\n if (_this.threaded) {\n uids = _this.uids[0];\n _this.uids.splice(0, 1);\n }\n\n // Instanciate Message objects\n _.reduce(_this.uids, function(msgs, msg, i) {\n var data, msgObject;\n if (_this.threaded)\n data = _.zipObject(uids, msg);\n else\n data = {uid: msg.toString()};\n\n // Build map of UID <=> index\n _this.uidsMap[data.uid] = i;\n\n msgObject = new Mailbox.$Message(_this.$account.id, _this, data, true);\n\n // Restore selection\n msgObject.selected = selectedMessages.indexOf(msgObject.uid) > -1;\n\n msgs.push(msgObject);\n\n return msgs;\n }, _this.$messages);\n\n // Extend Message objects with received headers\n _.forEach(_this.headers, function(data) {\n var msg = _.zipObject(headers, data),\n i = _this.uidsMap[msg.uid.toString()];\n _.extend(_this.$messages[i], msg);\n });\n }\n Mailbox.$log.debug('mailbox ' + _this.id + ' ready');\n _this.$isLoading = false;\n deferred.resolve(_this.$messages);\n });\n }, function(data) {\n angular.extend(_this, data);\n _this.isError = true;\n _this.$isLoading = false;\n deferred.reject();\n });\n\n return deferred.promise;\n };\n\n /**\n * @function $unwrapHeaders\n * @memberof Mailbox.prototype\n * @desc Unwrap a promise and extend matching Message objects using received data.\n * @param {promise} futureHeadersData - a promise of some messages metadata\n */\n Mailbox.prototype.$unwrapHeaders = function(futureHeadersData) {\n var _this = this;\n\n futureHeadersData.then(function(data) {\n Mailbox.$timeout(function() {\n var headers, j;\n if (data.length > 0) {\n // First entry of 'headers' are keys\n headers = _.invokeMap(data[0], 'toLowerCase');\n data.splice(0, 1);\n _.forEach(data, function(messageHeaders) {\n messageHeaders = _.zipObject(headers, messageHeaders);\n j = _this.uidsMap[messageHeaders.uid.toString()];\n if (angular.isDefined(j)) {\n _.extend(_this.$messages[j], messageHeaders);\n }\n });\n }\n });\n });\n };\n\n /**\n * @function $updateSubscribe\n * @memberof Mailbox.prototype\n * @desc Update mailbox subscription state with server.\n */\n Mailbox.prototype.$updateSubscribe = function() {\n var action = this.subscribed? 'subscribe' : 'unsubscribe';\n\n Mailbox.$$resource.post(this.id, action);\n };\n\n})();\n","/* -*- Mode: javascript; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n\n(function() {\n 'use strict';\n\n /**\n * @name Message\n * @constructor\n * @param {string} accountId - the account ID\n * @param {string} mailboxPath - an array of the mailbox path components\n * @param {object} futureAddressBookData - either an object literal or a promise\n * @param {bool} lazy - do \"lazy loading\" so we are very quick at initializing message instances\n */\n function Message(accountId, mailbox, futureMessageData, lazy) {\n this.accountId = accountId;\n this.$mailbox = mailbox;\n this.$hasUnsafeContent = false;\n this.$loadUnsafeContent = false;\n this.editable = {to: [], cc: [], bcc: []};\n this.selected = false;\n\n // Data is immediately available\n if (typeof futureMessageData.then !== 'function') {\n //console.debug(JSON.stringify(futureMessageData, undefined, 2));\n if (angular.isUndefined(lazy) || !lazy) {\n angular.extend(this, futureMessageData);\n this.$formatFullAddresses();\n }\n this.uid = parseInt(futureMessageData.uid);\n }\n else {\n // The promise will be unwrapped first\n this.$unwrap(futureMessageData);\n }\n }\n\n /**\n * @memberof Message\n * @desc The factory we'll use to register with Angular\n * @returns the Message constructor\n */\n Message.$factory = ['$q', '$timeout', '$log', 'sgSettings', 'sgMessage_STATUS', 'Resource', 'Preferences', function($q, $timeout, $log, Settings, Message_STATUS, Resource, Preferences) {\n angular.extend(Message, {\n STATUS: Message_STATUS,\n $q: $q,\n $timeout: $timeout,\n $log: $log,\n $$resource: new Resource(Settings.activeUser('folderURL') + 'Mail', Settings.activeUser()),\n $Preferences: Preferences,\n $avatar: angular.bind(Preferences, Preferences.avatar)\n });\n\n // Initialize tags form user's defaults\n if (Preferences.defaults.SOGoMailLabelsColors) {\n Message.$tags = Preferences.defaults.SOGoMailLabelsColors;\n }\n if (Preferences.defaults.SOGoMailDisplayRemoteInlineImages &&\n Preferences.defaults.SOGoMailDisplayRemoteInlineImages == 'always') {\n Message.$displayRemoteInlineImages = true;\n }\n\n return Message; // return constructor\n }];\n\n /**\n * @module SOGo.MailerUI\n * @desc Factory registration of Message in Angular module.\n */\n try {\n angular.module('SOGo.MailerUI');\n }\n catch(e) {\n angular.module('SOGo.MailerUI', ['SOGo.Common']);\n }\n angular.module('SOGo.MailerUI')\n .constant('sgMessage_STATUS', {\n NOT_LOADED: 0,\n DELAYED_LOADING: 1,\n LOADING: 2,\n LOADED: 3,\n DELAYED_MS: 300\n })\n .factory('Message', Message.$factory);\n\n /**\n * @function filterTags\n * @memberof Message.prototype\n * @desc Search for tags (ie., mail labels) matching some criterias\n * @param {string} search - the search string to match\n * @returns a collection of strings\n */\n Message.filterTags = function(query, excludedTags) {\n var re = new RegExp(query, 'i'),\n results = [];\n\n _.forEach(_.keys(Message.$tags), function(tag) {\n var pair = Message.$tags[tag];\n if (pair[0].search(re) != -1) {\n if (!_.includes(excludedTags, tag))\n results.push({ name: tag, description: pair[0], color: pair[1] });\n }\n });\n\n return results;\n };\n\n /**\n * @function $absolutePath\n * @memberof Message.prototype\n * @desc Build the path of the message\n * @returns a string representing the path relative to the mail module\n */\n Message.prototype.$absolutePath = function(options) {\n var _this = this, id = this.id;\n\n function buildPath() {\n var path;\n path = _.map(_this.$mailbox.path.split('/'), function(component) {\n return 'folder' + component.asCSSIdentifier();\n });\n path.splice(0, 0, _this.accountId); // insert account ID\n return path.join('/');\n }\n\n if (angular.isUndefined(this.id) || options && options.nocache) {\n this.id = buildPath() + '/' + this.uid; // add message UID\n id = this.id;\n }\n if (options && options.asDraft && this.draftId) {\n id = buildPath() + '/' + this.draftId; // add draft ID\n }\n if (options && options.withResourcePath) {\n id = Message.$$resource.path(id); // return absolute URL\n }\n\n return id;\n };\n\n /**\n * @function $setUID\n * @memberof Message.prototype\n * @desc Change the UID of the message. This happens when saving a draft.\n * @param {number} uid - the new message UID\n */\n Message.prototype.$setUID = function(uid) {\n var oldUID = (this.uid || -1), _this = this, index;\n\n if (oldUID != parseInt(uid)) {\n this.uid = parseInt(uid);\n this.$absolutePath({nocache: true});\n if (oldUID > -1) {\n oldUID = oldUID.toString();\n if (angular.isDefined(this.$mailbox.uidsMap[oldUID])) {\n index = this.$mailbox.uidsMap[oldUID];\n this.$mailbox.uidsMap[uid] = index;\n delete this.$mailbox.uidsMap[oldUID];\n\n // Update messages list of mailbox\n _.forEach(['from', 'to', 'subject'], function(attr) {\n _this.$mailbox.$messages[index][attr] = _this[attr];\n });\n }\n }\n else {\n // Refresh selected folder if it's the drafts mailbox\n if (this.$mailbox.constructor.selectedFolder &&\n this.$mailbox.constructor.selectedFolder.type == 'draft') {\n this.$mailbox.constructor.selectedFolder.$filter();\n }\n }\n }\n };\n\n /**\n * @function $formatFullAddresses\n * @memberof Message.prototype\n * @desc Format all sender and recipients addresses with a complete description (name <email>).\n * This function also generates the avatar URL for each email address and a short name\n */\n Message.prototype.$formatFullAddresses = function() {\n var _this = this;\n var identities = _.map(_this.$mailbox.$account.identities, 'email');\n\n // Build long representation of email addresses\n _.forEach(['from', 'to', 'cc', 'bcc', 'reply-to'], function(type) {\n _.forEach(_this[type], function(data) {\n if (data.name && data.name != data.email) {\n data.full = data.name + ' <' + data.email + '>';\n\n if (data.name.length < 10)\n // Name is already short\n data.shortname = data.name;\n else if (data.name.split(' ').length)\n // If we have \"Alice Foo\" or \"Foo, Alice\" as name, we grab \"Alice\"\n data.shortname = _.first(_.last(data.name.split(/, */)).split(/ +/)).replace('\\'','');\n }\n else if (data.email) {\n data.full = '<' + data.email + '>';\n data.shortname = data.email.split('@')[0];\n }\n\n data.image = Message.$avatar(data.email, 32);\n\n // If the current user is the recepient, overwrite\n // the short name with 'me'\n if (_.indexOf(identities, data.email) >= 0)\n data.shortname = l('me');\n });\n });\n };\n\n /**\n * @function $shortRecipients\n * @memberof Message.prototype\n * @desc Format all recipients into a very compact string\n * @returns a compacted string of all recipients\n */\n Message.prototype.$shortRecipients = function(max) {\n var _this = this, result = [], count = 0, total = 0;\n\n // Build short representation of email addresses\n _.forEach(['to', 'cc', 'bcc'], function(type) {\n total += _this[type]? _this[type].length : 0;\n _.forEach(_this[type], function(data, i) {\n if (count < max)\n result.push(data.shortname);\n count++;\n });\n });\n\n if (total > max)\n result.push(l('and %{0} more...', (total - max)));\n\n return result.join(', ');\n };\n\n /**\n * @function $shortAddress\n * @memberof Message.prototype\n * @desc Format the first address of a specific type with a short description.\n * @returns a string of the name or the email of the envelope address type\n */\n Message.prototype.$shortAddress = function(type) {\n var address = '';\n if (this[type] && this[type].length > 0) {\n address = this[type][0].name || this[type][0].email || '';\n }\n\n return address;\n };\n\n /**\n * @function allowReplyAll\n * @memberof Message.prototype\n * @desc Check if 'Reply to All' is an appropriate action on the message.\n * @returns true if the message is not a draft and has more than one recipient\n */\n Message.prototype.allowReplyAll = function() {\n var recipientsCount = 0;\n recipientsCount = _.reduce(['to', 'cc'], _.bind(function(count, type) {\n if (this[type])\n return count + this[type].length;\n else\n return count;\n }, this), recipientsCount);\n\n return !this.isDraft && recipientsCount > 1;\n };\n\n /**\n * @function loadUnsafeContent\n * @memberof Message.prototype\n * @desc Mark the message to load unsafe resources when calling $content().\n */\n Message.prototype.loadUnsafeContent = function() {\n this.$loadUnsafeContent = true;\n delete this.$parts;\n };\n\n /**\n * @function $content\n * @memberof Message.prototype\n * @desc Get the message body as accepted by SCE (Angular Strict Contextual Escaping).\n * @returns the HTML representation of the body\n */\n Message.prototype.$content = function() {\n var _this = this,\n parts = [],\n _visit = function(part) {\n part.msgclass = 'msg-attachment-other';\n if (part.type == 'UIxMailPartAlternativeViewer') {\n _visit(_.find(part.content, function(alternatePart) {\n return part.preferredPart == alternatePart.contentType;\n }));\n }\n // Can be used for UIxMailPartMixedViewer, UIxMailPartMessageViewer, and UIxMailPartSignedViewer\n else if (angular.isArray(part.content)) {\n if (part.type == 'UIxMailPartSignedViewer' && part['supports-smime'] === 1) {\n _this.signed = {\n valid: part.valid,\n certificate: part.certificates[part.certificates.length - 1],\n message: part.message\n };\n }\n else if (part.type == 'UIxMailPartEncryptedViewer') {\n _this.encrypted = {\n valid: part.valid\n };\n if (part.valid)\n _this.encrypted.message = l(\"This message is encrypted\");\n else\n _this.encrypted.message = l(\"This message can't be decrypted. Please make sure you have uploaded your S/MIME certificate from the mail preferences module.\");\n }\n _.forEach(part.content, function(mixedPart) {\n _visit(mixedPart);\n });\n }\n else {\n if (angular.isUndefined(part.safeContent)) {\n // Keep a copy of the original content\n part.safeContent = part.content;\n _this.$hasUnsafeContent |= (part.safeContent.indexOf(' unsafe-') > -1);\n }\n if (part.type == 'UIxMailPartHTMLViewer') {\n part.html = true;\n if (_this.$loadUnsafeContent || Message.$displayRemoteInlineImages) {\n if (angular.isUndefined(part.unsafeContent)) {\n part.unsafeContent = document.createElement('div');\n part.unsafeContent.innerHTML = part.safeContent;\n angular.forEach(['src', 'data', 'classid', 'background', 'style'], function(suffix) {\n var elements = part.unsafeContent.querySelectorAll('[unsafe-' + suffix + ']'),\n element,\n value,\n i;\n for (i = 0; i < elements.length; i++) {\n element = angular.element(elements[i]);\n value = element.attr('unsafe-' + suffix);\n element.attr(suffix, value);\n element.removeAttr('unsafe-' + suffix);\n }\n });\n _this.$hasUnsafeContent = false;\n }\n part.content = part.unsafeContent.innerHTML;\n }\n else {\n part.content = part.safeContent;\n }\n parts.push(part);\n }\n else if (part.type == 'UIxMailPartICalViewer' ||\n part.type == 'UIxMailPartImageViewer' ||\n part.type == 'UIxMailPartLinkViewer') {\n\n if (part.type == 'UIxMailPartImageViewer')\n part.msgclass = 'msg-attachment-image';\n else if (part.type == 'UIxMailPartLinkViewer')\n part.msgclass = 'msg-attachment-link';\n\n // Trusted content that can be compiled (Angularly-speaking)\n part.compile = true;\n parts.push(part);\n }\n else {\n part.html = true;\n part.content = part.safeContent;\n parts.push(part);\n }\n }\n };\n\n if (this.$parts)\n // Use the cache\n return this.$parts;\n\n else if (this.parts)\n _visit(this.parts);\n\n // Cache result\n this.$parts = parts;\n\n return parts;\n };\n\n /**\n * @function $editableContent\n * @memberof Message.prototype\n * @desc First, fetch the draft ID that corresponds to the temporary draft object on the SOGo server.\n * Secondly, fetch the editable message body along with other metadata such as the recipients.\n * @returns the HTML representation of the body\n */\n Message.prototype.$editableContent = function() {\n var _this = this;\n\n return Message.$$resource.fetch(this.$absolutePath(), 'edit').then(function(data) {\n angular.extend(_this, data);\n return Message.$$resource.fetch(_this.$absolutePath({asDraft: true}), 'edit').then(function(data) {\n // Try to match a known account identity from the specified \"from\" address\n var identity = _.find(_this.$mailbox.$account.identities, function(identity) {\n return data.from.toLowerCase().indexOf(identity.email) !== -1;\n });\n if (identity)\n data.from = identity.full;\n var accountDefaults = Message.$Preferences.defaults.AuxiliaryMailAccounts[_this.$mailbox.$account.id];\n if (accountDefaults.security) {\n if (accountDefaults.security.alwaysSign)\n data.sign = true;\n if (accountDefaults.security.alwaysEncrypt)\n data.encrypt = true;\n }\n Message.$log.debug('editable = ' + JSON.stringify(data, undefined, 2));\n angular.extend(_this.editable, data);\n return data.text;\n });\n });\n };\n\n /**\n * @function $plainContent\n * @memberof Message.prototype\n * @returns the a plain text representation of the subject and body\n */\n Message.prototype.$plainContent = function() {\n return Message.$$resource.fetch(this.$absolutePath(), 'viewplain');\n };\n\n /**\n * @function addTag\n * @memberof Message.prototype\n * @desc Add a mail tag on the current message.\n * @param {string} tag - the tag name\n * @returns a promise of the HTTP operation\n */\n Message.prototype.addTag = function(tag) {\n return this.$addOrRemoveTag('add', tag);\n };\n\n /**\n * @function removeTag\n * @memberof Message.prototype\n * @desc Remove a mail tag from the current message.\n * @param {string} tag - the tag name\n * @returns a promise of the HTTP operation\n */\n Message.prototype.removeTag = function(tag) {\n return this.$addOrRemoveTag('remove', tag);\n };\n\n /**\n * @function $addOrRemoveTag\n * @memberof Message.prototype\n * @desc Add or remove a mail tag on the current message.\n * @param {string} operation - the operation name to perform\n * @param {string} tag - the tag name\n * @returns a promise of the HTTP operation\n */\n Message.prototype.$addOrRemoveTag = function(operation, tag) {\n var data = {\n operation: operation,\n msgUIDs: [this.uid],\n flags: tag\n };\n\n if (tag)\n return Message.$$resource.post(this.$mailbox.$id(), 'addOrRemoveLabel', data);\n };\n\n /**\n * @function $imipAction\n * @memberof Message.prototype\n * @desc Perform IMIP actions on the current message.\n * @param {string} path - the path of the IMIP calendar part\n * @param {string} action - the the IMIP action to perform\n * @param {object} data - the delegation info\n */\n Message.prototype.$imipAction = function(path, action, data) {\n var _this = this;\n Message.$$resource.post([this.$absolutePath(), path].join('/'), action, data).then(function(data) {\n Message.$timeout(function() {\n _this.$reload();\n });\n });\n };\n\n /**\n * @function $sendMDN\n * @memberof Message.prototype\n * @desc Send MDN response for current email message\n */\n Message.prototype.$sendMDN = function() {\n this.shouldAskReceipt = 0;\n return Message.$$resource.post(this.$absolutePath(), 'sendMDN');\n };\n\n /**\n * @function $deleteAttachment\n * @memberof Message.prototype\n * @desc Delete an attachment from a message being composed\n * @param {string} filename - the filename of the attachment to delete\n */\n Message.prototype.$deleteAttachment = function(filename) {\n var data = { 'filename': filename };\n var _this = this;\n Message.$$resource.fetch(this.$absolutePath({asDraft: true}), 'deleteAttachment', data).then(function(data) {\n Message.$timeout(function() {\n _this.editable.attachmentAttrs = _.filter(_this.editable.attachmentAttrs, function(attachment) {\n return attachment.filename != filename;\n });\n });\n });\n };\n\n /**\n * @function $markAsFlaggedOrUnflagged\n * @memberof Message.prototype\n * @desc Add or remove a the \\\\Flagged flag on the current message.\n * @returns a promise of the HTTP operation\n */\n Message.prototype.toggleFlag = function() {\n var _this = this,\n action = 'markMessageFlagged';\n\n if (this.isflagged)\n action = 'markMessageUnflagged';\n\n return Message.$$resource.post(this.$absolutePath(), action).then(function(data) {\n Message.$timeout(function() {\n _this.isflagged = !_this.isflagged;\n });\n });\n };\n\n /**\n * @function $isLoading\n * @memberof Message.prototype\n * @returns true if the Message content is still being retrieved from server after a specific delay\n * @see sgMessage_STATUS\n */\n Message.prototype.$isLoading = function() {\n return this.$loaded == Message.STATUS.LOADING;\n };\n\n /**\n * @function $reload\n * @memberof Message.prototype\n * @desc Fetch the viewable message body along with other metadata such as the list of attachments.\n * @param {object} [options] - set {useCache: true} to use already fetched data\n * @returns a promise of the HTTP operation\n */\n Message.prototype.$reload = function(options) {\n var _this = this, futureMessageData;\n\n if (options && options.useCache && this.$futureMessageData) {\n if (!this.isread) {\n Message.$$resource.fetch(this.$absolutePath(), 'markMessageRead').then(function() {\n Message.$timeout(function() {\n _this.isread = true;\n _this.$mailbox.unseenCount--;\n });\n });\n }\n return this;\n }\n\n futureMessageData = Message.$$resource.fetch(this.$absolutePath(options), 'view');\n\n return this.$unwrap(futureMessageData);\n };\n\n /**\n * @function $parseMailto\n * @memberof Message.prototype\n * @desc Extend the editable content of the message with the\n * information parsed from the specified \"mailto:\" link.\n */\n Message.prototype.$parseMailto = function(mailto) {\n var to, data, match = /^mailto:([^\\?]+)/.exec(mailto);\n if (match) {\n // Recipients\n to = _.map(decodeURIComponent(match[1]).split(','), function(email) {\n return '<' + email.trim() + '>';\n });\n data = { to: to };\n // Subject & body\n _.forEach(['subject', 'body'], function(param) {\n var re = new RegExp(param + '=([^&]+)');\n param = (param == 'body')? 'text' : param;\n match = re.exec(mailto);\n if (match)\n data[param] = decodeURIComponent(match[1]);\n });\n // Other Recipients\n _.forEach(['cc', 'bcc'], function(param) {\n var re = new RegExp(param + '=([^&]+)');\n match = re.exec(mailto);\n if (match)\n data[param] = _.map(decodeURIComponent(match[1]).split(','), function(email) {\n return '<' + email.trim() + '>';\n });\n });\n angular.extend(this.editable, data);\n }\n };\n\n /**\n * @function $reply\n * @memberof Message.prototype\n * @desc Prepare a new Message object as a reply to the sender.\n * @returns a promise of the HTTP operations\n */\n Message.prototype.$reply = function() {\n return this.$newDraft('reply');\n };\n\n /**\n * @function $replyAll\n * @memberof Message.prototype\n * @desc Prepare a new Message object as a reply to the sender and all recipients.\n * @returns a promise of the HTTP operations\n */\n Message.prototype.$replyAll = function() {\n return this.$newDraft('replyall');\n };\n\n /**\n * @function $forward\n * @memberof Message.prototype\n * @desc Prepare a new Message object as a forward.\n * @returns a promise of the HTTP operations\n */\n Message.prototype.$forward = function() {\n return this.$newDraft('forward');\n };\n\n /**\n * @function $newDraft\n * @memberof Message.prototype\n * @desc Prepare a new Message object as a reply or a forward of the current message and associated\n * to the draft mailbox.\n * @see {@link Account.$newMessage}\n * @see {@link Message.$editableContent}\n * @see {@link Message.$reply}\n * @see {@link Message.$replyAll}\n * @see {@link Message.$forwad}\n * @param {string} action - the HTTP action to perform on the message\n * @returns a promise of the HTTP operations\n */\n Message.prototype.$newDraft = function(action) {\n var _this = this;\n\n // Query server for draft folder and draft UID\n return Message.$$resource.fetch(this.$absolutePath(), action).then(function(data) {\n var mailbox, message;\n Message.$log.debug('New ' + action + ': ' + JSON.stringify(data, undefined, 2));\n mailbox = _this.$mailbox.$account.$getMailboxByPath(data.mailboxPath);\n message = new Message(data.accountId, mailbox, data);\n // Fetch draft initial data\n return Message.$$resource.fetch(message.$absolutePath({asDraft: true}), 'edit').then(function(data) {\n Message.$log.debug('New ' + action + ': ' + JSON.stringify(data, undefined, 2) + ' original UID: ' + _this.uid);\n var accountDefaults = Message.$Preferences.defaults.AuxiliaryMailAccounts[_this.$mailbox.$account.id];\n if (accountDefaults.security) {\n if (accountDefaults.security.alwaysSign)\n data.sign = true;\n if (accountDefaults.security.alwaysEncrypt)\n data.encrypt = true;\n }\n angular.extend(message.editable, data);\n\n // We keep a reference to our original message in order to update the flags\n message.origin = {message: _this, action: action};\n return message;\n });\n });\n };\n\n /**\n * @function $save\n * @memberof Message.prototype\n * @desc Save the message to the server.\n * @returns a promise of the HTTP operation\n */\n Message.prototype.$save = function() {\n var _this = this,\n data = this.editable;\n\n Message.$log.debug('save = ' + JSON.stringify(data, undefined, 2));\n\n return Message.$$resource.save(this.$absolutePath({asDraft: true}), data).then(function(response) {\n Message.$log.debug('save = ' + JSON.stringify(response, undefined, 2));\n _this.$setUID(response.uid);\n _this.$reload(); // fetch a new viewable version of the message\n _this.isNew = false;\n });\n };\n\n /**\n * @function $send\n * @memberof Message.prototype\n * @desc Send the message.\n * @returns a promise of the HTTP operation\n */\n Message.prototype.$send = function() {\n var _this = this,\n data = angular.copy(this.editable);\n\n Message.$log.debug('send = ' + JSON.stringify(data, undefined, 2));\n\n return Message.$$resource.post(this.$absolutePath({asDraft: true}), 'send', data).then(function(response) {\n if (response.status == 'success') {\n if (angular.isDefined(_this.origin)) {\n if (_this.origin.action.startsWith('reply'))\n _this.origin.message.isanswered = true;\n else if (_this.origin.action == 'forward')\n _this.origin.message.isforwarded = true;\n }\n return response;\n }\n else {\n return Message.$q.reject(response.data);\n }\n });\n };\n\n /**\n * @function $unwrap\n * @memberof Message.prototype\n * @desc Unwrap a promise.\n * @param {promise} futureMessageData - a promise of some of the Message's data\n */\n Message.prototype.$unwrap = function(futureMessageData) {\n var _this = this;\n\n // Message is not loaded yet\n this.$loaded = Message.STATUS.DELAYED_LOADING;\n Message.$timeout(function() {\n if (_this.$loaded != Message.STATUS.LOADED)\n _this.$loaded = Message.STATUS.LOADING;\n }, Message.STATUS.DELAYED_MS);\n\n // Resolve and expose the promise\n this.$futureMessageData = futureMessageData.then(function(data) {\n // Calling $timeout will force Angular to refresh the view\n if (_this.isread === 0) {\n _this.isread = true;\n _this.$mailbox.unseenCount--;\n }\n return Message.$timeout(function() {\n delete _this.$parts;\n angular.extend(_this, data);\n _this.$formatFullAddresses();\n _this.$loadUnsafeContent = false;\n _this.$loaded = Message.STATUS.LOADED;\n return _this;\n });\n });\n\n return this.$futureMessageData;\n };\n\n /**\n * @function $omit\n * @memberof Message.prototype\n * @desc Return a sanitized object used to send to the server.\n * @return an object literal copy of the Message instance\n */\n Message.prototype.$omit = function(options) {\n var message = {},\n privateAttributes = options && options.privateAttributes;\n angular.forEach(this, function(value, key) {\n if (key != 'constructor' && key[0] != '$' || privateAttributes) {\n message[key] = value;\n }\n });\n\n return message;\n };\n\n /**\n * @function download\n * @memberof Message.prototype\n * @desc Download the current message\n * @returns a promise of the HTTP operation\n */\n Message.prototype.download = function() {\n var data, options;\n\n data = { uids: [this.uid] };\n options = { filename: this.subject + '.zip' };\n\n return Message.$$resource.download(this.$mailbox.id, 'saveMessages', data, options);\n };\n\n /**\n * @function downloadAttachments\n * @memberof Message.prototype\n * @desc Download an archive of all attachments\n * @returns a promise of the HTTP operation\n */\n Message.prototype.downloadAttachments = function() {\n var options;\n\n options = { filename: l('attachments') + \"-\" + this.uid + \".zip\" };\n\n return Message.$$resource.download(this.$absolutePath(), 'archiveAttachments', null, options);\n };\n\n})();\n","/* -*- Mode: javascript; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n\n(function() {\n 'use strict';\n\n /**\n * @name ImageGallery\n * @constructor\n */\n function ImageGallery() {\n this.show = false;\n this.message = null;\n this.elements = [];\n }\n\n /**\n * @memberof ImageGallery\n * @desc The factory we'll use to register with Angular\n * @returns an ImageGallery instance\n */\n ImageGallery.$factory = ['$document', '$timeout', '$mdPanel', 'sgHotkeys', function($document, $timeout, $mdPanel, sgHotkeys) {\n angular.extend(ImageGallery, {\n $document: $document,\n $timeout: $timeout,\n $mdPanel: $mdPanel,\n sgHotkeys: sgHotkeys\n });\n\n return new ImageGallery(); // return unique instance\n }];\n\n /**\n * @function setMessage\n * @memberof ImageGallery.prototype\n * @desc Set current message object of gallery\n */\n ImageGallery.prototype.setMessage = function(message) {\n this.message = message;\n };\n\n /**\n * @function registerImage\n * @memberof ImageGallery.prototype\n * @desc Add an image to the gallery. Called from sgZoomableImage directive.\n */\n ImageGallery.prototype.registerImage = function(element) {\n this.elements.push(element);\n };\n\n /**\n * @function registerHotkeys\n * @memberof ImageGallery.prototype\n * @desc Allow keyboard navigation\n */\n ImageGallery.prototype.registerHotkeys = function($ctrl) {\n this.keys = [\n ImageGallery.sgHotkeys.createHotkey({\n key: 'left',\n description: l('View previous item'),\n callback: angular.bind($ctrl, $ctrl.previousImage)\n }),\n ImageGallery.sgHotkeys.createHotkey({\n key: 'right',\n description: l('View next item'),\n callback: angular.bind($ctrl, $ctrl.nextImage)\n })\n ];\n _.forEach(this.keys, function(key) {\n ImageGallery.sgHotkeys.registerHotkey(key);\n });\n };\n\n /**\n * @function showGallery\n * @memberof ImageGallery.prototype\n * @desc Build and show the md-panel\n */\n ImageGallery.prototype.showGallery = function($event, partIndex) {\n var _this = this,\n $mdPanel = ImageGallery.$mdPanel,\n partSrc = angular.element(this.message.$content()[partIndex].content).find('img')[0].src;\n\n var images = _.filter(this.message.attachmentAttrs, function(attrs) {\n return attrs.mimetype.indexOf('image/') === 0;\n });\n\n var selectedIndex = _.findIndex(images, function(image) {\n return image.url.indexOf(partSrc) >= 0;\n });\n\n // Add a class to the body in order to modify the panel backdrop opacity\n angular.element(ImageGallery.$document[0].body).addClass('sg-image-gallery-backdrop');\n\n // Fullscreen panel\n var panelPosition = $mdPanel.newPanelPosition()\n .absolute();\n\n var panelAnimation = $mdPanel.newPanelAnimation()\n .openFrom($event.target)\n .duration(100)\n .withAnimation($mdPanel.animation.FADE);\n\n var config = {\n attachTo: angular.element(document.body),\n locals: {\n lastIndex: images.length -1,\n images: images,\n selectedIndex: selectedIndex,\n selectedImage: images[selectedIndex]\n },\n bindToController: true,\n controller: PanelController,\n controllerAs: '$panelCtrl',\n position: panelPosition,\n animation: panelAnimation,\n targetEvent: $event,\n fullscreen: true,\n hasBackdrop: true,\n template: [\n '<sg-image-gallery layout=\"column\">',\n ' <div class=\"md-toolbar-tools\" layout=\"row\" layout-align=\"space-between center\">',\n ' <md-button class=\"md-icon-button\"',\n ' aria-label=\"' + l('Close') + '\"',\n ' ng-click=\"$panelCtrl.close()\">',\n ' <md-icon>arrow_back</md-icon>',\n ' </md-button>',\n ' <md-icon class=\"md-primary\">image</md-icon>',\n ' <div md-truncate class=\"md-flex\" ng-bind=\"$panelCtrl.selectedImage.filename\"></div>',\n ' <md-button class=\"md-icon-button\"',\n ' aria-label=\"' + l('Save Attachment') + '\"',\n ' ng-href=\"{{$panelCtrl.selectedImage.urlAsAttachment}}\">',\n ' <md-icon>file_download</md-icon>',\n ' </md-button>',\n ' </div>',\n ' <div class=\"md-flex\" layout=\"row\" layout-align=\"space-between center\">',\n ' <md-button class=\"md-icon-button\" ng-click=\"$panelCtrl.previousImage()\"',\n ' ng-disabled=\"$panelCtrl.selectedIndex == 0\">',\n ' <md-icon>navigate_before</md-icon>',\n ' </md-button>',\n ' <img class=\"sg-image\" ng-src=\"{{$panelCtrl.selectedImage.url}}\">',\n ' <md-button class=\"md-icon-button\" ng-click=\"$panelCtrl.nextImage()\"',\n ' ng-disabled=\"$panelCtrl.selectedIndex == $panelCtrl.lastIndex\">',\n ' <md-icon>navigate_next</md-icon>',\n ' </md-button>',\n ' </div>',\n ' <div class=\"sg-image-thumbnails\">',\n ' <div class=\"sg-image-thumbnail\" ng-repeat=\"image in ::$panelCtrl.images\">',\n ' <img class=\"sg-hide\" ng-src=\"{{::image.url}}\" ng-click=\"$panelCtrl.selectImage($index)\">',\n ' </div>',\n ' </div>',\n '</sg-image-gallery>'\n ].join(''),\n trapFocus: true,\n clickOutsideToClose: true,\n escapeToClose: true,\n focusOnOpen: true,\n onOpenComplete: function() {\n _this.show = true;\n _.forEach(ImageGallery.$document.find('sg-image-gallery')[0].getElementsByClassName('sg-image-thumbnail'),\n function(imgContainer) {\n var imgEl = imgContainer.children[0];\n angular.element(imgEl).one('load', function() {\n if (imgEl.naturalWidth < imgEl.naturalHeight)\n imgEl.classList.add('portrait');\n });\n // Display thumbnail\n ImageGallery.$timeout(function() {\n imgEl.classList.remove('sg-hide');\n }, 1000);\n });\n },\n onDomRemoved: function() {\n angular.element(ImageGallery.$document[0].body).removeClass('sg-image-gallery-backdrop');\n _this.show = false;\n // Deregister hotkeys\n _.forEach(_this.hotkeys, function(key) {\n ImageGallery.sgHotkeys.deregisterHotkey(key);\n });\n }\n };\n\n $mdPanel.open(config).then(function(mdPanelRef) {\n _this.registerHotkeys(mdPanelRef.$ctrl);\n });\n\n PanelController.$inject = ['mdPanelRef'];\n function PanelController(mdPanelRef) {\n var $menuCtrl = this;\n\n mdPanelRef.$ctrl = this;\n\n this.close = function() {\n mdPanelRef.close();\n };\n\n this.selectImage = function(index) {\n this.selectedIndex = index;\n this.selectedImage = this.images[index];\n };\n\n this.nextImage = function() {\n if (this.selectedIndex != this.lastIndex)\n this.selectImage(this.selectedIndex + 1);\n };\n\n this.previousImage = function() {\n if (this.selectedIndex > 0)\n this.selectImage(this.selectedIndex - 1);\n };\n\n } // PanelController\n\n };\n\n /* Factory registration in Angular module */\n angular.module('SOGo.MailerUI')\n .factory('ImageGallery', ImageGallery.$factory);\n\n})();\n","/* -*- Mode: javascript; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n\n(function() {\n 'use strict';\n\n /**\n * @name VirtualMailbox\n * @constructor\n * @param {object} account - the mail account associated with the virtual search\n */\n function VirtualMailbox(account) {\n this.$account = account;\n }\n\n /**\n * @memberof VirtualMailbox\n * @desc The factory we'll use to register with Angular\n * @returns the VirtualMailbox constructor\n */\n VirtualMailbox.$factory = ['$q', '$timeout', '$log', 'sgSettings', 'Resource', 'Message', 'Mailbox', 'sgMailbox_PRELOAD', function($q, $timeout, $log, Settings, Resource, Mailbox, Message, PRELOAD) {\n angular.extend(VirtualMailbox, {\n $q: $q,\n $timeout: $timeout,\n $log: $log,\n $$resource: new Resource(Settings.activeUser('folderURL') + 'Mail', Settings.activeUser()),\n $Message: Message,\n selectedFolder: null,\n PRELOAD: PRELOAD\n });\n\n return VirtualMailbox; // return constructor\n }];\n\n /**\n * @module SOGo.MailerUI\n * @desc Factory registration of VirtualMailbox in Angular module.\n */\n try {\n angular.module('SOGo.MailerUI');\n }\n catch(e) {\n angular.module('SOGo.MailerUI', ['SOGo.Common']);\n }\n angular.module('SOGo.MailerUI')\n .constant('sgMailbox_PRELOAD', {\n LOOKAHEAD: 50,\n SIZE: 100\n })\n .factory('VirtualMailbox', VirtualMailbox.$factory);\n\n /**\n * @memberof VirtualMailbox\n * @desc Build the path of the virtual mailbox (or account only).\n * @param {string} accountId - the account ID\n * @returns a string representing the path relative to the mail module\n */\n VirtualMailbox.$absolutePath = function(accountId) {\n return [accountId, \"virtual\"].join('/');\n };\n\n /**\n * @function init\n * @memberof VirtualMailbox.prototype\n * @desc Extend instance with new data and compute additional attributes.\n * @param {object} data - attributes of mailbox\n */\n VirtualMailbox.prototype.init = function(data) {\n this.$isLoading = false;\n this.$mailboxes = [];\n this.uidsMap = {};\n angular.extend(this, data);\n this.id = this.$id();\n };\n\n VirtualMailbox.prototype.setMailboxes = function(data) {\n this.$mailboxes = data;\n\n _.forEach(this.$mailboxes, function(mailbox) {\n mailbox.$messages = [];\n mailbox.uidsMap = {};\n });\n };\n\n VirtualMailbox.prototype.startSearch = function(match, params) {\n var _this = this,\n search = VirtualMailbox.$q.when();\n\n this.$isLoading = true;\n\n _.forEach(this.$mailboxes, function(mailbox) {\n search = search.then(function() {\n if (_this.$isLoading) {\n VirtualMailbox.$log.debug(\"searching mailbox \" + mailbox.path);\n return mailbox.$filter( {sort: \"date\", asc: false, match: match}, params);\n }\n });\n });\n\n search.finally(function() {\n _this.$isLoading = false;\n });\n };\n\n VirtualMailbox.prototype.stopSearch = function() {\n VirtualMailbox.$log.debug(\"stopping search...\");\n this.$isLoading = false;\n };\n\n /**\n * @function selectFolder\n * @memberof VirtualMailbox.prototype\n * @desc A no-op for virtual mailbox\n */\n VirtualMailbox.prototype.selectFolder = function() {\n return;\n };\n\n /**\n * @function resetSelectedMessage\n * @memberof VirtualMailbox.prototype\n * @desc Delete 'selectedMessage' attribute of all submailboxes.\n */\n VirtualMailbox.prototype.resetSelectedMessage = function() {\n _.forEach(this.$mailboxes, function(mailbox) {\n delete mailbox.selectedMessage;\n });\n };\n\n /**\n * @function hasSelectedMessage\n * @memberof VirtualMailbox.prototype\n * @desc Check if a message is selected among the resulting mailboxes\n * @returns true if one message is selected\n */\n VirtualMailbox.prototype.hasSelectedMessage = function() {\n return angular.isDefined(_.find(this.$mailboxes, function(mailbox) {\n return angular.isDefined(mailbox.selectedMessage);\n }));\n };\n\n /**\n * @function isSelectedMessage\n * @memberof VirtualMailbox.prototype\n * @desc Check if the message of the specified mailbox is selected.\n * @param {string} messageId\n * @param {string} mailboxPath\n * @returns true if the specified message is selected\n */\n VirtualMailbox.prototype.isSelectedMessage = function(messageId, mailboxPath) {\n return angular.isDefined(_.find(this.$mailboxes, function(mailbox) {\n return mailbox.path == mailboxPath && mailbox.selectedMessage == messageId;\n }));\n };\n\n /**\n * @function getLength\n * @memberof VirtualMailbox.prototype\n * @desc Used by md-virtual-repeat / md-on-demand\n * @returns the number of items in the mailbox\n */\n VirtualMailbox.prototype.getLength = function() {\n var len = 0;\n\n if (!angular.isDefined(this.$mailboxes))\n return len;\n\n _.forEach(this.$mailboxes, function(mailbox) {\n len += mailbox.$messages.length;\n });\n\n return len;\n };\n\n /**\n * @function getItemAtIndex\n * @memberof VirtualMailbox.prototype\n * @desc Used by md-virtual-repeat / md-on-demand\n * @returns the message as the specified index\n */\n VirtualMailbox.prototype.getItemAtIndex = function(index) {\n var i, j, k, mailbox, message;\n\n if (angular.isDefined(this.$mailboxes) && index >= 0) {\n i = 0;\n for (j = 0; j < this.$mailboxes.length; j++) {\n mailbox = this.$mailboxes[j];\n for (k = 0; k < mailbox.$messages.length; i++, k++) {\n message = mailbox.$messages[k];\n if (i == index) {\n if (mailbox.$loadMessage(message.uid))\n return message;\n }\n }\n }\n }\n\n return null;\n };\n\n /**\n * @function $id\n * @memberof VirtualMailbox.prototype\n * @desc Build the unique ID to identified the mailbox.\n * @returns a string representing the path relative to the mail module\n */\n VirtualMailbox.prototype.$id = function() {\n return VirtualMailbox.$absolutePath(this.$account.id);\n };\n\n /**\n * @function $selectedMessages\n * @memberof VirtualMailbox.prototype\n * @desc Return an associative array of the selected messages for each mailbox. Keys are the mailboxes ids.\n * @returns an associative array\n */\n VirtualMailbox.prototype.$selectedMessages = function() {\n var messagesMap = {};\n return _.transform(this.$mailboxes, function(messagesMap, mailbox) {\n messagesMap[mailbox.id] = mailbox.$selectedMessages();\n }, {});\n };\n\n /**\n * @function $selectedCount\n * @memberof VirtualMailbox.prototype\n * @desc Return the number of messages selected by the user.\n * @returns the number of selected messages\n */\n VirtualMailbox.prototype.$selectedCount = function() {\n return _.sum(_.invokeMap(this.$mailboxes, '$selectedCount'));\n };\n\n /**\n * @function $flagMessages\n * @memberof VirtualMailbox.prototype\n * @desc Add or remove a flag on a message set\n * @param {object} messagesMap\n * @param {array} flags\n * @param {string} operation\n * @returns a promise of the HTTP operation\n */\n VirtualMailbox.prototype.$flagMessages = function(messagesMap, flags, operation) {\n var data = {\n flags: flags,\n operation: operation\n };\n var allMessages = [];\n var promises = [];\n\n _.forEach(messagesMap, function(messages, id) {\n if (messages.length > 0) {\n var uids = _.map(messages, 'uid');\n allMessages.push(messages);\n var promise = VirtualMailbox.$$resource.post(id, 'addOrRemoveLabel', _.assign(data, {msgUIDs: uids}));\n promises.push(promise);\n }\n });\n\n return VirtualMailbox.$q.all(promises).then(function() {\n return _.flatten(allMessages);\n });\n };\n\n /**\n * @function $deleteMessages\n * @memberof VirtualMailbox.prototype\n * @desc Delete multiple messages from mailbox.\n * @param {object} messagesMap\n * @return a promise of the HTTP operation\n */\n VirtualMailbox.prototype.$deleteMessages = function(messagesMap) {\n var promises = [];\n\n _.forEach(messagesMap, function(messages, id) {\n if (messages.length > 0) {\n var mailbox = messages[0].$mailbox;\n var promise = mailbox.$deleteMessages(messages);\n promises.push(promise);\n }\n });\n\n return VirtualMailbox.$q.all(promises);\n };\n\n /**\n * @function $markOrUnMarkMessagesAsJunk\n * @memberof VirtualMailbox.prototype\n * @desc Mark messages as junk/not junk\n * @param {object} messagesMap\n * @return a promise of the HTTP operation\n */\n VirtualMailbox.prototype.$markOrUnMarkMessagesAsJunk = function(messagesMap) {\n var promises = [];\n\n _.forEach(messagesMap, function(messages, id) {\n if (messages.length > 0) {\n var mailbox = messages[0].$mailbox;\n var promise = mailbox.$markOrUnMarkMessagesAsJunk(messages);\n promises.push(promise);\n }\n });\n\n return VirtualMailbox.$q.all(promises);\n };\n\n /**\n * @function $copyMessages\n * @memberof VirtualMailbox.prototype\n * @desc Copy multiple messages from the current mailbox to a target one\n * @param {object} messagesMap\n * @param {string} folder\n * @return a promise of the HTTP operation\n */\n VirtualMailbox.prototype.$copyMessages = function(messagesMap, folder) {\n var promises = [];\n\n _.forEach(messagesMap, function(messages, id) {\n if (messages.length > 0) {\n var mailbox = messages[0].$mailbox;\n var promise = mailbox.$copyMessages(messages, folder);\n promises.push(promise);\n }\n });\n\n return VirtualMailbox.$q.all(promises);\n };\n\n /**\n * @function $moveMessages\n * @memberof VirtualMailbox.prototype\n * @desc Move multiple messages from the current mailbox to a target one\n * @param {object} messagesMap\n * @param {string} folder\n * @return a promise of the HTTP operation\n */\n VirtualMailbox.prototype.$moveMessages = function(messagesMap, folder) {\n var promises = [];\n\n _.forEach(messagesMap, function(messages, id) {\n if (messages.length > 0) {\n var mailbox = messages[0].$mailbox;\n var promise = mailbox.$moveMessages(messages, folder);\n promises.push(promise);\n }\n });\n\n return VirtualMailbox.$q.all(promises);\n };\n\n})();\n","/* -*- Mode: javascript; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n\n(function() {\n 'use strict';\n\n /**\n * @ngInject\n */\n MailboxController.$inject = ['$window', '$scope', '$timeout', '$q', '$state', '$mdDialog', '$mdToast', 'stateAccounts', 'stateAccount', 'stateMailbox', 'sgHotkeys', 'encodeUriFilter', 'sgSettings', 'sgFocus', 'Dialog', 'Preferences', 'Account', 'Mailbox'];\n function MailboxController($window, $scope, $timeout, $q, $state, $mdDialog, $mdToast, stateAccounts, stateAccount, stateMailbox, sgHotkeys, encodeUriFilter, sgSettings, focus, Dialog, Preferences, Account, Mailbox) {\n var vm = this,\n defaultWindowTitle = angular.element($window.document).find('title').attr('sg-default') || \"SOGo\",\n hotkeys = [];\n\n this.$onInit = function() {\n // Expose controller for eventual popup windows\n $window.$mailboxController = vm;\n\n this.service = Mailbox;\n this.accounts = stateAccounts;\n this.account = stateAccount;\n this.selectedFolder = stateMailbox;\n this.messageDialog = null; // also access from Message controller\n this.mode = { search: false, multiple: 0 };\n\n _registerHotkeys(hotkeys);\n\n // Expunge mailbox when leaving the Mail module\n angular.element($window).on('beforeunload', _compactBeforeUnload);\n $scope.$on('$destroy', function() {\n angular.element($window).off('beforeunload', _compactBeforeUnload);\n // Deregister hotkeys\n _.forEach(hotkeys, function(key) {\n sgHotkeys.deregisterHotkey(key);\n });\n });\n\n // Update window's title with unseen messages count of selected mailbox\n $scope.$watch(function() { return vm.selectedFolder.unseenCount; }, function(unseenCount) {\n var title = defaultWindowTitle + ' - ';\n if (unseenCount)\n title += '(' + unseenCount + ') ';\n title += vm.selectedFolder.$displayName;\n $window.document.title = title;\n });\n };\n\n\n function _registerHotkeys(keys) {\n keys.push(sgHotkeys.createHotkey({\n key: l('hotkey_search'),\n description: l('Search'),\n callback: vm.searchMode\n }));\n keys.push(sgHotkeys.createHotkey({\n key: l('hotkey_compose'),\n description: l('Write a new message'),\n callback: function($event) {\n if (vm.messageDialog === null)\n vm.newMessage($event);\n }\n }));\n keys.push(sgHotkeys.createHotkey({\n key: l('hotkey_junk'),\n description: l('Mark the selected messages as junk'),\n callback: vm.markOrUnMarkMessagesAsJunk\n }));\n keys.push(sgHotkeys.createHotkey({\n key: 'space',\n description: l('Toggle item'),\n callback: vm.toggleMessageSelection\n }));\n keys.push(sgHotkeys.createHotkey({\n key: 'shift+space',\n description: l('Toggle range of items'),\n callback: vm.toggleMessageSelection\n }));\n keys.push(sgHotkeys.createHotkey({\n key: 'up',\n description: l('View next item'),\n callback: _nextMessage,\n preventInClass: ['sg-mail-part']\n }));\n keys.push(sgHotkeys.createHotkey({\n key: 'down',\n description: l('View previous item'),\n callback: _previousMessage,\n preventInClass: ['sg-mail-part']\n }));\n keys.push(sgHotkeys.createHotkey({\n key: 'shift+up',\n description: l('Add next item to selection'),\n callback: _addNextMessageToSelection,\n preventInClass: ['sg-mail-part']\n }));\n keys.push(sgHotkeys.createHotkey({\n key: 'shift+down',\n description: l('Add previous item to selection'),\n callback: _addPreviousMessageToSelection,\n preventInClass: ['sg-mail-part']\n }));\n _.forEach(['backspace', 'delete'], function(hotkey) {\n keys.push(sgHotkeys.createHotkey({\n key: hotkey,\n description: l('Delete selected message or folder'),\n callback: vm.confirmDeleteSelectedMessages\n }));\n });\n\n // Register the hotkeys\n _.forEach(keys, function(key) {\n sgHotkeys.registerHotkey(key);\n });\n }\n\n function _compactBeforeUnload(event) {\n return vm.selectedFolder.$compact();\n }\n\n this.centerIsClose = function(navController_centerIsClose) {\n // Allow the messages list to be hidden only if a message is selected\n return this.selectedFolder.hasSelectedMessage() && !!navController_centerIsClose;\n };\n\n this.sort = function(field) {\n vm.selectedFolder.$filter({ sort: field });\n };\n\n this.sortedBy = function(field) {\n return Mailbox.$query.sort == field;\n };\n\n this.searchMode = function() {\n vm.mode.search = true;\n focus('search');\n };\n\n this.cancelSearch = function() {\n vm.mode.search = false;\n vm.selectedFolder.$filter().then(function() {\n if (vm.selectedFolder.selectedMessage) {\n $timeout(function() {\n vm.selectedFolder.$topIndex = vm.selectedFolder.uidsMap[vm.selectedFolder.selectedMessage];\n });\n }\n });\n };\n\n this.composeWindowEnabled = function() {\n return Preferences.defaults.SOGoMailComposeWindowEnabled;\n };\n\n this.newMessage = function($event, inPopup) {\n var message;\n\n if (vm.messageDialog === null) {\n if (inPopup || Preferences.defaults.SOGoMailComposeWindow == 'popup')\n _newMessageInPopup();\n else {\n message = vm.account.$newMessage();\n vm.messageDialog = $mdDialog\n .show({\n parent: angular.element(document.body),\n targetEvent: $event,\n clickOutsideToClose: false,\n escapeToClose: false,\n templateUrl: 'UIxMailEditor',\n controller: 'MessageEditorController',\n controllerAs: 'editor',\n locals: {\n stateAccount: vm.account,\n stateMessage: message\n }\n })\n .catch(_.noop) // Cancel\n .finally(function() {\n vm.messageDialog = null;\n });\n }\n }\n };\n\n function _newMessageInPopup() {\n var url = [sgSettings.baseURL(),\n 'UIxMailPopupView#!/Mail',\n vm.account.id,\n // The double-encoding is necessary\n encodeUriFilter(encodeUriFilter(vm.selectedFolder.path)),\n 'new']\n .join('/'),\n wId = vm.selectedFolder.$id() + '/' + Math.random(0, 1000);\n console.debug(url);\n $window.open(url, wId,\n [\"width=680\",\n \"height=520\",\n \"resizable=1\",\n \"scrollbars=1\",\n \"toolbar=0\",\n \"location=0\",\n \"directories=0\",\n \"status=0\",\n \"menubar=0\",\n \"copyhistory=0\"]\n .join(','));\n }\n\n /**\n * User has pressed up arrow key\n */\n function _nextMessage($event) {\n var index = vm.selectedFolder.$selectedMessageIndex();\n\n if (angular.isDefined(index)) {\n index--;\n if (vm.selectedFolder.$topIndex > 0)\n vm.selectedFolder.$topIndex--;\n }\n else {\n // No message is selected, show oldest message\n index = vm.selectedFolder.getLength() - 1;\n vm.selectedFolder.$topIndex = vm.selectedFolder.getLength();\n }\n\n if (index > -1)\n vm.selectMessage(vm.selectedFolder.$messages[index]);\n\n $event.preventDefault();\n\n return index;\n }\n\n /**\n * User has pressed the down arrow key\n */\n function _previousMessage($event) {\n var index = vm.selectedFolder.$selectedMessageIndex();\n\n if (angular.isDefined(index)) {\n index++;\n if (vm.selectedFolder.$topIndex < vm.selectedFolder.getLength())\n vm.selectedFolder.$topIndex++;\n }\n else\n // No message is selected, show newest\n index = 0;\n\n if (index < vm.selectedFolder.getLength())\n vm.selectMessage(vm.selectedFolder.$messages[index]);\n else\n index = -1;\n\n $event.preventDefault();\n\n return index;\n }\n\n function _addNextMessageToSelection($event) {\n var index;\n\n if (vm.selectedFolder.hasSelectedMessage()) {\n index = _nextMessage($event);\n if (index >= 0)\n vm.toggleMessageSelection($event, vm.selectedFolder.$messages[index]);\n }\n }\n\n function _addPreviousMessageToSelection($event) {\n var index;\n\n if (vm.selectedFolder.hasSelectedMessage()) {\n index = _previousMessage($event);\n if (index >= 0)\n vm.toggleMessageSelection($event, vm.selectedFolder.$messages[index]);\n }\n }\n\n this.selectMessage = function(message) {\n if (Mailbox.$virtualMode)\n $state.go('mail.account.virtualMailbox.message', {mailboxId: encodeUriFilter(message.$mailbox.path), messageId: message.uid});\n else\n $state.go('mail.account.mailbox.message', {messageId: message.uid});\n };\n\n this.toggleMessageSelection = function($event, message) {\n var folder = vm.selectedFolder,\n selectedIndex, nextSelectedIndex, i;\n\n if (!message)\n message = folder.$selectedMessage();\n if (!message)\n return true;\n message.selected = !message.selected;\n vm.mode.multiple += message.selected? 1 : -1;\n\n // Select closest range of messages when shift key is pressed\n if ($event.shiftKey && folder.$selectedCount() > 1) {\n selectedIndex = folder.uidsMap[message.uid];\n // Search for next selected message above\n nextSelectedIndex = selectedIndex - 2;\n while (nextSelectedIndex >= 0 &&\n !folder.$messages[nextSelectedIndex].selected)\n nextSelectedIndex--;\n if (nextSelectedIndex < 0) {\n // Search for next selected message bellow\n nextSelectedIndex = selectedIndex + 2;\n while (nextSelectedIndex < folder.getLength() &&\n !folder.$messages[nextSelectedIndex].selected)\n nextSelectedIndex++;\n }\n if (nextSelectedIndex >= 0 && nextSelectedIndex < folder.getLength()) {\n for (i = Math.min(selectedIndex, nextSelectedIndex);\n i <= Math.max(selectedIndex, nextSelectedIndex);\n i++)\n folder.$messages[i].selected = true;\n }\n }\n\n $event.preventDefault();\n $event.stopPropagation();\n };\n\n /**\n * Batch operations\n */\n\n function _currentMailboxes() {\n if (Mailbox.$virtualMode)\n return vm.selectedFolder.$mailboxes;\n else\n return [vm.selectedFolder];\n }\n\n // Unselect current message and cleverly load the next message.\n // This function must not be called in virtual mode.\n function _unselectMessage(message, index) {\n var nextMessage, previousMessage, nextIndex = index;\n vm.mode.multiple = vm.selectedFolder.$selectedCount();\n if (message) {\n // Select either the next or previous message\n if (index > 0) {\n nextIndex -= 1;\n nextMessage = vm.selectedFolder.$messages[nextIndex];\n }\n if (index < vm.selectedFolder.$messages.length)\n previousMessage = vm.selectedFolder.$messages[index];\n if (nextMessage) {\n if (nextMessage.isread && previousMessage && !previousMessage.isread) {\n nextIndex = index;\n nextMessage = previousMessage;\n }\n }\n else if (previousMessage) {\n nextIndex = index;\n nextMessage = previousMessage;\n }\n if (nextMessage) {\n vm.selectedFolder.$topIndex = nextIndex;\n $state.go('mail.account.mailbox.message', { messageId: nextMessage.uid });\n }\n else {\n $state.go('mail.account.mailbox');\n }\n }\n else {\n $timeout(function() {\n console.warn('go to mailbox');\n $state.go('mail.account.mailbox');\n });\n }\n }\n\n this.confirmDeleteSelectedMessages = function($event) {\n var selectedMessages = vm.selectedFolder.$selectedMessages();\n\n if (vm.messageDialog === null && _.size(selectedMessages) > 0)\n vm.messageDialog = Dialog.confirm(l('Confirmation'),\n l('Are you sure you want to delete the selected messages?'),\n { ok: l('Delete') })\n .then(function() {\n var deleteSelectedMessage = vm.selectedFolder.hasSelectedMessage();\n vm.selectedFolder.$deleteMessages(selectedMessages).then(function(index) {\n if (Mailbox.$virtualMode) {\n // When performing an advanced search, we refresh the view if the selected message\n // was deleted, but only once all promises have completed.\n if (deleteSelectedMessage)\n $state.go('mail.account.virtualMailbox');\n }\n else {\n // In normal mode, we immediately unselect the selected message.\n _unselectMessage(deleteSelectedMessage, index);\n }\n }, function(response) {\n vm.messageDialog = Dialog.confirm(l('Warning'),\n l('The messages could not be moved to the trash folder. Would you like to delete them immediately?'),\n { ok: l('Delete') })\n .then(function() {\n vm.selectedFolder.$deleteMessages(selectedMessages, { withoutTrash: true }).then(function(index) {\n if (Mailbox.$virtualMode) {\n // When performing an advanced search, we refresh the view if the selected message\n // was deleted, but only once all promises have completed.\n if (deleteSelectedMessage)\n $state.go('mail.account.virtualMailbox');\n }\n else {\n // In normal mode, we immediately unselect the selected message.\n _unselectMessage(deleteSelectedMessage, index);\n }\n });\n });\n });\n })\n .finally(function() {\n vm.messageDialog = null;\n });\n\n $event.preventDefault();\n };\n\n this.markOrUnMarkMessagesAsJunk = function() {\n var moveSelectedMessage = vm.selectedFolder.hasSelectedMessage();\n var selectedMessages = vm.selectedFolder.$selectedMessages();\n if (_.size(selectedMessages) === 0 && moveSelectedMessage)\n selectedMessages = [vm.selectedFolder.$selectedMessage()];\n if (_.size(selectedMessages) > 0)\n vm.selectedFolder.$markOrUnMarkMessagesAsJunk(selectedMessages).then(function() {\n var dstFolder = '/' + vm.account.id + '/folderINBOX';\n if (vm.selectedFolder.type != 'junk') {\n dstFolder = '/' + vm.account.$getMailboxByType('junk').id;\n }\n vm.selectedFolder.$moveMessages(selectedMessages, dstFolder).then(function(index) {\n if (Mailbox.$virtualMode) {\n // When performing an advanced search, we refresh the view if the selected message\n // was deleted, but only once all promises have completed.\n if (moveSelectedMessage)\n $state.go('mail.account.virtualMailbox');\n }\n else {\n // In normal mode, we immediately unselect the selected message.\n _unselectMessage(moveSelectedMessage, index);\n }\n });\n });\n };\n\n this.copySelectedMessages = function(dstFolder) {\n var selectedMessages = vm.selectedFolder.$selectedMessages();\n if (_.size(selectedMessages) > 0)\n vm.selectedFolder.$copyMessages(selectedMessages, '/' + dstFolder).then(function() {\n $mdToast.show(\n $mdToast.simple()\n .content(l('%{0} message(s) copied', vm.selectedFolder.$selectedCount()))\n .position('top right')\n .hideDelay(2000));\n });\n };\n\n this.moveSelectedMessages = function(dstFolder) {\n var moveSelectedMessage = vm.selectedFolder.hasSelectedMessage();\n var selectedMessages = vm.selectedFolder.$selectedMessages();\n var count = vm.selectedFolder.$selectedCount();\n if (_.size(selectedMessages) > 0)\n vm.selectedFolder.$moveMessages(selectedMessages, '/' + dstFolder).then(function(index) {\n $mdToast.show(\n $mdToast.simple()\n .content(l('%{0} message(s) moved', count))\n .position('top right')\n .hideDelay(2000));\n if (Mailbox.$virtualMode) {\n // When performing an advanced search, we refresh the view if the selected message\n // was moved, but only once all promises have completed.\n if (moveSelectedMessage)\n $state.go('mail.account.virtualMailbox');\n }\n else {\n // In normal mode, we immediately unselect the selected message.\n _unselectMessage(moveSelectedMessage, index);\n }\n });\n };\n\n this.selectAll = function() {\n var count = 0;\n _.forEach(_currentMailboxes(), function(folder) {\n var i = 0, length = folder.$messages.length;\n for (; i < length; i++)\n folder.$messages[i].selected = true;\n count += length;\n });\n vm.mode.multiple = count;\n };\n\n this.unselectMessages = function() {\n _.forEach(_currentMailboxes(), function(folder) {\n _.forEach(folder.$messages, function(message) {\n message.selected = false;\n });\n });\n vm.mode.multiple = 0;\n };\n\n this.markSelectedMessagesAsFlagged = function() {\n var selectedMessages = vm.selectedFolder.$selectedMessages();\n if (_.size(selectedMessages) > 0)\n vm.selectedFolder.$flagMessages(selectedMessages, '\\\\Flagged', 'add').then(function(messages) {\n _.forEach(messages, function(message) {\n message.isflagged = true;\n });\n });\n };\n\n this.markSelectedMessagesAsUnread = function() {\n var selectedMessages = vm.selectedFolder.$selectedMessages();\n if (_.size(selectedMessages) > 0) {\n vm.selectedFolder.$flagMessages(selectedMessages, 'seen', 'remove').then(function(messages) {\n _.forEach(messages, function(message) {\n if (message.isread)\n message.$mailbox.unseenCount++;\n message.isread = false;\n });\n });\n }\n };\n\n this.markSelectedMessagesAsRead = function() {\n var selectedMessages = vm.selectedFolder.$selectedMessages();\n if (_.size(selectedMessages) > 0) {\n vm.selectedFolder.$flagMessages(selectedMessages, 'seen', 'add').then(function(messages) {\n _.forEach(messages, function(message) {\n if (!message.isread)\n message.$mailbox.unseenCount--;\n message.isread = true;\n });\n });\n }\n };\n\n }\n\n angular\n .module('SOGo.MailerUI')\n .controller('MailboxController', MailboxController);\n\n /**\n * @ngInject\n */\n mdVirtualRepeatContainerDirectiveDecorator.$inject = ['$delegate'];\n function mdVirtualRepeatContainerDirectiveDecorator($delegate) {\n $delegate[0].controller.prototype.resetScroll = function() {\n // Don't scroll to top if current virtual repeater is the messages list\n // but do update the container size\n if (this.$element.parent().attr('id') == 'messagesList')\n this.updateSize();\n else\n this.scrollTo(0);\n };\n return $delegate;\n }\n\n angular\n .module('material.components.virtualRepeat')\n .decorator('mdVirtualRepeatContainerDirective', mdVirtualRepeatContainerDirectiveDecorator);\n\n})();\n\n","/* -*- Mode: js; indent-tabs-mode: nil; js-indent-level: 2; -*- */\n\n(function() {\n 'use strict';\n\n /**\n * @ngInject\n */\n MailboxesController.$inject = ['$scope', '$state', '$transitions', '$timeout', '$window', '$mdDialog', '$mdToast', 'sgFocus', 'encodeUriFilter', 'Dialog', 'sgSettings', 'sgHotkeys', 'Account', 'Mailbox', 'VirtualMailbox', 'User', 'Preferences', 'stateAccounts'];\n function MailboxesController($scope, $state, $transitions, $timeout, $window, $mdDialog, $mdToast, focus, encodeUriFilter, Dialog, Settings, sgHotkeys, Account, Mailbox, VirtualMailbox, User, Preferences, stateAccounts) {\n var vm = this,\n account,\n mailbox,\n hotkeys = [];\n\n this.$onInit = function () {\n this.service = Mailbox;\n this.accounts = stateAccounts;\n\n // Advanced search options\n this.currentSearchParam = '';\n this.search = {\n options: {'': '', // no placeholder when no criteria is active\n subject: l('Enter Subject'),\n from: l('Enter From'),\n to: l('Enter To'),\n cc: l('Enter Cc'),\n body: l('Enter Body')\n },\n subfolders: 1,\n match: 'AND',\n params: []\n };\n\n this.showSubscribedOnly = Preferences.defaults.SOGoMailShowSubscribedFoldersOnly;\n\n this.refreshUnseenCount();\n\n _registerHotkeys(hotkeys);\n\n $scope.$on('$destroy', function() {\n // Deregister hotkeys\n _.forEach(hotkeys, function(key) {\n sgHotkeys.deregisterHotkey(key);\n });\n });\n };\n\n\n function _registerHotkeys(keys) {\n _.forEach(['backspace', 'delete'], function(hotkey) {\n keys.push(sgHotkeys.createHotkey({\n key: hotkey,\n description: l('Delete selected message or folder'),\n callback: function() {\n if (Mailbox.selectedFolderController && Mailbox.selectedFolder && !Mailbox.selectedFolder.hasSelectedMessage())\n Mailbox.selectedFolderController.confirmDelete(Mailbox.selectedFolder);\n }\n }));\n });\n\n // Register the hotkeys\n _.forEach(keys, function(key) {\n sgHotkeys.registerHotkey(key);\n });\n }\n\n this.hideAdvancedSearch = function() {\n vm.service.$virtualPath = false;\n vm.service.$virtualMode = false;\n\n account = vm.accounts[0];\n mailbox = vm.searchPreviousMailbox;\n $state.go('mail.account.mailbox', { accountId: account.id, mailboxId: encodeUriFilter(mailbox.path) });\n };\n\n this.toggleAdvancedSearch = function() {\n if (Mailbox.selectedFolder.$isLoading) {\n // Stop search\n vm.virtualMailbox.stopSearch();\n }\n else {\n // Start search\n var root, mailboxes = [],\n _visit = function(folders) {\n _.forEach(folders, function(o) {\n mailboxes.push(o);\n if (o.children && o.children.length > 0) {\n _visit(o.children);\n }\n });\n };\n\n vm.virtualMailbox = new VirtualMailbox(vm.accounts[0]);\n\n // Don't set the previous selected mailbox if we're in virtual mode\n // That allows users to do multiple advanced search but return\n // correctly to the previously selected mailbox once done.\n if (!Mailbox.$virtualMode)\n vm.searchPreviousMailbox = Mailbox.selectedFolder;\n\n Mailbox.selectedFolder = vm.virtualMailbox;\n Mailbox.$virtualMode = true;\n\n if (angular.isDefined(Mailbox.$virtualPath)) {\n root = vm.accounts[0].$getMailboxByPath(Mailbox.$virtualPath);\n mailboxes.push(root);\n if (vm.search.subfolders && root.children.length)\n _visit(root.children);\n }\n else {\n mailboxes = vm.accounts[0].$flattenMailboxes();\n }\n\n vm.virtualMailbox.setMailboxes(mailboxes);\n vm.virtualMailbox.startSearch(vm.search.match, vm.search.params);\n if ($state.$current.name != 'mail.account.virtualMailbox')\n $state.go('mail.account.virtualMailbox', { accountId: vm.accounts[0].id });\n }\n };\n\n this.addSearchParam = function(v) {\n vm.currentSearchParam = v;\n focus('advancedSearch');\n return false;\n };\n\n this.newSearchParam = function(pattern) {\n if (pattern.length && vm.currentSearchParam.length) {\n var n = 0, searchParam = vm.currentSearchParam;\n if (pattern.startsWith(\"!\")) {\n n = 1;\n pattern = pattern.substring(1).trim();\n }\n vm.currentSearchParam = '';\n return { searchBy: searchParam, searchInput: pattern, negative: n };\n }\n };\n\n this.toggleAccountState = function (account) {\n account.$expanded = !account.$expanded;\n account.$flattenMailboxes({ reload: true, saveState: true });\n // Fire a window resize to recompute the virtual-repeater.\n // This is a fix until the following issue is officially resolved:\n // https://github.com/angular/material/issues/7309\n $timeout(function() {\n angular.element($window).triggerHandler('resize');\n }, 150);\n };\n\n this.subscribe = function(account) {\n $mdDialog.show({\n templateUrl: account.id + '/subscribe',\n controller: SubscriptionsDialogController,\n controllerAs: 'subscriptions',\n clickOutsideToClose: true,\n escapeToClose: true,\n locals: {\n srcAccount: account\n }\n }).finally(function() {\n account.$getMailboxes({reload: true});\n });\n\n /**\n * @ngInject\n */\n SubscriptionsDialogController.$inject = ['$scope', '$mdDialog', 'srcAccount'];\n function SubscriptionsDialogController($scope, $mdDialog, srcAccount) {\n var vm = this;\n\n vm.loading = true;\n vm.filter = { name: '' };\n vm.account = new Account({\n id: srcAccount.id,\n name: srcAccount.name\n });\n vm.close = close;\n\n vm.account.$getMailboxes({ reload: true, all: true }).then(function() {\n vm.loading = false;\n });\n\n function close() {\n $mdDialog.hide();\n }\n }\n };\n\n this.newFolder = function(parentFolder) {\n Dialog.prompt(l('New Folder...'),\n l('Enter the new name of your folder'))\n .then(function(name) {\n parentFolder.$newMailbox(parentFolder.id, name)\n .then(function() {\n // success\n }, function(data, status) {\n Dialog.alert(l('An error occured while creating the mailbox \"%{0}\".', name),\n l(data.error));\n });\n });\n };\n\n this.delegate = function(account) {\n $mdDialog.show({\n templateUrl: account.id + '/delegation', // UI/Templates/MailerUI/UIxMailUserDelegation.wox\n controller: MailboxDelegationController,\n controllerAs: 'delegate',\n clickOutsideToClose: true,\n escapeToClose: true,\n locals: {\n User: User,\n account: account\n }\n });\n\n /**\n * @ngInject\n */\n MailboxDelegationController.$inject = ['$scope', '$mdDialog', 'User', 'account'];\n function MailboxDelegationController($scope, $mdDialog, User, account) {\n var vm = this;\n\n vm.users = account.delegates;\n vm.account = account;\n vm.userToAdd = '';\n vm.searchText = '';\n vm.userFilter = userFilter;\n vm.closeModal = closeModal;\n vm.removeUser = removeUser;\n vm.addUser = addUser;\n\n function userFilter($query) {\n return User.$filter($query, account.delegates);\n }\n\n function closeModal() {\n $mdDialog.hide();\n }\n\n function removeUser(user) {\n account.$removeDelegate(user.uid).catch(function(data, status) {\n Dialog.alert(l('Warning'), l('An error occured please try again.'));\n });\n }\n\n function addUser(data) {\n if (data) {\n account.$addDelegate(data).then(function() {\n vm.userToAdd = '';\n vm.searchText = '';\n }, function(error) {\n Dialog.alert(l('Warning'), error);\n });\n }\n }\n }\n }; // delegate\n\n this.refreshUnseenCount = function() {\n var unseenCountFolders = $window.unseenCountFolders, refreshViewCheck;\n\n _.forEach(vm.accounts, function(account) {\n\n // Always include the INBOX\n if (!_.includes(unseenCountFolders, account.id + '/folderINBOX'))\n unseenCountFolders.push(account.id + '/folderINBOX');\n\n _.forEach(account.$$flattenMailboxes, function(mailbox) {\n if (angular.isDefined(mailbox.unseenCount) &&\n !_.includes(unseenCountFolders, mailbox.id))\n unseenCountFolders.push(mailbox.id);\n });\n });\n\n Account.$$resource.post('', 'unseenCount', {mailboxes: unseenCountFolders}).then(function(data) {\n _.forEach(vm.accounts, function(account) {\n _.forEach(account.$$flattenMailboxes, function(mailbox) {\n if (data[mailbox.id])\n mailbox.unseenCount = data[mailbox.id];\n });\n });\n });\n\n refreshViewCheck = Preferences.defaults.SOGoRefreshViewCheck;\n if (refreshViewCheck && refreshViewCheck != 'manually')\n $timeout(vm.refreshUnseenCount, refreshViewCheck.timeInterval()*1000);\n };\n\n this.isDroppableFolder = function(srcFolder, dstFolder) {\n return (dstFolder.id != srcFolder.id) && !dstFolder.isNoSelect();\n };\n\n this.dragSelectedMessages = function(srcFolder, dstFolder, mode) {\n var dstId, messages, uids, clearMessageView, promise, success;\n\n dstId = '/' + dstFolder.id;\n messages = srcFolder.$selectedMessages();\n if (messages.length === 0)\n messages = [srcFolder.$selectedMessage()];\n uids = _.map(messages, 'uid');\n clearMessageView = (srcFolder.selectedMessage && uids.indexOf(srcFolder.selectedMessage) >= 0);\n\n if (mode == 'copy') {\n promise = srcFolder.$copyMessages(messages, dstId);\n success = l('%{0} message(s) copied', messages.length);\n }\n else {\n promise = srcFolder.$moveMessages(messages, dstId);\n success = l('%{0} message(s) moved', messages.length);\n }\n\n promise.then(function() {\n if (clearMessageView)\n $state.go('mail.account.mailbox');\n $mdToast.show(\n $mdToast.simple()\n .content(success)\n .position('top right')\n .hideDelay(2000));\n });\n };\n\n }\n\n angular\n .module('SOGo.MailerUI')\n .controller('MailboxesController', MailboxesController);\n})();\n\n","/* -*- Mode: javascript; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n\n(function() {\n 'use strict';\n\n /**\n * @ngInject\n */\n MessageController.$inject = ['$window', '$scope', '$state', '$mdMedia', '$mdDialog', 'sgConstant', 'stateAccounts', 'stateAccount', 'stateMailbox', 'stateMessage', 'sgHotkeys', 'encodeUriFilter', 'sgSettings', 'ImageGallery', 'sgFocus', 'Dialog', 'Preferences', 'Calendar', 'Component', 'Account', 'Mailbox', 'Message'];\n function MessageController($window, $scope, $state, $mdMedia, $mdDialog, sgConstant, stateAccounts, stateAccount, stateMailbox, stateMessage, sgHotkeys, encodeUriFilter, sgSettings, ImageGallery, focus, Dialog, Preferences, Calendar, Component, Account, Mailbox, Message) {\n var vm = this, popupWindow = null, hotkeys = [];\n\n this.$onInit = function() {\n // Expose controller\n $window.$messageController = vm;\n\n // Initialize image gallery service\n ImageGallery.setMessage(stateMessage);\n\n this.$state = $state;\n this.accounts = stateAccounts;\n this.account = stateAccount;\n this.mailbox = stateMailbox;\n this.message = stateMessage;\n this.service = Message;\n this.tags = { searchText: '', selected: '' };\n this.showFlags = stateMessage.flags && stateMessage.flags.length > 0;\n this.$showDetailedRecipients = false;\n\n vm.showRawSource = false;\n\n _registerHotkeys(hotkeys);\n\n // One-way refresh of the parent window when modifying the message from a popup window.\n if ($window.opener) {\n // Update the message flags. The message must be displayed in the parent window.\n $scope.$watchCollection(function() { return vm.message.flags; }, function(newTags, oldTags) {\n var ctrls;\n if (newTags || oldTags) {\n ctrls = $parentControllers();\n if (ctrls.messageCtrl) {\n ctrls.messageCtrl.service.$timeout(function() {\n ctrls.messageCtrl.showFlags = true;\n ctrls.messageCtrl.message.flags = newTags;\n });\n }\n }\n });\n // Update the \"isflagged\" (star icon) of the message. The mailbox must be displayed in the parent window.\n $scope.$watch(function() { return vm.message.isflagged; }, function(isflagged, wasflagged) {\n var ctrls = $parentControllers();\n if (ctrls.mailboxCtrl) {\n ctrls.mailboxCtrl.service.$timeout(function() {\n var message = _.find(ctrls.mailboxCtrl.selectedFolder.$messages, { uid: vm.message.uid });\n message.isflagged = isflagged;\n });\n }\n });\n }\n else {\n // Flatten new tags when coming from the predefined list of tags (Message.$tags) and\n // sync tags with server when adding or removing a tag.\n $scope.$watchCollection(function() { return vm.message.flags; }, function(_newTags, _oldTags) {\n var newTags, oldTags, tags;\n if (_newTags || _oldTags) {\n newTags = _newTags || [];\n oldTags = _oldTags || [];\n _.forEach(newTags, function(tag, i) {\n if (angular.isObject(tag))\n newTags[i] = tag.name;\n });\n if (newTags.length > oldTags.length) {\n tags = _.difference(newTags, oldTags);\n _.forEach(tags, function(tag) {\n vm.message.addTag(tag);\n });\n }\n else if (newTags.length < oldTags.length) {\n tags = _.difference(oldTags, newTags);\n _.forEach(tags, function(tag) {\n vm.message.removeTag(tag);\n });\n }\n }\n });\n }\n\n $scope.$on('$destroy', function() {\n // Deregister hotkeys\n _.forEach(hotkeys, function(key) {\n sgHotkeys.deregisterHotkey(key);\n });\n });\n\n }; // $onInit\n\n\n /**\n * To keep track of the currently active dialog, we share a common variable with the parent controller.\n */\n function _messageDialog() {\n if ($scope.mailbox) {\n if (arguments.length > 0)\n $scope.mailbox.messageDialog = arguments[0];\n return $scope.mailbox.messageDialog;\n }\n return null;\n }\n\n function _unlessInDialog(callback) {\n return function() {\n // Check if a dialog is opened either from the current controller or the parent controller\n if (_messageDialog() === null)\n return callback.apply(vm, arguments);\n };\n }\n\n function _registerHotkeys(keys) {\n keys.push(sgHotkeys.createHotkey({\n key: l('hotkey_reply'),\n description: l('Reply to the message'),\n callback: _unlessInDialog(angular.bind(vm, vm.reply))\n }));\n keys.push(sgHotkeys.createHotkey({\n key: l('hotkey_replyall'),\n description: l('Reply to sender and all recipients'),\n callback: _unlessInDialog(angular.bind(vm, vm.replyAll))\n }));\n keys.push(sgHotkeys.createHotkey({\n key: l('hotkey_forward'),\n description: l('Forward selected message'),\n callback: _unlessInDialog(angular.bind(vm, vm.forward))\n }));\n keys.push(sgHotkeys.createHotkey({\n key: l('hotkey_flag'),\n description: l('Flagged'),\n callback: _unlessInDialog(angular.bind(stateMessage, stateMessage.toggleFlag))\n }));\n _.forEach(['backspace', 'delete'], function(hotkey) {\n keys.push(sgHotkeys.createHotkey({\n key: hotkey,\n callback: _unlessInDialog(function($event) {\n if (vm.mailbox.$selectedCount() === 0)\n vm.deleteMessage();\n $event.preventDefault();\n }),\n }));\n });\n\n // Register the hotkeys\n _.forEach(keys, function(key) {\n sgHotkeys.registerHotkey(key);\n });\n }\n\n /**\n * If this is a popup window, retrieve the matching controllers (mailbox and message) of the parent window.\n */\n function $parentControllers() {\n var message, mailbox, ctrls = {};\n if ($window.opener) {\n // Deleting the message from a popup window\n if ($window.opener.$mailboxController &&\n $window.opener.$mailboxController.selectedFolder.$id() == stateMailbox.$id()) {\n // The message mailbox is opened in the parent window\n mailbox = $window.opener.$mailboxController;\n ctrls.mailboxCtrl = mailbox;\n if ($window.opener.$messageController &&\n $window.opener.$messageController.message.uid == stateMessage.uid) {\n // The message is opened in the parent window\n message = $window.opener.$messageController;\n ctrls.messageCtrl = message;\n }\n }\n }\n return ctrls;\n }\n\n this.addFlags = function($event) {\n this.showFlags = true;\n focus(\"flags\");\n };\n\n this.toggleDetailedRecipients = function($event) {\n this.$showDetailedRecipients = !this.$showDetailedRecipients;\n $event.stopPropagation();\n $event.preventDefault();\n };\n\n this.filterMailtoLinks = function($event) {\n var href, match, to, cc, bcc, subject, body, data;\n if ($event.target.tagName == 'A' && 'href' in $event.target.attributes) {\n href = $event.target.attributes.href.value;\n match = /^mailto:([^\\?]+)/.exec(href);\n if (match) {\n delete $event.target.attributes.target;\n this.newMessage($event, href); // will stop event propagation\n }\n }\n };\n\n this.deleteMessage = function() {\n var mailbox, message, state, nextMessage, previousMessage,\n parentCtrls = $parentControllers();\n\n if (parentCtrls.messageCtrl) {\n mailbox = parentCtrls.mailboxCtrl.selectedFolder;\n message = parentCtrls.messageCtrl.message;\n state = parentCtrls.messageCtrl.$state;\n }\n else {\n mailbox = stateMailbox;\n message = stateMessage;\n state = $state;\n }\n\n mailbox.$deleteMessages([message]).then(function(index) {\n var nextIndex = index;\n // Remove message object from scope\n message = null;\n if (angular.isDefined(state)) {\n // Select either the next or previous message\n if (index > 0) {\n nextIndex -= 1;\n nextMessage = mailbox.$messages[nextIndex];\n }\n if (index < mailbox.$messages.length)\n previousMessage = mailbox.$messages[index];\n\n if (nextMessage) {\n if (nextMessage.isread && previousMessage && !previousMessage.isread) {\n nextIndex = index;\n nextMessage = previousMessage;\n }\n }\n else if (previousMessage) {\n nextIndex = index;\n nextMessage = previousMessage;\n }\n\n try {\n if (nextMessage && $mdMedia(sgConstant['gt-md'])) {\n state.go('mail.account.mailbox.message', { messageId: nextMessage.uid });\n if (nextIndex < mailbox.$topIndex)\n mailbox.$topIndex = nextIndex;\n else if (nextIndex > mailbox.$lastVisibleIndex)\n mailbox.$topIndex = nextIndex - (mailbox.$lastVisibleIndex - mailbox.$topIndex);\n }\n else {\n state.go('mail.account.mailbox').then(function() {\n message = null;\n delete mailbox.selectedMessage;\n });\n }\n }\n catch (error) {}\n }\n vm.closePopup();\n });\n };\n\n function _showMailEditor($event, message) {\n if (_messageDialog() === null) {\n _messageDialog(\n $mdDialog\n .show({\n parent: angular.element(document.body),\n targetEvent: $event,\n clickOutsideToClose: false,\n escapeToClose: false,\n templateUrl: 'UIxMailEditor',\n controller: 'MessageEditorController',\n controllerAs: 'editor',\n locals: {\n stateAccount: vm.account,\n stateMessage: message\n }\n })\n .catch(_.noop) // Cancel\n .finally(function() {\n _messageDialog(null);\n vm.closePopup();\n })\n );\n }\n }\n\n this._showMailEditorInPopup = function(action) {\n if (!sgSettings.isPopup &&\n Preferences.defaults.SOGoMailComposeWindow == 'popup') {\n this.openInPopup(action);\n return true;\n }\n return false;\n };\n\n this.close = function() {\n $state.go('mail.account.mailbox').then(function() {\n vm.message = null;\n delete stateMailbox.selectedMessage;\n });\n };\n\n this.reply = function($event) {\n if (!this._showMailEditorInPopup('reply')) {\n _showMailEditor($event, this.message.$reply());\n }\n };\n\n this.replyAll = function($event) {\n if (!this._showMailEditorInPopup('replyall')) {\n _showMailEditor($event, this.message.$replyAll());\n }\n };\n\n this.forward = function($event) {\n if (!this._showMailEditorInPopup('forward')) {\n _showMailEditor($event, this.message.$forward());\n }\n };\n\n this.edit = function($event) {\n if (!this._showMailEditorInPopup('edit')) {\n this.message.$editableContent().then(function() {\n _showMailEditor($event, vm.message);\n });\n }\n };\n\n this.openInPopup = function(action) {\n var url = [sgSettings.baseURL(),\n 'UIxMailPopupView#!/Mail',\n this.message.accountId,\n // The double-encoding is necessary\n encodeUriFilter(encodeUriFilter(this.message.$mailbox.path)),\n this.message.uid]\n .join('/'),\n wId = this.message.$absolutePath();\n if (action) url += '/' + action;\n popupWindow = $window.open(url, wId,\n [\"width=680\",\n \"height=520\",\n \"resizable=1\",\n \"scrollbars=1\",\n \"toolbar=0\",\n \"location=0\",\n \"directories=0\",\n \"status=0\",\n \"menubar=0\",\n \"copyhistory=0\"]\n .join(','));\n };\n\n this.closePopup = function() {\n if ($window.document.body.classList.contains('popup'))\n $window.close();\n };\n\n this.newMessage = function($event, mailto) {\n $event.stopPropagation();\n $event.preventDefault();\n this.account.$newMessage({ mailto: mailto }).then(function(message) {\n _showMailEditor($event, message);\n });\n };\n\n this.toggleRawSource = function($event) {\n if (!this.showRawSource && !this.message.$rawSource) {\n Message.$$resource.post(this.message.id, \"viewsource\").then(function(data) {\n vm.message.$rawSource = data;\n vm.showRawSource = true;\n });\n }\n else {\n this.showRawSource = !this.showRawSource;\n }\n };\n\n this.print = function($event) {\n $window.print();\n };\n\n this.convertToEvent = function($event) {\n return _convertToComponent($event, 'appointment');\n };\n\n this.convertToTask = function($event) {\n return _convertToComponent($event, 'task');\n };\n\n function _convertToComponent($event, type) {\n vm.message.$plainContent().then(function(data) {\n var componentData = {\n pid: Calendar.$defaultCalendar(),\n type: type,\n summary: data.subject,\n comment: data.content\n };\n var component = new Component(componentData);\n // UI/Templates/SchedulerUI/UIxAppointmentEditorTemplate.wox or\n // UI/Templates/SchedulerUI/UIxTaskEditorTemplate.wox\n var templateUrl = [\n sgSettings.activeUser('folderURL'),\n 'Calendar',\n 'UIx' + type.capitalize() + 'EditorTemplate'\n ].join('/');\n return $mdDialog.show({\n parent: angular.element(document.body),\n targetEvent: $event,\n clickOutsideToClose: true,\n escapeToClose: true,\n templateUrl: templateUrl,\n controller: 'ComponentEditorController',\n controllerAs: 'editor',\n locals: {\n stateComponent: component\n }\n });\n });\n }\n }\n\n angular\n .module('SOGo.MailerUI')\n .controller('MessageController', MessageController);\n})();\n","/* -*- Mode: javascript; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n\n(function() {\n 'use strict';\n\n /**\n * @ngInject\n */\n MessageEditorController.$inject = ['$scope', '$window', '$stateParams', '$mdConstant', '$mdUtil', '$mdDialog', '$mdToast', 'FileUploader', 'stateAccount', 'stateMessage', 'encodeUriFilter', '$timeout', 'Dialog', 'AddressBook', 'Card', 'Preferences'];\n function MessageEditorController($scope, $window, $stateParams, $mdConstant, $mdUtil, $mdDialog, $mdToast, FileUploader, stateAccount, stateMessage, encodeUriFilter, $timeout, Dialog, AddressBook, Card, Preferences) {\n var vm = this;\n\n this.$onInit = function() {\n vm.addRecipient = addRecipient;\n vm.autocomplete = {to: {}, cc: {}, bcc: {}};\n vm.autosave = null;\n vm.autosaveDrafts = autosaveDrafts;\n vm.cancel = cancel;\n vm.contactFilter = contactFilter;\n vm.isFullscreen = false;\n vm.hideBcc = (stateMessage.editable.bcc.length === 0);\n vm.hideCc = (stateMessage.editable.cc.length === 0);\n vm.identities = _.uniq(_.map(stateAccount.identities, 'full'));\n vm.message = stateMessage;\n vm.recipientSeparatorKeys = [\n $mdConstant.KEY_CODE.ENTER,\n $mdConstant.KEY_CODE.TAB,\n $mdConstant.KEY_CODE.COMMA,\n $mdConstant.KEY_CODE.SEMICOLON\n ];\n vm.removeAttachment = removeAttachment;\n vm.save = save;\n vm.send = send;\n vm.sendState = false;\n vm.toggleFullscreen = toggleFullscreen;\n\n _initFileUploader();\n\n // Read user's defaults\n if (Preferences.defaults.SOGoMailAutoSave)\n // Enable auto-save of draft\n vm.autosave = $timeout(vm.autosaveDrafts, Preferences.defaults.SOGoMailAutoSave*1000*60);\n // Set the locale of CKEditor\n vm.localeCode = Preferences.defaults.LocaleCode;\n\n // Destroy file uploader when the controller is being deactivated\n $scope.$on('$destroy', function() { vm.uploader.destroy(); });\n\n if ($stateParams.actionName == 'reply') {\n stateMessage.$reply().then(function(msgObject) {\n vm.message = msgObject;\n vm.hideCc = (!msgObject.editable.cc || msgObject.editable.cc.length === 0);\n vm.hideBcc = (!msgObject.editable.bcc || msgObject.editable.bcc.length === 0);\n _updateFileUploader();\n });\n }\n else if ($stateParams.actionName == 'replyall') {\n stateMessage.$replyAll().then(function(msgObject) {\n vm.message = msgObject;\n vm.hideCc = (!msgObject.editable.cc || msgObject.editable.cc.length === 0);\n vm.hideBcc = (!msgObject.editable.bcc || msgObject.editable.bcc.length === 0);\n _updateFileUploader();\n });\n }\n else if ($stateParams.actionName == 'forward') {\n stateMessage.$forward().then(function(msgObject) {\n vm.message = msgObject;\n _updateFileUploader();\n _addAttachments();\n });\n }\n else if (angular.isDefined(stateMessage)) {\n vm.message = stateMessage;\n _updateFileUploader();\n _addAttachments();\n }\n };\n\n /**\n * If this is a popup window, retrieve the mailbox controller of the parent window.\n */\n function $parentControllers() {\n var originMessage, ctrls = {};\n\n try {\n if ($window.opener) {\n if ('$mailboxController' in $window.opener &&\n 'selectedFolder' in $window.opener.$mailboxController) {\n if ($window.opener.$mailboxController.selectedFolder.type == 'draft') {\n ctrls.draftMailboxCtrl = $window.opener.$mailboxController;\n if ('$messageController' in $window.opener &&\n $window.opener.$messageController.message.uid == stateMessage.uid) {\n // The draft is opened in the parent window\n ctrls.draftMessageCtrl = $window.opener.$messageController;\n }\n }\n else if (stateMessage.origin) {\n originMessage = stateMessage.origin.message;\n if ($window.opener.$mailboxController.selectedFolder.$id() == originMessage.$mailbox.$id()) {\n // The message mailbox is opened in the parent window\n ctrls.originMailboxCtrl = $window.opener.$mailboxController;\n }\n }\n }\n }\n }\n catch (e) {}\n\n return ctrls;\n }\n\n function _initFileUploader() {\n vm.uploader = new FileUploader({\n url: vm.message.$absolutePath({asDraft: true, withResourcePath: true}) + '/save',\n autoUpload: true,\n alias: 'attachments',\n removeAfterUpload: false,\n // onProgressItem: function(item, progress) {\n // console.debug(item); console.debug(progress);\n // },\n onSuccessItem: function(item, response, status, headers) {\n vm.message.$setUID(response.uid);\n vm.message.$reload({asDraft: false});\n item.inlineUrl = response.lastAttachmentAttrs[0].url;\n //console.debug(item); console.debug('success = ' + JSON.stringify(response, undefined, 2));\n },\n onCancelItem: function(item, response, status, headers) {\n //console.debug(item); console.debug('cancel = ' + JSON.stringify(response, undefined, 2));\n // We remove the attachment\n vm.message.$deleteAttachment(item.file.name);\n this.removeFromQueue(item);\n },\n onErrorItem: function(item, response, status, headers) {\n $mdToast.show(\n $mdToast.simple()\n .content(l('Error while uploading the file \\\"%{0}\\\":', item.file.name) +\n ' ' + (response.message? l(response.message) : ''))\n .position('top right')\n .action(l('OK'))\n .hideDelay(false));\n this.removeFromQueue(item);\n //console.debug(item); console.debug('error = ' + JSON.stringify(response, undefined, 2));\n }\n });\n }\n\n function _updateFileUploader() {\n vm.uploader.url = vm.message.$absolutePath({asDraft: true, withResourcePath: true}) + '/save';\n }\n\n function _addAttachments() {\n // Add existing attached files to uploader\n var i, data, fileItem, attrs = vm.message.editable.attachmentAttrs;\n if (attrs)\n for (i = 0; i < attrs.length; i++) {\n data = {\n name: attrs[i].filename,\n type: attrs[i].mimetype,\n size: parseInt(attrs[i].size)\n };\n fileItem = new FileUploader.FileItem(vm.uploader, data);\n fileItem.progress = 100;\n fileItem.isUploaded = true;\n fileItem.isSuccess = true;\n fileItem.inlineUrl = attrs[i].url;\n vm.uploader.queue.push(fileItem);\n }\n }\n\n function removeAttachment(item, id) {\n if (item.isUploading)\n vm.uploader.cancelItem(item);\n else {\n vm.message.$deleteAttachment(item.file.name);\n item.remove();\n }\n // Hack to allow adding the same file again\n // See https://github.com/nervgh/angular-file-upload/issues/671\n var element = $window.document.getElementById(id);\n if (element)\n angular.element(element).prop('value', null);\n }\n\n function cancel() {\n if (vm.autosave)\n $timeout.cancel(vm.autosave);\n\n if (vm.message.isNew && vm.message.attachmentAttrs)\n vm.message.$mailbox.$deleteMessages([vm.message]);\n\n $mdDialog.cancel();\n }\n\n function save() {\n var ctrls = $parentControllers();\n vm.message.$save().then(function(data) {\n vm.message.$rawSource = null;\n if (ctrls.draftMailboxCtrl) {\n // We're saving a draft from a popup window.\n // Reload draft mailbox\n ctrls.draftMailboxCtrl.selectedFolder.$filter().then(function() {\n if (ctrls.draftMessageCtrl) {\n // Reload selected message\n ctrls.draftMessageCtrl.$state.go('mail.account.mailbox.message', { messageId: vm.message.uid });\n }\n });\n }\n $mdToast.show(\n $mdToast.simple()\n .content(l('Your email has been saved'))\n .position('top right')\n .hideDelay(3000));\n });\n }\n\n function send() {\n vm.sendState = 'sending';\n if (vm.autosave)\n $timeout.cancel(vm.autosave);\n\n vm.message.$send().then(function(data) {\n var ctrls = $parentControllers();\n vm.sendState = 'sent';\n if (ctrls.draftMailboxCtrl) {\n // We're sending a draft from a popup window and the draft mailbox is opened.\n // Reload draft mailbox\n ctrls.draftMailboxCtrl.selectedFolder.$filter().then(function() {\n if (ctrls.draftMessageCtrl) {\n // Close draft\n ctrls.draftMessageCtrl.close();\n }\n });\n }\n if (ctrls.originMailboxCtrl) {\n // We're sending a draft from a popup window and the original mailbox is opened.\n // Reload mailbox\n ctrls.originMailboxCtrl.selectedFolder.$filter();\n }\n $mdToast.show(\n $mdToast.simple()\n .content(l('Your email has been sent'))\n .position('top right')\n .hideDelay(3000));\n\n // Let the user see the succesfull message before closing the dialog\n $timeout($mdDialog.hide, 1000);\n }, function(response) {\n $timeout(function() {\n vm.sendState = 'error';\n vm.errorMessage = response.data? response.data.message : response.statusText;\n });\n });\n }\n\n function toggleFullscreen() {\n vm.isFullscreen = !vm.isFullscreen;\n }\n\n function contactFilter($query) {\n return AddressBook.$filterAll($query).then(function(cards) {\n // Divide the matching cards by email addresses so the user can select\n // the recipient address of her choice\n var explodedCards = [];\n _.forEach(_.invokeMap(cards, 'explode'), function(manyCards) {\n _.forEach(manyCards, function(card) {\n explodedCards.push(card);\n });\n });\n // Remove duplicates\n return _.uniqBy(explodedCards, function(card) {\n return card.$$fullname + ' ' + card.$$email;\n });\n });\n }\n\n function addRecipient(contact, field) {\n var recipients, recipient, list, i, address;\n var emailRE = /([\\w\\!\\#$\\%\\&\\'\\*\\+\\-\\/\\=\\?\\^\\`{\\|\\}\\~]+\\.)*[\\w\\!\\#$\\%\\&\\'\\*\\+\\-\\/\\=\\?\\^\\`{\\|\\}\\~]+@((((([a-z0-9]{1}[a-z0-9\\-]{0,62}[a-z0-9]{1})|[a-z])\\.)+[a-z]{2,})|(\\d{1,3}\\.){3}\\d{1,3}(\\:\\d{1,5})?)/i;\n\n recipients = vm.message.editable[field];\n\n if (angular.isString(contact)) {\n // Examples that are handled:\n // Smith, John <john@smith.com>\n // <john@appleseed.com>;<foo@bar.com>\n // foo@bar.com abc@xyz.com\n address = '';\n for (i = 0; i < contact.length; i++) {\n if ((contact.charCodeAt(i) == 9 || // tab\n contact.charCodeAt(i) == 32 || // space\n contact.charCodeAt(i) == 44 || // ,\n contact.charCodeAt(i) == 59) && // ;\n emailRE.test(address)) {\n recipients.push(address);\n address = '';\n }\n else {\n address += contact.charAt(i);\n }\n }\n if (address)\n recipients.push(address);\n return null;\n }\n\n if (contact.$isList({expandable: true})) {\n // If the list's members were already fetch, use them\n if (angular.isDefined(contact.refs) && contact.refs.length) {\n _.forEach(contact.refs, function(ref) {\n if (ref.email.length)\n recipients.push(ref.$shortFormat());\n });\n }\n else {\n list = Card.$find(contact.container, contact.c_name);\n list.$id().then(function(listId) {\n _.forEach(list.refs, function(ref) {\n if (ref.email.length)\n recipients.push(ref.$shortFormat());\n });\n });\n }\n }\n else {\n recipient = contact.$shortFormat();\n }\n\n if (recipient)\n return recipient;\n else\n return null;\n }\n\n // Drafts autosaving\n function autosaveDrafts() {\n vm.message.$save();\n if (Preferences.defaults.SOGoMailAutoSave)\n vm.autosave = $timeout(vm.autosaveDrafts, Preferences.defaults.SOGoMailAutoSave*1000*60);\n }\n\n }\n\n SendMessageToastController.$inject = ['$scope', '$mdToast'];\n function SendMessageToastController($scope, $mdToast) {\n $scope.closeToast = function() {\n $mdToast.hide();\n };\n }\n\n angular\n .module('SOGo.MailerUI')\n .controller('SendMessageToastController', SendMessageToastController)\n .controller('MessageEditorController', MessageEditorController);\n\n})();\n","/* -*- Mode: javascript; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n\n(function() {\n\n /**\n * sgAccountSection - A directive that is only a controller to manage the selection of the mailboxes.\n * @memberof SOGo.MailerUI\n */\n function sgAccountSection() {\n return {\n restrict: 'C',\n scope: {},\n controller: 'sgAccountController'\n };\n }\n\n /**\n * @ngInject\n */\n sgAccountController.$inject = ['$element', '$transitions', '$state', '$mdMedia', '$mdSidenav', 'sgConstant', 'Mailbox', 'encodeUriFilter'];\n function sgAccountController($element, $transitions, $state, $mdMedia, $mdSidenav, sgConstant, Mailbox, encodeUriFilter) {\n var $ctrl = this, mailboxes = [];\n\n\n this.$postLink = function () {\n this.quotaElement = _.find($element.find('div'), function(div) {\n return div.classList.contains('sg-quota');\n });\n };\n\n\n // Register a sgMailboxListItem controller\n this.addMailboxController = function (mailboxController) {\n mailboxes.push(mailboxController);\n };\n\n\n // Called from a sgMailboxListItem controller\n this.selectFolder = function (mailboxController) {\n Mailbox.selectedFolderController = mailboxController;\n if (Mailbox.selectedFolder !== null) {\n var selectedMailboxCtrl = _.find(mailboxes, function(ctrl) {\n return ctrl.mailbox.id == Mailbox.selectedFolder.id;\n });\n if (selectedMailboxCtrl)\n selectedMailboxCtrl.unselectFolder();\n }\n // Close sidenav on small devices\n if (!$mdMedia(sgConstant['gt-md']))\n $mdSidenav('left').close();\n };\n\n }\n\n angular\n .module('SOGo.MailerUI')\n .controller('sgAccountController', sgAccountController)\n .directive('sgAccountSection', sgAccountSection);\n})();\n","/* -*- Mode: javascript; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n\n(function() {\n\n /**\n * sgImageGallery - A directive that defines the content of a md-list-item for a mailbox.\n * @memberof SOGo.MailerUI\n */\n function sgImageGallery() {\n return {\n restrict: 'E',\n scope: {},\n bindToController: {\n message: '=sgMessage'\n },\n controller: 'sgImageGalleryController'\n };\n }\n\n /**\n * @ngInject\n */\n sgImageGalleryController.$inject = ['$scope', '$element', '$state', '$mdToast', '$mdPanel', '$mdMedia', '$mdSidenav', 'sgConstant', 'Dialog', 'Mailbox', 'encodeUriFilter'];\n function sgImageGalleryController($scope, $element, $state, $mdToast, $mdPanel, $mdMedia, $mdSidenav, sgConstant, Dialog, Mailbox, encodeUriFilter) {\n var $ctrl = this;\n\n\n this.$onInit = function() {\n };\n\n\n this.$postLink = function() {\n };\n\n\n this.addImage = function(imgSrc) {\n console.warn(imgSrc);\n };\n\n\n this.showGallery = function($event, imgSrc) {\n var panelPosition = $mdPanel.newPanelPosition()\n .relativeTo($event.target)\n .addPanelPosition(\n $mdPanel.xPosition.ALIGN_START,\n $mdPanel.yPosition.ALIGN_TOPS\n );\n\n var panelAnimation = $mdPanel.newPanelAnimation()\n .openFrom($event.target)\n .duration(100)\n .withAnimation($mdPanel.animation.FADE);\n\n var config = {\n attachTo: angular.element(document.body),\n locals: {\n message: this.message\n },\n bindToController: true,\n controller: PanelController,\n controllerAs: '$panelCtrl',\n position: panelPosition,\n animation: panelAnimation,\n targetEvent: $event,\n fullscreen: true,\n template: [\n '<div class=\"sg-image-gallery\" layout=\"column\" layout-fill=\"layout-fill\">',\n ' <div layout=\"row\">',\n ' <></>',\n 'foobar',\n '</div>'\n ].join(''),\n trapFocus: true,\n clickOutsideToClose: true,\n escapeToClose: true,\n focusOnOpen: true\n };\n\n $mdPanel.open(config)\n .then(function(panelRef) {\n // Automatically close panel when clicking inside of it\n panelRef.panelEl.one('click', function() {\n panelRef.close();\n });\n });\n\n PanelController.$inject = ['mdPanelRef', '$state', '$mdDialog'];\n function PanelController(mdPanelRef, $state, $mdDialog) {\n var $menuCtrl = this;\n\n \n\n } // PanelController\n\n\n };\n }\n\n\n // angular\n // .module('SOGo.MailerUI')\n // .controller('sgImageGalleryController', sgImageGalleryController)\n // .directive('sgImageGallery', sgImageGallery);\n})();\n","/* -*- Mode: javascript; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n\n(function() {\n /* jshint validthis: true */\n 'use strict';\n\n /**\n * sgIMIP - A directive to handle IMIP actions on emails\n * @memberof SOGo.MailerUI\n * @example:\n\n */\n function sgImip() {\n return {\n restrict: 'A',\n link: link,\n controller: 'sgImipController'\n };\n\n function link(scope, iElement, attrs, ctrl) {\n ctrl.pathToAttachment = attrs.sgImipPath;\n }\n }\n\n /**\n * @ngInject\n */\n sgImipController.$inject = ['$scope', 'User'];\n function sgImipController($scope, User) {\n var vm = this;\n\n $scope.delegateInvitation = false;\n $scope.delegatedTo = '';\n $scope.searchText = '';\n\n $scope.userFilter = function($query) {\n return User.$filter($query);\n };\n\n $scope.iCalendarAction = function(action) {\n var data;\n\n if (action == 'delegate') {\n data = {\n receiveUpdates: false,\n delegatedTo: $scope.delegatedTo.c_email\n };\n }\n\n $scope.viewer.message.$imipAction(vm.pathToAttachment, action, data);\n };\n }\n\n angular\n .module('SOGo.MailerUI')\n .controller('sgImipController', sgImipController)\n .directive('sgImip', sgImip);\n})();\n\n","/* -*- Mode: javascript; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n\n(function() {\n\n /**\n * sgMailboxListItem - A directive that defines the content of a md-list-item for a mailbox.\n * @memberof SOGo.MailerUI\n */\n function sgMailboxListItem() {\n return {\n restrict: 'C',\n require: {\n accountController: '^^sgAccountSection'\n },\n scope: {},\n bindToController: {\n mailbox: '=sgMailbox'\n },\n template: [\n ' <div class=\"sg-child-level-0\"',\n ' ng-class=\"$ctrl.childLevel()\">',\n ' <md-checkbox class=\"sg-folder\"',\n ' ng-class=\"$ctrl.mailbox.$icon\"',\n ' aria-label=\"' + l(\"Expanded\") + '\"',\n ' ng-model=\"$ctrl.mailbox.$expanded\"',\n ' ng-disabled=\"$ctrl.mailbox.children.length == 0\"',\n ' ng-change=\"$ctrl.mailbox.$account.$flattenMailboxes({ reload: true, saveState: true })\">',\n ' <md-icon>{{$ctrl.mailbox.$icon}}</md-icon></md-checkbox>',\n ' </div>',\n ' <p class=\"sg-item-name\"',\n ' ng-click=\"$ctrl.selectFolder($event)\"',\n ' ng-dblclick=\"$ctrl.editFolder($event)\">',\n ' <span ng-bind=\"$ctrl.mailbox.$displayName\"></span>',\n ' <span class=\"sg-counter-badge ng-hide\"',\n ' ng-show=\"$ctrl.mailbox.unseenCount\"',\n ' ng-bind=\"$ctrl.mailbox.unseenCount\"></span>',\n ' </p>',\n ' <md-input-container class=\"md-flex ng-hide\">',\n ' <input class=\"sg-item-name\" type=\"text\"',\n ' aria-label=\"' + l(\"Enter the new name of your folder\") + '\"',\n ' ng-blur=\"$ctrl.saveFolder($event)\"',\n ' sg-enter=\"$ctrl.saveFolder($event)\"',\n ' sg-escape=\"$ctrl.revertEditing()\" />',\n ' </md-input-container>',\n ' <md-icon class=\"md-menu\" ng-click=\"$ctrl.showMenu($event)\" aria-label=\"' + l(\"Options\") + '\">more_vert</md-icon>'\n ].join(''),\n controller: 'sgMailboxListItemController',\n controllerAs: '$ctrl'\n };\n }\n\n /**\n * @ngInject\n */\n sgMailboxListItemController.$inject = ['$scope', '$element', '$state', '$mdToast', '$mdPanel', '$mdMedia', '$mdSidenav', 'sgConstant', 'Dialog', 'Mailbox', 'encodeUriFilter'];\n function sgMailboxListItemController($scope, $element, $state, $mdToast, $mdPanel, $mdMedia, $mdSidenav, sgConstant, Dialog, Mailbox, encodeUriFilter) {\n var $ctrl = this;\n\n\n this.$onInit = function() {\n this.$element = $element;\n this.editMode = false;\n this.accountController.addMailboxController(this);\n };\n\n\n this.$postLink = function() {\n this.selectableElement = $element.find('div')[0];\n this.clickableElement = $element.find('p')[0];\n this.inputContainer = $element.find('md-input-container')[0];\n this.inputElement = $element.find('input')[0];\n this.moreOptionsButton = _.last($element.find('md-icon'));\n\n // Check if router's state has selected a mailbox\n if (Mailbox.selectedFolder !== null && Mailbox.selectedFolder.id == this.mailbox.id) {\n this.accountController.selectFolder(this);\n }\n };\n\n this.childLevel = function() {\n return 'sg-child-level-' + this.mailbox.level;\n };\n\n\n this.selectFolder = function($event) {\n if (this.editMode || this.mailbox == Mailbox.selectedFolder || this.mailbox.isNoSelect())\n return;\n Mailbox.$virtualPath = false;\n Mailbox.$virtualMode = false;\n this.accountController.selectFolder(this);\n if ($event) {\n $state.go('mail.account.mailbox', {\n accountId: this.mailbox.$account.id,\n mailboxId: encodeUriFilter(this.mailbox.path)\n });\n $event.stopPropagation();\n $event.preventDefault();\n }\n };\n\n\n this.unselectFolder = function() {\n $element[0].classList.remove('md-bg');\n };\n\n\n this.editFolder = function($event) {\n this.editMode = true;\n this.inputElement.value = this.mailbox.name;\n this.clickableElement.classList.add('ng-hide');\n this.inputContainer.classList.remove('ng-hide');\n this.inputElement.focus();\n this.inputElement.select();\n if ($event) {\n $event.stopPropagation();\n $event.preventDefault();\n }\n };\n\n\n this.saveFolder = function($event) {\n if (this.inputElement.disabled)\n return;\n\n this.mailbox.name = this.inputElement.value;\n this.inputElement.disabled = true;\n this.mailbox.$rename()\n .then(function(data) {\n $ctrl.editMode = false;\n $ctrl.inputContainer.classList.add('ng-hide');\n $ctrl.clickableElement.classList.remove('ng-hide');\n })\n .finally(function() {\n $ctrl.inputElement.disabled = false;\n });\n };\n\n\n this.revertEditing = function() {\n this.editMode = false;\n this.clickableElement.classList.remove('ng-hide');\n this.inputContainer.classList.add('ng-hide');\n this.inputElement.value = this.mailbox.name;\n };\n\n\n this.confirmDelete = function() {\n Dialog.confirm(l('Warning'),\n l('Do you really want to move this folder into the trash ?'),\n { ok: l('Delete') })\n .then(function() {\n $ctrl.mailbox.$delete()\n .then(function() {\n $state.go('mail.account.inbox');\n }, function(response) {\n Dialog.confirm(l('Warning'),\n l('The mailbox could not be moved to the trash folder. Would you like to delete it immediately?'),\n { ok: l('Delete') })\n .then(function() {\n $ctrl.mailbox.$delete({ withoutTrash: true })\n .then(function() {\n $state.go('mail.account.inbox');\n }, function(response) {\n Dialog.alert(l('An error occured while deleting the mailbox \"%{0}\".', $ctrl.mailbox.name),\n l(response.error));\n });\n });\n });\n });\n };\n\n\n this.showMenu = function($event) {\n var panelPosition = $mdPanel.newPanelPosition()\n .relativeTo(this.moreOptionsButton)\n .addPanelPosition(\n $mdPanel.xPosition.ALIGN_START,\n $mdPanel.yPosition.ALIGN_TOPS\n );\n\n var panelAnimation = $mdPanel.newPanelAnimation()\n .openFrom(this.moreOptionsButton)\n .duration(100)\n .withAnimation($mdPanel.animation.FADE);\n\n var config = {\n attachTo: angular.element(document.body),\n locals: {\n itemCtrl: this,\n folder: this.mailbox,\n confirmDelete: this.confirmDelete\n },\n bindToController: true,\n controller: MenuController,\n controllerAs: '$menuCtrl',\n position: panelPosition,\n animation: panelAnimation,\n targetEvent: $event,\n templateUrl: 'UIxMailFolderMenu',\n trapFocus: true,\n clickOutsideToClose: true,\n escapeToClose: true,\n focusOnOpen: true\n };\n\n $mdPanel.open(config)\n .then(function(panelRef) {\n // Automatically close panel when clicking inside of it\n panelRef.panelEl.one('click', function() {\n panelRef.close();\n });\n });\n\n MenuController.$inject = ['mdPanelRef', '$state', '$mdDialog', 'User'];\n function MenuController(mdPanelRef, $state, $mdDialog, User) {\n var $menuCtrl = this;\n\n this.markFolderRead = function() {\n this.folder.$markAsRead();\n };\n\n this.newFolder = function() {\n Dialog.prompt(l('New Folder...'),\n l('Enter the new name of your folder'))\n .then(function(name) {\n $menuCtrl.folder.$newMailbox($menuCtrl.folder.id, name)\n .then(function() {\n // success\n }, function(data, status) {\n Dialog.alert(l('An error occured while creating the mailbox \"%{0}\".', name),\n l(data.error));\n });\n });\n };\n\n this.editFolder = function() {\n this.itemCtrl.editFolder();\n };\n\n this.compactFolder = function() {\n this.folder.$compact().then(function() {\n $mdToast.show(\n $mdToast.simple()\n .content(l('Folder compacted'))\n .position('top right')\n .hideDelay(3000));\n });\n };\n\n this.emptyTrashFolder = function() {\n this.folder.$emptyTrash().then(function() {\n $mdToast.show(\n $mdToast.simple()\n .content(l('Trash emptied'))\n .position('top right')\n .hideDelay(3000));\n });\n };\n\n this.showAdvancedSearch = function() {\n Mailbox.$virtualPath = this.folder.path;\n // Close sidenav on small devices\n if (!$mdMedia(sgConstant['gt-md']))\n $mdSidenav('left').close();\n };\n\n this.share = function() {\n // Fetch list of ACL users\n this.folder.$acl.$users().then(function() {\n // Show ACL editor\n $mdDialog.show({\n templateUrl: $menuCtrl.folder.id + '/UIxAclEditor', // UI/Templates/UIxAclEditor.wox\n controller: 'AclController', // from the ng module SOGo.Common\n controllerAs: 'acl',\n clickOutsideToClose: true,\n escapeToClose: true,\n locals: {\n usersWithACL: $menuCtrl.folder.$acl.users,\n User: User,\n folder: $menuCtrl.folder\n }\n });\n });\n };\n\n this.setFolderAs = function(type) {\n this.folder.$setFolderAs(type).then(function() {\n $menuCtrl.folder.$account.$getMailboxes({reload: true});\n });\n };\n\n } // MenuController\n\n\n };\n }\n\n\n angular\n .module('SOGo.MailerUI')\n .controller('sgMailboxListItemController', sgMailboxListItemController)\n .directive('sgMailboxListItem', sgMailboxListItem);\n})();\n","/* -*- Mode: javascript; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n\n(function() {\n\n /**\n * sgMessageListItem - A directive that watches some attributes of a message. Any component inside the\n * list item should depends on this directive and extend the 'onUpdate' method instead of creating new\n * independent watchers.\n * @memberof SOGo.MailerUI\n */\n function sgMessageListItem() {\n return {\n restrict: 'C',\n scope: {},\n bindToController: {\n message: '=sgMessage'\n },\n controller: 'sgMessageListItemController'\n };\n }\n\n /**\n * @ngInject\n */\n sgMessageListItemController.$inject = ['$scope', '$element', 'Mailbox'];\n function sgMessageListItemController($scope, $element, Mailbox) {\n var $ctrl = this;\n\n\n this.$onInit = function () {\n var watchedAttrs = ['uid', 'isread', 'isflagged', 'flags', 'subject'];\n\n // this.service = Message;\n this.MailboxService = Mailbox;\n\n if (Mailbox.selectedFolder.type == 'draft')\n watchedAttrs.push('subject');\n\n $scope.$watch(\n function() {\n return $ctrl.message? [ _.pick($ctrl.message, watchedAttrs) ] : null;\n },\n function(newId, oldId) {\n if ($ctrl.message) {\n // Message has changed\n $ctrl.onUpdate();\n }\n },\n true // compare for object equality\n );\n };\n\n\n this.onUpdate = function () {\n // Is the message unread?\n if (this.message.isread)\n $element.removeClass('unread');\n else\n $element.addClass('unread');\n // Is the message selected?\n if (Mailbox.selectedFolder.isSelectedMessage(this.message.uid, this.message.$mailbox.path))\n $element.addClass('md-default-theme md-accent md-bg md-hue-2');\n else\n $element.removeClass('md-default-theme md-accent md-bg md-hue-2');\n };\n\n\n this.setVisibility = function (element, visible) {\n if (visible)\n element.classList.remove('ng-hide');\n else\n element.classList.add('ng-hide');\n };\n\n }\n\n\n angular\n .module('SOGo.MailerUI')\n .controller('sgMessageListItemController', sgMessageListItemController)\n .directive('sgMessageListItem', sgMessageListItem);\n})();\n","/* -*- Mode: javascript; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n\n(function() {\n\n /**\n * sgMessageListItemMain - The main section of a list item for a message. It relies on the\n * 'onUpdate' method of the parent sgMessageListItem controller to update its content.\n * @memberof SOGo.MailerUI\n * @example:\n */\n function sgMessageListItemMain() {\n return {\n restrict: 'C',\n require: '^^sgMessageListItem',\n scope: {},\n template: [\n '<div class=\"sg-tile-content\">',\n ' <div class=\"sg-md-subhead\">',\n ' <div>',\n ' <span class=\"sg-label-outline ng-hide\"><!-- mailbox --></span>',\n ' <md-icon class=\"ng-hide\">error</md-icon>', // the priority icon\n ' <span><!-- sender or recipient --></span>',\n ' </div>',\n ' <div class=\"sg-tile-date\"><!-- date --></div>',\n ' </div>',\n ' <div class=\"sg-md-body\">',\n ' <div class=\"sg-tile-subject\"><!-- subject --></div>',\n ' <div class=\"sg-tile-size\"><!-- size --></div>',\n ' </div>',\n '</div>',\n '<div class=\"sg-tile-icons\">',\n ' <md-icon class=\"ng-hide\">star</md-icon>',\n ' <md-icon class=\"ng-hide\">reply</md-icon>',\n ' <md-icon class=\"ng-hide\">forward</md-icon>',\n ' <md-icon class=\"ng-hide\">attach_file</md-icon>',\n '</div>',\n '<div class=\"sg-progress-linear-bottom\">',\n ' <md-progress-linear class=\"md-accent\"',\n ' md-mode=\"indeterminate\"',\n ' ng-disabled=\"!$ctrl.message.$isLoading()\"><!-- message loading progress --></md-progress-linear>',\n '</div>'\n ].join(''),\n link: postLink,\n controller: 'sgMessageListItemMainController',\n controllerAs: '$ctrl'\n };\n\n function postLink(scope, element, attrs, parentController) {\n scope.parentController = parentController;\n }\n\n }\n\n /**\n * @ngInject\n */\n sgMessageListItemMainController.$inject = ['$scope', '$element', '$parse', '$state', '$mdUtil', '$mdToast', 'Mailbox', 'Message', 'encodeUriFilter'];\n function sgMessageListItemMainController($scope, $element, $parse, $state, $mdUtil, $mdToast, Mailbox, Message, encodeUriFilter) {\n var $ctrl = this;\n\n this.$postLink = function () {\n var contentDivElement, iconsDivElement;\n var parentControllerOnUpdate, setVisibility;\n\n this.parentController = $scope.parentController;\n\n parentControllerOnUpdate = this.parentController.onUpdate;\n setVisibility = this.parentController.setVisibility;\n\n _.forEach($element.find('div'), function(div) {\n if (div.classList.contains('sg-tile-content'))\n contentDivElement = angular.element(div);\n else if (div.classList.contains('sg-tile-icons'))\n iconsDivElement = angular.element(div);\n });\n\n this.priorityIconElement = contentDivElement.find('md-icon')[0];\n\n if (Mailbox.$virtualMode) {\n // Show mailbox name in front of the subject\n this.mailboxNameElement = contentDivElement.find('span')[0];\n this.mailboxNameElement.classList.remove('ng-hide');\n }\n\n this.senderElement = contentDivElement.find('span')[1];\n\n _.forEach(contentDivElement.find('div'), function(div) {\n if (div.classList.contains('sg-tile-subject'))\n $ctrl.subjectElement = div;\n else if (div.classList.contains('sg-tile-size'))\n $ctrl.sizeElement = div;\n else if (div.classList.contains('sg-tile-date'))\n $ctrl.dateElement = div;\n });\n\n _.forEach(iconsDivElement.find('md-icon'), function(div) {\n if (div.textContent == 'star')\n $ctrl.flagIconElement = div;\n else if (div.textContent == 'reply')\n $ctrl.answerIconElement = div;\n else if (div.textContent == 'forward')\n $ctrl.forwardIconElement = div;\n else if (div.textContent == 'attach_file')\n $ctrl.attachmentIconElement = div;\n });\n\n /**\n * Update the template when the parent controller has detected a change.\n */\n this.parentController.onUpdate = function () {\n var i;\n $ctrl.message = $ctrl.parentController.message;\n\n // Flags\n var flagElements = $mdUtil.nodesToArray($element[0].querySelectorAll('.sg-category'));\n _.forEach(flagElements, function(flagElement) {\n $element[0].removeChild(flagElement);\n });\n for (i = 0; i < $ctrl.message.flags.length && i < 5; i++) {\n var tag = $ctrl.message.flags[i];\n if ($ctrl.service.$tags[tag]) {\n var flagElement = angular.element('<div class=\"sg-category\"></div>');\n flagElement.css('left', (i*3) + 'px');\n flagElement.css('background-color', $ctrl.service.$tags[tag][1]);\n $element.prepend(flagElement);\n }\n }\n\n // Mailbox name when in virtual mode\n if ($ctrl.mailboxNameElement)\n $ctrl.mailboxNameElement.innerHTML = $ctrl.message.$mailbox.$displayName;\n\n // Sender or recipient when in\n if ($ctrl.MailboxService.selectedFolder.type == 'sent')\n $ctrl.senderElement.innerHTML = $ctrl.message.$shortAddress('to').encodeEntities();\n else\n $ctrl.senderElement.innerHTML = $ctrl.message.$shortAddress('from').encodeEntities();\n\n // Priority icon\n if ($ctrl.message.priority && $ctrl.message.priority.level < 3) {\n $ctrl.priorityIconElement.classList.remove('ng-hide');\n if ($ctrl.message.priority.level < 2)\n $ctrl.priorityIconElement.classList.add('md-warn');\n else\n $ctrl.priorityIconElement.classList.remove('md-warn');\n }\n else\n $ctrl.priorityIconElement.classList.add('ng-hide');\n\n // Subject\n $ctrl.subjectElement.innerHTML = $ctrl.message.subject.encodeEntities();\n\n // Message size\n $ctrl.sizeElement.innerHTML = $ctrl.message.size;\n\n // Received Date\n $ctrl.dateElement.innerHTML = $ctrl.message.relativedate;\n\n setVisibility($ctrl.flagIconElement,\n $ctrl.message.isflagged);\n setVisibility($ctrl.answerIconElement,\n $ctrl.message.isanswered);\n setVisibility($ctrl.forwardIconElement,\n $ctrl.message.isforwarded);\n setVisibility($ctrl.attachmentIconElement,\n $ctrl.message.hasattachment);\n\n // Call original method on parent controller\n angular.bind($ctrl.parentController, parentControllerOnUpdate)();\n };\n\n this.service = Message;\n this.MailboxService = Mailbox;\n };\n\n }\n\n\n angular\n .module('SOGo.MailerUI')\n .controller('sgMessageListItemMainController', sgMessageListItemMainController)\n .directive('sgMessageListItemMain', sgMessageListItemMain);\n})();\n","/* -*- Mode: javascript; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n\n(function() {\n /* jshint validthis: true */\n 'use strict';\n\n /*\n * sgZoomableImage - Show the image fullscreen when clicking on the image inside the container.\n * @memberof SOGo.MailerUI\n * @restrict attribute\n * @ngInject\n * @example:\n\n <div sg-zoomable-image=\"$index\">\n <md-card>\n <img src=\"foo.png\">\n </md-card>\n </div>\n */\n function sgZoomableImage() {\n return {\n restrict: 'A',\n bindToController: {\n partIndex: '=sgZoomableImage'\n },\n controller: sgZoomableImageController\n };\n\n function link(scope, iElement, attrs, ctrl) {\n var parentNode = iElement.parent(),\n imgElement, showImage, toggleClass;\n\n imgElement = iElement.find('img');\n\n toggleClass = function(event) {\n if (event.target.tagName == 'IMG')\n parentNode.toggleClass('sg-zoom');\n };\n\n showImage = function(event) {\n if (event.target.tagName == 'IMG')\n ctrl.showGallery(event, imgElement[0].src);\n };\n\n if (imgElement.length)\n ctrl.addImage(imgElement[0].src);\n\n iElement.on('click', showImage);\n }\n }\n\n /**\n * @ngInject\n */\n sgZoomableImageController.$inject = ['$element', 'ImageGallery'];\n function sgZoomableImageController($element, ImageGallery) {\n var $ctrl = this;\n\n this.$postLink = function() {\n ImageGallery.registerImage($element);\n $element.on('click', this.showImage);\n };\n\n this.showImage = function($event) {\n if ($event.target.tagName == 'IMG')\n ImageGallery.showGallery($event, $ctrl.partIndex);\n };\n }\n\n angular\n .module('SOGo.MailerUI')\n .directive('sgZoomableImage', sgZoomableImage);\n})();\n"]} |