PageSourceSearch

https://foro.valencianistas.ru/styles/vru4/template/spoiler.js

js valencianistas.ru collected 2026-10-04 18:15:03 UTC 5,470 bytes, 202 lines download raw bytes

1(function($) {
2	$.fn.bb2Spoiler = function(options){
3	//Image width
4	//var maxW = Math.round(screen.width - (screen.width / 1.5));
5	var maxW = 670;
6	var hidePostImg = false;
7	var hideSigImg = false;
8
9	initPost($(this));
10
11	function imgFit (img, maxW)
12	{
13
14
15
16
17		/*
18		if (typeof(img.naturalHeight) == undefined) {
19			img.naturalHeight = img.height;
20			img.naturalWidth  = img.width;
21		}
22
23		if (img.width > maxW) {
24			img.height = Math.round((maxW/img.width)*img.height);
25			img.width  = maxW;
26			//img.title  = 'Click image to view full size';
27			img.style.cursor = 'pointer';
28			return false;
29		}
30
31
32
33		else if (img.width == maxW && img.width < img.naturalWidth) {
34			*/
35			img.height = img.naturalHeight;
36			img.width  = img.naturalWidth;
37
38			//img.title  = 'Click to fit in the browser window';
39			return false;
40			/*
41		}
42		else {
43			return true;
44		}
45		*/
46	}
47
48	function initPost(context)
49	{
50		initPostImages(context);
51		initSpoilers(context);
52	}
53	function initPostImages(context)
54	{
55		var $in_spoilers = $('div.sp-body var.postImg', context);
56		var banned_image_hosts = /imagebanana|hidebehind/i;//banned image hosts
57
58		$('var.postImg', context).not($in_spoilers).each(function(){
59			var $v = $(this);
60			var src = $v.attr('title');
61			var img_align = $v.attr('align')!=undefined ? ' align="'+ $v.attr('align') +'"' : '';
62			var $img = $('<img src="'+ src +'"'+ img_align + ' class="'+ $v.attr('className') +'" alt="" />');
63
64			var is_signature = $v.parents().hasClass('signature') ? true : false;
65
66			var original_width = this.naturalWidth;
67
68			if(!is_signature) {
69				if (hidePostImg){ return $(this).replaceWith(''); }
70
71				if (src.match(banned_image_hosts)) {
72					return $(this).replaceWith('<a href="#" title="Sorry, images from this server banned"><img  src="./styles/valencianistas/imageset/tr_oops.gif" alt="Banned!" /></a>');//Link to rules
73				}
74				else
75				{
76					$img = fixPostImage($img);
77				}
78
79
80
81				//console.log(original_width +" vs "+ $img.width());
82
83				//Original
84				//$img.bind('click', function(){ return !window.open(src); });
85				//Fancybox
86				/*$img.bind('click', function(){
87					$(".postImg").fancybox({
88						'modal': false,
89						'titleShow': true,
90						'titlePosition': 'inside',
91						'autoScale': true,
92						'autoDimensions': true,
93						'type': 'image',
94						'href': src,
95						'scrolling': 'auto',
96						'titleFormat': function(title, currentArray, currentIndex, currentOpts)
97						{
98							return '<a href="' + src + '" target="_blank">' +  src + '</a>';
99						}
100					});
101				 });*/
102
103				$('#preload').append($img);
104				var loading_icon = '<a href="'+ src +'" target="_blank"><img src="./styles/valencianistas/imageset/pic_loading.gif" alt="" /></a>';
105				$v.html(loading_icon);
106
107				if (navigator.userAgent.indexOf("MSIE")!=-1 || navigator.userAgent.indexOf("Opera")!=-1) {
108					
109					$img.one('load', function(){ imgFit(this, maxW); });
110					$v.empty().append($img);
111					$v.after('<wbr>');
112				}
113				else
114				{
115
116					$img.one('load', function(){
117						
118						var original_width = this.naturalWidth;
119						imgFit(this, maxW);
120						$v.empty().append(this);
121						if (original_width > $img.width()) {
122							/*
123							img.height = Math.round((maxW/img.width)*img.height);
124							img.width  = maxW;
125							//img.title  = 'Click image to view full size';*/
126							$img.css( 'cursor', 'pointer' );
127							$img.addClass('like_a_link');
128							$img.bind('click', function(){ return !window.open(src); });
129							/*
130							return false;*/
131						}
132
133					});
134				}
135				var is_href = $v.parent().attr('href');
136
137				if(is_href)
138				{
139					$img.unbind('click');
140				}
141			}
142			else
143			{
144				if (hideSigImg){ return $(this).replaceWith(''); }
145				$v.empty().append($img);
146			}
147		});
148	}
149	function initSpoilers(context)
150	{
151		$('div.sp-body', context).each(function(){
152			var $sp_body = $(this);
153			var name = this.title || 'Скрытый текст';
154			this.title = '';
155			$('<div class="sp-head folded clickable">'+ name +'</div>').insertBefore($sp_body).click(function(e){
156				if (!$sp_body.hasClass('inited')) {
157					initPostImages($sp_body);
158					$sp_body.prepend('<div class="clear"></div>').append('<div class="clear"></div>').addClass('inited');
159					$('<div class="sp-head unfolded clickable">Закрыть</div>').insertAfter($sp_body).click(function(){
160						if($(document).scrollTop() > $sp_body.prev().offset().top)
161						{
162							$(document).scrollTop($sp_body.prev().offset().top - 200);
163						}
164						$(this).slideToggle('fast');
165						$sp_body.slideToggle('fast');
166						$sp_body.prev().toggleClass('unfolded');
167					});
168				}
169				else
170				{
171					$sp_body.next().slideToggle('fast');
172				}
173				if (e.shiftKey) {
174					e.stopPropagation();
175					e.shiftKey = false;
176					var fold = $(this).hasClass('unfolded');
177					$('div.sp-head', $($sp_body.parents('td')[0])).filter( function(){ return $(this).hasClass('unfolded') ? fold : !fold } ).click();
178				}
179				else {
180					$(this).toggleClass('unfolded');
181					$sp_body.slideToggle('fast');
182				}
183			});
184		});
185	}
186	function fixPostImage ($img)
187	{
188		var src = $img[0].src;
189		// keep4u
190		if (src.match(/keep4u/i)) {
191			var new_src = src.replace(/http:\/\/keep4u.ru\/imgs\/\w\/(.*)\/(.*)\.(.*)/, "//keep4u.ru/imgs/s/$1/$2.$3");
192			//var new_url = src.replace(/http:\/\/keep4u.ru\/imgs\/\w\/(.*)\/(.*)\.(.*)/, "//keep4u.ru/full/$1/$2/$3");
193			$img.attr('src', new_src).addClass('clickable');
194		}
195		return $img;
196	}
197}})(jQuery);
198
199$(document).ready(function(){
200	$(this).bb2Spoiler();
201});
202

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.