/* RainLoop Webmail (c) RainLoop Team | MIT */ (function(){function a(a){function l(){if(g&&d iLimit && fLimitCallback) { bCallLimit = true; fLimitCallback(iInputLimit); } } } } } }; /** * @param {*} oInput * @param {Function} fFileCallback * @param {number=} iLimit = 20 * @param {Function=} fLimitCallback */ Utils.getDataFromInput = function (oInput, fFileCallback, iLimit, fLimitCallback) { var aFiles = oInput && oInput.files && 0 < oInput.files.length ? oInput.files : null; if (aFiles) { Utils.getDataFromFiles(aFiles, fFileCallback, iLimit, fLimitCallback); } else { fFileCallback({ 'FileName': oInput.value.split('\\').pop().split('/').pop(), 'Size': null, 'Type': null, 'Folder': '', 'File' : null }); } }; Utils.eventContainsFiles = function (oEvent) { var bResult = false; if (oEvent && oEvent.dataTransfer && oEvent.dataTransfer.types && oEvent.dataTransfer.types.length) { var iIindex = 0, iLen = oEvent.dataTransfer.types.length ; for (; iIindex < iLen; iIindex++) { if (oEvent.dataTransfer.types[iIindex].toLowerCase() === 'files') { bResult = true; break; } } } return bResult; }; /** * @param {Event} oEvent * @param {Function} fFileCallback * @param {number=} iLimit = 20 * @param {Function=} fLimitCallback */ Utils.getDataFromDragEvent = function (oEvent, fFileCallback, iLimit, fLimitCallback) { var aFiles = null; oEvent = Utils.getEvent(oEvent); if (oEvent && Utils.eventContainsFiles(oEvent)) { aFiles = (Utils.getValue(oEvent, 'files', null) || (oEvent.dataTransfer ? Utils.getValue(oEvent.dataTransfer, 'files', null) : null)); if (aFiles && 0 < aFiles.length) { Utils.getDataFromFiles(aFiles, fFileCallback, iLimit, fLimitCallback); } } }; Utils.createNextLabel = function () { return $('').css({ 'opacity': 0 }); }; Utils.createNextInput = function () { return $(''); }; /** * @param {string=} sName * @param {boolean=} bMultiple = true * @return {?Object} */ Utils.getNewInput = function (sName, bMultiple) { sName = Utils.isUndefined(sName) ? '' : sName.toString(); var oLocal = Utils.createNextInput(); if (0 < sName.length) { oLocal.attr('name', sName); } if (Utils.isUndefined(bMultiple) ? true : bMultiple) { oLocal.prop('multiple', true); } return oLocal; }; /** * @param {?} mStringOrFunction * @param {Array=} aFunctionParams * @return {string} */ Utils.getStringOrCallFunction = function (mStringOrFunction, aFunctionParams) { return $.isFunction(mStringOrFunction) ? mStringOrFunction.apply(null, $.isArray(aFunctionParams) ? aFunctionParams : []).toString() : mStringOrFunction.toString(); }; module.exports = Utils; }()); /***/ }, /* 5 */ /***/ function(module, exports, __webpack_require__) { (function () { 'use strict'; var $ = __webpack_require__(3), Globals = __webpack_require__(2), Utils = __webpack_require__(4) ; /** * @constructor * @param {Jua} oJua * @param {Object} oOptions */ function AjaxDriver(oJua, oOptions) { this.oXhrs = {}; this.oUids = {}; this.oJua = oJua; this.oOptions = oOptions; } /** * @type {Object} */ AjaxDriver.prototype.oXhrs = {}; /** * @type {Object} */ AjaxDriver.prototype.oUids = {}; /** * @type {?Jua} */ AjaxDriver.prototype.oJua = null; /** * @type {Object} */ AjaxDriver.prototype.oOptions = {}; /** * @return {boolean} */ AjaxDriver.prototype.isDragAndDropSupported = function () { return true; }; /** * @param {string} sUid */ AjaxDriver.prototype.regTaskUid = function (sUid) { this.oUids[sUid] = true; }; /** * @param {string} sUid * @param {?} oFileInfo * @param {Function} fCallback */ AjaxDriver.prototype.uploadTask = function (sUid, oFileInfo, fCallback) { if (false === this.oUids[sUid] || !oFileInfo || !oFileInfo['File']) { fCallback(null, sUid); return false; } try { var self = this, oXhr = new XMLHttpRequest(), oFormData = new FormData(), sAction = Utils.getValue(this.oOptions, 'action', ''), aHidden = Utils.getValue(this.oOptions, 'hidden', {}), fStartFunction = this.oJua.getEvent('onStart'), fCompleteFunction = this.oJua.getEvent('onComplete'), fProgressFunction = this.oJua.getEvent('onProgress') ; oXhr.open('POST', sAction, true); if (fProgressFunction && oXhr.upload) { oXhr.upload.onprogress = function (oEvent) { if (oEvent && oEvent.lengthComputable && !Utils.isUndefined(oEvent.loaded) && !Utils.isUndefined(oEvent.total)) { fProgressFunction(sUid, oEvent.loaded, oEvent.total); } }; } oXhr.onreadystatechange = function () { if (4 === oXhr.readyState && 200 === oXhr.status) { if (fCompleteFunction) { var bResult = false, oResult = null ; try { oResult = $.parseJSON(oXhr.responseText); bResult = true; } catch (oException) { oResult = null; } fCompleteFunction(sUid, bResult, oResult); } if (!Utils.isUndefined(self.oXhrs[sUid])) { self.oXhrs[sUid] = null; } fCallback(null, sUid); } else { if (4 === oXhr.readyState) { fCompleteFunction(sUid, false, null); fCallback(null, sUid); } } }; if (fStartFunction) { fStartFunction(sUid); } oFormData.append('jua-post-type', 'ajax'); oFormData.append(Utils.getValue(this.oOptions, 'name', 'juaFile'), oFileInfo['File']); $.each(aHidden, function (sKey, sValue) { oFormData.append(sKey, Utils.getStringOrCallFunction(sValue, [oFileInfo])); }); oXhr.send(oFormData); this.oXhrs[sUid] = oXhr; return true; } catch (oError) { } fCallback(null, sUid); return false; }; AjaxDriver.prototype.generateNewInput = function (oClickElement) { var self = this, oLabel = null, oInput = null ; if (oClickElement) { oInput = Utils.getNewInput('', !Utils.getValue(this.oOptions, 'disableMultiple', false)); oLabel = Utils.createNextLabel(); oLabel.append(oInput); $(oClickElement).append(oLabel); oInput .on('click', function () { var fOn = self.oJua.getEvent('onDialog'); if (fOn) { fOn(); } }) .on('change', function () { Utils.getDataFromInput(this, function (oFile) { self.oJua.addNewFile(oFile); self.generateNewInput(oClickElement); setTimeout(function () { oLabel.remove(); }, 10); }, Utils.getValue(self.oOptions, 'multipleSizeLimit', Globals.iDefLimit), self.oJua.getEvent('onLimitReached') ); }) ; } }; AjaxDriver.prototype.cancel = function (sUid) { this.oUids[sUid] = false; if (this.oXhrs[sUid]) { try { if (this.oXhrs[sUid].abort) { this.oXhrs[sUid].abort(); } } catch (oError) { } this.oXhrs[sUid] = null; } }; module.exports = AjaxDriver; }()); /***/ }, /* 6 */ /***/ function(module, exports, __webpack_require__) { (function () { 'use strict'; var window = __webpack_require__(1), $ = __webpack_require__(3), Globals = __webpack_require__(2), Utils = __webpack_require__(4) ; /** * @constructor * @param {Jua} oJua * @param {Object} oOptions */ function IframeDriver(oJua, oOptions) { this.oUids = {}; this.oForms = {}; this.oJua = oJua; this.oOptions = oOptions; } /** * @type {Object} */ IframeDriver.prototype.oUids = {}; /** * @type {Object} */ IframeDriver.prototype.oForms = {}; /** * @type {?Jua} */ IframeDriver.prototype.oJua = null; /** * @type {Object} */ IframeDriver.prototype.oOptions = {}; /** * @return {boolean} */ IframeDriver.prototype.isDragAndDropSupported = function () { return false; }; /** * @param {string} sUid */ IframeDriver.prototype.regTaskUid = function (sUid) { this.oUids[sUid] = true; }; /** * @param {string} sUid * @param {?} oFileInfo * @param {Function} fCallback */ IframeDriver.prototype.uploadTask = function (sUid, oFileInfo, fCallback) { if (false === this.oUids[sUid]) { fCallback(null, sUid); return false; } var oForm = this.oForms[sUid], aHidden = Utils.getValue(this.oOptions, 'hidden', {}), fStartFunction = this.oJua.getEvent('onStart'), fCompleteFunction = this.oJua.getEvent('onComplete') ; if (oForm) { oForm.append($('').attr('name', 'jua-post-type').val('iframe')); $.each(aHidden, function (sKey, sValue) { oForm.append($('').attr('name', sKey).val(Utils.getStringOrCallFunction(sValue, [oFileInfo]))); }); oForm.trigger('submit'); if (fStartFunction) { fStartFunction(sUid); } oForm.find('iframe').on('load', function () { var bResult = false, oIframeDoc = null, oResult = {} ; if (fCompleteFunction) { try { oIframeDoc = this.contentDocument ? this.contentDocument: this.contentWindow.document; oResult = $.parseJSON(oIframeDoc.body.innerHTML); bResult = true; } catch (oErr) { oResult = {}; } fCompleteFunction(sUid, bResult, oResult); } fCallback(null, sUid); window.setTimeout(function () { oForm.remove(); }, 100); }); } else { fCallback(null, sUid); } return true; }; IframeDriver.prototype.generateNewInput = function (oClickElement) { var self = this, sUid = '', oInput = null, oIframe = null, sAction = Utils.getValue(this.oOptions, 'action', ''), oForm = null ; if (oClickElement) { sUid = Utils.getNewUid(); oInput = Utils.getNewInput(Utils.getValue(this.oOptions, 'name', 'juaFile'), !Utils.getValue(this.oOptions, 'disableMultiple', false)); oForm = $('
'); oIframe = $('