public_html/layouts/basic/modules/Documents/resources/Edit.min.js.map
{"version":3,"file":"Edit.min.js","sources":["Edit.js"],"sourcesContent":["/*+***********************************************************************************\n * The contents of this file are subject to the vtiger CRM Public License Version 1.0\n * (\"License\"); You may not use this file except in compliance with the License\n * The Original Code is: vtiger CRM Open Source\n * The Initial Developer of the Original Code is vtiger.\n * Portions created by vtiger are Copyright (C) vtiger.\n * All Rights Reserved.\n * Contributor(s): YetiForce S.A.\n *************************************************************************************/\n'use strict';\n\nVtiger_Edit_Js(\n\t'Documents_Edit_Js',\n\t{},\n\t{\n\t\tINTERNAL_FILE_LOCATION_TYPE: 'I',\n\t\tEXTERNAL_FILE_LOCATION_TYPE: 'E',\n\n\t\tisFileLocationInternalType: function (fileLocationElement) {\n\t\t\tif (fileLocationElement.val() == this.INTERNAL_FILE_LOCATION_TYPE) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\treturn false;\n\t\t},\n\n\t\tisFileLocationExternalType: function (fileLocationElement) {\n\t\t\tif (fileLocationElement.val() == this.EXTERNAL_FILE_LOCATION_TYPE) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\treturn false;\n\t\t},\n\n\t\tconvertFileSizeInToDisplayFormat: function (fileSizeInBytes) {\n\t\t\tvar i = -1;\n\t\t\tvar byteUnits = [' kB', ' MB', ' GB', ' TB', 'PB', 'EB', 'ZB', 'YB'];\n\t\t\tdo {\n\t\t\t\tfileSizeInBytes = fileSizeInBytes / 1024;\n\t\t\t\ti++;\n\t\t\t} while (fileSizeInBytes > 1024);\n\n\t\t\treturn Math.max(fileSizeInBytes, 0.1).toFixed(1) + byteUnits[i];\n\t\t},\n\n\t\tregisterFileLocationTypeChangeEvent: function (container) {\n\t\t\tvar thisInstance = this;\n\t\t\tcontainer.on('change', 'select[name=\"filelocationtype\"]', function (e) {\n\t\t\t\tvar fileLocationTypeElement = container.find('[name=\"filelocationtype\"]');\n\t\t\t\tvar fileNameElement = container.find('[name=\"filename\"]');\n\t\t\t\tvar newFileNameElement;\n\t\t\t\tif (thisInstance.isFileLocationInternalType(fileLocationTypeElement)) {\n\t\t\t\t\tnewFileNameElement = jQuery('<input type=\"file\"/>');\n\t\t\t\t} else {\n\t\t\t\t\tnewFileNameElement = jQuery('<input type=\"text\" />');\n\t\t\t\t}\n\t\t\t\tvar oldElementAttributeList = fileNameElement.get(0).attributes;\n\n\t\t\t\tfor (var index = 0; index < oldElementAttributeList.length; index++) {\n\t\t\t\t\tvar attributeObject = oldElementAttributeList[index];\n\t\t\t\t\t//Dont update the type attribute\n\t\t\t\t\tif (attributeObject.name == 'type' || attributeObject.name == 'value' || attributeObject.name == 'class') {\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\tvar value = attributeObject.value;\n\t\t\t\t\tvar className = '';\n\t\t\t\t\tif (attributeObject.name == 'data-fieldinfo') {\n\t\t\t\t\t\tvalue = JSON.parse(value);\n\t\t\t\t\t\tif (thisInstance.isFileLocationExternalType(fileLocationTypeElement)) {\n\t\t\t\t\t\t\tvalue['type'] = 'url';\n\t\t\t\t\t\t\tclassName = 'form-control';\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tvalue['type'] = 'file';\n\t\t\t\t\t\t}\n\t\t\t\t\t\tvalue = JSON.stringify(value);\n\t\t\t\t\t}\n\t\t\t\t\tnewFileNameElement.attr(attributeObject.name, value);\n\t\t\t\t\tnewFileNameElement.addClass(className);\n\t\t\t\t}\n\t\t\t\tfileNameElement.replaceWith(newFileNameElement);\n\t\t\t\tvar fileNameElementTd = newFileNameElement.closest('.fieldValue');\n\t\t\t\tvar uploadFileDetails = fileNameElementTd.find('.uploadedFileDetails');\n\t\t\t\tif (thisInstance.isFileLocationExternalType(fileLocationTypeElement)) {\n\t\t\t\t\tuploadFileDetails.addClass('d-none').removeClass('show');\n\t\t\t\t} else {\n\t\t\t\t\tuploadFileDetails.addClass('show').removeClass('d-none');\n\t\t\t\t}\n\t\t\t});\n\t\t},\n\n\t\tregisterFileChangeEvent: function (container) {\n\t\t\tvar thisInstance = this;\n\n\t\t\tcontainer.on('change', 'input[name=\"filename\"]', function (e) {\n\t\t\t\tif (e.target.type === 'text') {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t\tlet element = container.find('[name=\"filename\"]');\n\t\t\t\t//ignore all other types than file\n\t\t\t\tif (element.attr('type') !== 'file') {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tlet uploadFileSizeHolder = element.closest('.fileUploadContainer').find('.uploadedFileSize');\n\t\t\t\tlet fileSize = element.get(0).files[0].size;\n\t\t\t\tif (fileSize > CONFIG['maxUploadLimit']) {\n\t\t\t\t\tapp.showAlert(app.vtranslate('JS_UPLOADED_FILE_SIZE_EXCEEDS'));\n\t\t\t\t\telement.val('');\n\t\t\t\t\tuploadFileSizeHolder.text('');\n\t\t\t\t} else {\n\t\t\t\t\tuploadFileSizeHolder.text(thisInstance.convertFileSizeInToDisplayFormat(fileSize));\n\t\t\t\t}\n\t\t\t});\n\t\t},\n\n\t\t/**\n\t\t * Function to save the quickcreate module\n\t\t * @param accepts form element as parameter\n\t\t * @returns {Promise}\n\t\t */\n\t\tquickCreateSave: function (form) {\n\t\t\tvar thisInstance = this;\n\t\t\tvar aDeferred = jQuery.Deferred();\n\t\t\t//Using formData object to send data to server as a multipart/form-data form submit\n\t\t\tvar formData = new FormData(form[0]);\n\t\t\tvar fileLocationTypeElement = form.find('[name=\"filelocationtype\"]');\n\t\t\tvar params = {\n\t\t\t\turl: 'index.php',\n\t\t\t\ttype: 'POST',\n\t\t\t\tdata: formData,\n\t\t\t\tprocessData: false,\n\t\t\t\tcontentType: false\n\t\t\t};\n\t\t\tAppConnector.request(params)\n\t\t\t\t.done(function (data) {\n\t\t\t\t\taDeferred.resolve(data);\n\t\t\t\t})\n\t\t\t\t.fail(function (textStatus, errorThrown) {\n\t\t\t\t\taDeferred.reject(textStatus, errorThrown);\n\t\t\t\t});\n\t\t\treturn aDeferred.promise();\n\t\t},\n\t\tregisterBasicEvents: function (container) {\n\t\t\tthis._super(container);\n\t\t\tthis.registerFileLocationTypeChangeEvent(container);\n\t\t\tthis.registerFileChangeEvent(container);\n\t\t},\n\n\t\tregisterEvents: function () {\n\t\t\tthis._super();\n\t\t}\n\t}\n);\n"],"names":["Vtiger_Edit_Js","INTERNAL_FILE_LOCATION_TYPE","EXTERNAL_FILE_LOCATION_TYPE","isFileLocationInternalType","fileLocationElement","val","isFileLocationExternalType","convertFileSizeInToDisplayFormat","fileSizeInBytes","i","Math","max","toFixed","registerFileLocationTypeChangeEvent","container","thisInstance","on","newFileNameElement","fileLocationTypeElement","find","fileNameElement","jQuery","attributeObject","oldElementAttributeList","get","attributes","index","length","name","value","className","JSON","parse","type","stringify","attr","addClass","replaceWith","fileNameElementTd","closest","uploadFileDetails","removeClass","registerFileChangeEvent","e","target","element","uploadFileSizeHolder","fileSize","files","size","CONFIG","maxUploadLimit","app","showAlert","vtranslate","text","quickCreateSave","form","aDeferred","Deferred","formData","FormData","AppConnector","request","url","data","processData","contentType","done","resolve","fail","textStatus","errorThrown","reject","promise","registerBasicEvents","_super","registerEvents"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,uFACA,YAAY,CAEZA,cAAc,CACb,mBAAmB,CACnB,EAAE,CACF,CACCC,2BAA2B,CAAE,GAAG,CAChCC,2BAA2B,CAAE,GAAG,CAEhCC,0BAA0B,CAAE,SAAAA,0BAAAA,CAAUC,mBAAmB,CAAE,UACtDA,mBAAmB,CAACC,GAAG,EAAE,EAAI,IAAI,CAACJ,2BAA2B,CAIlE,CAAC,CAEDK,0BAA0B,CAAE,SAAAA,0BAAUF,CAAAA,mBAAmB,CAAE,CAAA,OAAA,EACtDA,mBAAmB,CAACC,GAAG,EAAE,EAAI,IAAI,CAACH,2BAA2B,CAIlE,CAAC,CAEDK,gCAAgC,CAAE,SAAAA,gCAAAA,CAAUC,eAAe,CAAE,CACxD,IAAAC,CAAC,CAAG,CAAC,CAAC,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