| [ Index ] |
PHP Cross Reference of vtigercrm-6.1.0 |
[Summary view] [Print] [Text view]
1 /*+*********************************************************************************** 2 * The contents of this file are subject to the vtiger CRM Public License Version 1.0 3 * ("License"); You may not use this file except in compliance with the License 4 * The Original Code is: vtiger CRM Open Source 5 * The Initial Developer of the Original Code is vtiger. 6 * Portions created by vtiger are Copyright (C) vtiger. 7 * All Rights Reserved. 8 *************************************************************************************/ 9 10 Settings_Vtiger_Detail_Js('Settings_Webforms_Detail_Js', { 11 12 /* 13 * function to trigger delete record action 14 * @params: delete record url. 15 */ 16 deleteRecord : function(deleteRecordActionUrl) { 17 var message = app.vtranslate('LBL_DELETE_CONFIRMATION'); 18 Vtiger_Helper_Js.showConfirmationBox({'message' : message}).then(function(data) { 19 AppConnector.request(deleteRecordActionUrl).then( 20 function(data){ 21 if(data.success == true){ 22 window.location.href = data.result; 23 }else{ 24 Vtiger_Helper_Js.showPnotify(data.error.message); 25 } 26 }); 27 }, 28 function(error, err){ 29 } 30 ); 31 }, 32 33 /** 34 * Function to trigger show webform record action 35 * @params: show webform record url 36 */ 37 showForm : function(showFormRecordActionUrl){ 38 AppConnector.request(showFormRecordActionUrl).then( 39 function(data){ 40 var callback = function(container){ 41 //Form should be aas html without rendering 42 var showFormContents = container.find('pre').html(); 43 showFormContents = showFormContents + '<script type="text/javascript">'+ 44 'window.onload = function() { '+ 45 'var N=navigator.appName, ua=navigator.userAgent, tem;'+ 46 'var M=ua.match(/(opera|chrome|safari|firefox|msie)\\/?\\s*(\\.?\\d+(\\.\\d+)*)/i);'+ 47 'if(M && (tem= ua.match(/version\\/([\\.\\d]+)/i))!= null) M[2]= tem[1];'+ 48 'M=M? [M[1], M[2]]: [N, navigator.appVersion, "-?"];'+ 49 'var browserName = M[0];'+ 50 51 'var form = document.forms[0], '+ 52 'inputs = form.elements; '+ 53 'form.onsubmit = function() { '+ 54 'var required = [], att, val; '+ 55 'for (var i = 0; i < inputs.length; i++) { '+ 56 'att = inputs[i].getAttribute("required"); '+ 57 'val = inputs[i].value; '+ 58 'type = inputs[i].type; '+ 59 'if(type == "email") {'+ 60 'if(val != "") {'+ 61 'var elemLabel = inputs[i].getAttribute("label");'+ 62 'var emailFilter = /^[_/a-zA-Z0-9]+([!"#$%&()*+,./:;<=>?\\^_`{|}~-]?[a-zA-Z0-9/_/-])*@[a-zA-Z0-9]+([\\_\\-\\.]?[a-zA-Z0-9]+)*\\.([\\-\\_]?[a-zA-Z0-9])+(\\.?[a-zA-Z0-9]+)?$/;'+ 63 'var illegalChars= /[\\(\\)\\<\\>\\,\\;\\:\\\"\\[\\]]/ ;'+ 64 'if (!emailFilter.test(val)) {'+ 65 'alert("For "+ elemLabel +" field please enter valid email address"); return false;'+ 66 '} else if (val.match(illegalChars)) {'+ 67 'alert(elemLabel +" field contains illegal characters");return false;'+ 68 '}'+ 69 '}'+ 70 '}'+ 71 'if (att != null) { '+ 72 'if (val.replace(/^\\s+|\\s+$/g, "") == "") { '+ 73 'required.push(inputs[i].getAttribute("label")); '+ 74 '} '+ 75 '} '+ 76 '} '+ 77 'if (required.length > 0) { '+ 78 'alert("The following fields are required: " + required.join()); '+ 79 'return false; '+ 80 '} '+ 81 'var numberTypeInputs = document.querySelectorAll("input[type=number]");'+ 82 'for (var i = 0; i < numberTypeInputs.length; i++) { '+ 83 'val = numberTypeInputs[i].value;'+ 84 'var elemLabel = numberTypeInputs[i].getAttribute("label");'+ 85 'if(val != "") {'+ 86 'var intRegex = /^[+-]?\\d+$/;'+ 87 'if (!intRegex.test(val)) {'+ 88 'alert("For "+ elemLabel +" field please enter valid number"); return false;'+ 89 '}'+ 90 '}'+ 91 '}'; 92 if(container.find('[name=isCaptchaEnabled]').val() == true) { 93 showFormContents = Settings_Webforms_Detail_Js.getCaptchaCode(showFormContents); 94 } else { 95 showFormContents = showFormContents + 96 '}; '+ 97 '}'+ 98 '</script>'; 99 } 100 //Html contents should be placed inside textarea element 101 container.find('#showFormContent').text(showFormContents); 102 //Rendering content has been removed from container 103 container.find('pre').remove(); 104 container.find('code').remove(); 105 app.showScrollBar(container.find('#showFormContent'), {'height':'350px'}); 106 } 107 app.showModalWindow(data,callback); 108 }, 109 function(error){ 110 } 111 ) 112 }, 113 114 /** 115 * Function get Captcha Code 116 * @param <string> showFormContents 117 * @return <string> showFormContents 118 */ 119 getCaptchaCode : function(showFormContents) { 120 var captchaContents = '<script type="text/javascript">'+ 121 'var RecaptchaOptions = { theme : "clean" };' + 122 '</script>'+ 123 '<script type="text/javascript"'+ 124 'src="http://www.google.com/recaptcha/api/challenge?k=6Lchg-wSAAAAAIkV51_LSksz6fFdD2vgy59jwa38">'+ 125 '</script>'+ 126 '<noscript>'+ 127 '<iframe src="http://www.google.com/recaptcha/api/noscript?k=6Lchg-wSAAAAAIkV51_LSksz6fFdD2vgy59jwa38"'+ 128 'height="300" width="500" frameborder="0"></iframe><br>'+ 129 '<textarea name="recaptcha_challenge_field" rows="3" cols="40">'+ 130 '</textarea>'+ 131 '<input type="hidden" name="recaptcha_response_field" value="manual_challenge">'+ 132 '</noscript>'; 133 showFormContents = showFormContents.replace('<div id="captchaField"></div>',captchaContents); 134 showFormContents = showFormContents + 135 'var recaptchaValidationValue = document.getElementById("recaptcha_validation_value").value;'+ 136 'if (recaptchaValidationValue!= true){'+ 137 'var recaptchaResponseElement = document.getElementsByName("recaptcha_response_field")[0].value;'+ 138 'var recaptchaChallengeElement = document.getElementsByName("recaptcha_challenge_field")[0].value;'+ 139 'var captchaUrl = document.getElementById("captchaUrl").value;'+ 140 'var url = captchaUrl+"?recaptcha_response_field="+recaptchaResponseElement;'+ 141 'url = url + "&recaptcha_challenge_field="+recaptchaChallengeElement+"&callback=JSONPCallback";'+ 142 'jsonp.fetch(url);'+ 143 'return false;'+ 144 '}'+ 145 '}; '+ 146 '};'+ 147 'var jsonp = {' + 148 'callbackCounter: 0,'+ 149 150 'fetch: function(url) {'+ 151 'url = url +"&callId="+this.callbackCounter;'+ 152 'var scriptTag = document.createElement("SCRIPT");'+ 153 'scriptTag.src = url;'+ 154 'scriptTag.async = true;'+ 155 'scriptTag.id = "JSONPCallback_"+this.callbackCounter;'+ 156 'scriptTag.type = "text/javascript";'+ 157 'document.getElementsByTagName("HEAD")[0].appendChild(scriptTag);'+ 158 'this.callbackCounter++;'+ 159 '}'+ 160 '};'+ 161 'function JSONPCallback(data) {'+ 162 'if(data.result.success == true) {'+ 163 'document.getElementById("recaptcha_validation_value").value = true;'+ 164 'var form = document.forms[0];'+ 165 'form.submit();'+ 166 '} else {'+ 167 'document.getElementById("recaptcha_reload").click();'+ 168 'alert("you entered wrong captcha");'+ 169 '}'+ 170 'var element = document.getElementById("JSONPCallback_"+data.result.callId);'+ 171 'element.parentNode.removeChild(element);'+ 172 '}'+ 173 '</script>'; 174 175 return showFormContents; 176 } 177 }, { 178 /** 179 * Function which will handle the registrations for the elements 180 */ 181 registerEvents : function() { 182 this._super(); 183 Vtiger_Helper_Js.showHorizontalTopScrollBar(); 184 } 185 })
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Fri Nov 28 20:08:37 2014 | Cross-referenced by PHPXref 0.7.1 |