PageSourceSearch

https://tennis.bg/assets/js/script.js?v=1

js tennis.bg collected 2026-10-02 18:18:51 UTC 17,747 bytes, 687 lines download raw bytes

1var App = (function()
2{
3	var base = '';
4
5	var _getBaseURL = function()
6	{
7		var bases = document.getElementsByTagName('base');
8		var baseHref = '';
9
10		if(bases.length>0)
11		{
12			baseHref = bases[0].href;
13		}
14
15		return baseHref;
16	};
17
18	var _capitalizeFirst = function(string)
19	{
20		return string.charAt(0).toUpperCase()+string.slice(1);
21	};
22
23	var _reloadCaptcha = function(selector)
24	{
25		var $this = $(selector);
26
27		$.ajax(
28		{
29			type: 'GET',
30			url: base+'captcha/image',
31			dataType: 'json',
32			async: true,
33			success: function(data)
34			{
35				if(typeof(data)!=='undefined')
36				{
37					$this.find(' > img').prop('src',data+'?'+Math.floor((Math.random()*100000)+1));
38				}
39			},
40			error: function(data,textStatus)
41			{
42				swal(
43				{
44					title: _capitalizeFirst(textStatus),
45					text: data.status+' '+data.statusText,
46					type: "error",
47					confirmButtonText: 'Затвори',
48					timer: 5000,
49					closeOnConfirm: true
50				});
51			}
52		});
53	};
54
55	var _handleForms = function(exclude)
56	{
57		var suffix = '';
58
59		if(typeof(exclude)!=='undefined')
60		{
61			suffix = ":not("+exclude+")";
62		}
63
64		if($("form"+suffix).length)
65		{
66			$.extend($.validator.messages, {
67				required: "Полето е задължително.",
68				remote: "Моля, въведете правилната стойност.",
69				email: "Моля, въведете валиден email.",
70				url: "Моля, въведете валидно URL.",
71				date: "Моля, въведете валидна дата.",
72				dateISO: "Моля, въведете валидна дата (ISO).",
73				number: "Моля, въведете валиден номер.",
74				digits: "Моля, въведете само цифри",
75				creditcard: "Моля, въведете валиден номер на кредитна карта.",
76				equalTo: "Моля, въведете същата стойност отново.",
77				accept: "Моля, въведете стойност с валидно разширение.",
78				maxlength: $.validator.format("Моля, въведете повече от {0} символа."),
79				minlength: $.validator.format("Моля, въведете поне {0} символа."),
80				minWords: $.validator.format("Моля, въведете поне {0} думи."),
81				rangelength: $.validator.format("Моля, въведете стойност с дължина между {0} и {1} символа."),
82				range: $.validator.format("Моля, въведете стойност между {0} и {1}."),
83				max: $.validator.format("Моля, въведете стойност по-малка или равна на {0}."),
84				min: $.validator.format("Моля, въведете стойност по-голяма или равна на {0}.")
85			});
86
87			var rules_params = {
88				"name": {
89					minlength: 3,
90					required: true
91				},
92				"email": {
93					email: true,
94					required: true
95				},
96				"comment": {
97					required: true
98				},
99				"captchax": {
100					minlength: 3,
101					maxlength: 5,
102					digits: true,
103					required: true
104				}
105			};
106
107			$("form"+suffix).each(function(index,element)
108			{
109				$(this).validate(
110				{
111					rules: rules_params,
112					highlight: function(element,errorClass)
113					{
114						$(element).closest('.has-feedback').removeClass('has-success').addClass('has-error');
115					},
116					unhighlight: function(element,errorClass)
117					{
118						$(element).closest('.has-feedback').removeClass('has-error').addClass('has-success');
119						if($(element).closest('.has-feedback').find('span.help-block').length>0)
120						{
121							$(element).closest('.has-feedback').find('span.help-block').remove();
122						}
123					},
124					errorClass: 'help-block help-style text-right',
125					errorElement: 'span',
126					errorPlacement: function(error,element)
127					{
128						if(element.parent('.input-group').length)
129						{
130							element.parent('.input-group').next('span.help-block').remove();
131							error.insertAfter(element.parent());
132						}
133						else if(element.parents('.checkbox').length)
134						{
135							element.parents('.checkbox').next('span.help-block').remove();
136							error.insertAfter(element.parents('.checkbox'));
137						}
138						else
139						{
140							element.next('span.help-block').remove();
141							error.insertAfter(element);
142						}
143					}
144				});
145			});
146
147			if($('#captchaspan').length)
148			{
149				$('#captchaspan').click(function()
150				{
151					_reloadCaptcha('#captchaspan');
152				});
153			}
154
155			if($("#submitcomment").length)
156			{
157				$("#submitcomment").click(function(e)
158				{
159					e.preventDefault();
160
161					var $form = $(this).closest('form');
162					var $item = $form.find('input[type=hidden]');
163
164					if($form.valid())
165					{
166						var module = 'posts';
167
168						if(typeof($form.data('module'))!=='undefined' && $form.data('module')!=='')
169						{
170							module = $form.data('module');
171						}
172
173						$.ajax(
174						{
175							type: "POST",
176							url: base+module+'/addComment',
177							data: $form.serialize(),
178							success: function(data)
179							{
180								if(data==='session')
181								{
182									swal(
183									{
184										title: 'Грешка',
185										text: 'Некоректно въведен код!',
186										type: "error",
187										confirmButtonText: 'Затвори',
188										closeOnConfirm: true
189									});
190								}
191								else
192								{
193									swal(
194									{
195										title: 'Добавянето е успешно!',
196										text: 'Вашият коментар ще бъде публикуван след одобрение.',
197										type: "success",
198										confirmButtonText: 'Затвори',
199										timer: 5000,
200										closeOnConfirm: true
201									});
202
203									$.ajax(
204									{
205										type: 'POST',
206										dataType: 'json',
207										data: {
208											'item': $item.val(),
209											'page': 99
210										},
211										url: base+module+'/viewComments',
212										cache: false,
213										error: function(data,textStatus)
214										{
215											swal(
216											{
217												title: _capitalizeFirst(textStatus),
218												text: data.status+' '+data.statusText,
219												type: "error",
220												confirmButtonText: 'Затвори',
221												timer: 5000,
222												closeOnConfirm: true
223											});
224										},
225										beforeSend: function ()
226										{
227											$('#newsCommentsContainer').css("opacity","0.1");
228											$("#load_more").hide();
229										},
230										complete: function ()
231										{
232											$('#newsCommentsContainer').css("opacity","1");
233										},
234										success: function(data)
235										{
236											$("#newsCommentsContainer").html(data.html);
237
238											App.scrollDown('dalidali',310,500);
239
240											$form.trigger('reset');
241
242											_reloadCaptcha('#captchaspan');
243
244											if(data.count===1)
245											{
246												$("#load_more").hide();
247											}
248										}
249									});
250								}
251							}
252						});
253					}
254				});
255			}
256		}
257	};
258
259	return {
260		init: function()
261		{
262			base = _getBaseURL();
263
264			_handleForms('#search-form');
265		},
266		baseURL: function()
267		{
268			return _getBaseURL();
269		},
270		loadMore: function(module,id,limit)
271		{
272			if(module==='')
273			{
274				module = 'posts';
275			}
276
277			var page = $('#newsCommentsContainer > div.newsCommentsRow').length;
278			page = Math.floor(page/limit)+1;
279
280			$.ajax(
281			{
282				type: 'POST',
283				dataType: 'json',
284				data: {
285					'item': id,
286					'page': page
287				},
288				url: base+module+'/viewComments',
289				cache: false,
290				beforeSend: function ()
291				{
292					$('#newsCommentsContainer').css("opacity","0.1");
293					$("#load_more").hide();
294				},
295				complete: function ()
296				{
297					$('#newsCommentsContainer').css("opacity","1");
298				},
299				success: function(data)
300				{
301					$("#newsCommentsContainer").html(data.html);
302
303					$("#load_more").show();
304
305					if(data.count===1)
306					{
307						$("#load_more").hide();
308					}
309				},
310				error: function(data,textStatus)
311				{
312					swal(
313					{
314						title: _capitalizeFirst(textStatus),
315						text: data.status+' '+data.statusText,
316						type: "error",
317						confirmButtonText: 'Затвори',
318						timer: 5000,
319						closeOnConfirm: true
320					});
321				}
322			});
323		},
324		voteComment: function(module,page,id,type)
325		{
326			if(typeof(module)!=='undefined' && typeof(type)!=='undefined' && typeof(id)!=='undefined')
327			{
328				if(module==='')
329				{
330					module = 'posts';
331				}
332
333				$.ajax(
334				{
335					type: 'POST',
336					url: base+module+'/voteComment',
337					data: {
338						'item_id': page,
339						'comment_id': id,
340						'vote': type
341					},
342					dataType: 'html',
343					async: true,
344					success: function(data)
345					{
346						if(data!=='no')
347						{
348							if($('#rating'+type+'_'+id).length)
349							{
350								swal(
351								{
352									title: 'Благодарим Ви!',
353									text: 'Рейтингът към коментара е добавен успешно.',
354									type: "success",
355									confirmButtonText: 'Затвори',
356									timer: 5000,
357									closeOnConfirm: true
358								});
359
360								$('#rating'+type+'_'+id).html(data);
361							}
362						}
363						else
364						{
365							swal(
366							{
367								title: 'Информация',
368								text: 'Вече сте гласували за този коментар.',
369								type: "info",
370								confirmButtonText: 'Затвори',
371								closeOnConfirm: true
372							});
373						}
374					},
375					error: function(data,textStatus)
376					{
377						swal(
378						{
379							title: _capitalizeFirst(textStatus),
380							text: data.status+' '+data.statusText,
381							type: "error",
382							confirmButtonText: 'Затвори',
383							timer: 5000,
384							closeOnConfirm: true
385						});
386					}
387				});
388			}
389		},
390		scrollDown: function(elem,value,duration)
391		{
392			var selector = '#'+elem;
393
394			if(elem.indexOf('.')===0 || elem.indexOf('div')===0 || elem.indexOf('h4')===0)
395			{
396				selector = elem;
397			}
398
399			if($(selector).length>0)
400			{
401				// calculate destination place
402				var dest = 0;
403				var offset = ((typeof value!=="undefined") ? value : 0);
404
405				if($(selector).offset().top>$(document).height()-$(window).height())
406				{
407					dest = ($(document).height()-$(window).height())-offset;
408				}
409				else
410				{
411					dest = $(selector).offset().top-offset;
412				}
413				// go to destination
414				$('html,body').animate({scrollTop:dest}, duration,'swing');
415			}
416		},
417		scrollTop: function(duration)
418		{
419			var dest = 0;
420			// go to destination
421			$('html,body').animate({scrollTop:dest}, duration,'swing');
422		},
423		showModal: function(element)
424		{
425			if($('#watchModal').length)
426			{
427				var $element = $(element);
428				var title = 'Гледай на живо';
429				var url = '';
430
431				if(typeof($element.data('title'))!=='undefined')
432				{
433					title = $element.data('title');
434				}
435
436				if(typeof($element.data('url'))!=='undefined')
437				{
438					url = $element.data('url');
439				}
440
441				$('#watchModal').on('show.bs.modal',function()
442				{
443					var $this = $(this);
444console.log($this);
445					if($this.find('.modal-title').length)
446					{
447						$this.find('.modal-title').html(title);
448					}
449
450					if($this.find('iframe').length)
451					{
452						$this.find('iframe').prop('src',url);
453					}
454				});
455
456				$('#watchModal').modal(
457				{
458					show:true
459				});
460			}
461		}
462	};
463})();
464
465
466//************  End costume JS here  ******************/
467jQuery(document).ready(function($)
468{
469	App.init();
470
471	if($('[data-toggle="tooltip"]').length)
472	{
473		$('[data-toggle="tooltip"]').tooltip();
474	}
475
476	if($('.tooltips').length)
477	{
478		$('.tooltips').tooltip();
479	}
480
481	$(document).delegate('*[data-toggle="lightbox"]', 'click', function(event) {
482		event.preventDefault();
483		$(this).ekkoLightbox();
484	});
485
486
487	if($('.newsDetailsRelatedImg').length)
488	{
489		$(".toolbox").css('height',$('.newsDetailsRelatedImg').height() + 'px');
490	}
491	$('.homeBranding').each(function() {
492		var marginBannerTop = '165px';
493
494		if ($(this).find('img').length) {
495			if($( window ).width() > '801'){
496				$('main section:first-child').css('margin-top',marginBannerTop);
497			}
498		}
499	});
500
501	//*** Controller for all of the animations ****/
502	$( "main > section" ).each(function()
503	{
504		if($(this).attr("class")){
505			//createWOWAnimation('#' + $(this).attr('id'),'fadeInUp','2s','0s','100');
506		}
507	});
508	$( ".banner" ).each(function()
509	{
510		//createWOWAnimation('.banner','fadeInUp','2s','0s','100');
511	});
512
513	//createWOWAnimation('.homeBranding','fadeIn','4s','0s','100');
514	//createWOWAnimation('.footer','fadeIn','2s','0s','100');
515	//createWOWAnimation('.slideText','fadeInDown','2s','0.5s','0');
516	//createWOWAnimation('.slideSlogan','fadeIn','3s','1s','0');
517	//createWOWAnimation('.sliderButton','fadeInUp','3s','1.5s','0');
518	//createWOWAnimation('.videoHomePlay','fadeInUp','3s','1.5s','0');
519	//createWOWAnimation('.carousel-control.left','fadeInLeft','2s','1s','0');
520	//createWOWAnimation('.carousel-control.right','fadeInRight','2s','1s','0');
521
522	var animation = new WOW(
523		{
524			boxClass: 'cws-animate'
525		});
526	animation.init();
527	//*** end animations ****/
528
529//    $('.sliderTitles').click(
530//        function(e)
531//        {
532//            var sliderButonID = $(this).attr('data-trigger');
533//            if(sliderButonID)
534//            {
535//                console.log(e);
536//                if(($(e.target).is('.videoHomePlay')) || ($(e.target).is('.videoHomePlayIcon')))
537//                {
538//                    e.preventDefault();
539//                    return;
540//                }else{
541//                    $(sliderButonID).get(0).click();
542//                }
543//
544//            }
545//        }
546//    );
547
548
549	var timeoutTimeHover;
550	var timeoutTimeHoverDelay = 300;
551	var timeoutTimeHoverItem = null;
552	var timeoutTimeHoverSlideTo;
553	$('.sliderIndicatorsHome li').hover(
554		function()
555		{
556			timeoutTimeHoverItem = $(this);
557			timeoutTimeHoverSlideTo = $(this).attr('data-slide-to');
558			timeoutTimeHoverSlideID = $(this).attr('data-slide-id');
559			if (!timeoutTimeHover)
560			{
561				timeoutTimeHover = window.setTimeout(
562				function()
563				{
564					timeoutTimeHover = null;
565					$(timeoutTimeHoverItem).click
566					(
567						function(clicked)
568						{
569							var get_URL_SLIDE = $('#sliderButtonHome-' + timeoutTimeHoverSlideID).attr('href');
570							//console.log(get_URL_SLIDE);
571							window.location.href = get_URL_SLIDE;
572							//$('#sliderButtonHome-' + timeoutTimeHoverSlideID).trigger('click');
573						}
574					)
575					//console.log(timeoutTimeHoverSlideTo);
576					$(".carousel").carousel(parseInt(timeoutTimeHoverSlideTo));
577
578				}, timeoutTimeHoverDelay);
579			}
580		},
581		function ()
582		{
583			if (timeoutTimeHover) {
584				window.clearTimeout(timeoutTimeHover);
585				timeoutTimeHover = null;
586			}
587
588		}
589	);
590
591	$('.carousel').not('#newsDetailsImages').carousel({
592		interval: 12000
593	});
594
595
596	var rateTriggerID = '#article-rating';
597	if($(rateTriggerID).length)
598	{
599		var rateReadOnly =  $(rateTriggerID).data('read-only');
600		var rateID = $(rateTriggerID).data('rating-id');
601		var rateScore = $(rateTriggerID).data('score');
602		var rateModule = $(rateTriggerID).data('module');
603		var rateHref = App.baseURL();
604
605		if(typeof(rateModule)==='undefined' || rateModule==='')
606		{
607			rateModule = 'posts';
608		}
609
610		$(rateTriggerID).raty({
611			width       : 190,
612			readOnly    : rateReadOnly,
613			scoreName   : 'rating',
614			score       : rateScore,
615			number      : 5,
616			size        : 20,
617			hints       : ['много зле', 'слабо', 'става', 'добро', 'страхотно'],
618			path        : rateHref + 'assets/img/',
619			starOn      : 'star-on.png',
620			starHalf    : 'star-half.png',
621			starOff     : 'star-off.png',
622			space       : false,
623			noRatedMsg  : 'Няма оценка!',
624			click       : function(rating, evt)
625			{
626				$.post(rateHref + rateModule + "/rate",
627				{
628					item_id:rateID,
629					rating: rating
630				});
631				$(rateTriggerID).raty('readOnly', true);
632			}
633		});
634	}
635
636	var rateTriggerID_two = '#article-rating-two';
637	if($(rateTriggerID_two).length)
638	{
639		var rateReadOnly =  $(rateTriggerID_two).data('read-only');
640		var rateID = $(rateTriggerID_two).data('rating-id');
641		var rateScore = $(rateTriggerID_two).data('score');
642		var rateModule = $(rateTriggerID_two).data('module');
643		var rateHref = App.baseURL();
644
645		if(typeof(rateModule)==='undefined' || rateModule==='')
646		{
647			rateModule = 'posts';
648		}
649
650		$(rateTriggerID_two).raty({
651			width       : 190,
652			readOnly    : rateReadOnly,
653			scoreName   : 'rating',
654			score       : rateScore,
655			number      : 5,
656			size        : 20,
657			hints       : ['много зле', 'слабо', 'става', 'добро', 'страхотно'],
658			path        : rateHref + 'assets/img/',
659			starOn      : 'star-on.png',
660			starHalf    : 'star-half.png',
661			starOff     : 'star-off.png',
662			space       : false,
663			noRatedMsg  : 'Няма оценка!',
664			click       : function(rating, evt)
665			{
666				$.post(rateHref + rateModule + "/rate",
667				{
668					item_id:rateID,
669					rating: rating
670				});
671				$(rateTriggerID_two).raty('readOnly', true);
672			}
673		});
674	}
675});
676
677function createWOWAnimation(elemnt,animation,duration,delay,offset)
678{
679	if($(elemnt).length)
680	{
681		$(elemnt).addClass('cws-animate '+animation);
682		$(elemnt).attr('data-wow-duration', duration);
683
684		$(elemnt).attr('data-wow-delay', delay);
685		$(elemnt).attr('data-wow-offset', offset);
686	}
687}

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.