芝麻web文件管理V1.00
编辑当前文件:/home/pulsehostuk9/public_html/cloud.pulsehost.co.uk/static/js/55.app.c69eacbce4dc26192b3c.js
"use strict"; (self["webpackChunkafterlogic_aurora_platform"] = self["webpackChunkafterlogic_aurora_platform"] || []).push([[55],{ /***/ "a6uM": /*!**************************************************************!*\ !*** ./modules/CoreWebclient/js/models/CAddressListModel.js ***! \**************************************************************/ /***/ ((module, __unused_webpack_exports, __webpack_require__) => { var _ = __webpack_require__(/*! underscore */ "C3HO"), CAddressModel = __webpack_require__(/*! modules/CoreWebclient/js/models/CAddressModel.js */ "vsHO") ; /** * @constructor */ function CAddressListModel() { this.aCollection = []; } /** * @param {object} oData */ CAddressListModel.prototype.parse = function (oData) { var aCollection = oData ? oData['@Collection'] : []; this.aCollection = []; if (_.isArray(aCollection)) { this.aCollection = _.map(aCollection, function (oItem) { var oAddress = new CAddressModel(); oAddress.parse(oItem); return oAddress; }); } }; /** * @param {Array} aCollection */ CAddressListModel.prototype.addCollection = function (aCollection) { _.each(aCollection, function (oAddress) { var oFoundAddress = _.find(this.aCollection, function (oThisAddress) { return oAddress.sEmail === oThisAddress.sEmail; }); if (!oFoundAddress) { this.aCollection.push(oAddress); } }, this); }; /** * @param {Array} aCollection */ CAddressListModel.prototype.excludeCollection = function (aCollection) { _.each(aCollection, function (oAddress) { this.aCollection = _.filter(this.aCollection, function (oThisAddress) { return oAddress.sEmail.toLowerCase() !== oThisAddress.sEmail.toLowerCase(); }); }, this); }; /** * @return {string} */ CAddressListModel.prototype.getFirstEmail = function () { if (this.aCollection.length > 0) { return this.aCollection[0].getEmail(); } return ''; }; /** * @return {string} */ CAddressListModel.prototype.getFirstName = function () { if (this.aCollection.length > 0) { return this.aCollection[0].getName(); } return ''; }; /** * @return {string} */ CAddressListModel.prototype.getFirstDisplay = function () { if (this.aCollection.length > 0) { return this.aCollection[0].getDisplay(); } return ''; }; /** * @param {string=} sMeReplacement * @param {string=} sMyAccountEmail * * @return {string} */ CAddressListModel.prototype.getDisplay = function (sMeReplacement, sMyAccountEmail) { var aAddresses = _.map(this.aCollection, function (oAddress) { if (sMeReplacement && sMyAccountEmail === oAddress.sEmail) { return sMeReplacement; } return oAddress.getDisplay(sMeReplacement); }); return aAddresses.join(', '); }; /** * @return {string} */ CAddressListModel.prototype.getFull = function () { var aAddresses = _.map(this.aCollection, function (oAddress) { return oAddress.getFull(); }); return aAddresses.join(', '); }; /** * @return {Array} */ CAddressListModel.prototype.getEmails = function () { var aEmails = _.map(this.aCollection, function (oAddress) { return oAddress.getEmail(); }); return aEmails; }; module.exports = CAddressListModel; /***/ }), /***/ "vsHO": /*!**********************************************************!*\ !*** ./modules/CoreWebclient/js/models/CAddressModel.js ***! \**********************************************************/ /***/ ((module, __unused_webpack_exports, __webpack_require__) => { var ko = __webpack_require__(/*! knockout */ "p09A"), AddressUtils = __webpack_require__(/*! modules/CoreWebclient/js/utils/Address.js */ "kG5I"), Types = __webpack_require__(/*! modules/CoreWebclient/js/utils/Types.js */ "KC/L") ; /** * @constructor */ function CAddressModel() { this.sName = ''; /** @type {string} */ this.sEmail = ''; this.sDisplay = ''; this.sFull = ''; this.loaded = ko.observable(false); this.found = ko.observable(false); } /** * @param {Object} oData */ CAddressModel.prototype.parse = function (oData) { if (oData !== null) { this.sName = Types.pString(oData.DisplayName); this.sEmail = Types.pString(oData.Email); this.sDisplay = (this.sName.length > 0) ? this.sName : this.sEmail; this.sFull = AddressUtils.getFullEmail(this.sName, this.sEmail); } }; /** * @return {string} */ CAddressModel.prototype.getEmail = function () { return this.sEmail; }; /** * @return {string} */ CAddressModel.prototype.getName = function () { return this.sName; }; /** * @return {string} */ CAddressModel.prototype.getDisplay = function () { return this.sDisplay; }; /** * @return {string} */ CAddressModel.prototype.getFull = function () { return this.sFull; }; module.exports = CAddressModel; /***/ }), /***/ "H2Cq": /*!***********************************************************!*\ !*** ./modules/CoreWebclient/js/utils/Contenteditable.js ***! \***********************************************************/ /***/ ((module, __unused_webpack_exports, __webpack_require__) => { const _ = __webpack_require__(/*! underscore */ "C3HO") const ContenteditableUtils = {} ContenteditableUtils.setCursorAtTheEnd = function (contentEditableElement) { if (document.createRange) { const range = document.createRange() range.selectNodeContents(contentEditableElement) range.collapse(false) const selection = window.getSelection() selection.removeAllRanges() selection.addRange(range) contentEditableElement.focus() range.detach() } } ContenteditableUtils.getSelectionRanges = function () { const ranges = [] if (window.getSelection) { const selection = window.getSelection(), count = selection.rangeCount for (let index = 0; index < count; index++) { ranges.push(selection.getRangeAt(index)) } } return ranges } ContenteditableUtils.setSelectionRanges = function (ranges, collapse = false) { let rangeText = '' if (window.getSelection && _.isArray(ranges)) { const count = ranges.length, selection = window.getSelection() selection.removeAllRanges() for (let index = 0; index < count; index++) { const range = ranges[index] if (range) { selection.addRange(range) rangeText += range if (collapse) { range.collapse(false) } } } } return rangeText } module.exports = ContenteditableUtils /***/ }), /***/ "7xgn": /*!*************************************************!*\ !*** ./modules/MailWebclient/js/AccountList.js ***! \*************************************************/ /***/ ((module, __unused_webpack_exports, __webpack_require__) => { var _ = __webpack_require__(/*! underscore */ "C3HO"), ko = __webpack_require__(/*! knockout */ "p09A"), Types = __webpack_require__(/*! modules/CoreWebclient/js/utils/Types.js */ "KC/L"), App = __webpack_require__(/*! modules/CoreWebclient/js/App.js */ "9kOp"), MainTab = App.isNewTab() && window.opener ? window.opener.MainTabMailMethods : null, Routing = __webpack_require__(/*! modules/CoreWebclient/js/Routing.js */ "W66n"), CoreAjax = __webpack_require__(/*! modules/CoreWebclient/js/Ajax.js */ "EFhx"), Ajax = __webpack_require__(/*! modules/MailWebclient/js/Ajax.js */ "QaEg"), LinksUtils = __webpack_require__(/*! modules/MailWebclient/js/utils/Links.js */ "CPab"), Settings = __webpack_require__(/*! modules/MailWebclient/js/Settings.js */ "oFXy"), CAccountModel = __webpack_require__(/*! modules/MailWebclient/js/models/CAccountModel.js */ "FSu3"), CFetcherModel = __webpack_require__(/*! modules/MailWebclient/js/models/CFetcherModel.js */ "P7A8"), CAliasModel = __webpack_require__(/*! modules/MailWebclient/js/models/CAliasModel.js */ "U1iB"), CIdentityModel = __webpack_require__(/*! modules/MailWebclient/js/models/CIdentityModel.js */ "ce4k") ; /** * @constructor */ function CAccountListModel() { this.collection = ko.observableArray([]); this.unifiedMailboxAccounts = ko.computed(function () { if (Settings.AllowUnifiedInbox) { return _.filter(this.collection(), function (oAccount) { return oAccount.includeInUnifiedMailbox(); }); } return []; }, this); this.unifiedInboxAllowed = ko.computed(function () { return this.unifiedMailboxAccounts().length > 1; }, this); this.unifiedInboxReady = ko.observable(false); } /** * @param {string} sHash */ CAccountListModel.prototype.getAccountByHash = function (sHash) { return _.find(this.collection(), function (oAcct) { return oAcct.hash() === sHash; }, this); }; /** * @param {string} sNewCurrentHash */ CAccountListModel.prototype.changeCurrentAccountByHash = function (sNewCurrentHash) { var oAccount = this.getAccountByHash(sNewCurrentHash); if (oAccount && oAccount.id() !== this.currentId()) { this.changeCurrentAccount(oAccount.id(), false); } }; /** * Changes current account. Sets hash to show new account data. * * @param {number} iNewCurrentId * @param {boolean} bPassToMail */ CAccountListModel.prototype.changeCurrentAccount = function (iNewCurrentId, bPassToMail) { var oCurrentAccount = this.getCurrent(), oNewCurrentAccount = this.getAccount(iNewCurrentId) ; if (oNewCurrentAccount && this.currentId() !== iNewCurrentId) { if (oCurrentAccount) { oCurrentAccount.isCurrent(false); } this.currentId(iNewCurrentId); oNewCurrentAccount.isCurrent(true); } else if (!oCurrentAccount) { this.currentId(0); } if (bPassToMail) { Routing.setHash(LinksUtils.getMailbox()); } }; /** * @param {string} sNewEditedHash */ CAccountListModel.prototype.changeEditedAccountByHash = function (sNewEditedHash) { var oAccount = this.getAccountByHash(sNewEditedHash); if (oAccount && oAccount.id() !== this.editedId()) { this.changeEditedAccount(oAccount.id()); } }; /** * Changes editable account. * * @param {number} iNewEditedId */ CAccountListModel.prototype.changeEditedAccount = function (iNewEditedId) { var oEditedAccount = this.getEdited(), oNewEditedAccount = this.getAccount(iNewEditedId) ; if (oNewEditedAccount && this.editedId() !== iNewEditedId) { if (oEditedAccount) { oEditedAccount.isEdited(false); } this.editedId(iNewEditedId); oNewEditedAccount.isEdited(true); } else if (!oEditedAccount) { this.editedId(0); } }; CAccountListModel.prototype.getDefaultFriendlyName = function() { var oCurrAccount = this.getCurrent(), oDefIdentity = _.find(oCurrAccount && oCurrAccount.identities() || [], function (oIdnt) { return oIdnt.isDefault(); }) || oCurrAccount ; return oDefIdentity ? oDefIdentity.friendlyName() || oDefIdentity.email() : ''; }; /** * @param {type} sHash * @returns {Object} */ CAccountListModel.prototype.getIdentityByHash = function(sHash) { var oIdentity = null; _.each(this.collection(), function (oAccount) { if (!oIdentity) { oIdentity = _.find(oAccount.identities() || [], function (oIdnt) { return oIdnt.hash() === sHash; }); } }, this); return oIdentity; }; /** * @param {type} sHash * @returns {Object} */ CAccountListModel.prototype.getFetcherByHash = function(sHash) { var oFoundFetcher = null; _.each(this.collection(), function (oAccount) { if (!oFoundFetcher) { oFoundFetcher = _.find(oAccount.fetchers(), function (oFetcher) { return oFetcher.hash() === sHash; }); } }, this); return oFoundFetcher; }; /** * @param {type} sHash * @returns {Object} */ CAccountListModel.prototype.getAliasByHash = function(sHash) { var oAlias = null; _.each(this.collection(), function (oAccount) { if (!oAlias) { oAlias = _.find(oAccount.aliases() || [], function (oAlias) { return oAlias.hash() === sHash; }); } }, this); return oAlias; }; /** * Fills the collection of accounts. * @param {Array} aAccounts */ CAccountListModel.prototype.parse = function (aAccounts) { if (_.isArray(aAccounts)) { this.collection(_.map(aAccounts, function (oRawAccount) { return new CAccountModel(oRawAccount); })); this.initObservables(this.collection().length > 0 ? this.collection()[0].id() : 0); } }; /** * @param {int} iCurrentId */ CAccountListModel.prototype.initObservables = function (iCurrentId) { var oCurrAccount = this.getAccount(iCurrentId); if (oCurrAccount) { oCurrAccount.isCurrent(true); oCurrAccount.isEdited(true); } this.currentId = ko.observable(iCurrentId); this.editedId = ko.observable(iCurrentId); }; /** * @return {boolean} */ CAccountListModel.prototype.hasAccount = function () { return this.collection().length > 0; }; /** * @param {number} iId * * @return {Object|undefined} */ CAccountListModel.prototype.getAccount = function (iId) { var oAccount = _.find(this.collection(), function (oAcct) { return oAcct.id() === iId; }, this); /** @type {Object|undefined} */ return oAccount; }; /** * @return {Object|undefined} */ CAccountListModel.prototype.getDefault = function () { var oAccount = _.find(this.collection(), function (oAcct) { return oAcct.bDefault; }, this); return oAccount; }; /** * @return {Object|undefined} */ CAccountListModel.prototype.getCurrent = function () { return this.getAccount(this.currentId()); }; /** * @return {Object|undefined} */ CAccountListModel.prototype.getEdited = function () { return this.getAccount(this.editedId()); }; /** * @param {number=} iAccountId * @return {string} */ CAccountListModel.prototype.getEmail = function (iAccountId) { iAccountId = iAccountId || this.currentId(); var sEmail = '', oAccount = this.getAccount(iAccountId) ; if (oAccount) { sEmail = oAccount.email(); } return sEmail; }; /** * @param {Object} oAccount */ CAccountListModel.prototype.addAccount = function (oAccount) { this.collection.push(oAccount); }; /** * @param {number} iId */ CAccountListModel.prototype.deleteAccount = function (iId) { this.collection.remove(function (oAcct) { return oAcct.id() === iId; }); var iFirstAccId = this.collection().length > 0 ? this.collection()[0].id() : 0; this.changeCurrentAccount(iFirstAccId, false); this.changeEditedAccount(iFirstAccId); }; /** * @param {number} iId * * @return {boolean} */ CAccountListModel.prototype.hasAccountWithId = function (iId) { var oAccount = _.find(this.collection(), function (oAcct) { return oAcct.id() === iId; }, this); return !!oAccount; }; CAccountListModel.prototype.populateFetchersIdentities = function () { this.populateFetchers(); this.populateIdentities(); this.populateAliases(); }; CAccountListModel.prototype.populateFetchers = function () { if (Settings.AllowFetchers) { CoreAjax.send(Settings.FetchersServerModuleName, 'GetFetchers', { 'AccountID': this.editedId() }, this.onGetFetchersResponse, this); } }; CAccountListModel.prototype.populateAliases = function (fAfterPopulateAliases) { if (Settings.AllowAliases) { CoreAjax.send( Settings.AliasesServerModuleName, 'GetAliases', { 'AccountID': this.editedId() }, function (oResponse, oRequest) { this.onGetAliasesResponse(oResponse, oRequest); if (_.isFunction(fAfterPopulateAliases)) { fAfterPopulateAliases(); } }, this ); } }; /** * @param {Object} oResponse * @param {Object} oRequest */ CAccountListModel.prototype.onGetFetchersResponse = function (oResponse, oRequest) { var oFetchers = {}; if (Types.isNonEmptyArray(oResponse.Result)) { _.each(oResponse.Result, function (oData) { var oFetcher = new CFetcherModel(); oFetcher.parse(oData); if (!oFetchers[oFetcher.accountId()]) { oFetchers[oFetcher.accountId()] = []; } oFetchers[oFetcher.accountId()].push(oFetcher); }); } _.each(this.collection(), function (oAccount) { var aFetchers = Types.isNonEmptyArray(oFetchers[oAccount.id()]) ? oFetchers[oAccount.id()] : []; oAccount.fetchers(aFetchers); }, this); }; /** * @param {Object} oResponse * @param {Object} oRequest */ CAccountListModel.prototype.onGetAliasesResponse = function (oResponse, oRequest) { var oAliases = {}; if (oResponse.Result && Types.isNonEmptyArray(oResponse.Result.ObjAliases)) { _.each(oResponse.Result.ObjAliases, function (oData) { var oAlias = new CAliasModel(); oAlias.parse(oData); if (!oAliases[oAlias.accountId()]) { oAliases[oAlias.accountId()] = []; } oAliases[oAlias.accountId()].push(oAlias); }); } _.each(this.collection(), function (oAccount) { var aAliases = Types.isNonEmptyArray(oAliases[oAccount.id()]) ? oAliases[oAccount.id()] : []; oAccount.aliases(aAliases); }, this); }; /** * @param {function} fAfterPopulateIdentities */ CAccountListModel.prototype.populateIdentities = function (fAfterPopulateIdentities) { if (Settings.AllowIdentities && this.collection().length >= 1) { Ajax.send('GetIdentities', null, function (oResponse, oRequest) { this.onGetIdentitiesResponse(oResponse, oRequest); if (_.isFunction(fAfterPopulateIdentities)) { fAfterPopulateIdentities(); } }, this); } }; /** * @param {Object} oResponse * @param {Object} oRequest */ CAccountListModel.prototype.onGetIdentitiesResponse = function (oResponse, oRequest) { var oIdentities = {}; if (Types.isNonEmptyArray(oResponse.Result)) { _.each(oResponse.Result, function (oIdentityData) { var oIdentity = new CIdentityModel(), iAccountId = -1 ; oIdentity.parse(oIdentityData); iAccountId = oIdentity.accountId(); if (!oIdentities[iAccountId]) { oIdentities[iAccountId] = []; } oIdentities[iAccountId].push(oIdentity); }); } _.each(this.collection(), function (oAccount) { var aIdentities = oIdentities[oAccount.id()], oIdentity = new CIdentityModel() ; if (!oAccount.bAllowUseIdentities || !Types.isNonEmptyArray(aIdentities)) { aIdentities = []; } oIdentity.parse({ AccountPart: true, Default: !_.find(aIdentities, function(oIdentity){ return oIdentity.isDefault(); }), Email: oAccount.email(), FriendlyName: oAccount.friendlyName(), IdAccount: oAccount.id(), EntityId: 0, // default identity id Signature: oAccount.signature(), UseSignature: oAccount.useSignature() }); aIdentities.unshift(oIdentity); oAccount.identities(aIdentities); }); }; /** * @param {Object} oSrcAccounts */ CAccountListModel.prototype.populateIdentitiesFromSourceAccount = function (oSrcAccounts) { if (oSrcAccounts) { _.each(this.collection(), function (oAccount) { var oSrcAccount = oSrcAccounts.getAccount(oAccount.id()); if (oSrcAccount) { oAccount.fetchers(oSrcAccount.fetchers()); oAccount.identities(oSrcAccount.identities()); oAccount.signature(oSrcAccount.signature()); oAccount.useSignature(oSrcAccount.useSignature()); } }); } }; CAccountListModel.prototype.getAccountsEmails = function () { return _.uniq(_.map(this.collection(), function (oAccount) { return oAccount.email(); })); }; CAccountListModel.prototype.getAllFullEmails = function () { var aFullEmails = []; _.each(this.collection(), function (oAccount) { if (oAccount) { if (Types.isNonEmptyArray(oAccount.identities())) { _.each(oAccount.identities(), function (oIdentity) { aFullEmails.push(oIdentity.fullEmail()); }); } else { aFullEmails.push(oAccount.fullEmail()); } _.each(oAccount.fetchers(), function (oFetcher) { if (oFetcher.isEnabled() && oFetcher.isOutgoingEnabled() && oFetcher.fullEmail() !== '') { aFullEmails.push(oFetcher.fullEmail()); } }); } }); return aFullEmails; }; CAccountListModel.prototype.getCurrentFetchersAndFiltersFolderNames = function () { var oAccount = this.getCurrent(), aFolders = [] ; if (oAccount) { if (oAccount.filters()) { _.each(oAccount.filters().collection(), function (oFilter) { aFolders.push(oFilter.folder()); }, this); } _.each(oAccount.fetchers(), function (oFetcher) { aFolders.push(oFetcher.folder()); }, this); } return aFolders; }; /** * @param {Array} aEmails * @returns {string} */ CAccountListModel.prototype.getAttendee = function (aEmails) { var aAccountsEmails = [], sAttendee = '' ; _.each(this.collection(), function (oAccount) { if (oAccount.isCurrent()) { aAccountsEmails = _.union([oAccount.email()], oAccount.getFetchersIdentitiesEmails(), aAccountsEmails); } else { aAccountsEmails = _.union(aAccountsEmails, [oAccount.email()], oAccount.getFetchersIdentitiesEmails()); } }); aAccountsEmails = _.uniq(aAccountsEmails); _.each(aAccountsEmails, _.bind(function (sAccountEmail) { if (sAttendee === '') { var sFoundEmail = _.find(aEmails, function (sEmail) { return (sEmail === sAccountEmail); }); if (sFoundEmail === sAccountEmail) { sAttendee = sAccountEmail; } } }, this)); return sAttendee; }; var AccountList = new CAccountListModel(); if (window.auroraAppData.Mail && _.isArray(window.auroraAppData.Mail.Accounts)) { AccountList.parse(window.auroraAppData.Mail.Accounts); } else { AccountList.parse([]); } if (MainTab) { AccountList.populateIdentitiesFromSourceAccount(MainTab.getAccountList()); } module.exports = AccountList; /***/ }), /***/ "QaEg": /*!******************************************!*\ !*** ./modules/MailWebclient/js/Ajax.js ***! \******************************************/ /***/ ((module, __unused_webpack_exports, __webpack_require__) => { const _ = __webpack_require__(/*! underscore */ "C3HO") const TextUtils = __webpack_require__(/*! modules/CoreWebclient/js/utils/Text.js */ "H20a"), Types = __webpack_require__(/*! modules/CoreWebclient/js/utils/Types.js */ "KC/L"), Ajax = __webpack_require__(/*! modules/CoreWebclient/js/Ajax.js */ "EFhx"), App = __webpack_require__(/*! modules/CoreWebclient/js/App.js */ "9kOp"), Screens = __webpack_require__(/*! modules/CoreWebclient/js/Screens.js */ "skxT") const Settings = __webpack_require__(/*! modules/MailWebclient/js/Settings.js */ "oFXy") Ajax.registerAbortRequestHandler(Settings.ServerModuleName, function (oRequest, oOpenedRequest) { var oParameters = oRequest.Parameters, oOpenedParameters = oOpenedRequest.Parameters switch (oRequest.Method) { case 'MoveMessages': case 'DeleteMessages': return ( oOpenedRequest.Method === 'GetRelevantFoldersInformation' || oOpenedRequest.Method === 'GetUnifiedRelevantFoldersInformation' || oOpenedRequest.Method === 'GetMessage' || oOpenedRequest.Method === 'GetUnifiedMailboxMessages' || oOpenedRequest.Method === 'GetMessagesByFolders' || (oOpenedRequest.Method === 'GetMessages' && oOpenedParameters.Folder === oParameters.Folder) ) case 'GetMessages': case 'GetUnifiedMailboxMessages': return ( oOpenedRequest.Method === 'GetUnifiedMailboxMessages' || oOpenedRequest.Method === 'GetMessagesByFolders' || (oOpenedRequest.Method === 'GetMessages' && oOpenedParameters.Folder === oParameters.Folder) ) case 'SetMessagesSeen': case 'SetMessageFlagged': return ( oOpenedRequest.Method === 'GetRelevantFoldersInformation' || oOpenedRequest.Method === 'GetUnifiedRelevantFoldersInformation' || oOpenedRequest.Method === 'GetUnifiedMailboxMessages' || oOpenedRequest.Method === 'GetMessagesByFolders' || (oOpenedRequest.Method === 'GetMessages' && oOpenedParameters.Folder === oParameters.Folder) ) case 'SetAllMessagesSeen': return ( oOpenedRequest.Method === 'GetRelevantFoldersInformation' || oOpenedRequest.Method === 'GetUnifiedRelevantFoldersInformation' || (oOpenedRequest.Method === 'GetMessages' && oOpenedParameters.Folder === oParameters.Folder) ) case 'ClearFolder': // GetRelevantFoldersInformation-request aborted during folder cleaning, not to get the wrong information. return ( oOpenedRequest.Method === 'GetRelevantFoldersInformation' || oOpenedRequest.Method === 'GetUnifiedRelevantFoldersInformation' || (oOpenedRequest.Method === 'GetMessages' && oOpenedParameters.Folder === oParameters.Folder) ) case 'GetRelevantFoldersInformation': return ( (oOpenedRequest.Method === 'GetRelevantFoldersInformation' && oParameters.AccountID === oOpenedParameters.AccountID) || oOpenedRequest.Method === 'GetUnifiedRelevantFoldersInformation' ) case 'GetMessagesFlags': return oOpenedRequest.Method === 'GetMessagesFlags' } return false }) module.exports = { getOpenedRequest: function (sMethod) { Ajax.getOpenedRequest('Mail', sMethod) }, hasOpenedRequests: function (sMethod) { return Ajax.hasOpenedRequests('Mail', sMethod || '') }, hasInternetConnectionProblem: function () { return Ajax.hasInternetConnectionProblem() }, registerOnAllRequestsClosedHandler: Ajax.registerOnAllRequestsClosedHandler, send: function (sMethod, oParameters, fResponseHandler, oContext) { var MailCache = __webpack_require__(/*! modules/MailWebclient/js/Cache.js */ "F0Fd"), fBaseResponseHandler = function (oResponse, oRequest) { if (!oResponse.Result && oResponse.ErrorCode === 4002 && App.getUserRole() !== Enums.UserRole.Anonymous) { var AccountList = __webpack_require__(/*! modules/MailWebclient/js/AccountList.js */ "7xgn"), aErrorMessageParts = oResponse.ErrorMessage.split(':'), iAccountId = Types.pInt(aErrorMessageParts.shift()), oAccount = AccountList.getAccount(iAccountId), sErrorMessage = aErrorMessageParts.join(':') if (oAccount && oAccount.bDefault) { oResponse = { Result: false, ErrorCode: Enums.Errors.AuthError } App.logoutAndGotoLogin() } else if (oAccount) { oAccount.passwordMightBeIncorrect(true) var sResultError = TextUtils.i18n('MAILWEBCLIENT/ERROR_CREDENTIALS_INCORRECT', { EMAIL: oAccount.email() }) if (sErrorMessage) { sResultError += ' (' + sErrorMessage + ')' } Screens.showError(sResultError, true) oResponse = { Result: false, ErrorCode: Enums.Errors.NotDisplayedError } } } if (_.isFunction(fResponseHandler)) { fResponseHandler.apply(oContext, [oResponse, oRequest]) } } if (oParameters && !oParameters.AccountID && sMethod !== 'GetUnifiedMailboxMessages') { oParameters.AccountID = MailCache.currentAccountId() } Ajax.send(Settings.ServerModuleName, sMethod, oParameters, fBaseResponseHandler, null) }, } /***/ }), /***/ "Qskt": /*!*******************************************!*\ !*** ./modules/MailWebclient/js/CCrea.js ***! \*******************************************/ /***/ ((module, __unused_webpack_exports, __webpack_require__) => { const _ = __webpack_require__(/*! underscore */ "C3HO"), $ = __webpack_require__(/*! jquery */ "M4cL") const App = __webpack_require__(/*! modules/CoreWebclient/js/App.js */ "9kOp"), Browser = __webpack_require__(/*! modules/CoreWebclient/js/Browser.js */ "dfnr"), ContenteditableUtils = __webpack_require__(/*! modules/CoreWebclient/js/utils/Contenteditable.js */ "H2Cq"), Types = __webpack_require__(/*! modules/CoreWebclient/js/utils/Types.js */ "KC/L") const CreaUtils = __webpack_require__(/*! modules/MailWebclient/js/utils/Crea.js */ "/5GA") /** * @constructor * * @param {Object} oOptions */ function CCrea(oOptions) { this.oOptions = _.extend( { creaId: 'creaId', fontNameArray: ['Tahoma'], defaultFontName: 'Tahoma', defaultFontSize: 3, alwaysTryUseImageWhilePasting: true, dropableArea: null, isRtl: false, onChange: function () {}, onCursorMove: function () {}, onFocus: function () {}, onBlur: function () {}, onUrlIn: function () {}, onUrlOut: function () {}, onImageSelect: function () {}, onImageBlur: function () {}, onItemOver: null, onItemOut: null, openInsertLinkDialog: function () {}, onUrlClicked: false, }, typeof oOptions === 'undefined' ? {} : oOptions ) } /** * @type {Object} */ CCrea.prototype.oOptions = {} /** * @type {Object} */ CCrea.prototype.$container = null /** * @type {Object} */ CCrea.prototype.$editableArea = null CCrea.prototype.aEditableAreaHtml = [] CCrea.prototype.iUndoRedoPosition = 0 CCrea.prototype.bEditable = false CCrea.prototype.bFocused = false /** * @type {Array} */ CCrea.prototype.aSizes = [ { inNumber: 1, inPixels: 10 }, { inNumber: 2, inPixels: 13 }, { inNumber: 3, inPixels: 16 }, { inNumber: 4, inPixels: 18 }, { inNumber: 5, inPixels: 24 }, { inNumber: 6, inPixels: 32 }, { inNumber: 7, inPixels: 48 }, ] CCrea.prototype.bInUrl = false CCrea.prototype.oCurrLink = null CCrea.prototype.oCurrImage = null CCrea.prototype.bInImage = false CCrea.prototype.sBasicFontName = '' CCrea.prototype.sBasicFontSize = '' CCrea.prototype.sBasicDirection = '' /** * Creates editable area. * * @param {boolean} bEditable */ CCrea.prototype.start = function (bEditable) { function isValidURL(sUrl) { var oRegExp = /^(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?$/ return oRegExp.test(sUrl) } function isCorrectEmail(sValue) { return !!sValue.match(/^[A-Z0-9\"!#\$%\^\{\}`~&'\+\-=_\.]+@[A-Z0-9\.\-]+$/i) } this.aRanges = null // if this.aRanges is not null first focus doesn't work properly, then insert image doesn't work this.$container = $('#' + this.oOptions.creaId) this.$editableArea = $('
') .addClass('crea-content-editable') .prop('contentEditable', 'true') .appendTo(this.$container) var self = this this.$editableArea.on('focus', function () { self.bFocused = true }) this.$editableArea.on('blur', function () { self.bFocused = false //self.editableSave(); //Undo/Redo fix }) this.$editableArea.on('click', 'img', function (ev) { var oImage = $(this) self.bInImage = true self.oCurrImage = oImage self.oOptions.onImageSelect(oImage, ev) ev.stopPropagation() }) this.$editableArea.on('click', function (ev) { self.bInImage = false self.oCurrImage = null self.oOptions.onImageBlur() }) if (self.oOptions.onItemOver !== null) { this.$editableArea.on('mouseover', function (ev) { self.oOptions.onItemOver(ev) }) } if (self.oOptions.onItemOver !== null) { this.$editableArea.on('mouseout', function (ev) { self.oOptions.onItemOut(ev) }) } this.$editableArea.on('cut paste', function () { self.editableSave() _.defer(function () { self.editableSave() }) }) this.$editableArea.on('paste', function (oEvent) { oEvent = oEvent.originalEvent || oEvent if (oEvent.clipboardData) { var sText = oEvent.clipboardData.getData('text/plain'), sHtml = oEvent.clipboardData.getData('text/html') if (self.oOptions.alwaysTryUseImageWhilePasting && self.pasteImage(oEvent)) { oEvent.preventDefault() } else { if (isValidURL(sText)) { oEvent.preventDefault() self.execCom('insertHTML', '
' + sText.replaceAll('&', '&') + '
') } else if (isCorrectEmail(sText)) { oEvent.preventDefault() self.execCom('insertHTML', '
' + sText.replaceAll('&', '&') + '
') } else if (sHtml !== '') { const preparedHtml = CreaUtils.preparePastedHtml(sHtml) if (preparedHtml) { oEvent.preventDefault() self.execCom('insertHTML', preparedHtml) } } } } }) this.$editableArea.on('keydown', function (oEvent) { var iKey = oEvent.keyCode || oEvent.which || oEvent.charCode || 0, bCtrlKey = oEvent.ctrlKey || oEvent.metaKey, bAltKey = oEvent.altKey, bShiftKey = oEvent.shiftKey, sLink = '' if ((bShiftKey && bCtrlKey && iKey === Enums.Key.z) || (bCtrlKey && iKey === Enums.Key.y)) { oEvent.preventDefault() self.editableRedo() } else if (bCtrlKey && !bAltKey && iKey === Enums.Key.z) { oEvent.preventDefault() self.editableUndo() } else if ( bCtrlKey && (iKey === Enums.Key.k || iKey === Enums.Key.b || iKey === Enums.Key.i || iKey === Enums.Key.u) ) { oEvent.preventDefault() switch (iKey) { case Enums.Key.k: sLink = self.getSelectedText() if (isValidURL(sLink)) { self.insertLink(sLink) } else if (isCorrectEmail(sLink)) { self.insertLink('mailto:' + sLink) } else { self.oOptions.openInsertLinkDialog() } break case Enums.Key.b: self.bold() break case Enums.Key.i: self.italic() break case Enums.Key.u: self.underline() break } } else if (!bAltKey && !bShiftKey && !bCtrlKey) { if (iKey === Enums.Key.Del || iKey === Enums.Key.Backspace) { self.editableSave() } } }) this.$editableArea.on('keyup', function (oEvent) { var iKey = oEvent.keyCode || oEvent.which || oEvent.charCode || 0, bCtrlKey = oEvent.ctrlKey || oEvent.metaKey, bAltKey = oEvent.altKey, bShiftKey = oEvent.shiftKey if (!bAltKey && !bShiftKey && !bCtrlKey) { if ( iKey === Enums.Key.Space || iKey === Enums.Key.Enter || iKey === Enums.Key.Del || iKey === Enums.Key.Backspace ) { self.editableSave() } else { self.oOptions.onChange() } } }) this.initContentEditable() this.setEditable(bEditable) App.broadcastEvent('MailWebclient::StartCrea::after', { EditableArea: this.$editableArea, InsertHtmlHandler: this.insertHtml.bind(this), }) } CCrea.prototype.clearUndoRedo = function () { this.aEditableAreaHtml = [] this.iUndoRedoPosition = 0 } CCrea.prototype.isUndoAvailable = function () { return this.iUndoRedoPosition > 0 } CCrea.prototype.clearRedo = function () { this.aEditableAreaHtml = this.aEditableAreaHtml.slice(0, this.iUndoRedoPosition + 1) } CCrea.prototype.editableSave = function () { var sEditableHtml = this.$editableArea.html(), oLastSaved = _.last(this.aEditableAreaHtml), sLastSaved = oLastSaved ? oLastSaved[0] : '' if (sEditableHtml !== sLastSaved) { this.clearRedo() this.aEditableAreaHtml.push([sEditableHtml, this.getCaretPos(this.$editableArea[0])]) this.iUndoRedoPosition = this.aEditableAreaHtml.length - 1 this.oOptions.onChange() } } CCrea.prototype.editableUndo = function () { var sEditableHtml = this.$editableArea.html(), oCurrSaved = this.aEditableAreaHtml[this.iUndoRedoPosition], sCurrSaved = oCurrSaved ? oCurrSaved[0] : '' if (sEditableHtml !== sCurrSaved) { this.editableSave() } if (this.iUndoRedoPosition > 0) { this.iUndoRedoPosition-- this.$editableArea.html(this.aEditableAreaHtml[this.iUndoRedoPosition]) this.setCaretPos(this.$editableArea[0], this.aEditableAreaHtml[this.iUndoRedoPosition][1]) } } CCrea.prototype.editableRedo = function () { if (this.iUndoRedoPosition < this.aEditableAreaHtml.length - 1) { this.iUndoRedoPosition++ this.$editableArea.html(this.aEditableAreaHtml[this.iUndoRedoPosition]) this.setCaretPos( this.$editableArea[0], this.aEditableAreaHtml[this.iUndoRedoPosition] ? this.aEditableAreaHtml[this.iUndoRedoPosition][1] : {} ) } } CCrea.prototype.getCaretPos = function (oContainerEl) { var oSel = null, oRange = {}, oPreSelectionRange = {}, iStart = 0, oCaretPos = {} if (window.getSelection && document.createRange) { oSel = window.getSelection() if (oSel.rangeCount > 0) { oRange = oSel.getRangeAt(0) oPreSelectionRange = oRange.cloneRange() oPreSelectionRange.selectNodeContents(oContainerEl) oPreSelectionRange.setEnd(oRange.startContainer, oRange.startOffset) iStart = oPreSelectionRange.toString().length oCaretPos = { start: iStart, end: iStart + oRange.toString().length, } } } else if (document.selection && document.body.createTextRange) { oRange = document.selection.createRange() oPreSelectionRange = document.body.createTextRange() oPreSelectionRange.moveToElementText(oContainerEl) if (typeof oPreSelectionRange.setEndPoint === 'function') { oPreSelectionRange.setEndPoint('EndToStart', oRange) } iStart = oPreSelectionRange.text.length oCaretPos = { start: iStart, end: iStart + oRange.text.length, } } return oCaretPos } CCrea.prototype.setCaretPos = function (oContainerEl, oSavedSel) { if (window.getSelection && document.createRange) { var oNodeStack = [oContainerEl], oNode = {}, oSel = {}, bFoundStart = false, bStop = false, iCharIndex = 0, iNextCharIndex = 0, iChildNodes = 0, oRange = document.createRange() oRange.setStart(oContainerEl, 0) oRange.collapse(true) oNode = oNodeStack.pop() while (!bStop && oNode) { if (oNode.nodeType === 3) { iNextCharIndex = iCharIndex + oNode.length if (!bFoundStart && oSavedSel.start >= iCharIndex && oSavedSel.start <= iNextCharIndex) { oRange.setStart(oNode, oSavedSel.start - iCharIndex) bFoundStart = true } if (bFoundStart && oSavedSel.end >= iCharIndex && oSavedSel.end <= iNextCharIndex) { oRange.setEnd(oNode, oSavedSel.end - iCharIndex) bStop = true } iCharIndex = iNextCharIndex } else { iChildNodes = oNode.childNodes.length while (iChildNodes--) { oNodeStack.push(oNode.childNodes[iChildNodes]) } } oNode = oNodeStack.pop() } oSel = window.getSelection() oSel.removeAllRanges() oSel.addRange(oRange) } else if (document.selection && document.body.createTextRange) { var oTextRange = document.body.createTextRange() oTextRange.moveToElementText(oContainerEl) oTextRange.collapse(true) oTextRange.moveEnd('character', oSavedSel.end) oTextRange.moveStart('character', oSavedSel.start) oTextRange.select() } } /** * Sets tab index. * * @param {string} sTabIndex */ CCrea.prototype.setTabIndex = function (sTabIndex) { if (sTabIndex) { this.$editableArea.attr('tabindex', sTabIndex) } } /** * Initializes properties. */ CCrea.prototype.initContentEditable = function () { this.$editableArea.bind({ mousemove: _.bind(this.storeSelectionPosition, this), mouseup: _.bind(this.onCursorMove, this), keydown: _.bind(this.onButtonPressed, this), keyup: _.bind(this.onCursorMove, this), click: _.bind(this.onClickWith, this), focus: this.oOptions.onFocus, blur: this.oOptions.onBlur, }) if (window.File && window.FileReader && window.FileList) { if (this.oOptions.enableDrop) { this.$editableArea.bind({ dragover: _.bind(this.onDragOver, this), dragleave: _.bind(this.onDragLeave, this), drop: _.bind(this.onFileSelect, this), }) } } var self = this, lazyScroll = _.debounce(function () { self.oCurrLink = null self.bInUrl = false self.oOptions.onUrlOut() }, 300) $('html, body').on('scroll', lazyScroll) } /** * Starts cursor move handlers. * @param {Object} ev */ CCrea.prototype.onCursorMove = function (ev) { var iKey = -1 if (window.event) { iKey = window.event.keyCode } else if (ev) { iKey = ev.which } if (iKey === 13) { // Enter this.breakQuotes(ev) } if (iKey === 17) { // Cntr this.$editableArea.find('a').css('cursor', 'inherit') } if (iKey === 8) { // BackSpace this.uniteWithNextQuote(ev) } if (iKey === 46 && Browser.chrome) { // Delete this.uniteWithPrevQuote(ev) } this.storeSelectionPosition() this.oOptions.onCursorMove() } /** * Starts when clicked. * @param {Object} oEvent */ CCrea.prototype.onClickWith = function (oEvent) { if (oEvent.ctrlKey) { if (oEvent.target.nodeName === 'A') { window.open(oEvent.target.href, '_blank') } } this.checkAnchorNode() } /** * Starts when key pressed. * @param {Object} oEvent */ CCrea.prototype.onButtonPressed = function (oEvent) { var iKey = -1 if (window.event) { iKey = window.event.keyCode } else if (oEvent) { iKey = oEvent.which } if (iKey === 17) { // Cntr this.$editableArea.find('a').css('cursor', 'pointer') } } /** * Starts cursor move handlers. * @param {Object} oEvent */ CCrea.prototype.onFileSelect = function (oEvent) { oEvent = (oEvent && oEvent.originalEvent ? oEvent.originalEvent : oEvent) || window.event if (oEvent) { oEvent.stopPropagation() oEvent.preventDefault() var oReader = null, oFile = null, aFiles = oEvent.files || (oEvent.dataTransfer ? oEvent.dataTransfer.files : null), self = this if (aFiles && 1 === aFiles.length && this.checkIsImage(aFiles[0])) { oFile = aFiles[0] oReader = new window.FileReader() oReader.onload = (function () { return function (oEvent) { self.insertImage(oEvent.target.result) } })() oReader.readAsDataURL(oFile) } } } CCrea.prototype.onDragLeave = function () { this.$editableArea.removeClass('editorDragOver') } /** * @param {Object} oEvent */ CCrea.prototype.onDragOver = function (oEvent) { oEvent.stopPropagation() oEvent.preventDefault() this.$editableArea.addClass('editorDragOver') } /** * @param {Object} oEvent * @returns {Boolean} */ CCrea.prototype.pasteImage = function (oEvent) { var oClipboardItems = oEvent.clipboardData && oEvent.clipboardData.items, self = this, bImagePasted = false if (window.File && window.FileReader && window.FileList && oClipboardItems) { _.each(oClipboardItems, function (oItem) { if (self.checkIsImage(oItem) && oItem['getAsFile']) { var oReader = null, oFile = oItem['getAsFile']() if (oFile) { oReader = new window.FileReader() oReader.onload = (function () { return function (oEvent) { self.insertImage(oEvent.target.result) } })() oReader.readAsDataURL(oFile) bImagePasted = true } } }) } return bImagePasted } /** * @param {Object} oItem * @return {boolean} */ CCrea.prototype.checkIsImage = function (oItem) { return oItem && oItem.type && 0 === oItem.type.indexOf('image/') } /** * Sets plain text to rich editor. * * @param {string} sText */ CCrea.prototype.setPlainText = function (sText) { if (typeof sText !== 'string') { sText = '' } if (this.$editableArea) { this.editableSave() this.$editableArea.empty().text(sText).css('white-space', 'pre') this.editableSave() } } /** * Sets text to rich editor. * * @param {string} sText */ CCrea.prototype.setText = function (sText) { if (typeof sText !== 'string') { sText = '' } if (this.$editableArea) { if (sText.length === 0) { sText = '
' } const preparedHtml = this.prepareHtmlWithoutWrappers(sText) this.$editableArea.empty().append(preparedHtml).css('white-space', 'normal') this.clearUndoRedo() this.editableSave() } } CCrea.prototype.prepareHtmlWithoutWrappers = function (html) { let outerNode = $(html) let isOuterElemChanged = false while ( outerNode.length === 1 && (outerNode.data('x-div-type') === 'html' || outerNode.data('x-div-type') === 'body') ) { outerNode = outerNode.children() isOuterElemChanged = true } if (outerNode.length === 1 && outerNode.data('crea') === 'font-wrapper') { this.setBasicStyles(outerNode.css('font-family'), outerNode.css('font-size'), outerNode.css('direction')) return outerNode.html() } this.setBasicStyles( this.oOptions.defaultFontName, this.convertFontSizeToPixels(this.oOptions.defaultFontSize), this.oOptions.isRtl ? 'rtl' : 'ltr' ) if (!isOuterElemChanged) { return html } else { let res = '' outerNode.each((index, elem) => { res += elem.outerHTML }) return res } } /** * @param {string} sFontName * @param {string} sFontSize * @param {string} sDirection */ CCrea.prototype.setBasicStyles = function (sFontName, sFontSize, sDirection) { this.sBasicFontName = sFontName this.sBasicFontSize = sFontSize this.sBasicDirection = sDirection this.$editableArea.css({ 'font-family': this.getFontNameWithFamily(this.sBasicFontName), 'font-size': this.sBasicFontSize, direction: this.sBasicDirection, }) } /** * Gets plain text from rich editor. * * @return {string} */ CCrea.prototype.getPlainText = function () { var sVal = '' if (this.$editableArea) { sVal = this.$editableArea .html() .replace(/([^>]{1})
/gi, '$1\n') .replace(/