PageSourceSearch

https://edustandart.by/media/mod_simpleform2/js/simpleform2.js

js edustandart.by collected 2026-10-02 21:21:59 UTC 10,320 bytes, 331 lines download raw bytes

1
2(function($){
3    
4    var SF2 = window.SF2 = {
5        shadeElement: $('<div class="sf2Shade"><div class="cssload-container"><div class="cssload-speeding-wheel"></div></div></div>'),
6    
7        showLoading: function(_blockJQObj){
8			$(':focus').blur();
9			var self = this;
10			var lid = 'sf2Shade_'+this.getRandomInt(1,99999);
11			var _f;
12			var shade;
13
14			if(_blockJQObj && _blockJQObj.length){
15				var ids = [];
16				_blockJQObj.each(function(index){
17					var tmp = self.shadeElement.clone().appendTo('body').click();
18					tmp.attr('id',lid+'_'+index);
19					tmp.addClass(lid);
20					ids.push(lid+'_'+index);
21				});
22				shade = $('#'+ids.join(',#'));
23				shade.css('position','absolute');
24				_f = function(){
25					_blockJQObj.each(function(index){
26						var $this = $(this);
27						var offset = $this.offset();
28						$('#'+lid+'_'+index).css({
29							left: offset.left,
30							top: offset.top,
31							width: $this.width(),
32							height: $this.height()
33						});
34					});
35				};
36				_f();
37				window[lid] = setInterval(_f,200);
38			}
39			else{
40				shade = this.shadeElement.clone().appendTo('body').click();
41				shade.attr('id',lid);
42				shade.addClass(lid);
43				shade.css({
44					left: 0,
45					top: 0,
46					width: '100%',
47					height: '100%',
48					position: 'fixed'
49				});
50			}
51			shade.stop().css('opacity',0).animate({
52				opacity: 1,
53			},200);
54			return lid;
55		},
56		
57		hideLoading: function(lid){
58			var shade = $('.'+lid);
59			shade.stop().css('opacity',1).animate({
60				opacity: 0,
61			},200,function(){
62				if(window[lid]){
63					clearInterval(window[lid]);
64					delete window[lid];
65				}
66				shade.remove();
67			});
68		},
69		
70		showSuccess: function(msg){
71			this.showPopupMessage(msg,'success');
72		},
73		
74		showError: function(msg){
75			this.showPopupMessage(msg,'error');
76		},
77        
78        showPopupMessage: function(msg,type){
79			$(':focus').blur();
80			var html = '<div class="sf2Shade sf2Message"><div class="sf2Win  '+type+'">';
81			html+= '<div class="sf2Win-body">'+msg+'</div>';
82			html+= '<div class="sf2Win-close">+</div>';
83			html+= '</div></div>';
84			var win = $(html).appendTo('body');
85			var modal = win.find('.sf2Win');
86			win.on('sf2Close',function(){
87				win.animate({
88					opacity: 0	
89				},200,'swing',function(){
90					win.remove();
91				});
92				modal.animate({
93					'margin-top': -100	
94				},200,'swing');
95			});
96			win.on('click',function(e){
97				var target = $(e.target);
98				if(target.is('.sf2Shade, .sf2Win-close') || target.parent().is('.sf2Win-close')){
99					win.trigger('sf2Close');
100				}
101			});
102			win.css({
103				opacity: 0	
104			});
105			modal.css({
106				'margin-top': -100
107			});
108			win.animate({
109				opacity: 1	
110			},300,'swing');
111			modal.animate({
112				'margin-top': 0	
113			},300,'swing');
114		},
115        
116        closePopup: function(){
117			$('.sf2Win').closest('.sf2Shade').trigger('sf2Close');
118		},
119        
120        getRandomInt: function(min, max) {
121			return Math.floor(Math.random() * (max - min + 1)) + min;
122		},
123        
124        Config: function(id){
125            var cfg = window.SF2Config || {};
126            this.cfg = {};
127            if(cfg[id]){
128                this.cfg = cfg[id];
129            }
130            return this;
131        },
132        
133        Text: function(key){
134            return window.SF2Lang[key];
135        },
136        
137        init: function(){
138            $('.sf2-callBtn').off('click');
139            $('.sf2-callBtn').on('click',function(){
140                var callerButton = $(this);
141                var form = $('#'+callerButton.attr('data-formid'));
142                var win = new SF2Window(form.parent());
143                return false;
144            });
145
146            $('form.simpleForm2').each(function(){
147                var form = $(this);
148                if(form.data('sf2processed') && form.data('sf2processed')===true){
149                    return;
150                }
151                form.data('sf2processed', true);
152                
153                var cfg = new SF2.Config(form.attr('id'));
154                form.on('submit',function(){
155                    if(!cfg.get('onBeforeSend')(form)){
156                        return false;
157                    }
158                    var isPopup = form.closest('.sf2Win').length;
159                    var lid = SF2.showLoading((isPopup?null:form));
160                    form.ajaxSubmit({
161                        'url': cfg.get('ajaxURI'),
162                        'form' : form,
163                        'method': 'POST',
164                        'resetForm': false,
165                        'dataType': 'json',
166                        'success': function(responce,textStatus,jqXHR,$form){
167                            SF2.hideLoading(lid);
168                            // <!-- Captcha reset
169                            $form.find('.sf2Captcha').click();
170                            if(typeof grecaptcha !== 'undefined' && grecaptcha){
171                                grecaptcha.reset();
172                            }
173                            // -->
174                            if(responce==null){
175                                SF2.showError('AJAX server error.');
176                                return;
177                            }
178                            if(!cfg.get('onAfterReceive')($form,responce)){
179                                return;
180                            }
181
182                            $form.find('.sf2-element-state-error').removeClass('sf2-element-state-error');
183
184                            if(responce.status=='success'){
185                                $form.html(responce.html);
186                                if(isPopup){
187                                    $('.sf2Win .sf2SendBtn').remove();
188                                }
189                                else{
190                                    SF2.showSuccess(responce.message);
191                                }
192                            }
193                            else if(responce.status=='error'){
194                                SF2.showError(responce.message);
195                                if(responce.elements){
196                                    var k;
197                                    while(k in responce.elements){
198                                        $form.find('#'+k).addClass('sf2-element-state-error');
199                                    }
200                                }
201                            }
202                            else{
203                                SF2.showError('AJAX server error.');
204                            }
205                        },
206                        'error': function(jqXHR, textStatus, errorThrown){
207                            if(typeof grecaptcha !== 'undefined' && grecaptcha){
208                                grecaptcha.reset();
209                            }
210                            SF2.hideLoading(lid);
211                            SF2.showError(errorThrown);
212                        }
213                    });
214                    return false;
215                });
216            });
217        }
218    }
219    
220    SF2.Config.prototype = {
221        get: function(paramName){
222            if(this.cfg[paramName]){
223                return this.cfg[paramName];
224            }
225            return null;
226        },
227    };
228    
229    var SF2Window = window.SF2Window = function(_container,_id,_isModal){
230		var html,
231			win,
232			modal,
233			body,
234            sendBtn,
235			closeBtn;
236		var winExists = false;
237		var self = this;
238        var form = _container.find('form');
239		if(!_id){
240			_id = 'sf2Win_'+SF2.getRandomInt(9999,99999);
241		}
242		if($('#'+_id).length>0){
243			winExists = true;
244			win = this.win = $('#'+_id).closest('.sf2Shade');
245		}
246		else{
247			html = '<div class="sf2Shade"><div class="sf2Win" id="'+_id+'">';
248			html+= '<div class="sf2Win-body"></div>';
249			html+= '<div class="sf2Win-footer">';
250            if(form.find('input,select,textarea').length>0){
251				var hasButton = form.find('input[type="submit"],button[type="submit"]');
252				if(hasButton.length){
253                    hasButton = hasButton.hide().clone().show();
254					hasButton.attr('type','button');
255					hasButton.addClass('sf2SendBtn');
256					html+= hasButton.prop('outerHTML');
257				}
258				else{
259					html+= '<button type="button" class="sf2SendBtn">'+SF2.Text('send')+'</button>';
260				}
261            }
262            html+= '<button type="button" class="sf2CloseBtn">'+SF2.Text('close')+'</button>';
263            html+= '</div>';
264			html+= '</div></div>';
265			win = this.win = $(html).appendTo('body').click();
266		}
267		modal = this.modal = win.find('.sf2Win');
268		body = this.body = win.find('.sf2Win-body');
269        sendBtn = this.sendBtn = win.find('.sf2SendBtn');
270		closeBtn = this.closeBtn = win.find('.sf2CloseBtn');
271
272        body.append(form);
273        win.on('sf2Close',function(){
274            self.onClose();
275            win.animate({
276                opacity: 0	
277            },200,'swing',function(){
278                _container.append(form);
279                win.remove();
280            });
281            modal.animate({
282                'margin-top': -100	
283            },200,'swing');
284        });
285        win.on('click',function(e){
286            var target = $(e.target);
287            if(target.is('.sf2CloseBtn') || (!_isModal && target.is('.sf2Shade'))){
288                win.trigger('sf2Close');
289            }
290            else if(target.is('.sf2SendBtn')){
291                form.submit();
292            }
293        });
294        win.css({
295            opacity: 0	
296        });
297        modal.css({
298            'margin-top': -100
299        });
300        win.animate({
301            opacity: 1	
302        },300,'swing');
303        modal.animate({
304            'margin-top': 0	
305        },300,'swing');
306	};
307	
308	SF2Window.prototype = {
309		close: function(){
310			this.win.trigger('sf2Close');
311		},
312		onClose: function(){},
313		getWin: function(){
314			return this.win;
315		},
316		getModal: function(){
317			return this.modal;
318		},
319		setContent: function(_html){
320			this.body.html(_html);
321		},
322		getContentBlock: function(){
323			return this.body;
324		},
325	};
326    
327    $(document).ready(function(){
328        SF2.init();
329    });
330    
331})(jQuery);

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.