YetiForceCompany/YetiForceCRM

View on GitHub
public_html/layouts/resources/Connector.min.js.map

Summary

Maintainability
Test Coverage
{"version":3,"file":"Connector.min.js","sources":["Connector.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 *************************************************************************************/\n'use strict';\n\nwindow.AppConnector = {\n\t/**\n\t * Sends a pjax request (push state +ajax)\n\t * The function is deferred. it will be resolved on success and error on failure\n\t *  Success - if request is success it will send you data that it recieved\n\t *  error - it will send two parameters first gives string regarding error\n\t *                   Second gives you error object if exists\n\t *\n\t *  @return - deferred promise\n\t */\n\trequestPjax: function (params) {\n\t\treturn AppConnector._request(params, true);\n\t},\n\n\t/**\n\t *  Sends ajax request to the specified url.\n\t *  The function is deferred. it will be resolved on success and error on failure\n\t *  Success - if request is success it will send you data that it recieved\n\t *  error - it will send two parameters first gives string regarding error\n\t *                   Second gives you error object if exists\n\t *\n\t *  @return - deferred promise\n\t */\n\trequest: function (params, rawData) {\n\t\treturn AppConnector._request(params, false, rawData);\n\t},\n\n\t_request: function (params, pjaxMode, rawData) {\n\t\tconst aDeferred = jQuery.Deferred();\n\t\tif (typeof rawData === 'undefined') {\n\t\t\trawData = false;\n\t\t}\n\t\tif (typeof pjaxMode === 'undefined') {\n\t\t\tpjaxMode = false;\n\t\t}\n\t\tif (typeof params === 'undefined') {\n\t\t\tparams = {};\n\t\t}\n\t\tlet fullUrl = '',\n\t\t\tindex,\n\t\t\tcallerParams;\n\t\t//caller has send only data\n\t\tif (typeof params.data === 'undefined' || rawData) {\n\t\t\tif (typeof params === 'string') {\n\t\t\t\tcallerParams = fullUrl = params;\n\t\t\t\tindex = callerParams.indexOf('?');\n\t\t\t\tif (index !== -1) {\n\t\t\t\t\tlet subStr = callerParams.substr(0, index + 1); //need to replace only \"index.php?\" or \"?\"\n\t\t\t\t\tcallerParams = callerParams.replace(subStr, '');\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tcallerParams = $.extend({}, params);\n\t\t\t}\n\t\t\tparams = {};\n\t\t\tparams.data = callerParams;\n\t\t}\n\t\t//Make the request as post by default\n\t\tif (typeof params.type === 'undefined' || rawData) params.type = 'POST';\n\t\tif (typeof params.jsonp === 'undefined' || rawData) params.jsonp = false;\n\n\t\t//By default we expect json from the server\n\t\tif (typeof params.dataType === 'undefined' || rawData) {\n\t\t\tlet data = params.data;\n\t\t\t//view will return html\n\t\t\tparams.dataType = 'json';\n\t\t\tif (data.hasOwnProperty('view')) {\n\t\t\t\tparams.dataType = 'html';\n\t\t\t} else if (typeof data === 'string' && data.indexOf('&view=') !== -1) {\n\t\t\t\tparams.dataType = 'html';\n\t\t\t}\n\t\t\tif (typeof params.url !== 'undefined' && params.url.indexOf('&view=') !== -1) {\n\t\t\t\tparams.dataType = 'html';\n\t\t\t}\n\t\t}\n\t\t//If url contains params then seperate them and make them as data\n\t\tif (typeof params.url !== 'undefined' && params.url.indexOf('?') !== -1) {\n\t\t\tfullUrl = params.url;\n\t\t\tlet urlSplit = params.url.split('?'),\n\t\t\t\tqueryString = urlSplit[1];\n\t\t\tparams.url = urlSplit[0];\n\t\t\tlet queryParameters = queryString.split('&');\n\t\t\tfor (index = 0; index < queryParameters.length; index++) {\n\t\t\t\tlet queryParam = queryParameters[index],\n\t\t\t\t\tqueryParamComponents = queryParam.split('=');\n\t\t\t\tparams.data[queryParamComponents[0]] = queryParamComponents[1];\n\t\t\t}\n\t\t}\n\t\tif (typeof params.url === 'undefined' || params.url.length <= 0) {\n\t\t\tparams.url = 'index.php';\n\t\t}\n\t\tparams.success = function (data, status, jqXHR) {\n\t\t\tif (data !== null && typeof data === 'object' && data.error) {\n\t\t\t\tapp.errorLog(data.error);\n\t\t\t\tif (data.error.message) {\n\t\t\t\t\tVtiger_Helper_Js.showMessage({\n\t\t\t\t\t\ttext: data.error.message,\n\t\t\t\t\t\ttype: 'error'\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t\taDeferred.resolve(data);\n\t\t};\n\t\tparams.error = function (jqXHR, textStatus, errorThrown) {\n\t\t\tlet action = jqXHR.getResponseHeader('yf-action');\n\t\t\tif (action === 'logout') {\n\t\t\t\twindow.location.href = 'index.php';\n\t\t\t}\n\t\t\tif (CONFIG.debug) {\n\t\t\t\tif (jqXHR.status === 406) {\n\t\t\t\t\tlet sep = '-'.repeat(150);\n\t\t\t\t\tconsole.warn(\n\t\t\t\t\t\t'%cYetiForce debug mode!!!',\n\t\t\t\t\t\t'color: red; font-family: sans-serif; font-size: 1.5em; font-weight: bolder; text-shadow: #000 1px 1px;'\n\t\t\t\t\t);\n\t\t\t\t\tconsole.error(\n\t\t\t\t\t\t'Error: ' + errorThrown,\n\t\t\t\t\t\t'\\n' + sep + '\\nTrace:\\n' + sep + '\\n' + (jqXHR.responseJSON ? jqXHR.responseJSON.error.trace : ''),\n\t\t\t\t\t\t'\\n' + sep + '\\nParams:\\n' + sep + '\\n' + JSON.stringify(params, null, '\\t')\n\t\t\t\t\t);\n\t\t\t\t} else {\n\t\t\t\t\tapp.errorLog(jqXHR, textStatus, errorThrown);\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (textStatus == 'error' && jqXHR.responseJSON) {\n\t\t\t\ttextStatus = jqXHR.responseJSON.error.message;\n\t\t\t}\n\t\t\taDeferred.reject(textStatus, errorThrown, jqXHR);\n\t\t};\n\t\tif (params.data === '') {\n\t\t\tapp.showNotify({ type: 'error', title: app.vtranslate('JS_ERROR') });\n\t\t\treturn aDeferred.reject();\n\t\t}\n\t\tjQuery.ajax(params);\n\t\tif (pjaxMode) {\n\t\t\tapp.changeUrl(params);\n\t\t}\n\t\treturn aDeferred.promise();\n\t},\n\t/**\n\t * Send form data\n\t * @param {string} url\n\t * @param {object} postData\n\t * @param {object} formAttr\n\t */\n\trequestForm: function (url, postData = {}, formAttr = {}) {\n\t\t$.extend(formAttr, {\n\t\t\tmethod: 'post',\n\t\t\taction: url,\n\t\t\tstyle: 'display:none;'\n\t\t});\n\t\tlet form = $('<form></form>', formAttr);\n\t\tif (typeof csrfMagicName !== 'undefined') {\n\t\t\tpostData[csrfMagicName] = csrfMagicToken;\n\t\t}\n\t\t$.each(postData, (index, value) => {\n\t\t\tlet isMultiple = typeof value === 'object' && value.length && index.slice(-2) === '[]';\n\t\t\tconst item = document.createElement(isMultiple ? 'select' : 'input');\n\n\t\t\titem.setAttribute('type', 'hidden');\n\t\t\titem.setAttribute('name', index);\n\n\t\t\tif (isMultiple) {\n\t\t\t\titem.setAttribute('multiple', 'multiple');\n\t\t\t\tfor (let i in value) {\n\t\t\t\t\tlet option = document.createElement('option');\n\t\t\t\t\toption.setAttribute('value', value[i]);\n\t\t\t\t\toption.setAttribute('selected', true);\n\t\t\t\t\titem.appendChild(option);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\titem.setAttribute('value', value);\n\t\t\t}\n\t\t\tform.append(item);\n\t\t});\n\t\t$('body').append(form);\n\t\tform.trigger('submit');\n\t\tform.remove();\n\t}\n};\n"],"names":["_typeof","o","Symbol","iterator","constructor","prototype","window","AppConnector","requestPjax","params","_request","request","rawData","pjaxMode","aDeferred","jQuery","Deferred","index","callerParams","fullUrl","data","$","extend","indexOf","subStr","substr","replace","type","jsonp","dataType","hasOwnProperty","url","urlSplit","split","queryString","queryParameters","length","queryParam","queryParamComponents","success","error","app","errorLog","message","Vtiger_Helper_Js","showMessage","text","resolve","jqXHR","textStatus","errorThrown","action","getResponseHeader","location","href","CONFIG","debug","status","repeat","console","warn","responseJSON","trace","JSON","stringify","reject","showNotify","title","vtranslate","ajax","changeUrl","promise","requestForm","postData","arguments","formAttr","method","style","form","csrfMagicName","csrfMagicToken","each","value","isMultiple","slice","item","document","createElement","setAttribute","i","option","appendChild","append","trigger","remove"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;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