1$(function() { 2 function fixFormId($container) { 3 if ((match = $container.data('api-url').match(/form_id[^=]?=(\d+)/)) && match != null && typeof match[1] !== undefined) { 4 $container.find('[name="form_id"]').val(match[1]); 5 }; 6 } 7 var s3From = { 8 init: function() { 9 this.initForms(); 10 }, 11 initForms: function(parent, callback, from_response) { 12 var self = this; 13 if (!parent) parent = document; 14 if ($(parent)[0] === document || !$(parent).is('[data-api-url][data-api-type=form]')) { 15 parent = $(parent).find('[data-api-url][data-api-type=form]'); 16 } 17 18 if (!callback) { 19 callback = typeof parent.data('callback') === 'function' ? parent.data('callback') : eval(parent.data('callback')); 20 } 21 22 $(parent).each(function() { 23 var $container = $(this); 24 var $form = $container.is("form") ? $container : $container.find("form"); 25 fixFormId($container); 26 if ($container.data('s3form_inited')) { 27 return; 28 } 29 if ($form.length) { 30 $form.submit(function() { 31 $.post($container.data('api-url'), $form.serialize(), res); 32 return false; 33 }); 34 } else if (!from_response) { 35 $.getJSON($container.data('api-url'), null, res); 36 } 37 38 initFormCalendars($form); 39 40 $container.data('s3form_inited', true); 41 42 function res(response) { 43 if (response.result.success && response.result['redirect_url']) { 44 document.location = response.result['redirect_url']; 45 } else if (response.result && response.result.html) { 46 var uploaders_inits = ''; 47 var scripts = response.result.html.match(/<script[^>]*>[^<]*newSWFU[^<]*<\/script>/gm); 48 if (scripts) { 49 for (var i = 0; i < scripts.length; i++) { 50 uploaders_inits += scripts[i].replace(/<script[^>]*>([^<]+)<\/script>/, "$1"); 51 } 52 } 53 var $replacement = $(response.result.html.replace(/[\r\n]/g, '').replace(/<script[^>]*>.*?<\/script>/g, '')); 54 if (!$($replacement).is('[data-api-url][data-api-type=form]')) { 55 $replacement = $($replacement).find('[data-api-url][data-api-type=form]'); 56 } 57 $container.replaceWith($replacement); 58 $container = $replacement; 59 60 var $uploads = $container.find('input[type="hidden"][id^="hidUploadField"]'); 61 62 if ($uploads.length) { 63 if (typeof window['newSWFU'] !== 'function') { 64 $.getScript('/assets/site/s3/swfupload/swfupload.upload.pack.js', function() { 65 inituploaders(); 66 }); 67 } else { 68 inituploaders(); 69 } 70 } 71 72 function inituploaders() { 73 if (uploaders_inits) { 74 eval(uploaders_inits); 75 } 76 } 77 78 self.initForms($container, callback, true); 79 80 if (typeof callback === 'function') { 81 callback(); 82 } 83 } 84 } 85 function initFormCalendars($container) { 86 var formCalendars = $container.find('.s3wm-datepicker-calendar'); 87 var formCalendarsInterval = $container.find('.s3wm-datepicker-calendar_interval'); 88 89 if (!formCalendars.length && !formCalendarsInterval.length) { 90 var siteLang = $('html').attr('lang') !== 'ru' ? 'en' : 'ru'; 91 // Init form calendars 92 $container.find('.init-calendar').each(function(i){ 93 new tcal({ 94 'controlname':this.id, 95 'place':this.parentNode, 96 'lang': siteLang 97 }); 98 99 }); 100 101 // Init form calendar intervals 102 $container.find('.init-calendar-interval').each(function(i){ 103 for(var j=0; j<2; ++j){ 104 var e = f_getElement(this.id + '['+j+']'); 105 new tcal({ 106 'controlname':e.id, 107 'place':e.parentNode, 108 'lang': siteLang, 109 'intervalpair':[ 110 this.id + '[0]', 111 this.id + '[1]' 112 ], 113 'intervalupdatecont' : this.id 114 }); 115 } 116 }); 117 } 118 if (formCalendars.length && $.datepicker) { 119 formCalendars.each(function(){ 120 var thisInputCalendar = $(this); 121 122 if (thisInputCalendar.hasClass('hasDatepicker')) {return false;} 123 124 thisInputCalendar.datepicker({ 125 changeMonth: true, 126 changeYear: true 127 }); 128 }); 129 } 130 if (formCalendarsInterval.length && $.datepicker) { 131 formCalendarsInterval.each(function(){ 132 var thisCalendarInterval = $(this); 133 134 if (thisCalendarInterval.hasClass('calendar-init')) {return false;} 135 136 thisCalendarInterval.addClass('calendar-init'); 137 138 var calendarWrap = thisCalendarInterval.closest('.form-calendar_interval,.form_c
138alendar_interval'); 139 var inputInterval = calendarWrap.find('[type="text"]'); 140 141 inputInterval.eq(0).datepicker({ 142 changeMonth: true, 143 changeYear: true, 144 onClose: function(selectedDate) { 145 inputInterval.eq(1).datepicker("option", "minDate", selectedDate); 146 } 147 }); 148 inputInterval.eq(1).datepicker({ 149 changeMonth: true, 150 changeYear: true, 151 onClose: function(selectedDate) { 152 inputInterval.eq(0).datepicker("option", "maxDate", selectedDate); 153 thisCalendarInterval.val(inputInterval.eq(0).val() + ' - ' + inputInterval.eq(1).val()); 154 } 155 }); 156 }); 157 } 158 } 159 }) 160 } 161 }; 162 163 var s3PopupForm = { 164 init: function() { 165 this.initPopupForms(); 166 }, 167 initPopupForms: function(parent, callback) { 168 if (typeof myo) { 169 if (!parent) parent = document; 170 if ($(parent)[0] === document || !$(parent).is('[data-api-url][data-api-type=popup-form]')) { 171 parent = $(parent).find('[data-api-url][data-api-type=popup-form]'); 172 } 173 if (parent.data('api-url')) { 174 fixFormId(parent); 175 parent = parent.filter(function() { 176 return !$(this).data('s3form_inited'); 177 }); 178 if (!callback) { 179 callback = typeof parent.data('callback') === 'function' ? parent.data('callback') : eval(parent.data('callback')); 180 } 181 parent.data('s3form_inited', true).click(function(e) { 182 var $this = $(this); 183 if (myo.show) { 184 myo.show({ 185 html: '<div data-api-url="' + $this.data('api-url') + '" data-api-type="form"></div>', 186 clas: $(this).data('wr-class'), 187 afterOpen: function() { 188 var win = this; 189 win.loadDiv.show(); 190 s3From.initForms(win.bodyDiv.find('>div[data-api-type]'), function() { 191 win.loadDiv.hide(); 192 if (typeof callback === 'function') { 193 callback(); 194 } 195 }); 196 } 197 }); 198 } else if (myo.open) { 199 myo.open({ 200 html: '<div data-api-url="' + $this.data('api-url') + '" data-api-type="form"></div>', 201 clas: $(this).data('wr-class'), 202 afterOpen: function() { 203 var win = this; 204 win.loadDiv.show(); 205 s3From.initForms(win.bodyDiv.find('>div[data-api-type]'), function() { 206 win.loadDiv.hide(); 207 if (typeof callback === 'function') { 208 callback(); 209 } 210 }); 211 } 212 }); 213 } 214 e.preventDefault(); 215 return false; 216 }) 217 } 218 } 219 } 220 }; 221 222 s3PopupForm.init(); 223 s3From.init(); 224});
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.