PageSourceSearch

https://www.mlaikas.lt/public/js/functions.js?v=1

js mlaikas.lt collected 2026-10-02 21:35:58 UTC 20,768 bytes, 599 lines download raw bytes

1tinymce.init({
2	language : 'lt',
3    selector: "textarea.tinymce",
4    menubar: false,
5    height: 200,
6    plugins: [  "advlist autolink lists charmap print preview anchor",
7        		"searchreplace visualblocks fullscreen",
8        		"insertdatetime media table paste",
9        		"code image link contextmenu" ],
10	toolbar: "undo redo | styleselect | bold italic underline | alignleft aligncenter alignright alignjustify | bullist numlist | link",
11	//image_advtab: true,
12	relative_urls : false,
13	remove_script_host : false,
14	document_base_url : "http://www.mūsųlaikas.lt/",
15	convert_urls : false,
16	entity_encoding : "raw",
17	//paste_as_text: true,
18	//paste_auto_cleanup_on_paste : true
19	paste_preprocess : function(pl, o) {
20		o.content = strip_tags(o.content, "<b><u><i><p>");
21	}
22});
23
24var breakingStart = true;
25var breakingSpeed = 28;
26var elementsToClone = true;
27var breakingOffset = 0;
28var breakingScroll = 0;
29
30$(document).ready(function() {
31	var uploadObj = $(".submitting-article-photos").uploadFile({
32		url: "/news/upload_submitting_photos",
33		method: "POST",
34		allowedTypes: "jpg,png,gif",
35		onSuccess:function(files, data, xhr) {
36	        $("#status").html("<font color='green'>Upload is success</font>");
37	    },
38	    onError: function(files, status, errMsg) {       
39	        $("#status").html("<font color='red'>Upload is Failed</font>");
40	    },
41	    deleteCallback: function(data, pd) {
42			$.ajax({
43				type: "POST",
44				url: "/news/delete_submitted_photo",
45				data: {
46					name: data.file,
47			 		id: data.id
48			 	},
49				success: function(resp, textStatus, jqXHR) {
50					pd.statusbar.hide(); 
51				}
52			});	
53		}
54	});
55	$(document).on("click", ".upload-submitting-photos", function () {
56		uploadObj.startUpload();
57	});
58
59	$(document).on("click", ".subscription-content input[type=radio]", function () {
60		if ($(this).hasClass("type1")) {
61			$(".comp-hidd").hide();
62		} else {
63			$(".comp-hidd").show();
64		}
65	});
66
67	$(document).on("click", "#del_address", function () {
68		if ($(this).is(":checked")) {
69			$(".del_addr").hide();
70		} else if (!$(this).is(":checked")) {
71			$(".del_addr").show();
72		}
73	});
74
75	var theFontSize = 15;
76	$(document).on("click", "a[href=#change-font-size]", function () {
77		if ($(this).data("rel") == "up") {
78			theFontSize = (theFontSize < 30) ? theFontSize+2 : theFontSize;
79		} else if($(this).data("rel") == "down") {
80			theFontSize = (theFontSize > 13) ? theFontSize-2: theFontSize;
81		}
82		
83		$(".changable-content, .changable-content p").css("font-size", theFontSize+"px");
84		return false;
85	});
86
87	start();
88	$('.breaking-message').mouseover(function (){
89		breakingStart = false;
90		$('.breaking-line ul').stop(true);
91	}).mouseout(function (){
92		breakingStart = true;
93		start();
94	});
95
96	$(".relative-block").each(function (){
97		$(this).css("height", jQuery(".footer-content").height()+"px");
98	});
99
100	$(document).on("click", ".panel-content .title-top a.tabbed-panel", function () {
101		var thatitle = $(this).attr("title");
102		var thalink = $(this).attr("href").split("#");
103		$(this).parent().parent().parent().children("h3").html($(this).attr("title"));
104		$(this).parent().parent().parent().children(".panel-content").hide();
105		$(this).parent().parent().parent().children("." + thalink[1]).show();
106		return false;
107	});
108
109	$(document).on("click", ".gallery-navi-right, .article-photo-next", function () {
110		var thiscount = parseInt($(this).parent().find("ul li").size()) - 1;
111		var thisindex = parseInt($(this).parent().find("ul li.active").index());
112		var thisnext = (thisindex >= thiscount) ? (0) : (thisindex + 1);
113		
114		$(this).parent().find("ul li.active").addClass("current");
115		$(this).parent().find("ul li.current").removeClass("active");
116		$(this).parent().find("ul li").eq(thisnext).addClass("active");
117		$(this).parent().find("ul li.current").removeClass("current");
118		return false;
119	});
120	
121	$(document).on("click", ".gallery-navi-left, .article-photo-prev", function () {
122		var thiscount = parseInt($(this).parent().find("ul li").size()) - 1;
123		var thisindex = parseInt($(this).parent().find("ul li.active").index());
124		var thisnext = (thisindex <= 0) ? (thiscount) : (thisindex - 1);
125		
126		$(this).parent().find("ul li.active").addClass("current");
127		$(this).parent().find("ul li.current").removeClass("active");
128		$(this).parent().find("ul li").eq(thisnext).addClass("active");
129		$(this).parent().find("ul li.current").removeClass("current");
130		return false;
131	});
132
133	$(document).on("click", ".article-videos .youtube-video a", function () {
134		var videoID = $(this).attr("href").split("#");
135		var videoWidth = parseInt($(this).parent().parent().css("width"));
136		var videoHeight = Math.ceil(videoWidth*(0.56)+1);
137		
138		$(this).hide();
139		$(this).parent().append('<iframe width="'+videoWidth+'" height="'+videoHeight+'" src="https://www.youtube.com/embed/'+(videoID[1])+'?rel=0&autoplay=1" frameborder="0" allowfullscreen></iframe>');
140		return false;
141	});
142
143	$(".article-galleries .album-photos").each(function() {
144		var gallery = $(this).data("gallery-id");
145		$(".image-gallery-" + gallery).magnificPopup({
146			delegate: 'a',
147	       	type: 'image',
148	   		mainClass: 'mfp-img-mobile',
149	       	gallery: {
150	            enabled: true,
151	            navigateByImgClick: true
152	       	},
153	       	zoom: {
154				enabled: true,
155				duration: 300,
156				easing: 'ease-in-out'
157			}
158		});
159	});
160
161	$(".image-gallery, .article-photos-gallery, .newspapers.image-gallery").magnificPopup({
162		delegate: 'a[class="album-image"], a[class="article-image"], a[class="newspaper-image"]',
163       	type: 'image',
164   		mainClass: 'mfp-img-mobile',
165       	gallery: {
166            enabled: true,
167            navigateByImgClick: true,
168            preload: [0,1]
169       	},
170       	zoom: {
171			enabled: true,
172			duration: 300,
173			easing: 'ease-in-out'
174		}
175	});
176
177	$(".image-link").magnificPopup({
178		type: 'image',
179   		mainClass: 'mfp-img-mobile',
180       	gallery: {
181            enabled: true,
182            navigateByImgClick: true,
183            preload: [0,1]
184       	},
185       	zoom: {
186			enabled: true,
187			duration: 300,
188			easing: 'ease-in-out'
189		}
190	});
191
192	$(".small-events-calendar").sidebarCalendar();
193
194	$(".datetime-picker").datetimepicker();
195
196	$(document).on("click", ".count_price", function() {
197		var person_val  	= parseInt($('input[name="person"]:checked').val());
198		var version_val 	= parseInt($('input[name="version"]:checked').val());
199		var period_val  	= parseInt($("#period").val());
200		var pubs_val  		= new Array();
201		var delivery_from 	= $('#del_from').val()
202		$('input[name="newspaper[]"]:checked').each(function() {
203			pubs_val.push($(this).val());
204		});
205		$.ajax({
206			type: "POST",
207			url: "/subscription/ajax_count_price",
208			data: { person: person_val, version: version_val, period: period_val, publications: pubs_val, del_from: delivery_from },
209			dataType: "json",
210			success: function(result) {
211				if (result.status == 1) {
212					$("li.price > span").text(result.price);
213				} else {
214					$("li.price > span").html("<span style='font-size:11px'>Klaida.</span>");
215				}
216			}
217		});
218		return false;
219	});
220
221	$(document).on("click", ".update-points-balance, .my-points-balance b", function() {
222		$.ajax({
223			type: "POST",
224			url: "/users/update_points",
225			success: function(result) {
226				$(".my-points-balance b").text(result);
227				$(".points-system div.bottom").html("<span style='color:green;font-weight:600'>Balansas atnaujintas.</span>");
228			}
229		});
230		return false;
231	});
232
233	$(document).on("click", "a[href='#nppPaid']", function () {
234	    var cart = $(".paid-newspapers");
235        var imgtodrag = $(this).parent().parent().find("img");
236        if (imgtodrag) {
237            var imgclone = imgtodrag.clone()
238                .offset({
239                top: imgtodrag.offset().top,
240                left: imgtodrag.offset().left
241            	})
242                .css({
243                	'opacity': '0.9',
244                    'position': 'absolute',
245                    'height': '150px',
246                    'width': '150px',
247                    'z-index': '100'
248            	})
249                .appendTo($('body'))
250                .animate({
251                	'top': cart.offset().top+130,
252                    'left': cart.offset().left+90,
253                    'width': 100,
254                    'height': 140
255            	}, 900);
256
257            	imgclone.animate({
258	                'width': 0,
259	                'height': 0
260	            }, function () {
261	                $(this).detach()
262	            });
263        }
264        $("#npp_number").val($(this).data('select'));
265	    setNewspaperNo($(this).data('select'));
266        return false;
267	});
268
269	$(document).on("change", "#npp_number", function () {
270		var value = $(this).val();
271		setNewspaperNo(value);
272        return false;
273	});
274
275	$(document).on("click", ".confirm_paper_payment", function () {
276		//window.open($(this).data("url"));
277		$(".paid-newspapers .changeable-content .information").html("<span style='font-weight:600;color:green'>Ačiū, kad perkate!</span>");
278		$(".paid-newspapers .changeable-content .confirm > .enter_code").html("");
279
280		//var points_balance = $(".my-points-balance b").text();
281		//var undersized_balance = parseInt(points_balance) - 20;
282		//$(".my-points-balance b").text(undersized_balance);
283	});
284
285
286
287	/* temporary new website poll ----------------------------------------------------------*/
288	$(document).on("click", ".vote-for-new-site > .click-for-vote", function() {
289		if ($(this).parent().hasClass("can-vote")) {
290			var check_vote = false;
291			if ($(this).hasClass("like")) {
292				var vote_for = 1,
293					check_vote = true;
294			} else if ($(this).hasClass("dislike")) {
295				var vote_for = 0,
296					check_vote = true;
297			}
298			if (check_vote) {
299				$.ajax({
300					type: "POST",
301					url: "/homepage/temp_website_poll",
302					data: { vote: vote_for },
303					dataType: "json",
304					success: function(response) {
305						if (response.result == "OK") {
306							$(".vote-for-new-site").removeClass("can-vote");
307							$(".vote-for-new-site > .like").text(response.likes);
308							$(".vote-for-new-site > .dislike").text(response.dislikes);
309						}
310					}
311				});
312			}
313		}
314		return false;
315	});
316	/* temporary new website poll ends -----------------------------------------------------*/
317
318	$(document).on("submit", ".send-email-form", function() {
319		$.ajax({
320			type: "POST",
321			url: "/contact_us/send_email",
322			data: { 
323				author: $(".send-email-form #author").val(), 
324				email: $(".send-email-form #email").val(), 
325				message: $(".send-email-form #message").val() 
326			},
327			dataType: "json",
328			success: function(response) {
329				if (response) {
330					if (response.success == "OK") {
331						$(".contact-us-form.send-email-form").html("<div style='text-align:center;font-weight:600;color:green'>Jūsų žinutė išsiųsta.</div>");
332					} else {
333						var result = "<ul class='form-errors'>"
334						$.each(response, function(i, j){
335							if (j.author)  result += "<li class='form-error'>" + j.author + "</li>";
336							if (j.email)   result += "<li class='form-error'>" + j.email + "</li>";
337							if (j.message) result += "<li class='form-error'>" + j.message + "</li>";
338						});
339						result += "</ul>";
340
341						$(".send-email-form > p").html(result);
342					}
343				}
344			}
345		});
346		return false;
347	});
348	
349});
350
351function start() {
352	if($('.breaking-line ul').size() > 0){
353		if(!breakingStart)return false;
354		var theBreakingMargin = parseInt($('.breaking-line ul li').css("margin-right"));
355		if(elementsToClone){  
356			var theBreakingWidth = parseInt($('.breaking-line').css("width"));
357			theCount = ($('.breaking-line ul > li').size()*(theBreakingWidth+theBreakingMargin));
358			$('.breaking-line ul li').clone().appendTo('.breaking-line ul');
359			elementsToClone = false;
360		}
361		var theNumber = theCount+breakingOffset;
362		if(Math.abs(theNumber) <= (Math.abs(breakingScroll))){
363			cloneBreakingLine();
364		}
365		breakingScroll = breakingScroll-1;
366		$('.breaking-line ul').animate({left: breakingScroll+'px'}, breakingSpeed, 'linear', function(){ start(); });
367	}
368}
369
370function cloneBreakingLine(){
371	breakingScroll = 0;
372	$('.breaking-line ul').css("left", "0px");
373}
374
375function setNewspaperNo(nppId) {
376	$(".paid-newspapers .changeable-content").hide().children(".information").html("");
377	$.ajax({
378		type: "POST",
379		url: "/newspapers/check_npp_to_buy",
380		dataType: "json",
381		data: { paper: nppId },
382		success: function(result) {
383			$(".paid-newspapers .changeable-content .information").html(result.information);
384			$(".paid-newspapers .changeable-content .confirm").html(result.form);
385			$(".laikrascio_numeris").html(nppId);
386		}
387	});
388	if (nppId.value != 0) {
389		$(".paid-newspapers p").slideUp("fast");
390		$(".paid-newspapers .changeable-content").slideDown("fast");
391	} else {
392		$(".paid-newspapers p").slideDown("fast");
393	}
394}
395
396function printArticle() {
397	var html = $(".changable-content").html();
398	var htmltitle = $(".article-big-header.top h1").html();
399	var htmllogo = $(".header-logo > a").html();
400	var htmlcopy = $(".footer-copy .left").html();
401	var htmlauthor = $(".article-author .article-user span").html();
402	var htmldate = $(".article-author .article-date span").html();
403
404	top.consoleRef=window.open('','articleprint',
405		'width=680,height=800'
406		+',menubar=0'
407		+',toolbar=1'
408		+',status=0'
409		+',scrollbars=1'
410		+',resizable=1');
411	top.consoleRef.document.writeln(
412		  '<html>'
413		+ '<head>'
414			+ '<title>' + $(document).attr('title') + '</title>'
415			+ '<link type="text/css" rel="stylesheet" href="css/reset.css" />'
416			+ '<link type="text/css" rel="stylesheet" href="css/print.css?'+Date()+'" />'
417		+ '</head>'
418		+ '<body onLoad="self.focus()">'
419			+ '<div class="wrapper">'
420				+ '<div style="text-align:center">'+htmllogo+'</div>'
421				+ '<h1>'+htmltitle+'</h1>'
422				+ '<div class="smallinfo">'
423					+ '<strong>'+htmlauthor+'</strong><span>'+htmldate+'</span><br/>'
424					+ $(location).attr('href')
425				+ '</div>'
426				+ '<div class="article-main-content">'+html+'</div>'
427					+ htmlcopy
428			+ '</div>'
429		+ '</body>'
430		+ '</html>'
431		);
432	top.consoleRef.document.close();
433}
434
435/* Ajax & Forms Validations*/
436function CheckValue(input_id) {
437	var input = $("#" + input_id);
438	if ($.trim(input.val()).length > 0) {
439		return false;
440	} else {
441		return true;
442	}
443}
444
445function ShowError(input_id, message) {
446	$('<span class="input-error-span"><span class="icon-text">&#9888;</span>KLAIDA: ' + message + '</span>').insertBefore("#" + input_id);
447	$("#" + input_id).addClass("input-error");
448
449	if ($("#" + input_id).hasClass("fl-small")) {
450		$(".input-error-span").addClass("small");
451	}
452}
453
454function DestroyErrors() {
455	$("input, textarea").removeClass("input-error");
456	$("input, textarea").parent().find(".input-error-span").remove();
457}
458
459$(document).ready(function() {
460	$(document).on("click", ".add-vote", function() {
461		var answers 	= $(this).parent();
462		var answer_id 	= answers.find('input[type="radio"]:checked').val();
463
464		if (answer_id) {
465			$.ajax({
466				type: "POST",
467				url: "/polls/vote",
468				data: { answer: answer_id, "mlaikas_csrf_token": $("input:hidden[name='mlaikas_csrf_token']").val() },
469				success: function(result) {
470					answers.html(result);
471				}
472			});
473		}
474	})
475
476	$(document).on("submit", "#create-forum", function() {
477		var button = $(this).find("input[type=submit]");
478		button.attr("disabled", "disabled");	
479		$.ajax({
480			type: "POST",
481			url: "/forums/save",
482			data: { thread: $("#thread-title").val(), text: $("#thread-text").val() },
483			dataType: 'json',
484			success: function(result) {
485				if (result.errors == "none") {
486					$("#create-forum .form-content").addClass("message").html(result.message);
487					$("#create-forum .form-content").css("color", "green");
488					$('<div class="thread-content"><div><a href="'+result.url+'">'+result.title+'</a><span class="count">(0)</span><span class="time-stamp">'+result.date+'</span></div><div class="thread-text"><span>'+result.text+'</span><a href="'+result.url+'">Diskutuoti <span class="icon-text">&#10150;</span></a></div></div>').insertAfter("#create-forum");
489				} else {
490					var response = "<span class='icon-text'>&#9888;</span><ul class='form-errors'>"
491					$.each(result, function(i, j){
492						if (j.thread) response += "<li class='form-error'>" + j.thread + "</li>";
493						if (j.text) response += "<li class='form-error'>" + j.text + "</li>";
494					});
495					response += "</ul>";
496
497					$("#create-forum .form-content p").css({"height":"40px","padding-top":"5px","color":"#c53c1c"}).html(response).children(".icon-text").css("color","#c53c1c");
498					button.attr("disabled", false);
499				}
500			}
501		});
502		return false;
503	});
504
505	$(document).on("submit", "#write-answer", function() {
506		var button = $(this).find("input[type=submit]");
507		button.attr("disabled", "disabled");
508		$.ajax({
509			type: "POST",
510			url: "/forums/post_answer",
511			data: { answer: $("#thread-answer").val(), author: $("#thread-author").val(), thread: $("#thread-post").val(), "mlaikas_csrf_token": $("input:hidden[name='mlaikas_csrf_token']").val() },
512			dataType: 'json',
513			success: function(result) {
514				if (result.errors == "none") {
515					$("#write-answer").addClass("message").html(result.message);
516					$("#write-answer").css("color", "green");
517					if ($(".thread-posts").length == 0) {
518						$("<div class='thread-posts'></div>").insertAfter("#write-answer");
519					}
520					$(".thread-posts").prepend('<div class="post"><div class="top"><span class="author-name">'+result.title+'</span><span class="ip">IP: '+result.ip+'</span><span class="time-stamp">Atsakyta: '+result.date+'</span><div class="clear-float"></div></div><div class="post-text">'+result.text+'</div></div>');
521				} else {
522					var response = "<span class='icon-text'>&#9888;</span><ul class='form-errors'>"
523					$.each(result, function(i, j){
524						if (j.author) response += "<li class='form-error'>" + j.author + "</li>";
525						if (j.answer) response += "<li class='form-error'>" + j.answer + "</li>";
526					});
527					response += "</ul>";
528
529					$("#write-answer p").css({"height":"40px","padding-top":"5px","color":"#c53c1c"}).html(response).children(".icon-text").css({"color":"#c53c1c","top":"21px"});
530					button.attr("disabled", false);
531				}
532			}
533		});
534		return false;
535	});
536
537	$(document).on("submit", "#write-article-comment", function() {
538		var button = $(this).find("input[type=submit]");
539		button.attr("disabled", "disabled");
540		$.ajax({
541			type: "POST",
542			url: "/news/write_comment",
543			data: { comment: $("#comment").val(), author: $("#author").val(), article: $("#article-id").val(), "mlaikas_csrf_token": $("input:hidden[name='mlaikas_csrf_token']").val() },
544			dataType: 'json',
545			success: function(result) {
546				if (result.errors == "none") {
547					$("#write-article-comment").addClass("message").html(result.message).css("color", "green");
548					if ($(".comments-block").length == 0) {
549						$('<ol class="comments-block"></ol>').insertAfter("#write-article-comment");
550					}
551					$(".comments-block").prepend('<li><div class="commment-content"><div class="top-bar"><span class="user-nick">'+result.name+'</span><span class="time-stamp">'+result.date+'</span><span class="user-ip">'+result.ip+'</span><div class="clear-float"></div></div><div class="comment-text">'+result.text+'</div></div></li>');
552					$(".tab-comments").html("<span class='article-comment-button'>&nbsp;</span>" + result.count + " komentarų");
553				} else {
554					var response = "<span class='icon-text'>&#9888;</span><ul class='form-errors'>"
555					$.each(result, function(i, j){
556						if (j.author) response += "<li class='form-error'>" + j.author + "</li>";
557						if (j.comment) response += "<li class='form-error'>" + j.comment + "</li>";
558					});
559					response += "</ul>";
560
561					$("#write-article-comment p").css({"height":"40px","padding-top":"5px","color":"#c53c1c"}).html(response).children(".icon-text").css({"color":"#c53c1c","top":"21px"});
562					button.attr("disabled", false);
563				}
564			}
565		});
566		return false;
567	});
568});
569
570$(function() {
571	$(".datepicker").datepicker({
572		minDate: 10/*,
573		beforeShowDay: function(date) {
574	        return [date.getDay() == 5];
575	    }*/
576	});
577});
578
579$(document).on("submit", "#pirkti_laikrasti", function(e){
580    e.preventDefault();
581	if(!$("#paper_payment_code").val())
582	{
583		$("#paper_payment_code").css("border", "1px solid red");
584		return false;
585	}
586	else
587	{
588		window.location.href = $('#pirkti_laikrasti').attr('action') + $('#paper_payment_code').val();
589		$('.changeable-content').html('<div style="text-align: center;"><h4>Ačiū, kad perkate.</h4><p><b>Mūsų laikas</b></p></div>');
590	}
591    //$('#pirkti_laikrasti').attr('action', $('#pirkti_laikrasti').attr('action') + $('#paper_payment_code').val());
592	//window.location.href = $('#pirkti_laikrasti').attr('action') + $('#paper_payment_code').val();
593	//return true;
594});
595
596function submitinam() {
597	$('#pirkti_laikrasti').attr('action', $('#pirkti_laikrasti').attr('action') + $('#paper_payment_code').val());
598	$('#pirkti_laikrasti').submit();
599}

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.