1var scrollEvents = ['scroll', 'mousewheel','wheel']; 2function func(e){ 3 e.preventDefault(); 4 e.stopPropagation(); 5 return false; 6}; 7function freezeScroll(elem, status=true) { 8 let options = { 9 passive: false 10 }; 11 if(status) { 12 scrollEvents.forEach(function (item) { 13 if(item == "scroll"){ 14 var current = $(window).scrollTop(); 15 $(window).scroll(function() { $(window).scrollTop(current);}); 16 } else { 17 elem.addEventListener(item, func, options); 18 } 19 }); 20 } 21 else { 22 scrollEvents.forEach(function (item) { 23 if(item == "scroll"){ 24 $(window).off('scroll'); 25 } else { 26 elem.removeEventListener(item, func, options); 27 } 28 }); 29 } 30} 31 32!(function($, window, document, undefined){ 33 $.fn.extend({ 34 popupAjaxForm: function(options){ 35 const 36 $body = $("body"), 37 pluginPath = window.location.protocol + '//' + window.location.hostname + '/ajaxforms', 38 maskPath = pluginPath + '/js/jquery.mask.js', 39 linkPath = pluginPath + '/tpl/ajaxforms-styles.css'; 40 41 var 42 config = $.extend({}, { 43 id: 'pp-01', 44 mask: "+7 (999) 999-99-99" 45 }, options), 46 params = { 47 id:{ 48 form: 'thisform', 49 overlay: 'overlay', 50 }, 51 cl:{ 52 main: 'ajaxform', 53 scrlstop: 'stop-scrolling', 54 phonemask: 'phonefield' 55 }, 56 tpl: pluginPath + '/tpl/' + config.id + '.php' 57 }, 58 methods = { 59 init: function(){ 60 var stylelink = { 61 type: 'text/css', 62 rel: 'stylesheet', 63 id: 'ajaxforms', 64 href: linkPath 65 }, 66 m = "#" + config.id; 67 68 if (!$("link[href*='ajaxforms']").length) { 69 $('<link>').attr(stylelink).appendTo('head'); 70 } 71 $.get(params.tpl, function(data) { 72 if($(m).length < 1){ 73 $body.append(data); 74 } 75 },'html'); 76 }, 77 78 lockScroll: function(){ 79 freezeScroll(document.body); 80 }, 81 unlockScroll: function(){ 82 freezeScroll(document.body, false); 83 }, 84 clearform() { 85 this.handler = setTimeout(function () { 86 var m = "#" + config.id + ' form'; 87 $(m + ' input[type="text"], ' + m + ' textarea').val('').removeClass('error'); 88 if ((m + ' label').length) { 89 $(m).find('label.error').remove(); 90 } 91 $(m + ' > div.loadBar').css({ 92 'height': '0', 93 'background': '#fff' 94 }).empty(); 95 $(m + ' input[type="checkbox"]').prop("checked",false); 96 $(m + ' button.button.send').attr("disabled","disabled"); 97 if($(m).attr('id') == params.id.form){ 98 $(m).removeAttr('id'); 99 } 100 methods.init(); 101 }, 100); 102 }, 103 hide: function(){ 104 var f = "#" + config.id, 105 m = "#" + params.id.form, 106 c = "." + params.cl.main, 107 o = "#" + params.id.overlay; 108 109 this.unlockScroll(); 110 $body.find(o).fadeOut(); 111 112 if (!$(f).find(m).length) { 113 $(m).find(c).attr('id', m); 114 } 115 $(document).find(f).addClass('hidden'); 116 117 setTimeout(function () { 118 methods.clearform(); 119 }, 200); 120 }, 121 showPopup: function(){ 122 var m = "#" + config.id, 123 o = "#" + params.id.overlay, 124 el = m + " form" , 125 pm = "." + params.cl.phonemask; 126 127 function applyMask(selector) { 128 setTimeout(function() { 129 var $phoneField = $(selector); 130 if ($phoneField.length) { 131 $phoneField.mask(config.mask, { 132 selectOnFocus: true, 133 clearIfNotMatch: true 134 }); 135 136 if ($phoneField.val().trim() === '') { 137 $phoneField.val('+7'); 138 setTimeout(function() { 139 if ($phoneField[0]) { 140 $phoneField[0].setSelectionRange(5, 5); 141 } 142 }, 50); 143 } 144 } 145 }, 100); 146 } 147 148 function showNow(){ 149 if (window.screen.width > 767) { 150 methods.lockScroll(); 151 } 152 $body.find(o).fadeIn(); 153 154 $body.find(m).removeClass('hidden').on("mouseup", function (e){ 155 if ($(e.target).parents(m).length === 0 || $(e.target).closest(".close").length) { 156 methods.hide(); 157 } 158 }); 159 160 if (typeof $.fn.mask === 'undefined') { 161 $.getScript(maskPath, function() { 162 applyMask(pm); 163 }); 164 } else { 165 applyMask(pm); 166 } 167 } 168 169 if(config.id !== 'pp-00'){ 170 var input = $("#payment-individual").find('input'); 171 var select = $("#payment-individual").find('select'); 172 173 if ((input.val() == '') && (select.val() == '')) { 174 alert('ÐÑ Ð½Ðµ заполнили ÑоÑмÑ!'); 175 return false;
176 } else { 177 showNow(); 178 return true; 179 } 180 } else { 181 showNow(); 182 } 183 } 184 }; 185 186 function main(e) { 187 methods.init(); 188 e.click(function(event){ 189 event.preventDefault(); 190 methods.showPopup(); 191 var sf = new ajaxsend(); 192 $('body').on('click', '#ajax-send',function(event){ 193 event.preventDefault(); 194 sf.send(config.id); 195 }); 196 }); 197 } 198 199 this.each(function() { 200 if (options) { 201 $.extend(config, options); 202 } 203 main($(this)); 204 }); 205 206 return this; 207 } 208 }); 209 210 function ajaxsend(){ 211 const 212 $body = $("body"), 213 pluginPath = window.location.protocol + '//' + window.location.hostname + '/ajaxforms', 214 validatePath = '//ajax.aspnetcdn.com/ajax/jquery.validate/1.15.0/jquery.validate.min.js', 215 spinPath = pluginPath + '/js/spin.min.js', 216 spinOptions={lines:13,length:20,width:6,radius:13,scale:1,corners:1,color:'#fff',opacity:0.25,rotate:0,direction:1,speed:1.3,trail:60,fps:20,zIndex:2e9,className:'spinner',top:'50%',left:'50%',shadow:false,hwaccel:false,position:'absolute'}, 217 handlerPath = pluginPath + '/lib/special/sendform.php', 218 errMessages = ['ÐбÑзаÑелÑное поле', 'ÐинимÑм 3 знака','Ðе вÑе ÑиÑÑÑ','ÐÑибка в e-mail'], 219 validateOptions = { 220 debug:false, 221 rules:{ 222 name:{ 223 required:true, 224 minlength:3 225 }, 226 phone:{ 227 required:true, 228 minlength:18 229 }, 230 email:{ 231 required: true, 232 email: true 233 } 234 }, 235 messages:{ 236 name:{ 237 required: errMessages[0], 238 minlength: errMessages[1] 239 }, 240 phone:{ 241 required: errMessages[0], 242 minlength: errMessages[2] 243 }, 244 email:{ 245 required: errMessages[0], 246 email: errMessages[3] 247 } 248 } 249 }; 250 251 function init(){ 252 $body.on('focus', '.ajaxform input[type="text"], .ajaxform input[type="number"]', function (e) { 253 var $ajaxform = $(e.target).closest('.ajaxform'); 254 255 if ($ajaxform.attr('id') !== 'thisform') { 256 if(!$('#thisform').length){ 257 if ($ajaxform.attr('id') !== 'undefined') { 258 $($ajaxform).removeAttr('id'); 259 } 260 $ajaxform.attr({ id: 'thisform' }); 261 } 262 } 263 }); 264 } 265 266 function toggleSpin() { 267 if (!$('.spinner').length) { 268 var target = document.getElementById('spinnercontainer'); 269 spinner = new Spinner(spinOptions).spin(target); 270 $('#spinnercontainer').addClass('display'); 271 } else { 272 spinner.stop(); 273 $('#spinnercontainer').removeClass('display').find('.spinner').remove(); 274 } 275 } 276 277 function sendform(popup) { 278 $.getScript(validatePath, function(){ 279 var $form = $('#thisform'); 280 $form.validate(validateOptions); 281 282 if ($form.valid()) { 283 $.getScript(spinPath).done(function () { 284 toggleSpin(); 285 console.log(handlerPath); 286 $.post(handlerPath, $form.serialize(), function (response) { 287 if(response == '111'){ 288 toggleSpin(); 289 $('#pp-00 .ajaxform').addClass('success'); 290 setTimeout(function(){ 291 $('#pp-00').addClass('hidden'); 292 setTimeout(function(){ 293 $('#pp-00 .ajaxform').removeClass('success'); 294 freezeScroll(document.body, false); 295 $('.ajaxform').find('input[type="text"]').val(""); 296 },800); 297 },400); 298 } else { 299 console.log(response); 300 return false; 301 } 302 }); 303 }).fail(function(jqxhr, settings, exception) { 304 console.log(jqxhr);console.log(settings);console.log(exception); 305 }); 306 } 307 }, true); 308 } 309 310 init(); 311 this.send = sendform; 312 } 313 314 $(function(){ 315 $('#call-callback-ajaxforms, #call-callback-ajaxforms-home').popupAjaxForm({'id':'pp-00'}); 316 }); 317})(jQuery, window, document);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.