1/*_* 2* Name: PiroBox Extended v.1.0 3* Date: Gen 2011 4* Autor: Diego Valobra (http://www.pirolab.it),(http://www.diegovalobra.com) 5* Version: 1.0 6* Licence: CC-BY-SA http://creativecommons.org/licenses/by-sa/3/it/ 7**/ 8 9(function($) { 10 // Ametys: as $.browser is removed in jQuery > 1.9, we must make browser detection manually 11 $.browser = (function($) { 12 if (!$.isFunction($.uaMatch)) 13 { 14 $.uaMatch = function(ua) { 15 ua = ua.toLowerCase(); 16 17 var match = /(chrome)[ \/]([\w.]+)/.exec( ua ) || 18 /(webkit)[ \/]([\w.]+)/.exec( ua ) || 19 /(opera)(?:.*version|)[ \/]([\w.]+)/.exec( ua ) || 20 /(msie) ([\w.]+)/.exec( ua ) || 21 ua.indexOf("compatible") < 0 && /(mozilla)(?:.*? rv:([\w.]+)|)/.exec( ua ) || 22 []; 23 24 return { 25 browser: match[ 1 ] || "", 26 version: match[ 2 ] || "0" 27 }; 28 }; 29 } 30 31 var matched = $.uaMatch(navigator.userAgent), 32 browser = {}; 33 34 if (matched.browser) 35 { 36 browser[ matched.browser ] = true; 37 browser.version = matched.version; 38 } 39 40 // Chrome is Webkit, but Webkit is also Safari. 41 if (browser.chrome) 42 { 43 browser.webkit = true; 44 } 45 else if (browser.webkit) 46 { 47 browser.safari = true; 48 } 49 50 return browser; 51 })($); 52 // end of Ametys 53 54 $.fn.piroBox_ext = function(opt) { 55 opt = jQuery.extend({ 56 piro_speed : 700, 57 bg_alpha : 0.9, 58 piro_scroll : true, 59 next_label: "Next", 60 prev_label: "Previous", 61 close_label: "Close" 62 }, opt); 63 $.fn.piroFadeIn = function(speed, callback) { 64 $(this).fadeIn(speed, function() { 65 if(jQuery.browser.msie) 66 $(this).get(0).style.removeAttribute('filter'); 67 if(callback != undefined) 68 callback(); 69 }); 70 }; 71 $.fn.piroFadeOut = function(speed, callback) { 72 $(this).fadeOut(speed, function() { 73 if(jQuery.browser.msie) 74 $(this).get(0).style.removeAttribute('filter'); 75 if(callback != undefined) 76 callback(); 77 }); 78 }; 79 var my_gall_obj = $('a[class*="pirobox"]'); 80 var map = new Object(); 81 for (var i=0; i<my_gall_obj.length; i++) { 82 var it=$(my_gall_obj[i]); 83 map['a.'+ it.attr('class').match(/^pirobox_gall\w*/)]=0; 84 } 85 var gall_settings = new Array(); 86 for (var key in map) { 87 gall_settings.push(key); 88 } 89 for (var i=0; i<gall_settings.length; i++) { 90 $(gall_settings[i]+':first').addClass('first'); 91 $(gall_settings[i]+':last').addClass('last'); 92 } 93 var piro_gallery = $(my_gall_obj); 94 $('a[class*="pirobox_gall"]').each(function(rev){this.rev = rev+0}); 95 var struct =( 96 '<div class="piro_overlay"></div>'+ 97 '<table class="piro_html" cellpadding="0" cellspacing="0">'+ 98 '<tr>'+ 99 '<td class="h_t_l"></td>'+ 100 '<td class="h_t_c" title="drag me!!"></td>'+ 101 '<td class="h_t_r"></td>'+ 102 '</tr>'+ 103 '<tr>'+ 104 '<td class="h_c_l"></td>'+ 105 '<td class="h_c_c">'+ 106 '<div class="piro_loader" title="close"><span></span></div>'+ 107 '<div class="resize">'+ 108 '<div class="nav_container">'+ 109 '<a href="#prev" class="piro_prev" title="' + opt.prev_label + '">' + opt.prev_label + '</a>'+ 110 '<a href="#next" class="piro_next" title="' + opt.next_label + '">'+ opt.next_label + '</a>'+ 111 '<div class="piro_prev_fake">prev</div>'+ 112 '<div class="piro_next_fake">next</div>'+ 113 '<div class="piro_close" title="'+ opt.close_label +'"></div>'+ 114 '</div>'+ 115 '<div class="caption"></div>'+ 116 '<div class="div_reg"></div>'+ 117 '</div>'+ 118 '</td>'+ 119 '<td class="h_c_r"></td>'+ 120 '</tr>'+ 121 '<tr>'+ 122 '<td class="h_b_l"></td>'+ 123 '<td class="h_b_c"></td>'+ 124 '<td class="h_b_r"></td>'+ 125 '</tr>'+ 126 '</table>' 127 ); 128 $('body').append(struct); 129 var wrapper = $('.piro_html'), 130 piro_capt = $('.piro_html .caption'), 131 piro_bg = $('.piro_overlay'), 132 piro_next = $('.piro_next'), 133 piro_prev = $('.piro_prev'), 134 piro_next_fake = $('.piro_next_fake'), 135 piro_prev_fake = $('.piro_prev_fake'), 136 piro_close = $('.piro_close'), 137 div_reg = $('.div_reg'), 138 piro_loader = $('.piro_loader'), 139 resize = $('.resize'), 140 btn_info = $('.btn_info'); 141 var rz_img =0.95; /*::::: ADAPT IMAGE TO BROWSER WINDOW SIZE :::::*/ 142 if ( $.browser.msie ) { 143 wrapper.draggable({ handle:'.h_t_c,.h_b_c,.div_reg img'}); 144 }else{ 145 wrapper.draggable({ handle:'.h_t_c,.h_b_c,.div_reg img',opacity: 0.80}); 146 } 147 var y = $(window).height(); 148 var x = $(window).width(); 149 $('.nav_container').hide(); 150 wrapper.css({left: ((x/2)-(250))+ 'px',top: parseInt($(document).scrollTop())+(100)}); 151 $(wrapper).add(piro_capt).add(piro_bg).hide(); 152 piro_bg.css({'opacity':opt.bg_alpha}); 153 $(piro_prev).add(piro_next).bind('click',function(c) { 154 $('.nav_container').hide(); 155 c.preventDefault(); 156 piro_next.add(piro_prev).hide(); 157 var obj_count = parseInt($('a[class*="pirobox_gall"]').filter('.item').attr('rev')); 158 var start = $(this).is('.piro_prev') ? $('a[class*="pirobox_gall"]').eq(obj_count - 1) : $('a[class*="pirobox_gall"]').eq(obj_count + 1); 159 start.click(); 160 }); 161 $('html').bind('keyup', function (c) { 162 if(c.keyCode == 27) { 163 c.preventDefault(); 164 if($(piro_close).is(':visible')){close_all();} 165 } 166 }); 167 $('html').bind('keyup' ,function(e) { 168 if ($('.item').is('.first')){ 169 }else if(e.keyCode == 37){ 170 e.preventDefault(); 171 if($(piro_close).is(':visible')){piro_prev.click();} 172 } 173 }); 174 $('html').bind('keyup' ,function(z) { 175 if ($('.item').is('.last')){ 176 }else if(z.keyCode == 39){ 177 z.preventDefault(); 178 if($(piro_close).is(':visible')){piro_next.click();} 179 } 180 }); 181 $(window).resize(function(){ 182 var new_y = $(window).height(); 183 var new_x = $(window).width(); 184 var new_h = wrapper.height(); 185 var new_w = wrapper.width(); 186 wrapper.css({ 187 left: ((new_x/2)-(new_w/2))+ 'px', 188 top: parseInt($(document).scrollTop())+(new_y-new_h)/2 189 }); 190 }); 191 function scrollIt (){ 192 $(window).scroll(function(){ 193 var new_y = $(window).height(); 194 var new_x = $(window).width(); 195 var new_h = wrapper.height(); 196 var new_w = wrapper.width(); 197 wrapper.css({ 198 left: ((new_x/2)-(new_w/2))+ 'px', 199 top: parseInt($(document).scrollTop())+(new_y-new_h)/2 200 }); 201 }); 202 } 203 if(opt.piro_scroll == true){ 204 scrollIt() 205 } 206 $(piro_gallery).each(function(){ 207 208 var descr = $(this).attr('title'); 209 var params = $(this).attr('rel').split('-'); 210 var p_link = $(this).attr('href'); 211 $(this).unbind(); 212 $(this).bind('click', function(e) { 213 piro_bg.css({'opacity':opt.bg_alpha}); 214 e.preventDefault(); 215 piro_next.add(piro_prev).hide().css('visibility','hidden'); 216 $(piro_gallery).filter('.item').removeClass('item'); 217 $(this).addClass('item'); 218 open_all(); 219 if($(this).is('.first')){ 220 piro_prev.hide(); 221 piro_next.show(); 222 piro_prev_fake.show().css({'opacity':0.5,'visibility':'hidden'}); 223 }else{ 224 piro_next.add(piro_prev).show(); 225 piro_next_fake.add(piro_prev_fake).hide(); 226 } 227 if($(this).is('.last')){ 228 piro_prev.show(); 229 piro_next_fake.show().css({'opacity':0.5,'visibility':'hidden'}); 230 piro_next.hide(); 231 } 232 if($(this).is('.pirobox')){ 233 piro_next.add(piro_prev).hide(); 234 } 235 236 }); 237 238 function open_all(){ 239 wrapper.add(piro_bg).add(div_reg).add(piro_loader).show(); 240 function animate_html(){ 241 if(params[1] == 'full' && params[2] == 'full'){ 242 params[2] = $(window).height()-70; 243 params[1] = $(window).width()-55; 244 } 245 var y = $(window).height(); 246 var x = $(window).width(); 247 piro_close.hide(); 248 div_reg.add(resize).animate({ 249 'height':+ (params[2]) +'px', 250 'width':+ (params [1])+'px' 251 },opt.piro_speed).css('visibility','visible'); 252 253 wrapper.animate({ 254 height:+ (params[2])+20 +'px', 255 width:+ (params[1]) +20+'px', 256 left: ((x/2)-((params[1])/2+10))+ 'px', 257 top: parseInt($(document).scrollTop())+(y-params[2])/2-10 258 },opt.piro_speed ,function(){ 259 piro_next.add(piro_prev).css({'height':'20px','width':'20px'}); 260 piro_next.add(piro_prev).add(piro_prev_fake).add(piro_next_fake).css('visibility','visible'); 261 $('.nav_container').show(); 262 piro_close.show(); 263 }); 264 } 265 function animate_image (){ 266 var img = new Image(); 267 img.onerror = function (){ 268 piro_capt.html(''); 269 img.src = "http://www.pirolab.it/pirobox/js/error.jpg"; 270 } 271 img.onload = function() { 272 piro_capt.add(btn_info).hide(); 273 var y = $(window).height(); 274 var x = $(window).width();
275 var imgH = img.height; 276 var imgW = img.width; 277 278 //var rz_img =1.203; /*::::: ORIGINAL SIZE :::::*/ 279 if(imgH+20 > y || imgW+20 > x){ 280 var _x = (imgW + 20)/x; 281 var _y = (imgH + 20)/y; 282 if ( _y > _x ){ 283 imgW = Math.round(img.width* (rz_img/_y)); 284 imgH = Math.round(img.height* (rz_img/_y)); 285 }else{ 286 imgW = Math.round(img.width * (rz_img/_x)); 287 imgH = Math.round(img.height * (rz_img/_x)); 288 } 289 }else{ 290 imgH = img.height; 291 imgW = img.width; 292 } 293 294 var y = $(window).height(); 295 var x = $(window).width(); 296 $(img).height(imgH).width(imgW).hide(); 297 298 $(img).fadeOut(300,function(){}); 299 $('.div_reg img').remove(); 300 $('.div_reg').html(''); 301 div_reg.append(img).show(); 302 $(img).addClass('immagine'); 303 304 div_reg.add(resize).animate({height:imgH+'px',width:imgW+'px'},opt.piro_speed); 305 wrapper.animate({ 306 height : (imgH+20) + 'px' , 307 width : (imgW+20) + 'px' , 308 left: ((x/2)-((imgW+20)/2)) + 'px', 309 top: parseInt($(document).scrollTop())+(y-imgH)/2-20 310 },opt.piro_speed, function(){ 311 var cap_w = resize.width(); 312 piro_capt.css({width:cap_w+'px'}); 313 piro_loader.hide(); 314 $(img).fadeIn(300,function(){ 315 piro_close.add(btn_info).show(); 316 piro_capt.slideDown(200); 317 piro_next.add(piro_prev).css({'height':'20px','width':'20px'}); 318 piro_next.add(piro_prev).add(piro_prev_fake).add(piro_next_fake).css('visibility','visible'); 319 $('.nav_container').show(); 320 resize.resize(function(){ 321 NimgW = img.width;//1.50; 322 NimgH = img.heigh;//1.50; 323 piro_capt.css({width:(NimgW)+'px'}); 324 }); 325 }); 326 }); 327 } 328 329 img.src = p_link; 330 piro_loader.click(function(){ 331 img.src = 'about:blank'; 332 }); 333 } 334 335 switch (params[0]) { 336 337 case 'iframe': 338 div_reg.html('').css('overflow','hidden'); 339 resize.css('overflow','hidden'); 340 piro_close.add(btn_info).add(piro_capt).hide(); 341 animate_html(); 342 div_reg.piroFadeIn(300,function(){ 343 div_reg.append( 344 '<iframe id="my_frame" class="my_frame" src="'+p_link+'" frameborder="0" allowtransparency="true" scrolling="auto" align="top"></iframe>' 345 ); 346 $('.my_frame').css({'height':+ (params[2]) +'px','width':+ (params [1])+'px'}); 347 piro_loader.hide(); 348 }); 349 break; 350 351 case 'content': 352 div_reg.html('').css('overflow','auto'); 353 resize.css('overflow','auto'); 354 $('.my_frame').remove(); 355 piro_close.add(btn_info).add(piro_capt).hide(); 356 animate_html() 357 div_reg.piroFadeIn(300,function(){ 358 div_reg.load(p_link); 359 piro_loader.hide(); 360 }); 361 break; 362 363 case 'inline': 364 div_reg.html('').css('overflow','auto'); 365 resize.css('overflow','auto'); 366 $('.my_frame').remove(); 367 piro_close.add(btn_info).add(piro_capt).hide(); 368 animate_html() 369 div_reg.piroFadeIn(300,function(){ 370 $(p_link).clone(true).appendTo(div_reg).piroFadeIn(300); 371 piro_loader.hide(); 372 }); 373 break 374 375 case 'gallery': 376 div_reg.css('overflow','hidden'); 377 resize.css('overflow','hidden'); 378 $('.my_frame').remove(); 379 piro_close.add(btn_info).add(piro_capt).hide(); 380 if(descr == ""){ 381 piro_capt.html(''); 382 }else{ 383 piro_capt.html('<p>' + descr + '</p>'); 384 } 385 animate_image(); 386 break; 387 388 case 'single': 389 piro_close.add(btn_info).add(piro_capt).hide(); 390 div_reg.html('').css('overflow','hidden'); 391 resize.css('overflow','hidden'); 392 $('.my_frame').remove(); 393 if(descr == ""){ 394 piro_capt.html(''); 395 }else{ 396 piro_capt.html('<p>' + descr + '</p>'); 397 } 398 animate_image(); 399 break 400 } 401 } 402 }); 403 404 // Ametys: jQuery 1.9 upgrade. live() removed, on() is the recommended 405 // method. 406 $(document).on('click', '.immagine', function(){
407 piro_capt.slideToggle(200); 408 }); 409 410 function close_all (){ 411 if($('.piro_close').is(':visible')){ 412 $('.my_frame').remove(); 413 wrapper.add(div_reg).add(resize).stop(); 414 var ie_sucks = wrapper; 415 if ( $.browser.msie ) { 416 ie_sucks = div_reg.add(piro_bg); 417 $('.div_reg img').remove(); 418 }else{ 419 ie_sucks = wrapper.add(piro_bg); 420 } 421 ie_sucks.piroFadeOut(200,function(){ 422 div_reg.html(''); 423 piro_loader.add(piro_capt).add(btn_info).hide(); 424 $('.nav_container').hide(); 425 piro_bg.add(wrapper).hide().css('visibility','visible'); 426 }); 427 } 428 } 429 piro_close.add(piro_loader).add(piro_bg).bind('click',function(y){y.preventDefault(); close_all(); }); 430 } 431})(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.