1/* 2 Author: Igor Mirochnik 3 Site: http://ida-freewares.ru 4 Site: http://im-cloud.ru 5 Email: [email protected] 6 Type: commercial 7*/ 8 9function IMCallMeAskMe_getQueryParam(name) { 10 var results = new RegExp('[\\?&]' + name + '=([^&#]*)').exec(window.location.href.split('#')[0]); 11 if (results) 12 return results[1]; 13 else 14 return ''; 15} 16 17// ЧÑÐ¾Ð±Ñ ÑобиÑаÑÑ disabled 18(function ($) { 19 $.fn.serializeAll = function () { 20 var data = $(this).serializeArray(); 21 22 $(':disabled[name]', this).each(function () { 23 data.push({ name: this.name, value: $(this).val() }); 24 }); 25 26 return data; 27 } 28})(jQuery); 29 30function IMCallMeAskMe_collectParams(form) { 31 var sendArray = form.serializeAll(), 32 queryArray = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_content', 'utm_term'] 33 ; 34 35 // Ð¡Ð¾Ñ ÑанÑем UTM меÑки 36 for (var cnt = 0; cnt < queryArray.length; cnt++) { 37 sendArray.push({ 38 name: queryArray[cnt], 39 value: IMCallMeAskMe_getQueryParam(queryArray[cnt]) 40 }); 41 } 42 43 return sendArray; 44} 45 46function IMCallMeAskMe_afterSubmit(container, form, json) 47{ 48 var jq = jQuery 49 ; 50 container.find('.alert, .text-danger').remove(); 51 52 if (json['error']) { 53 if (json['errors']) { 54 for (var cnt = 0; cnt < json['errors'].length; cnt++) { 55 form.prepend( 56 '<div class="alert alert-warning">' 57 + json['errors'][cnt] 58 + '<button type="button" class="close" data-dismiss="alert">×</button>' 59 + '</div>' 60 ); 61 } 62 } 63 64 for (i in json['messages']) { 65 var element = container.find('input[name="' + i + '"], textarea[name="' + i + '"]'); 66 element.closest('.form-group').addClass('has-error'); 67 } 68 69 if (json['email_send']) { 70 var element = jq('<div class="alert alert-danger" role="alert"></div>'); 71 element.text(json['email_send']); 72 form.prepend(element); 73 } 74 75 // Highlight any found errors 76 jq('.text-danger').parent().addClass('has-error'); 77 } 78 else { 79 var status_complete = jQuery( 80 '<div class="alert alert-success">' 81 + json['complete'] 82 + '</div>' 83 ); 84 status_complete.insertBefore(form.find('*:first')); 85 container.find('#imcallask-form-container-popup').fadeOut(3000, function() { 86 // Удаление ÑоÑмÑ, еÑли вÑе коÑÑекÑно оÑпÑавлено (Ð´Ð»Ñ Ð¿Ð¾Ð²ÑоÑной загÑÑзки) 87 jq('#imcallask-form-container-popup').on('hidden.bs.modal', function () { 88 if (jq(this).find('form .alert-success').length > 0) { 89 jq('.imcallask-form-container').remove(); 90 } 91 }); 92 jq(this).modal('hide'); 93 //form.find('.alert-success').remove(); 94 });//.modal('hide'); 95 } 96} 97 98function IMCallMeAskMe_formSubmit(container) { 99 container.find('form').submit(function (e) { 100 e.preventDefault(); 101 102 var jq = jQuery, 103 form = jq(this), 104 submit = form.find('button[type=submit]') 105 ; 106 107 container.find('.has-error').removeClass('has-error'); 108 109 jq.ajax({ 110 url: form.attr('action'), 111 type: 'post', 112 cache: false, 113 data: IMCallMeAskMe_collectParams(form), 114 dataType: 'json', 115 beforeSend: function() { 116 submit.button('loading'); 117 }, 118 complete: function() { 119 submit.button('reset'); 120 }, 121 success: function(json) { 122 IMCallMeAskMe_afterSubmit(container, form, json); 123 }, 124 error: function(xhr, ajaxOptions, thrownError) { 125 alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText); 126 } 127 }); 128 129 return false; 130 }); 131} 132 133function IMCallMeAskMe_loadFile(container) 134{ 135 var mainForm = container.find('form'), 136 uploads = mainForm.find('.imcallask-file-upload'), 137 jq = jQuery 138 ; 139 140 if (uploads.length == 0) { 141 return; 142 } 143 144 uploads.find('button').click(function () { 145 var item = jq(this), 146 itemFormControl = item.closest('.imcallask-file-upload') 147 ; 148 149 mainForm.find('.alert-warning').remove(); 150 itemFormControl.find('.text-danger').remove(); 151 152 jq('.imcallask-file-upload-form').remove(); 153 154 jq('body').append( 155 '<form enctype="multipart/form-data" ' 156 + 'class="imcallask-file-upload-form" ' 157 + '>' 158 +'<input type="file" name="file" />' 159 + '</form>' 160 ); 161 162 var form = jq('.imcallask-file-upload-form'), 163 inputFile = form.find('input[name="file"]') 164 ; 165 166 inputFile.change(function (){ 167 168 jq.ajax('index.php?route=tool/upload',{ 169 type: 'post', 170 data: new FormData(form[0]), 171 dataType: 'json', 172 cache: false, 173 contentType: false, 174 processData: false, 175 beforeSend: function() { 176 item.button('loading'); 177 }, 178 complete: function() { 179 item.button('reset'); 180 }, 181 success: function(json) { 182 if (json['error']) { 183 item.closest('.input-group').after( 184 '<div class="text-danger">' 185 + json['error'].replace(/<[^>]+>/g, '') 186 + '</div>' 187 ); 188 itemFormControl.find('input[type="hidden"]').val(''); 189 itemFormControl.find('input[type="text"]').val(''); 190 } else if (json['success']) { 191 itemFormControl.find('input[type="hidden"]').val(json['code']); 192 193 var fileName = inputFile.val() 194 fileNameArray = fileName.split('\\') 195 ; 196 197 fileName = fileNameArray[fileNameArray.length - 1], 198 fileName = fileName.replace(/<!--(.*?)[-][-][>]/g, ''); 199 fileName = fileName.replace(/<[^>]+>/g, ''); 200 //fileName = escape(fileName); 201 202 itemFormControl.find('input[type="text"]').val(fileName); 203 } 204 }, 205 error: function(xhr, ajaxOptions, thrownError) { 206 alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText); 207 item.button('reset'); 208 } 209 210 });
211 212 }); 213 214 inputFile.trigger('click'); 215 }); 216} 217 218function IMCallMeAskMe_formPopup () { 219 var jq = jQuery 220 ; 221 222 if (jq('.imcallask-form-container').length > 0) { 223 jq('.imcallask-form-container #imcallask-form-container-popup').modal(); 224 } 225 else { 226 var container = jq('<div class="imcallask-form-container">') 227 ; 228 229 jQuery('body').append(container); 230 231 jq.ajax('index.php?route=module/IMCallMeAskMe/getPopup', { 232 success: function (html) { 233 var hidden = jq('<input type="hidden" name="url" value="">'); 234 235 container.html(html); 236 237 container.find('form').append(hidden); 238 239 hidden.val(encodeURIComponent(window.location)); 240 241 container.find('#imcallask-form-container-popup').modal(); 242 IMCallMeAskMe_formSubmit(container); 243 IMCallMeAskMe_loadFile(container); 244 } 245 }); 246 } 247} 248 249function IMCallMeAskMe_createButton() { 250 var jq = jQuery, 251 btn = jq('<a href="#" class="imcallask-btn-mini"><div class="imcallask-btn-mini-phone"></div></a>') 252 ; 253 254 jq('body').append(btn); 255 256 btn.click(function (e) { 257 e.preventDefault(); 258 IMCallMeAskMe_formPopup(); 259 return false; 260 }); 261} 262 263jQuery(function () { 264 var jq = jQuery 265 ; 266 // ÐÑли полÑзоваÑÐµÐ»Ñ Ñам ÑÑÑановил 267 if (jq('.imcallask-click').length > 0) { 268 jq('.imcallask-click').click(function (e) { 269 e.preventDefault(); 270 IMCallMeAskMe_formPopup(); 271 return false; 272 }); 273 } 274 else { 275 IMCallMeAskMe_createButton(); 276 } 277 278 // ÐополниÑелÑнÑе ÑлеменÑÑ 279 jq('.imcallask-click-additional').click(function (e) { 280 e.preventDefault(); 281 IMCallMeAskMe_formPopup(); 282 return false; 283 }); 284});
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.