1(function($) { 2 $.fn.bb3Spoiler = function(options){ 3 4 initPost($(this)); 5 6 function imgFit (img, spoilerMaxW) 7 { 8 if (typeof(img.naturalHeight) == undefined) { 9 img.naturalHeight = img.height; 10 img.naturalWidth = img.width; 11 } 12 13 if (img.width > spoilerMaxW) { 14 img.height = Math.round((spoilerMaxW/img.width)*img.height); 15 img.width = spoilerMaxW; 16 //img.title = 'Click image to view full size'; 17 img.style.cursor = 'pointer'; 18 return false; 19 } 20 else if (img.width == spoilerMaxW && img.width < img.naturalWidth) { 21 img.height = img.naturalHeight; 22 img.width = img.naturalWidth; 23 //img.title = 'Click to fit in the browser window'; 24 return false; 25 } 26 else { 27 return true; 28 } 29 } 30 31 function initPost(context) 32 { 33 initPostImages(context); 34 initSpoilers(context); 35 } 36 function initPostImages(context) 37 { 38 var $in_spoilers = $('div.sp-body var.postImg', context); 39 40 var rules_link='#'; 41 42 $('var.postImg', context).not($in_spoilers).each(function(){ 43 var $v = $(this); 44 var src = $v.attr('title'); 45 var img_align = $v.attr('align')!=undefined ? ' align="'+ $v.attr('align') +'"' : ''; 46 var className = $v.attr('class')!=undefined ? ' class="'+ $v.attr('class') +'"' : ''; 47 var is_href = $v.parent().attr('href'); 48 if(is_href) 49 { 50 $v.removeClass('postImg'); 51 } 52 var $img = $('<img src="'+ src +'"'+ img_align + className +' alt="" />'); 53 54 var is_signature = $v.parents().hasClass('signature') ? true : false; 55 56 57 if ((!is_signature && hidePostImg) || (is_signature && hideSigImg)) 58 { 59 return $(this).replaceWith(''); 60 } 61 62 if(banned_image_hosts && src.match(banned_image_hosts)) 63 { 64 if(is_href) 65 { 66 $v.parent().attr('href', banned_img); 67 } 68 return $(this).replaceWith('<a href="' + rules_link + '" title="' + bannedImageHosts + '"><img src="' + banned_img + '" alt="' + bannedImageHosts + '" /></a>'); 69 } 70 else 71 { 72 $img = fixPostImage($img); 73 } 74 75 if(open_type=='current_window') 76 { 77 //Original 78 $img.bind('click', function(){ imgFit(this, spoilerMaxW); }); 79 } 80 else if(open_type=='new_window') 81 { 82 //Default 83 $img.bind('click', function(){ return !window.open(src); }); 84 } 85// else if(open_type=='pretty_photo') 86// { 87// $img.bind('click', function() 88// { 89// api_images = [src]; 90// $.prettyPhoto.open(api_images); 91// }); 92// } 93// else if(open_type=='fancybox') 94// { 95// $img.bind('click', function() 96// { 97// api_images = src; 98// $.fancybox({ 99// //'orig': $(this), 100// 'padding': 0, 101// 'href': api_images, 102// 'transitionIn': 'elastic', 103// 'transitionOut': 'elastic' 104// }); 105// }); 106// $(".fancybox").click(function() { 107// $.fancybox({ 108// //'orig': $(this), 109// 'padding': 0, 110// 'href': src, 111// 'transitionIn': 'elastic', 112// 'transitionOut': 'elastic' 113// }); 114// }); 115// } 116// else if(open_type=='highslide') 117// { 118// $img.bind('click', function() 119// { 120// api_images = src; 121// hs.expand(null, {src: api_images}); 122// }); 123// } 124// else if(open_type=='lightbox2') 125// { 126// $img.bind('click', function() 127// { 128// $('.lightbox').trigger('click'); 129// }); 130// } 131// else if(open_type=='fancybox3') 132// { 133// $img.bind('click', function() 134// { 135// api_images = src;
136// $.fancybox.open({src: api_images, type: 'image', opts: {}}); 137// }); 138// } 139 140 $('#preload').append($img); 141 var loading_icon = '<a href="'+ src +'" target="_blank"><img src="' + loading_img + '" alt="" /></a>'; 142 $v.html(loading_icon); 143 144 if ($.browser.msie || $.browser.opera) 145 { 146 $img.one('load', function(){ imgFit(this, spoilerMaxW); }); 147 $v.empty().append($img); 148 $v.after('<wbr>'); 149 } 150 else 151 { 152 $img.one('load', function(){ 153 imgFit(this, spoilerMaxW); 154 $v.empty().append(this); 155 }); 156 } 157 158 if(is_href) 159 { 160 $img.unbind('click'); 161 } 162 163 }); 164 } 165 function initSpoilers(context) 166 { 167 $('div.sp-body', context).each(function(){ 168 var $sp_body = $(this); 169 var name = this.title || hiddenText; 170 this.title = ''; 171 $('<div class="sp-head folded clickable">'+ name +'</div>').insertBefore($sp_body).click(function(e){ 172 if (!$sp_body.hasClass('inited')) { 173 initPostImages($sp_body); 174 $sp_body.prepend('<div class="clear"></div>').append('<div class="clear"></div>').addClass('inited'); 175 $('<div class="sp-head unfolded clickable">' + spoilerClose + '</div>').insertAfter($sp_body).click(function(){ 176 if($(document).scrollTop() > $sp_body.prev().offset().top) 177 { 178 $(document).scrollTop($sp_body.prev().offset().top - 200); 179 } 180 $(this).slideToggle('fast'); 181 $sp_body.slideToggle('fast'); 182 $sp_body.prev().toggleClass('unfolded'); 183 }); 184 } 185 else 186 { 187 $sp_body.next().slideToggle('fast'); 188 } 189 if (e.shiftKey) { 190 e.stopPropagation(); 191 e.shiftKey = false; 192 var fold = $(this).hasClass('unfolded'); 193 $('div.sp-head', $($sp_body.parents('td')[0])).filter( function(){ return $(this).hasClass('unfolded') ? fold : !fold } ).click(); 194 } 195 else { 196 $(this).toggleClass('unfolded'); 197 $sp_body.slideToggle('fast'); 198 } 199 }); 200 }); 201 } 202 function fixPostImage ($img) 203 { 204 var src = $img[0].src; 205 // keep4u 206 if (src.match(/keep4u/i)) { 207 var new_src = src.replace(/http:\/\/keep4u.ru\/imgs\/\w\/(.*)\/(.*)\.(.*)/, "http://keep4u.ru/imgs/s/$1/$2.$3"); 208 //var new_url = src.replace(/http:\/\/keep4u.ru\/imgs\/\w\/(.*)\/(.*)\.(.*)/, "http://keep4u.ru/full/$1/$2/$3"); 209 $img.attr('src', new_src).addClass('clickable'); 210 } 211 return $img; 212 } 213}})(jQuery); 214 215jQuery(document).ready(function($){ 216 $(this).bb3Spoiler(); 217});
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.