1/* ------------------------------------------------------------------------ 2 LCweb Lightbox 3 Author: Luca Montanari aka Lweb (http://www.lcweb.it) 4 Version: 2.02 5------------------------------------------------------------------------- */ 6 7(function($) { 8 $.lcweb_lightbox = {}; 9 10 $.fn.lcweb_lightbox = function(lcl_settings) { 11 12 lcl_settings = jQuery.extend({ 13 hook: 'rel', // attribute to group the elements 14 15 url_src: 'href', // attribute containing the title 16 title_src: 'title', // attribute containing the title 17 author_src: 'lcl-author', // attribute containing the author 18 descr_src: 'alt', // attribute containing the description 19 20 animation_time: 250, // animation timing in millisecods / 1000 = 1sec 21 slideshow_time: 6000, // interval time of the slideshow in milliseconds / 1000 = 1sec 22 autoplay: false, /* autoplay slideshow / true/false */ 23 24 ol_opacity: 0.70, // overlay opacity / value between 0 and 1 25 ol_color: '#000', // background color of the overlay 26 ol_pattern: 'oblique_dots', // overlay patterns - insert the pattern name or false 27 border_w: 5, // width of the lightbox border in pixels 28 border_col: '#555', // color of the lightbox border 29 padding: 4, // width of the lightbox padding in pixels 30 radius: 12, // corner radius of the lightbox in pixels (not for IE < 9) 31 32 style: 'light', // light / dark 33 data_position: 'over', // over / under / lside / rside 34 35 show_title: true, // true/false 36 show_descr: true, // true/false 37 show_author: true, // true/false 38 39 thumb_nav: true, // enable the thumbnail navigation for image galleries 40 thumbs_maker_url: false, // script baseurl to create thumbnails (use src=%URL% w=%W% h=%H%) 41 thumb_w: 120, // width of the thumbs for the standard lightbox 42 thumb_h: 85, // height of the thumbs for the standard lightbox 43 44 fullscreen: true, // Allow the user to expand a resized image. true/false 45 fs_img_behaviour: 'smart', // resize mode of the fullscreen image - none/smart/fit/fill 46 fs_only: 'always', // open directly in fullscreen (only for image galleries) - none/mobile/always 47 48 socials: true, // bool 49 fb_share_fix: 'http://www.lcweb.it/lcis_fb_img_fix.php', // script to get rid of the facebook block on facebook CDN images 50 touchSwipe: true, // bool / Allow touchSwipe interactions for mobile 51 modal: false, // enable modal mode (no closing on overlay click) 52 53 max_width: '70%', // insert a percent value or an int for pixel value 54 max_height: '90%', // insert a percent value or an int for pixel value 55 56 open: false, // open the lightbox immediately 57 from_index: 0, // start index for automatic openings 58 manual_hook: false, // hook value for automatic openings 59 60 base_code: 61 '<div id="lcl_wrapper">'+ 62 '<div id="lcl_standard" class="lcl_standard_closed">'+ 63 '<div id="lcl_standard_cmd">'+ 64 '<table><tr>'+ 65 '<td>'+ 66 '<div class="lcl_icon lcl_prev"></div>'+ 67 '<div class="lcl_icon lcl_autoplay lcl_pause"></div>'+ 68 '<div class="lcl_icon lcl_next"></div>'+ 69 '</td>'+ 70 '<td>'+ 71 '<div class="lcl_icon lcl_close"></div>'+ 72 '<div class="lcl_icon lcl_fullscreen"></div>'+ 73 '<div class="lcl_icon lcl_socials"></div>'+ 74 '</td>'+ 75 '</tr></table>'+ 76 '</div>'+ 77 '<div id="lcl_standard_elem"></div>'+ 78 '<div id="lcl_standard_txt">'+ 79 '<h3>'+ 80 '<span id="lcl_standard_title"></span>'+ 81 '<span id="lcl_standard_author"></span>'+ 82 '</h3>'+ 83 '<div id="lcl_standard_descr"></div>'+ 84 '</div>'+ 85 '</div>'+ 86 '<div id="lcl_fullscreen" style="display: none;">'+ 87 '<div id="lcl_fs_cmd">'+ 88 '<section>'+ 89 '<div class="lcl_icon lcl_prev"><span></span></div>'+ 90 '<div class="lcl_icon lcl_autoplay lcl_pause"><span></span></div>'+ 91 '<div class="lcl_icon lcl_next"><span></span></div>'+ 92 '</section>'+ 93 '<div class="lcl_icon lcl_close"></div>'+ 94 '<div class="lcl_icon lcl_socials"></div>'+ 95 '<div class="lcl_icon lcl_toggle_info"></div>'+ 96 '</div>'+ 97 '<div id="lcl_fs_elem"></div>'+ 98 '<div id="lcl_fs_txt">'+ 99 '<h3>'+ 100 '<span id="lcl_fs_title"></span>'+ 101 '<span id="lcl_fs_author"></span>'+ 102 '</h3>'+ 103 '<div id="lcl_fs_descr"></div>'+ 104 '</div>'+ 105 '</div>'+ 106 '<div id="lcl_thumb_nav" style="display: none;"></div>'+ 107 '<div id="lcl_loader" style="display: none;"></div>'+ 108 '<div id="lcl_overlay" style="display: none;"></div>'+ 109 '</div>' 110 }, lcl_settings); 111 112 // Global variables accessible only by the plugin 113 var lcl_open, lcl_fullscreen_open, lcl_fs_txt = true, lcl_is_active = false, lcl_slideshow, lcl_txt_exists, lcl_txt_h, lcl_managed_img_h, lcl_count_txt_under, lcl_html_style, lcl_body_style, 114 115 // elements variables 116 lcl_elem_obj = this, lcl_tot_elements, lcl_elem_index, lcl_elem_url, lcl_elem_title, lcl_elem_author, lcl_elem_descr, lcl_curr_elem_w, lcl_
116curr_elem_h, lcl_is_img_gallery, 117 118 // thumbnail navigator variables 119 lcl_thumb_per_page, lcl_curr_thumb_pag, lcl_thumb_pag_w, lcl_scrolling_thumb = false; 120 121 // Window sizes 122 lcl_window_h = $(window).height(); lcl_window_w = $(window).width(); 123 124 125 /** 126 * Initialize and open the lightbox 127 */ 128 $.lcweb_lightbox.init = function() { 129 settings = lcl_settings; 130 131 lcl_elem_url = $.makeArray(); 132 lcl_elem_title = $.makeArray(); 133 lcl_elem_author = $.makeArray(); 134 lcl_elem_descr = $.makeArray(); 135 136 // find the hook to group images 137 if(!settings.open) { var hook_val = $(this).attr(settings.hook); } 138 else { var hook_val = settings.manual_hook; } 139 140 // get the images and put the data into arrays 141 jQuery.map(lcl_elem_obj, function(n, i){ 142 if( (!hook_val || typeof(hook_val) == 'undefined') || $(n).attr(settings.hook) == hook_val ) { 143 lcl_elem_url.push( $(n).attr(settings.url_src) ); 144 lcl_elem_title.push( $(n).attr(settings.title_src) ); 145 lcl_elem_author.push( $(n).attr(settings.author_src) ); 146 lcl_elem_descr.push( $(n).attr(settings.descr_src) ); 147 } 148 }); 149 150 // collection infos 151 lcl_tot_elements = lcl_elem_url.length; 152 153 if(!settings.open) { 154 lcl_elem_index = jQuery.inArray( $(this).attr(settings.url_src), lcl_elem_url); 155 } 156 else {lcl_elem_index = settings.from_index;} 157 158 // nav buttons manage 159 if(!lcl_elem_index) { 160 $('#lcl_standard_cmd .lcl_prev, #lcl_fullscreen_cmd .lcl_prev').addClass('lcl_nav_disabled'); 161 } 162 else if(lcl_elem_index == (lcl_tot_elements - 1)) { 163 $('#lcl_standard_cmd .lcl_next, #lcl_fullscreen_cmd .lcl_next').addClass('lcl_nav_disabled'); 164 } 165 166 if(lcl_tot_elements == 1) { 167 $('#lcl_standard_cmd .lcl_prev, #lcl_fullscreen_cmd .lcl_prev, #lcl_standard_cmd .lcl_next, #lcl_fullscreen_cmd .lcl_next').hide(); 168 } 169 170 // disable thumbs nav if there's only one image 171 if(lcl_tot_elements == 1) { 172 settings.thumb_nav = false; 173 } 174 175 // build the lightbox layout and show overlay 176 _build_layout(); 177 _first_load(); 178 179 // open 180 $.lcweb_lightbox.open(); 181 return false; 182 } 183 184 185 /** 186 * Open the lightbox 187 */ 188 $.lcweb_lightbox.open = function(custom) { 189 var settings = lcl_settings; 190 lcl_is_active = true; 191 192 if(typeof(custom) != 'undefined') { 193 // CUSTOM OPENING - TODO 194 } 195 else { 196 // wait content to be loaded and show 197 if( _elem_type() == 'image'){ 198 $('<img />').bind("load",function(){ 199 lcl_curr_elem_w = this.width; 200 lcl_curr_elem_h = this.height; 201 202 if(!lcl_fullscreen_open) { _adjust_and_show(); } 203 else { _manage_fs_img(); } 204 }).attr('src', lcl_elem_url[lcl_elem_index]); 205 206 _populate_lightbox(); 207 208 // Preload next and prev images 209 if(lcl_tot_elements > 1 && lcl_elem_index < lcl_tot_elements - 1 && _elem_type(lcl_elem_url[lcl_elem_index + 1]) == 'image') { 210 $('<img />').bind("load").attr('src', lcl_elem_url[lcl_elem_index + 1]); 211 } 212 if(lcl_tot_elements > 1 && lcl_elem_index > 0 && _elem_type(lcl_elem_url[lcl_elem_index - 1]) == 'image') { 213 $('<img />').bind("load").attr('src', lcl_elem_url[lcl_elem_index - 1]); 214 } 215 } 216 217 else { 218 // TODO get element sizes 219 _adjust_and_show(); 220 } 221 222 lcl_open = true; 223 } 224 225 setTimeout(function() { 226 lcl_is_active = false; 227 }, settings.animation_time); 228 } 229 230 231 /** 232 * Switch to fullscreen layout 233 */ 234 $.lcweb_lightbox.open_fullscreen = function() { 235 if(!_is_images_gallery()) { return false;} 236 var settings = lcl_settings; 237 238 $('#lcl_standard').fadeOut(); 239 $('#lcl_loader').fadeIn(); 240 241 if(settings.thumb_nav && _is_images_gallery()) { 242 $('#lcl_thumb_nav > div').css('opacity', 1); 243 $('#lcl_thumb_nav').fadeIn(400); 244 } else { 245 $('#lcl_thumb_nav').css('opacity', 0).hide(); 246 } 247 248 lcl_fullscreen_open = true; 249 250 // check the description box visibility 251 if($('#lcl_standard_txt').is(':hidden')) { $('#lcl_fs_txt, .lcl_toggle_info').hide(); } 252 253 // delay and process 254 setTimeout(function() { 255 $('#lcl_loader').fadeOut(); 256 $('#lcl_fullscreen').fadeIn(function() { 257 $.lcweb_lightbox.open(); 258 }); 259 }, 300); 260 } 261 262 263 /** 264 * Change the lightbox page 265 */ 266 $.lcweb_lightbox.change_page = function(direction) { 267 if( !lcl_is_active ) { 268 lcl_is_active = true; 269 270 if(direction == 'prev') { 271 lcl_elem_index--; 272 if (lcl_elem_index < 0) { lcl_elem_index = lcl_tot_elements - 1; } 273 } 274 else if(direction == 'next'){ 275 lcl_elem_index++; 276 if (lcl_elem_index > (lcl_tot_elements - 1)) { lcl_elem_index = 0; } 277 } 278 else{ 279 lcl_elem_index = parseInt(direction); // for jump-to-content 280 }; 281 282 if(!lcl_fullscreen_open) { 283 $('#lcl_standard >
283 *').clearQueue().fadeTo((settings.animation_time - 30), 0); 284 285 setTimeout(function() { 286 $('#lcl_standard_elem').css('width', $('#lcl_standard_elem').width()).css('height', $('#lcl_standard_elem').height()).addClass('lcl_pag_anim'); 287 288 $('#lcl_standard').removeClass('lcl_no_loader'); 289 $('#lcl_standard_elem').empty(); 290 $.lcweb_lightbox.open(); 291 292 }, (settings.animation_time + 30)); 293 } 294 else { 295 $('#lcl_fs_elem').removeClass('lcl_no_loader'); 296 $('#lcl_fs_elem > img, #lcl_fill_fs_img').clearQueue().fadeOut((settings.animation_time - 30)); 297 $('#lcl_fs_txt').clearQueue().fadeTo((settings.animation_time - 30), 0); 298 299 setTimeout(function() { 300 $('#lcl_fs_elem').empty(); 301 $.lcweb_lightbox.open(); 302 303 }, (settings.animation_time + 30)); 304 305 _manage_thumb_nav(); 306 } 307 } 308 } 309 310 311 /** 312 * Close the lightbox 313 */ 314 $.lcweb_lightbox.close = function() { 315 var settings = lcl_settings; 316 lcl_open = false; 317 lcl_fullscreen_open = false; 318 319 $('#lcl_wrapper *').stop(); 320 321 // restore html/body inline CSS 322 if(typeof(lcl_html_style) != 'undefined') {jQuery('html').attr('style', lcl_html_style);} 323 else {jQuery('html').removeAttr('style');} 324 325 if(typeof(lcl_body_style) != 'undefined') {jQuery('body').attr('style', lcl_body_style);} 326 else {jQuery('body').removeAttr('style');} 327 328 329 $('#lcl_wrapper').fadeOut(function() { 330 $(this).remove(); 331 }); 332 } 333 334 335 /** 336 * Reload lightbox elements 337 */ 338 $.lcweb_lightbox.reload = function(selector) { 339 $(selector).unbind('click.lcweb_lightbox').bind('click.lcweb_lightbox', $.lcweb_lightbox.init ); 340 lcl_elem_obj = $(selector); 341 return false; 342 } 343 344 345 /** 346 * Start the image slideshow 347 */ 348 $.lcweb_lightbox.start_slideshow = function(){ 349 var settings = lcl_settings; 350 351 clearInterval(lcl_slideshow); 352 lcl_slideshow = setInterval(function() { 353 $.lcweb_lightbox.change_page('next'); 354 }, (settings.slideshow_time + settings.animation_time)); 355 356 $('.lcl_autoplay').removeClass('lcl_play').addClass('lcl_pause'); 357 } 358 359 360 /** 361 * Stop slideshow 362 */ 363 $.lcweb_lightbox.stop_slideshow = function(){ 364 $('.lcl_autoplay').removeClass('lcl_pause').addClass('lcl_play'); 365 clearInterval(lcl_slideshow); 366 lcl_slideshow = false; 367 } 368 369 370 //////////////////////////////////////////////// 371 372 // show the overlay and the loader for the first use 373 function _first_load() { 374 // set slideshow variable 375 if(_is_images_gallery()) {lcl_slideshow = true;} 376 else {lcl_slideshow = false;} 377 378 $('#lcl_overlay, #lcl_loader').fadeIn(); 379 380 // backup html/body inline CSS 381 lcl_html_style = jQuery('html').attr('style'); 382 lcl_body_style = jQuery('body').attr('style'); 383 384 // avoid page scrolling 385 jQuery('html').css('overflow', 'hidden'); 386 jQuery('body').css('overflow', 'visible'); 387 388 lcl_window_h = $(window).height(); 389 lcl_window_w = $(window).width(); 390 } 391 392 393 // build the lightbox layout 394 function _build_layout() { 395 if( $('#lcl_wrapper').length ) { $('#lcl_wrapper').remove(); } 396 $('body').append( settings.base_code ); 397 398 // set maximum elastic width 399 $('#lcl_standard').css('max-width', settings.max_width).css('max-height', settings.max_height); 400 401 // show/hide navigation buttons if only one image 402 if(lcl_tot_elements > 1) { 403 $('.lcl_prev, .lcl_autoplay, .lcl_next').show(); 404 $('#lcl_fs_txt').css('top', 65); 405 } else { 406 $('.lcl_prev, .lcl_autoplay, .lcl_next').hide(); 407 $('#lcl_fs_txt').css('top', 20); 408 } 409 410 // data position 411 var data_layout_class = 'lcl_data_' + settings.data_position; 412 $('#lcl_standard').addClass( data_layout_class ); 413 414 // commands 415 if(!settings.fullscreen) { $('#lcl_standard_cmd .lcl_fullscreen').hide(); } 416 if(!settings.socials) { $('#lcl_standard_cmd .lcl_socials, #lcl_fs_cmd .lcl_socials').hide(); } 417 418 if(settings.autoplay) { $('#lcl_standard_cmd .lcl_autoplay, #lcl_fs_cmd .lcl_autoplay').removeClass('lcl_play').addClass('lcl_pause'); } 419 else { $('#lcl_standard_cmd .lcl_autoplay, #lcl_fs_cmd .lcl_autoplay').removeClass('lcl_pause').addClass('lcl_play'); } 420 421 // standard command - left/right positio in relation with padding 422 $('#lcl_standard_cmd').css('left', settings.padding).css('right', settings.padding); 423 424 // style 425 $('#lcl_loader, #lcl_standard, #lcl_fullscreen, #lcl_thumb_nav').addClass('lcl_' + settings.style); 426 427 // overlay 428 $('#lcl_overlay').css('background-color', settings.ol_color).fadeTo(0, settings.ol_opacity); 429 if(settings.ol_pattern) { $('#lcl_overlay').addClass('lcl_pattern_' + settings.ol_pattern); } 430 431 // standard lightbox - colors / padding / borders 432 $('#lcl_standard') 433 .css('padding', settings.padding) 434 .css('border-width', settings.border_w) 435 .css('border-color', settings.border_col) 436 .css('border-radius', settings.radius); 437 438 // data visibility 439 if( !settings.show_title ) { $('#lcl_standard_title, #lcl_fs_title').hide(); } 440 if( !settings.show_descr ) { $('#lcl_standard_descr, #lcl_fs_descr').hide(); } 441 if( !settings.show_author ) { $('#lcl_standard_author, #lcl_fs_author').hide(); } 442 443 // touch devices corrections 444 if( _is_touch_device() ) { 445 $('#lcl_wrapper').bind('touchstart.lcweb_lightbox', function() { 446 $('#lcl_standard_cmd table div, #lcl_fs_cmd div, #lcl_thumb_nav > div').css('opacity', 1); 447 }); 448 $('#lcl_wrapper').bind('touchend.lcweb_lightbox', function() { 449 $('#lcl_standard_cmd table div, #lcl_fs_cmd div, #lcl_thumb_nav > div').css('opacity', 0.4); 450 }); 451 } 452 } 453 454 455 // populate the lightbox with the proper content 456 function _populate_lightbox() { 457 var curr_elem_type = _elem_type(); 458 459 switch(curr_elem_type) { 460 case 'image' : 461 $('#lcl_standard_elem').append('<img src="'+ lcl_elem_url[lcl_elem_index] +'" />'); 462 $('#lcl_fs_elem').html('<img src="'+ lcl_elem_url[lcl_elem_index] +'" />'); 463 break; 464 } 465 466 // title 467 if( settings.show_title && $.trim(lcl_elem_title[lcl_elem_index]) != '' ) { $('#lcl_standard_title, #lcl_fs_title').html( lcl_elem_title[lcl_elem_index] ); } 468 else { $('#lcl_standard_title, #lcl_fs_title').empty(); } 469 470 // description 471 if( settings.show_descr && $.trim(lcl_elem_descr[lcl_elem_index]) != '' ) { $('#lcl_standard_descr, #lcl_fs_descr').html( lcl_elem_descr[lcl_elem_index] ); } 472 else { $('#lcl_standard_descr, #lcl_fs_descr').empty(); } 473 474 // author 475 if( settings.show_author && $.trim(lcl_elem_author[lcl_elem_index]) != '') { $('#lcl_standard_author, #lcl_fs_author').html('by ' + lcl_elem_author[lcl_elem_index] ); } 476 else { $('#lcl_standard_author, #lcl_fs_author').empty(); } 477 478 // if everything is hidden or doesn't exist any txt, hide the txt container 479 if(
480 (!settings.show_title && !settings.show_descr && !settings.show_author) || 481 ($.trim(lcl_elem_title[lcl_elem_index]) == '' && $.trim(lcl_elem_descr[lcl_elem_index]) == '' && $.trim(lcl_elem_author[lcl_elem_index]) == '') 482 ) { 483 $('#lcl_standard_txt, #lcl_fs_txt').hide(); 484 $('#lcl_fs_txt').addClass('lcl_fs_txt_hidden'); 485 $('.lcl_toggle_info').fadeOut('fast'); 486 lcl_txt_exists = false; 487 } 488 else { 489 $('#lcl_standard_txt').show(); 490 $('#lcl_fs_txt').removeClass('lcl_fs_txt_hidden'); 491 492 (lcl_fs_txt) ? $('#lcl_fs_txt').show() : $('#lcl_fs_txt').hide(); 493 $('.lcl_toggle_info').fadeIn('fast'); 494 495 lcl_txt_exists = true; 496 } 497 498 // if text over - adjust position with padding 499 if((settings.data_position == 'over' || settings.data_position == 'under') && lcl_txt_exists) { 500 jQuery('#lcl_standard_txt').css('left', settings.padding).css('right', settings.padding).css('bottom', settings.padding); 501 } 502 503 // if social enabled, prepare and append 504 if(settings.socials) { 505 var sanitized_title = encodeURIComponent( $.trim( lcl_elem_title[lcl_elem_index])).replace(/'/gi,"\\'"); 506 var sanitized_descr = encodeURIComponent( $.trim( lcl_elem_descr[lcl_elem_index])).replace(/'/gi,"\\'"); 507 508 var social_code = _social_code( 509 encodeURIComponent(lcl_elem_url[lcl_elem_index]), 510 sanitized_title, 511 sanitized_descr, 512 encodeURIComponent(window.location.href) 513 ); 514 var socials_opened = ($('#lcl_standard_cmd .lcl_social_box').is(':visible') || $('#lcl_fs_cmd .lcl_social_box').is(':visible')) ? true : false; 515 516 if(!lcl_fullscreen_open) { 517 if( $('#lcl_standard_cmd .lcl_social_box').length ) { $('#lcl_standard_cmd .lcl_social_box').remove(); } 518 $('#lcl_standard_cmd td:last-child').append(social_code); 519 if(socials_opened) { $('#lcl_standard_cmd .lcl_social_box').show(); } 520 } 521 else { 522 if( $('#lcl_fs_cmd .lcl_social_box').length ) { $('#lcl_fs_cmd .lcl_social_box').remove(); } 523 $('#lcl_fs_cmd').append(social_code); 524 if(socials_opened) { $('#lcl_fs_cmd .lcl_social_box').show(); } 525 } 526 } 527 } 528 529 530 // position the lightbox always on the page center 531 function _adjust_and_show() { 532 var settings = lcl_settings; 533 534 // thumb nav 535 _manage_thumb_nav(); 536 537 // max sizes according with global settigs 538 var add_space = (settings.border_w * 2) + (settings.padding * 2) 539 var max_height_px = (lcl_window_h * (parseInt(settings.max_height) / 100)) - parseInt($('#lcl_wrapper').css('padding-bottom')) - parseInt($('#lcl_wrapper').css('padding-top')) - add_space; 540 var max_width_px = (lcl_window_w * (parseInt(settings.max_width) / 100)) - parseInt($('#lcl_wrapper').css('padding-left')) - parseInt($('#lcl_wrapper').css('padding-right')) - add_space; 541 542 543 // buttons position if tiny image 544 if(Math.min(lcl_curr_elem_w, max_width_px) < 280) { 545 $('#lcl_wrapper').addClass('lcl_external_cmd'); 546 } else { 547 $('#lcl_wrapper').removeClass('lcl_external_cmd'); 548 } 549 550 // manage image height if taller than max 551 if(lcl_curr_elem_h > max_height_px) { 552 lcl_managed_img_h = true; 553 var true_img_h = lcl_curr_elem_h; 554 555 // check max width - if is resized 556 if(lcl_curr_elem_w > max_width_px) { 557 true_img_h = Math.round((lcl_curr_elem_h * max_width_px) / lcl_curr_elem_w); 558 } 559 560 // check then against max height 561 if(true_img_h > max_height_px) { 562 true_img_h = max_height_px; 563 } 564 565 $('#lcl_standard_elem > img').css('max-height', true_img_h); 566 } 567 else { 568 lcl_managed_img_h = false; 569 $('#lcl_standard_elem > img').css('max-height','none'); 570 var true_img_h = lcl_curr_elem_h; 571 } 572 573 // adjust if text under image 574 if(settings.data_position == 'under' && lcl_txt_exists) { 575 $('#lcl_standard_txt').css('width', $('#lcl_standard_elem > img').width()); 576 var txt_under_h = _manage_txt_under(max_height_px, true_img_h); 577 $('#lcl_standard_txt').css('width', 'auto'); 578
579 if(lcl_managed_img_h && lcl_count_txt_under) {true_img_h = true_img_h - txt_under_h}; 580 } 581 582 // if paginating - animate #lcl_standard_elem to be shaped accordingly with new image 583 if( !$('#lcl_standard').hasClass('lcl_standard_closed') && $('#lcl_standard_elem').hasClass('lcl_pag_anim')) { 584 var new_w = (!lcl_managed_img_h) ? lcl_curr_elem_w : Math.round((lcl_curr_elem_w * true_img_h) / lcl_curr_elem_h); 585 586 // if txt under - add bottom-padding 587 var btm_margin = (typeof(txt_under_h) != 'undefined' && lcl_txt_exists) ? txt_under_h : 0; 588 $('#lcl_standard_elem').clearQueue().animate({'width' : new_w, 'height' : true_img_h, marginBottom: btm_margin}, settings.animation_time); 589 590 setTimeout(function() { 591 $('#lcl_standard_elem').css('width', '100%').css('height', '100%'); 592 }, settings.animation_time + 10); 593 } 594 else { 595 // on resize - adjust text height 596 if(!$('#lcl_standard').hasClass('lcl_standard_closed')) { 597 $('#lcl_standard_elem').css('width', '100%').css('height', '100%').css('margin-bottom', txt_under_h); 598 } 599 } 600 601 /////////////// 602 603 // if is first opening 604 if( $('#lcl_standard').hasClass('lcl_standard_closed') ) { 605 606 // direct fullscreen switch 607 if( 608 (settings.fullscreen && settings.fs_only == 'always') || 609 (settings.fullscreen && settings.fs_only == 'mobile' && 610 _is_mobile() && navigator.appVersion.indexOf("MSIE") == -1 && 611 (navigator.appVersion.indexOf("WebKit") != -1 && (lcl_window_w < 650 || lcl_window_h < 650))) 612 ) { 613 // slideshow start 614 if(settings.autoplay && typeof(lcl_slideshow) != 'undefined' && lcl_slideshow !== false) { 615 $.lcweb_lightbox.start_slideshow(); 616 } 617 618 $.lcweb_lightbox.open_fullscreen(); 619 return true; 620 } 621 else { 622 $('#lcl_standard_cmd, #lcl_standard_elem, #lcl_standard_txt, #lcl_thumb_nav').css('opacity', 1); 623 624 // if text under - apply bottom padding 625 if(typeof(txt_under_h) != 'undefined') {$('#lcl_standard_elem').css('margin-bottom', txt_under_h);} 626 } 627 628 setTimeout(function() { 629 $('#lcl_loader').fadeOut(); 630 631 // old IE fallback 632 if( navigator.appVersion.indexOf("MSIE 8.") != -1 || navigator.appVersion.indexOf("MSIE 9.") != -1 ) { 633 $('#lcl_standard').fadeTo(400, 1); 634 } 635 636 $('#lcl_standard').removeClass('lcl_standard_closed').addClass('lcl_no_loader'); 637 if(settings.thumb_nav && _is_images_gallery()) { $('#lcl_thumb_nav').fadeIn(400); } 638 639 // slideshow start 640 if(settings.autoplay && typeof(lcl_slideshow) != 'undefined' && lcl_slideshow !== false) { 641 $.lcweb_lightbox.start_slideshow(); 642 } 643 }, 150); 644 645 if(_elem_type() == 'image') { _lcl_touchSwipe(); } 646 } 647 else { 648 setTimeout(function() { // show after lightbox sizing 649 $('#lcl_standard_elem').removeClass('lcl_pag_anim').css('opacity', 1); 650 $('#lcl_standard_cmd, #lcl_thumb_nav, #lcl_standard_elem > img').fadeTo(300, 1); 651 652 if(lcl_txt_exists) {$('#lcl_standard_txt').fadeTo(300, 1);} 653 $('#lcl_standard').addClass('lcl_no_loader'); 654 655 if(_elem_type() == 'image') { _lcl_touchSwipe(); } 656 }, settings.animation_time); 657 } 658 } 659 660 661 // calculate text under size and related image's max-height 662 function _manage_txt_under(max_height_px, true_img_h, second_check) { 663 var settings = lcl_settings; 664 $('#lcl_standard_txt').css('width', lcl_curr_elem_w); 665 666 var txt_under_h = (typeof(second_check) != 'undefined') ? second_check : Math.ceil( $('#lcl_standard_txt').outerHeight()); 667 var tu_overflow = max_height_px - (true_img_h + txt_under_h); 668 669 // if image's height + text are taller than max_h 670 if(tu_overflow < 0) { 671 tu_overflow = Math.ceil(tu_overflow * -1); 672 var new_h = true_img_h - tu_overflow; 673 674 // check a further time analyzing with new text width 675 if(typeof(second_check) == 'undefined') { 676 var new_w = Math.floor((lcl_curr_elem_w * new_h) / lcl_curr_elem_h); 677 $('#lcl_standard_txt').css('width', new_w); 678 679 var txt_under_h = Math.ceil( $('#lcl_standard_txt').outerHeight()); 680 return _manage_txt_under(max_height_px, true_img_h, txt_under_h); 681 } 682 else { 683 $('#lcl_standard_elem > img').css('max-height', new_h); 684 685 lcl_managed_img_h = true; 686 lcl_count_txt_under = true; 687 return txt_under_h; 688 } 689 } 690 else {
691 lcl_count_txt_under = false; 692 return txt_under_h; 693 } 694 } 695 696 697 // manage the fullscreen image 698 function _manage_fs_img() { 699 var settings = lcl_settings; 700 var $subj = $('#lcl_fs_elem > img'); 701 702 // never crop - only downscale if is bigger 703 if(settings.fs_img_behaviour == 'none') { 704 $subj.css('max-width', '100%').css('max-height', '100%'); 705 } 706 707 // fit the screen width or height 708 else if(settings.fs_img_behaviour == 'fit') { 709 var w_ratio = lcl_window_w / lcl_curr_elem_w; 710 var h_ratio = lcl_window_h / lcl_curr_elem_h; 711 712 if(w_ratio > h_ratio) { 713 $subj.css('width', 'auto').css('height', '100%'); 714 } else { 715 $subj.css('width', '100%').css('height', 'auto'); 716 } 717 } 718 719 // always fill the screen 720 else if(settings.fs_img_behaviour == 'always' || settings.fs_img_behaviour == 'fill') { 721 if(_is_old_IE()) { 722 $('#lcl_fs_elem').addClass('lcl_fill_fs_img_old_ie'); 723 } else { 724 $('#lcl_fs_elem').addClass('lcl_fill_fs_img'); 725 } 726 } 727 728 // smart resize&crop - only if ratio and sizes are similar 729 else if(settings.fs_img_behaviour == 'smart') { 730 var ratio_diff = (lcl_window_w / lcl_window_h) - (lcl_curr_elem_w / lcl_curr_elem_h) 731 var w_diff = lcl_window_w - lcl_curr_elem_w; 732 var h_diff = lcl_window_h - lcl_curr_elem_h; 733 734 if( (ratio_diff <= 1.15 && ratio_diff >= -1.15) && (w_diff <= 350 && h_diff <= 350) ) { // fill 735 $subj.css('max-width', 'none').css('max-height', 'none'); 736 737 if(_is_old_IE()) { 738 $('#lcl_fs_elem').addClass('lcl_fill_fs_img_old_ie'); 739 } else { 740 $('#lcl_fs_elem').addClass('lcl_fill_fs_img'); 741 } 742 } 743 else { // standard centering (as 'none') 744 $('#lcl_fs_elem').removeClass('lcl_fill_fs_img lcl_fill_fs_img_old_ie'); 745 $subj.css('max-width', '100%').css('max-height', '100%'); 746 } 747 } 748 749 setTimeout(function() { 750 $('#lcl_fs_elem').addClass('lcl_no_loader'); 751 $subj.fadeIn(settings.animation_time); 752 if(!$('#lcl_fs_txt').hasClass('lcl_fs_txt_hidden')) { $('#lcl_fs_txt').fadeTo(settings.animation_time, 1); } 753 }, 50); 754 755 _lcl_touchSwipe(); 756 } 757 758 759 // create and append the thumb navigator to the lightbox 760 function _manage_thumb_nav() { 761 var settings = lcl_settings; 762 if(!settings.thumb_nav || !_is_images_gallery()) {return false;} 763 764 var thumb_nav_btn_w = 46 ; 765 lcl_thumb_per_page = Math.floor( ($('#lcl_wrapper').width() - thumb_nav_btn_w) / (settings.thumb_w + 9) ); 766 767 if(lcl_thumb_per_page > 1 && lcl_window_h > 550) { 768 $('#lcl_thumb_nav').css('visibility', 'visible').removeClass('lcl_tn_disabled'); 769 770 var nav_width = thumb_nav_btn_w + ( (settings.thumb_w + 7) * lcl_thumb_per_page); 771 var nav_margin = Math.floor((lcl_window_w - nav_width) / 2); 772 773 // find the current page 774 lcl_curr_thumb_pag = Math.ceil((lcl_elem_index + 1) / lcl_thumb_per_page); 775 776 // vars for pagination 777 var tot_pages = Math.ceil( lcl_tot_elements / lcl_thumb_per_page ); 778 lcl_thumb_pag_w = (settings.thumb_w + 7/*fixed margin*/) * lcl_thumb_per_page; 779 780 // populate 781 if( !$('#lcl_thumb_nav li').length ) { 782 $('#lcl_thumb_nav').html( 783 '<div id="lcl_thumb_prev"><div></div></div>'+ 784 '<div id="lcl_thumb_container"><ul></ul></div>'+ 785 '<div id="lcl_thumb_next"><div></div></div>' 786 ); 787 788 // add image thumbs 789 lclt_pag = 1; 790 a = 1; 791 $.each(lcl_elem_url, function(k, img_url) { 792 var sel = (k == lcl_elem_index) ? 'lcl_curr_thumb' : ''; 793 794 // thumbs maker integration 795 if(settings.thumbs_maker_url) { 796 var base = settings.thumbs_maker_url; 797 img_url = base.replace('%URL%', encodeURIComponent(img_url)).replace('%W%', settings.thumb_w).replace('%H%', settings.thumb_h);
798 } 799 800 $('#lcl_thumb_container ul').append( 801 '<li id="lclt_'+k+'" class="lcl_tp_'+lclt_pag+' '+sel+'" style="width: '+settings.thumb_w+'px; height: '+settings.thumb_h+'px;"><img src="'+img_url+'" /></li>'); 802 803 // thumb preload and size 804 _thumb_nav_preloader(img_url, k); 805 806 if( a == lcl_thumb_per_page ) { 807 a = 1; 808 lclt_pag = lclt_pag + 1; 809 } 810 a = a + 1; 811 }); 812 } 813 else { 814 $('#lcl_thumb_container li').attr('class', 'lcl_no_loader'); 815 816 lclt_pag = 1; 817 a = 1; 818 $.each(lcl_elem_url, function(k, img_url) { 819 if(k == lcl_elem_index) { $('#lclt_'+k).addClass('lcl_curr_thumb'); } 820 else { $('#lclt_'+k).removeClass('lcl_curr_thumb'); } 821 822 $('#lclt_'+k).addClass('lcl_tp_'+lclt_pag); 823 824 if( a == lcl_thumb_per_page ) { 825 a = 1; 826 lclt_pag = lclt_pag + 1; 827 } 828 a = a + 1; 829 }); 830 } 831 832 // calculate the offset 833 if(tot_pages == 1) { 834 var cont_offset = Math.ceil( (lcl_tot_elements * (settings.thumb_w + 7/*fixed margin*/) - lcl_thumb_pag_w) / 2); 835 $('#lcl_thumb_prev, #lcl_thumb_next').css('visibility', 'hidden'); 836 } 837 else { 838 if(lcl_curr_thumb_pag == tot_pages) { var cont_offset = lcl_tot_elements * (settings.thumb_w + 7/*fixed margin*/) - lcl_thumb_pag_w; } 839 else { var cont_offset = (settings.thumb_w + 7/*fixed margin*/) * (lcl_thumb_per_page * (lcl_curr_thumb_pag - 1)); } 840 841 $('#lcl_thumb_prev, #lcl_thumb_next').css('visibility', 'visible'); 842 } 843 844 // thumb cmd management 845 $('#lcl_thumb_prev div, #lcl_thumb_next div').removeClass('disabled'); 846 if(!cont_offset) { $('#lcl_thumb_prev div').addClass('disabled'); } 847 if(lcl_curr_thumb_pag == tot_pages) { $('#lcl_thumb_next div').addClass('disabled'); } 848 849 // adjust the thumb container 850 $('#lcl_thumb_nav').css('width', nav_width).css('height', settings.thumb_h).css('left', nav_margin); 851 852 var nav_margin = Math.floor( (settings.thumb_h - $('#lcl_thumb_prev div').outerHeight()) / 2); 853 $('#lcl_thumb_prev div, #lcl_thumb_next div').css('margin-top', nav_margin).css('margin-bottom', nav_margin); 854 855 $('#lcl_thumb_container').css('width', (nav_width - thumb_nav_btn_w)); 856 $('#lcl_thumb_container > ul').css('width', (lcl_thumb_pag_w * tot_pages)); 857 858 // thumb container positioning 859 if( $('#lcl_thumb_nav').is(':hidden') ) { 860 $('#lcl_thumb_container > ul').clearQueue().animate({'marginLeft': (cont_offset * -1)}, 250); 861 } 862 else { 863 var curr_cont_margin = parseInt( $('#lcl_thumb_container > ul').css('margin-left') ); 864 if( (cont_offset * -1) != curr_cont_margin) { 865 $('#lcl_thumb_container > ul') 866 .css('margin-left', curr_cont_margin) 867 .clearQueue().animate({'marginLeft': (cont_offset * -1)}, settings.animation_time); 868 } 869 else { $('#lcl_thumb_container > ul').css('margin-left', (cont_offset * -1)); } 870 } 871 } 872 else { 873 $('#lcl_thumb_nav').css('visibility', 'hidden').addClass('lcl_tn_disabled'); 874 $('#lcl_wrapper').removeAttr('style'); // reset wrapper padding 875 } 876 877 // manage wrapper padding-bottom 878 if(settings.thumb_nav && !$('#lcl_thumb_nav').hasClass('lcl_tn_disabled')) { 879 var wrap_btm_padd = settings.thumb_h + 26; // bottom space / top space 880 $('#lcl_wrapper').css('padding-bottom', wrap_btm_padd); 881 } 882 } 883 884 885 886 887 // thumb navigator img preloader 888 function _thumb_nav_preloader(img_url, img_index) { 889 $('<img />').bind("load",function(){ 890 var img_w = this.width; 891 var img_h = this.height; 892 893 $('#lclt_'+img_index).addClass('lcl_no_loader'); 894 895 // in case of thumbnail maker 896 if(img_w == settings.thumb_w && img_h == settings.thumb_h) { 897 $('#lclt_'+img_index+' img').fadeIn('fast'); 898 } 899 else { 900 if(img_w > img_h) { 901 var ratio = img_w / img_h; 902 var new_img_w = Math.ceil(settings.thumb_h * ratio);
903 var margin_left = Math.ceil( (new_img_w * 1.2 - settings.thumb_w) / 2 ) * -1; 904 905 $('#lclt_'+img_index+' img') 906 .css('width', (new_img_w * 1.2)) 907 .css('height', (settings.thumb_h * 1.2)) 908 .css('margin-left', margin_left) 909 .fadeIn('fast'); 910 } 911 else { 912 var ratio = img_h / img_w; 913 var new_img_h = Math.ceil(settings.thumb_w * ratio); 914 var margin_top = Math.ceil( (new_img_h * 1.2 - settings.thumb_h) / 2 ) * -1; 915 $('#lclt_'+img_index+' img') 916 .css('width', (settings.thumb_w * 1.2)) 917 .css('height', (new_img_h * 1.2)) 918 .css('margin-top', margin_top) 919 .fadeIn('fast'); 920 } 921 } 922 }).attr('src', img_url); 923 } 924 925 926 // thumb navigator scroll 927 function _thumb_nav_scroll(direction) { 928 if(!lcl_scrolling_thumb) { 929 $('#lcl_thumb_prev div, #lcl_thumb_next div').removeClass('disabled'); 930 931 settings = lcl_settings; 932 var offset = settings.thumb_w + 7 /*fixed margin*/; 933 var curr_margin = parseInt( $('#lcl_thumb_container > ul').css('margin-left') ); 934 var max_margin = ((lcl_tot_elements * offset - lcl_thumb_pag_w) * -1); 935 936 // previous 937 if(direction == 'prev' && curr_margin < 0) { 938 lcl_scrolling_thumb = true; 939 var new_margin = curr_margin + offset; 940 $('#lcl_thumb_container > ul').clearQueue().animate({'marginLeft' : new_margin}, 200, function() { 941 if(!new_margin) { $('#lcl_thumb_prev div').addClass('disabled'); } 942 lcl_scrolling_thumb = false; 943 }); 944 } 945 946 // next 947 if(direction == 'next' && curr_margin > max_margin) { 948 lcl_scrolling_thumb = true; 949 var new_margin = curr_margin - offset; 950 $('#lcl_thumb_container > ul').clearQueue().animate({'marginLeft': new_margin}, 200, function() { 951 if(new_margin == max_margin) { $('#lcl_thumb_next div').addClass('disabled'); } 952 lcl_scrolling_thumb = false; 953 }); 954 } 955 956 // custom swipe 957 if( typeof direction == 'number' ) { 958 if( 959 (direction < 0 && curr_margin > max_margin) || 960 (direction > 0 && curr_margin < 0) 961 ) { 962 var to_move = Math.ceil( direction / offset ); 963 var new_margin = curr_margin + (to_move * offset); 964 965 // checks to avoid wrong results 966 if(new_margin > 0) { new_margin = 0;} 967 else if ( new_margin < max_margin) { new_margin = max_margin; } 968 969 lcl_scrolling_thumb = true; 970 $('#lcl_thumb_container > ul').clearQueue().animate({'marginLeft': new_margin}, 200, function() { 971 if(!new_margin) { $('#lcl_thumb_prev div').addClass('disabled'); } 972 if(new_margin == max_margin) { $('#lcl_thumb_next div').addClass('disabled'); } 973 lcl_scrolling_thumb = false; 974 }); 975 } 976 } 977 } 978 } 979 980 981 // socials code setup 982 function _social_code(url, title, descr, page_url) { 983 var settings = lcl_settings; 984 985 var code = 986 '<ul class="lcl_social_box">'+ 987 '<li class="lcl_icon lcl_fb"><a onClick="window.open(\'https://www.facebook.com/dialog/feed?app_id=425190344259188&display=popup&name='+title+'&description='+descr+' &picture='+settings.fb_share_fix+'?u='+url+'&link='+page_url+'&redirect_uri=http://www.lcweb.it/lcis_redirect.php\',\'sharer\',\'toolbar=0,status=0,width=590,height=325\');" href="javascript: void(0)"></a>'+ 988 '</li>'+ 989 '<li class="lcl_icon lcl_twit"><a onClick="window.open(\'https://twitter.com/share?text=Check%20out%20%22'+title+'%22%20@&url='+page_url+'\',\'sharer\',\'toolbar=0,status=0,width=548,height=325\');" href="javascript: void(0)"></a>'+ 990 '</li>'+ 991 '<li class="lcl_icon lcl_pint"><a onClick="window.open(\'http://pinterest.com/pin/create/button/?url='+page_url+'&media='+url+'&description='+title+'\',\'sharer\',\'toolbar=0,status=0,width=575,height=330\');" href="javascript: void(0)"></a>'+ 992 '</li>'+ 993 '</ul>'; 994 995 996 return code; 997 } 998 999 1000 // check for images gallery (for thumb navigator) 1001 function _is_images_gallery() { 1002 if( typeof(lcl_is_img_gallery) == 'undefined') { 1003 var only_img = true; 1004 1005 $.each(lcl_elem_url, function(k, v) { 1006 if( _elem_type(v) != 'image' ) {only_img = false;} 1007 }); 1008 1009 if(!only_img) {lcl_is_img_gallery = false;} 1010 else {lcl_is_img_gallery = true;} 1011 } 1012 1013 return lcl_is_img_gallery; 1014 } 1015 1016 1017 // get the current element type 1018 function _elem_type(elem_src) { 1019 if(typeof(elem_src) == 'undefined') { var elem_src = lcl_elem_url[lcl_elem_index]; } 1020 1021 if (elem_src.match(/youtube\.com\/watch/i) || elem_src.match(/youtu\.be/i)) { 1022 return 'youtube'; 1023 }else if (elem_src.match(/vimeo\.com/i)) { 1024 return 'vimeo'; 1025 }else if(elem_src.match(/\b.mov\b/i)){ 1026 return 'quicktime'; 1027 }else if(elem_src.match(/\b.swf\b/i)){ 1028 return 'flash'; 1029 }else if(elem_src.match(/\biframe=true\b/i)){ 1030 return 'iframe'; 1031 }else if(elem_src.match(/\bajax=true\b/i)){ 1032 return 'ajax'; 1033 }else if(elem_src.substr(0,1) == '#'){ 1034 return 'inline'; 1035 }else{ 1036 return 'image'; 1037 }; 1038 } 1039 1040 1041 // check if the browser is IE8 or older 1042 function _is_old_IE() { 1043 if( navigator.appVersion.indexOf("MSIE 7.") != -1 || navigator.appVersion.indexOf("MSIE 8.") != -1 ) {return true;} 1044 else {return false;} 1045 } 1046 1047 1048 // check for touch device 1049 function _is_touch_device() { 1050 return !!('ontouchstart' in window); 1051 } 1052 1053 1054 // check if is a mobile browser 1055 function _is_mobile() { 1056 if( /(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i.test(navigator.userAgent) || /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|
1056sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(navigator.userAgent) ) 1057 { return true;} 1058 else { return false; } 1059 } 1060 1061 1062 // event for touch devices that are not webkit - against double-tap need 1063 var lcl_ontouchstart = (!("ontouchstart" in document.documentElement) || navigator.userAgent.match(/(iPad|iPhone|iPod)/g)) ? '' : ' touchstart'; 1064 1065 //////////////////////////////////////////////// 1066 1067 // touchswipe for image elements 1068 function _lcl_touchSwipe() { 1069 if(!_is_old_IE() && lcl_tot_elements > 1) { 1070 var settings = lcl_settings; 1071 1072 if(settings.touchSwipe && $.fn.swipe){ 1073 // standard lightbox 1074 if(!lcl_fullscreen_open) { 1075 var treshold = Math.round( $('#lcl_standard_elem > img').width() / 2 ); 1076 $("#lcl_standard_elem > img").swipe( { 1077 swipeStatus:function(event, phase, direction, distance, duration, fingerCount) { 1078 1079 if(phase == 'end' && direction == 'left') { 1080 $.lcweb_lightbox.change_page('next'); 1081 $.lcweb_lightbox.stop_slideshow(); 1082 } 1083 if(phase == 'end' && direction == 'right') { 1084 $.lcweb_lightbox.change_page('prev'); 1085 $.lcweb_lightbox.stop_slideshow(); 1086 } 1087 }, 1088 triggerOnTouchEnd: false, 1089 maxTimeThreshold: 1000, 1090 threshold: treshold 1091 }); 1092 } 1093 1094 // fullscreen 1095 else { 1096 var fs_treshold = Math.round( $('#lcl_fs_elem').width() * 0.35 ); 1097 $("#lcl_fs_elem").swipe( { 1098 swipeStatus:function(event, phase, direction, distance, duration, fingerCount) { 1099 1100 if(phase == 'end' && direction == 'left') { 1101 $.lcweb_lightbox.change_page('next'); 1102 $.lcweb_lightbox.stop_slideshow(); 1103 } 1104 if(phase == 'end' && direction == 'right') { 1105 $.lcweb_lightbox.change_page('prev'); 1106 $.lcweb_lightbox.stop_slideshow(); 1107 } 1108 }, 1109 triggerOnTouchEnd: false, 1110 maxTimeThreshold: 1000, 1111 threshold: fs_treshold 1112 }); 1113 } 1114 1115 // thumb navigator 1116 if($('#lcl_thumb_container li').length > 1 && Math.ceil( lcl_tot_elements / lcl_thumb_per_page ) > 1) { 1117 $("#lcl_thumb_container").swipe( { 1118 swipeStatus:function(event, phase, direction, distance, duration, fingerCount) { 1119 1120 if(phase == 'end' && direction == 'left') { 1121 var offset = distance * -1; 1122 _thumb_nav_scroll( offset ); 1123 } 1124 if(phase == 'end' && direction == 'right') { 1125 var offset = distance; 1126 _thumb_nav_scroll( offset ); 1127 } 1128 }, 1129 triggerOnTouchEnd: false, 1130 threshold: null 1131 }); 1132 } 1133 } 1134 } 1135 1136 return false; 1137 } 1138 1139 1140 //////////////////////////////////////////////// 1141 1142 function lcl_debouncer($,cf,of, interval){ 1143 var debounce = function (func, threshold, execAsap) { 1144 var timeout; 1145 1146 return function debounced () { 1147 var obj = this, args = arguments; 1148 function delayed () { 1149 if (!execAsap) {func.apply(obj, args);} 1150 timeout = null; 1151 } 1152 1153 if (timeout) {clearTimeout(timeout);} 1154 else if (execAsap) {func.apply(obj, args);} 1155 1156 timeout = setTimeout(delayed, threshold || interval); 1157 }; 1158 }; 1159 jQuery.fn[cf] = function(fn){ return fn ? this.bind(of, debounce(fn)) : this.trigger(cf); }; 1160 }; 1161 lcl_debouncer($,'lcl_smartresize', 'resize', 49); 1162 1163 // lightbox center on resize 1164 $(window).lcl_smartresize(function() { 1165 if(lcl_open) { 1166 lcl_window_w = $(window).width(); 1167 lcl_window_h = $(window).height(); 1168 1169 if(!lcl_fullscreen_open) { _adjust_and_show(); } 1170 else { _manage_fs_img();} 1171 1172 _manage_thumb_nav(); 1173 } 1174 }); 1175 1176 //////////////////////////////////////////////// 1177 1178 // if not direct open - add trigger 1179 /*if(!lcl_settings.open) { 1180 $('body').delegate(lcl_elem_obj, 'click', function() { 1181 $.lcweb_lightbox.init(); 1182 }); 1183 }*/ 1184 1185 1186 // open fullscreen 1187 $('#lcl_standard_cmd .lcl_fullscreen').unbind('click.lcweb_lightbox'); 1188 $('body').delegate('#lcl_standard_cmd .lcl_fullscreen', 'click'+lcl_ontouchstart, function() { 1189 $.lcweb_lightbox.open_fullscreen(); 1190 }); 1191 1192 1193 // go to previous element 1194 $('.lcl_prev').unbind('click.lcweb_lightbox'); 1195 $('body').delegate('.lcl_prev', 'click'+lcl_ontouchstart, function() { 1196 $.lcweb_lightbox.change_page('prev'); 1197 $.lcweb_lightbox.stop_slideshow(); 1198 return false; 1199 }); 1200
1201 // go to next element 1202 $('.lcl_next, #lcl_standard_elem > img, #lcl_fs_elem > img').unbind('click.lcweb_lightbox'); 1203 $('body').delegate('.lcl_next, #lcl_standard_elem > img, #lcl_fs_elem > img', 'click'+lcl_ontouchstart, function() { 1204 if(lcl_tot_elements > 1) { 1205 $.lcweb_lightbox.change_page('next'); 1206 $.lcweb_lightbox.stop_slideshow(); 1207 } 1208 return false; 1209 }); 1210 1211 // close the lightbox 1212 $('.lcl_close').unbind('click.lcweb_lightbox'); 1213 $('body').delegate('.lcl_close', 'click', function() { 1214 $.lcweb_lightbox.stop_slideshow(); 1215 $.lcweb_lightbox.close(); 1216 return false; 1217 }); 1218 1219 if( !lcl_settings.modal ) { 1220 $('#lcl_overlay').unbind('click.lcweb_lightbox'); 1221 $('body').delegate('#lcl_overlay', 'click'+lcl_ontouchstart, function() { 1222 $.lcweb_lightbox.stop_slideshow(); 1223 $.lcweb_lightbox.close(); 1224 return false; 1225 }); 1226 } 1227 1228 1229 // start slideshow 1230 $('.lcl_play').unbind('click.lcweb_lightbox'); 1231 $('body').delegate('.lcl_play', 'click'+lcl_ontouchstart, function() { 1232 $.lcweb_lightbox.start_slideshow(); 1233 return false; 1234 }); 1235 1236 // stop slideshow 1237 $('.lcl_pause').unbind('click.lcweb_lightbox'); 1238 $('body').delegate('.lcl_pause', 'click'+lcl_ontouchstart, function() { 1239 $.lcweb_lightbox.stop_slideshow(); 1240 return false; 1241 }); 1242 1243 1244 // jump to image - thumb navigation 1245 $('#lcl_thumb_container li').unbind('click.lcweb_lightbox'); 1246 $('body').delegate('#lcl_thumb_container li', 'click'+lcl_ontouchstart, function() { 1247 var img_index = $(this).attr('id').substr(5); 1248 $.lcweb_lightbox.change_page(img_index); 1249 $.lcweb_lightbox.stop_slideshow(); 1250 }); 1251 1252 // thumb nav controls 1253 $('#lcl_thumb_prev, #lcl_thumb_next').unbind('click.lcweb_lightbox'); 1254 $('body').delegate('#lcl_thumb_prev', 'click'+lcl_ontouchstart, function() { 1255 if( !$(this).hasClass('disabled') ) { _thumb_nav_scroll('prev'); } 1256 return false; 1257 }); 1258 $('body').delegate('#lcl_thumb_next', 'click'+lcl_ontouchstart, function() { 1259 if( !$(this).hasClass('disabled') ) { _thumb_nav_scroll('next'); } 1260 return false; 1261 }); 1262 1263 1264 // socials toggle visibility 1265 $('.lcl_socials').unbind('click.lcweb_lightbox'); 1266 $('body').delegate('#lcl_standard_cmd .lcl_socials', 'click'+lcl_ontouchstart, function() { 1267 var $subj = $('#lcl_standard .lcl_social_box'); 1268 if( !$subj.hasClass('lcl_is_acting') ) { 1269 1270 $subj.addClass('lcl_is_acting'); 1271 $('#lcl_standard .lcl_social_box').slideToggle('fast', function() { 1272 $subj.removeClass('lcl_is_acting'); 1273 }); 1274 } 1275 return false; 1276 }); 1277 $('body').delegate('#lcl_fs_cmd .lcl_socials', 'click'+lcl_ontouchstart, function() { 1278 var $subj_fs = $('#lcl_fullscreen .lcl_social_box'); 1279 if( !$subj_fs.hasClass('lcl_is_acting') ) { 1280 1281 $subj_fs.addClass('lcl_is_acting'); 1282 $('#lcl_fullscreen .lcl_social_box').slideToggle('fast', function() { 1283 $subj_fs.removeClass('lcl_is_acting'); 1284 }); 1285 } 1286 return false; 1287 }); 1288 1289 1290 // fullscreen data toggle 1291 $('#lcl_fs_cmd .lcl_toggle_info').unbind('click.lcweb_lightbox'); 1292 $('body').delegate('#lcl_fs_cmd .lcl_toggle_info', 'click'+lcl_ontouchstart, function() { 1293 if(!lcl_is_active) { 1294 lcl_is_active = true; 1295 1296 if(!$('#lcl_fs_txt').hasClass('lcl_fs_txt_hidden')) { $('#lcl_fs_txt').fadeOut('fast').addClass('lcl_fs_txt_hidden'); lcl_fs_txt = false; } 1297 else { $('#lcl_fs_txt').fadeIn(250).removeClass('lcl_fs_txt_hidden'); lcl_fs_txt = true; } 1298 1299 setTimeout(function() { 1300 lcl_is_active = false; 1301 }, 250); 1302 } 1303 }); 1304 1305 1306 // Keyboard events 1307 $(document).unbind('keydown.lcweb_lightbox').bind('keydown.lcweb_lightbox',function(e){ 1308 if(lcl_open == true && !lcl_is_active && lcl_tot_elements > 1) { 1309 // prev 1310 if (e.keyCode == 37) { 1311 $.lcweb_lightbox.change_page('prev'); 1312 $.lcweb_lightbox.stop_slideshow(); 1313 } 1314 1315 // next 1316 if (e.keyCode == 39) { 1317 $.lcweb_lightbox.change_page('next'); 1318 $.lcweb_lightbox.stop_slideshow(); 1319 } 1320 1321 // close 1322 if (e.keyCode == 27) { 1323 $.lcweb_lightbox.close(); 1324 $.lcweb_lightbox.stop_slideshow(); 1325 } 1326 } 1327 }); 1328 1329 1330 //////////////////////////////////////////// 1331 1332 // auto launch
1333 if( lcl_settings.open ) { $.lcweb_lightbox.init(); return false; } 1334 else { 1335 return 1336 this.unbind('click.lcweb_lightbox') 1337 .bind('click.lcweb_lightbox', $.lcweb_lightbox.init ); //Use unbind method is to avoid click conflict when the plugin is called more than once 1338 } 1339 }; 1340 1341})(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.