1var bwg_param; 2var bwg = 0; 3 4var isMobile = (/android|webos|iphone|ipad|ipod|blackberry|iemobile|opera mini/i.test(navigator.userAgent.toLowerCase())); 5var bwg_click = isMobile ? 'touchend' : 'click'; 6 7/* Slideshow params */ 8var bwg_params = []; 9/* Image browser params */ 10var bwg_params_ib = []; 11/* Carousel params */ 12var bwg_params_carousel = []; 13 14jQuery.fn.extend({ 15 hideShow: function (callback) { 16 this.checkForVisiblilityChange(callback); 17 return this; 18 }, 19 checkForVisiblilityChange: function (callback) { 20 if (!(this.length >>> 0)) { 21 return undefined; 22 } 23 var elem, i = 0; 24 while ((elem = this[i++])) { 25 var curValue = jQuery(elem).is(":visible"); 26 (elem.lastVisibility === undefined) && (elem.lastVisibility = curValue); 27 (curValue !== elem.lastVisibility) && ( 28 elem.lastVisibility = curValue, 29 (typeof callback === "function") && ( 30 callback.apply(this, [new jQuery.Event('visibilityChanged'), curValue ? "shown" : "hidden"]) 31 ), 32 (function (elem, curValue) { 33 setTimeout(function () { 34 jQuery(elem).trigger('visibilityChanged', [curValue ? "shown" : "hidden"]) 35 }, 10) 36 })(elem, curValue) 37 ) 38 } 39 (function (that, a) { 40 setTimeout(function () { 41 that.checkForVisiblilityChange.apply(that, a); 42 }, 10) 43 })(this, arguments) 44 } 45}); 46 47/* Execute on ajax complete.*/ 48jQuery(document).ajaxComplete(function () { 49 setTimeout(function () { 50 bwg_main_ready(); 51 }); 52}); 53 54jQuery(document).ready(function () { 55 document.addEventListener("visibilitychange", function() { 56 var bwg_error = false; 57 /* If there is error (empty gallery).*/ 58 jQuery(".bwg_container").each(function () { 59 if ( jQuery(this).find(".wd_error").length > 0 ) { 60 bwg_error = true; 61 } 62 }); 63 if ( !bwg_error ) { 64 if (document.visibilityState == 'visible') { 65 bwg_slideshow_focus(); 66 } 67 if (document.visibilityState == 'hidden') { 68 bwg_slideshow_blur(); 69 } 70 } 71 }); 72 /* To bind only visible containers.*/ 73 bwg_main_ready(); 74 jQuery(this).hideShow(function(event, visibility) { 75 if ( visibility == 'shown' ) { 76 bwg_main_ready(); 77 } 78 }); 79}); 80 81function bwg_main_ready() { 82 /* If there is error (empty gallery).*/ 83 jQuery(".bwg_container").each(function () { 84 if ( jQuery(this).find(".wd_error").length > 0 ) { 85 var bwg = jQuery(this).data("bwg"); 86 bwg_container_loaded(bwg); 87 } 88 }); 89 bwg_document_ready();
90 jQuery(".bwg-thumbnails, .bwg-masonry-thumbnails, .bwg-album-thumbnails").each(function () { 91 bwg_all_thumnails_loaded(this); 92 }); 93 94 jQuery(".bwg-mosaic-thumbnails").each(function () { 95 bwg_thumbnail_mosaic(this); 96 }); 97 bwg_slideshow_ready(); 98 bwg_carousel_ready(); 99 bwg_carousel_onload(); 100 bwg_image_browser_ready(); 101} 102 103function bwg_resize_search_line() { 104 jQuery('.search_line').each(function() { 105 var element = jQuery(this); 106 if (element.width() < 410) { 107 element.addClass('bwg-search-line-responsive'); 108 } 109 else { 110 element.removeClass('bwg-search-line-responsive'); 111 } 112 }); 113} 114 115jQuery(window).on("resize", function () { 116 var bwg_error = false; 117 /* If there is error (empty gallery).*/ 118 jQuery(".bwg_container").each(function () { 119 if ( jQuery(this).find(".wd_error").length > 0 ) { 120 bwg_error = true; 121 } 122 }); 123 if ( !bwg_error ) { 124 jQuery(".bwg-thumbnails, .bwg-masonry-thumbnails, .bwg-album-thumbnails").each(function () { 125 bwg_all_thumnails_loaded(this); 126 }); 127 bwg_slideshow_resize(); 128 bwg_image_browser_resize(); 129 bwg_carousel_resize(); 130 bwg_blog_style_resize(); 131 jQuery(".bwg-mosaic-thumbnails").each(function () { 132 bwg_thumbnail_mosaic(this); 133 }); 134 } 135 bwg_resize_search_line(); 136}); 137 138jQuery(window).on("load", function () { 139 var bwg_error = false; 140 /* If there is error (empty gallery).*/ 141 jQuery(".bwg_container").each(function () { 142 if ( jQuery(this).find(".wd_error").length > 0 ) { 143 bwg_error = true; 144 } 145 }); 146 if ( !bwg_error ) { 147 bwg_blog_style_onload(); 148 jQuery(".bwg-mosaic-thumbnails").each(function () { 149 bwg_thumbnail_mosaic(this); 150 }); 151 } 152}); 153 154jQuery(".bwg-masonry-thumb-span img, .bwg-mosaic-thumb-span img").on("error", function() { 155 jQuery(this).height(100); 156 jQuery(this).width(100); 157}); 158 159function bwg_slideshow_resize() { 160 jQuery(".bwg_slideshow").each(function () { 161 bwg = jQuery(this).attr('data-bwg'); 162 if ( jQuery("#bwg_slideshow_image_container_" + bwg).length ) { 163 bwg_params[bwg] = JSON.parse(jQuery("#bwg_slideshow_image_container_" + bwg).attr("data-params")); 164 bwg_params[bwg]['event_stack'] = []; 165 bwg_popup_resize(bwg); 166 } 167 }); 168} 169 170function bwg_blog_style_resize() { 171 jQuery(".bwg_blog_style").each(function () { 172 bwg = jQuery(this).attr('data-bwg'); 173 jQuery('.bwg_embed_frame_16x9_'+bwg).each(function (e) { 174 jQuery(this).width(jQuery(this).parent().width()); 175 jQuery(this).height(jQuery(this).width() * 0.5625); 176 }); 177 jQuery('.bwg_embed_frame_instapost_'+bwg).each(function (e) { 178 jQuery(this).width(jQuery(this).parent().width()); 179 jQuery(this).height((jQuery(this).width() - 16) * jQuery(this).attr('data-height') / jQuery(this).attr('data-width') + 96); 180 }); 181 }) 182} 183 184function bwg_blog_style_onload() { 185 jQuery(".bwg_blog_style").each(function () { 186 bwg = jQuery(this).attr('data-bwg'); 187 var data_right_click = jQuery("#bwg_blog_style_"+bwg); 188 jQuery('.bwg_embed_frame_16x9_'+bwg).each(function (e) { 189 /* Conflict with Sydney Theme */ 190 if ( jQuery('.bwg_blog_style_image_' + bwg).find('.fluid-width-video-wrapper').length ) { 191 jQuery('.fluid-width-video-wrapper').removeAttr('style'); 192 var content = jQuery(this).parents('.bwg_blog_style_image_' + bwg).find('.fluid-width-video-wrapper').contents(); 193 jQuery(this).parents('.fluid-width-video-wrapper').replaceWith(content); 194 } 195 jQuery(this).width(jQuery(this).parents('.bwg_blog_style_image_' + bwg).width()); 196 jQuery(this).height(jQuery(this).width() * 0.5625); 197 }); 198 199 jQuery('.bwg_embed_frame_instapost_'+bwg).each(function (e) { 200 jQuery(this).width(jQuery(this).parents('.bwg_blog_style_image_' + bwg).width()); 201 /* 16 is 2*padding inside iframe */ 202 /* 96 is 2*padding(top) + 1*padding(bottom) + 40(footer) + 32(header) */ 203 jQuery(this).height((jQuery(this).width() - 16) * jQuery(this).attr('data-height') / jQuery(this).attr('data-width') + 96); 204 }); 205 206 bwg_container_loaded(bwg); 207 }); 208} 209 210function bwg_blog_style_ready() { 211 jQuery(".bwg_blog_style").each(function () { 212 var bwg = jQuery(this).attr('data-bwg'); 213 bwg_container_loaded( bwg ); 214 215 var bwg_touch_flag = false;
216 jQuery(this).find('.bwg_lightbox_' + bwg).on('click', function () { 217 var image_id = jQuery(this).attr('data-image-id'); 218 jQuery('#bwg_blog_style_share_buttons_' + image_id ).removeAttr('data-open-comment'); 219 if ( !bwg_touch_flag ) { 220 bwg_touch_flag = true; 221 setTimeout( function(){ bwg_touch_flag = false; }, 100 ); 222 bwg_gallery_box(image_id, jQuery(this).closest('.bwg_container')); 223 return false; 224 } 225 }); 226 jQuery(".bwg_lightbox_" + bwg + " .bwg_ecommerce").on("click", function (event) { 227 event.stopPropagation(); 228 if (!bwg_touch_flag) { 229 bwg_touch_flag = true; 230 setTimeout(function(){ bwg_touch_flag = false; }, 100); 231 bwg_gallery_box(jQuery(this).attr( "data-image-id" ), jQuery(this).closest( '.bwg_container' ), true); 232 return false; 233 } 234 }); 235 236 jQuery( 'div[id^="bwg_container"]' ).each( function () { 237 var bwg_container = jQuery(this); 238 var search_tags = bwg_container.find('.search_tags'); 239 if (search_tags.length) { 240 search_tags.SumoSelect({ 241 triggerChangeCombined: true, 242 placeholder: bwg_objectsL10n.bwg_select_tag, 243 search: 1, 244 searchText: bwg_objectsL10n.bwg_search, 245 forceCustomRendering: true, 246 noMatch: bwg_objectsL10n.bwg_tag_no_match, 247 captionFormatAllSelected: bwg_objectsL10n.bwg_all_tags_selected, 248 captionFormat: '{0} ' + bwg_objectsL10n.bwg_tags_selected, 249 }); 250 }
251 var bwg_order = bwg_container.find('.bwg_order'); 252 if (bwg_order.length) { 253 bwg_order.SumoSelect({ 254 triggerChangeCombined: true, 255 forceCustomRendering: true, 256 }); 257 } 258 }); 259 var bwg_hash = window.location.hash.substring(1); 260 if (bwg_hash) { 261 if (bwg_hash.indexOf("bwg") != "-1") { 262 bwg_hash_array = bwg_hash.replace("bwg", "").split("/"); 263 if(bwg_hash_array[0] == "<?php echo $params_array['gallery_id']; ?>"){ 264 bwg_gallery_box(bwg_hash_array[1]); 265 } 266 } 267 } 268 }); 269} 270 271function bwg_slideshow_focus() { 272 jQuery(".bwg_slideshow").each(function () { 273 bwg = jQuery(this).attr('data-bwg'); 274 if ( jQuery("#bwg_slideshow_image_container_" + bwg).length ) { 275 bwg_params[bwg] = JSON.parse(jQuery("#bwg_slideshow_image_container_" + bwg).attr("data-params")); 276 bwg_params[bwg]['event_stack'] = []; 277 window.clearInterval(window['bwg_playInterval' + bwg]); 278 if (!jQuery(".bwg_ctrl_btn_" + bwg).hasClass("fa-play")) { 279 bwg_play(bwg_params[bwg]['data'], bwg); 280 } 281 } 282 }); 283} 284 285function bwg_slideshow_blur() { 286 jQuery(".bwg_slideshow").each(function () { 287 bwg = jQuery(this).attr('data-bwg'); 288 if ( jQuery("#bwg_slideshow_image_container_" + bwg).length ) { 289 bwg_params[bwg] = JSON.parse(jQuery("#bwg_slideshow_image_container_" + bwg).attr("data-params")); 290 bwg_params[bwg]['event_stack'] = []; 291 window.clearInterval(window['bwg_playInterval' + bwg]); 292 } 293 }); 294} 295 296function bwg_carousel_ready() { 297 jQuery(".bwg-carousel").each(function () { 298 var bwg = jQuery(this).data("bwg"); 299 bwg_params_carousel[bwg] = []; 300 bwg_params_carousel[bwg]['bwg_currentCenterNum'] = 1; 301 bwg_params_carousel[bwg]['bwg_currentlyMoving'] = false; 302 bwg_params_carousel[bwg]['data'] = []; 303 304 jQuery("#spider_carousel_left-ico_" + bwg).on("click", function () { 305 bwg_params_carousel[bwg]['carousel'].prev(); 306 }); 307 jQuery("#spider_carousel_right-ico_" + bwg).on("click", function () { 308 bwg_params_carousel[bwg]['carousel'].next(); 309 }); 310 if ( parseInt(bwg_params_carousel[bwg]['carousel_enable_autoplay']) ) { 311 jQuery(".bwg_carousel_play_pause_" + bwg).attr("title", bwg_objectsL10n.pause); 312 jQuery(".bwg_carousel_play_pause_" + bwg).attr("class", "bwg_ctrl_btn_" + bwg + " bwg_carousel_play_pause_" + bwg + " fa fa-pause"); 313 } 314 jQuery(".bwg_carousel_play_pause_" + bwg).on(bwg_click, function () { 315 if (jQuery(".bwg_ctrl_btn_" + bwg).hasClass("fa-play") ) { 316 /*play*/ 317 jQuery(".bwg_carousel_play_pause_" + bwg).attr("title", bwg_objectsL10n.pause); 318 jQuery(".bwg_carousel_play_pause_" + bwg).attr("class", "bwg_ctrl_btn_" + bwg + " bwg_carousel_play_pause_" + bwg + " fa fa-pause"); 319 bwg_params_carousel[bwg]['carousel'].start(); 320 } 321 else { 322 /* Pause.*/ 323 jQuery(".bwg_carousel_play_pause_" + bwg).attr("title", bwg_objectsL10n.play); 324 jQuery(".bwg_carousel_play_pause_" + bwg).attr("class", "bwg_ctrl_btn_" + bwg + " bwg_carousel_play_pause_" + bwg + " fa fa-play"); 325 bwg_params_carousel[bwg]['carousel'].pause(); 326 } 327 }); 328 if (typeof jQuery().swiperight !== 'undefined') { 329 if (jQuery.isFunction(jQuery().swiperight)) { 330 jQuery("#bwg_container1_" + bwg).swiperight(function () { 331 bwg_params_carousel[bwg]['carousel'].prev(); 332 }); 333 } 334 } 335 if (typeof jQuery().swipeleft !== 'undefined') { 336 if (jQuery.isFunction(jQuery().swipeleft)) { 337 jQuery("#bwg_container1_" + bwg).swipeleft(function () { 338 bwg_params_carousel[bwg]['carousel'].next(); 339 }); 340 } 341 } 342 }); 343} 344 345function bwg_carousel_resize() { 346 jQuery(".bwg-carousel").each(function () { 347 var bwg = jQuery(this).data("bwg"); 348 bwg_carousel_params(bwg); 349 bwg_params_carousel[bwg]['carousel'].pause(); 350 bwg_carousel_watermark(bwg); 351 if ( !jQuery(".bwg_ctrl_btn_" + bwg).hasClass("fa-play") ) { 352 bwg_params_carousel[bwg]['carousel'].start(); 353 } 354 }); 355} 356 357function bwg_carousel_onload() {
358 jQuery(".bwg-carousel").each(function () { 359 var bwg = jQuery(this).data("bwg"); 360 361 bwg_params_carousel[bwg] = jQuery(this).data("params"); 362 bwg_carousel_watermark(bwg); 363 bwg_carousel_params(bwg); 364 bwg_container_loaded(bwg); 365 }); 366} 367 368function bwg_carousel_params(bwg) { 369 var parent_width = jQuery("#bwg_container1_" + bwg).parent().width(); 370 var par = 1; 371 if ( parent_width < bwg_params_carousel[bwg]['carousel_r_width'] ) { 372 par = parent_width / bwg_params_carousel[bwg]['carousel_r_width']; 373 } 374 else { 375 parent_width = bwg_params_carousel[bwg]['carousel_r_width']; 376 } 377 if ( bwg_params_carousel[bwg]['carousel_image_column_number'] > bwg_params_carousel[bwg]['count'] ) { 378 bwg_params_carousel[bwg]['carousel_image_column_number'] = bwg_params_carousel[bwg]['count']; 379 } 380 381 jQuery( ".bwg_carousel_play_pause_" + bwg).css({display: (!parseInt(bwg_params_carousel[bwg]['carousel_play_pause_butt']) ? 'none': '') }); 382 383 if ( !parseInt(bwg_params_carousel[bwg]['carousel_prev_next_butt']) ) { 384 jQuery("#bwg_carousel-left" + bwg).css({display:'none' }); 385 jQuery("#bwg_carousel-right" + bwg).css({display:'none' }); 386 } 387 else { 388 jQuery("#bwg_carousel-right" + bwg).css({display:'' }); 389 jQuery("#bwg_carousel-left" + bwg).css({display:'' }); 390 } 391 392 jQuery(".inner_instagram_iframe_bwg_embed_frame_" + bwg).each(function () { 393 /* 16 is 2*padding inside iframe */ 394 /* 96 is 2*padding(top) + 1*padding(bottom) + 40(footer) + 32(header) */ 395 var parent_container = jQuery(this).parent(); 396 if ( bwg_params_carousel[bwg]['image_height'] / (parseInt(parent_container.attr('data-height')) + 96) < bwg_params_carousel[bwg]['image_width'] / parseInt(parent_container.attr('data-width')) ) { 397 parent_container.height(bwg_params_carousel[bwg]['image_height'] * par); 398 parent_container.width((parent_container.height() - 96) * parent_container.attr('data-width') / parent_container.attr('data-height') + 16); 399 } 400 else { 401 parent_container.width(bwg_params_carousel[bwg]['image_width'] * par); 402 parent_container.height((parent_container.width() - 16) * parent_container.attr('data-height') / parent_container.attr('data-width') + 96); 403 } 404 }); 405 406 jQuery(".bwg_carousel_image_container_" + bwg).css({width: bwg_params_carousel[bwg]['image_width'] * par,height: bwg_params_carousel[bwg]['image_height'] * par }); 407 jQuery(".bwg_carousel_watermark_text_" + bwg + ", .bwg_carousel_watermark_text_" + bwg + ":hover").css({fontSize: ((parent_width) * (bwg_params_carousel[bwg]['watermark_font_size'] / bwg_params_carousel[bwg]['image_width']) * par)}); 408 jQuery(".bwg_carousel-image " + bwg).css({width: bwg_params_carousel[bwg]['image_width'] * par, height: bwg_params_carousel[bwg]['image_height'] * par }); 409 jQuery(".bwg_carousel_watermark_container_" + bwg).css({width: bwg_params_carousel[bwg]['image_width'] * par, height: bwg_params_carousel[bwg]['image_height'] * par }); 410 jQuery(".bwg_carousel_embed_video_" + bwg).css({width: bwg_params_carousel[bwg]['image_width'] * par, height: bwg_params_carousel[bwg]['image_height'] * par }); 411 jQuery(".bwg_carousel_watermark_spun_" + bwg).css({width: bwg_params_carousel[bwg]['image_width'] * par, height: bwg_params_carousel[bwg]['image_height'] * par }); 412 jQuery(".bwg_carousel-container" + bwg).css({width: parent_width, height: bwg_params_carousel[bwg]['image_height'] * par }); 413 jQuery(".bwg_video_hide" + bwg).css({width: bwg_params_carousel[bwg]['image_width'] * par, height: bwg_params_carousel[bwg]['image_height'] * par }); 414 415 bwg_params_carousel[bwg]['carousel'] = jQuery("#bwg_carousel" + bwg).featureCarousel({ 416 containerWidth: parent_width * par, 417 containerHeight: bwg_params_carousel[bwg]['image_height'] * par, 418 fit_containerWidth: bwg_params_carousel[bwg]['carousel_fit_containerWidth'], 419 largeFeatureWidth: bwg_params_carousel[bwg]['image_width'] * par, 420 largeFeatureHeight: bwg_params_carousel[bwg]['image_height'] * par, 421 smallFeaturePar: bwg_params_carousel[bwg]['carousel_image_par'], 422 currentlyMoving: false, 423 startingFeature: bwg_params_carousel[bwg]['bwg_currentCenterNum'], 424 featuresArray: [], 425 timeoutVar: null, 426 rotationsRemaining: 0, 427 autoPlay: bwg_params_carousel[bwg]['car_inter'] * 1000, 428 interval: bwg_params_carousel[bwg]['carousel_interval'] * 1000, 429 imagecount: bwg_params_carousel[bwg]['carousel_image_column_number'], 430 bwg_number: bwg, 431 enable_image_title: bwg_params_carousel[bwg]['enable_image_title'], 432 borderWidth: 0 433 }); 434} 435 436function bwg_carousel_watermark(bwg) { 437 var par = 1; 438 var parent_width = jQuery("#bwg_container1_" + bwg).parent().width(); 439 if ( parent_width < bwg_params_carousel[bwg]['carousel_r_width'] ) { 440 par = parent_width / bwg_params_carousel[bwg]['carousel_r_width']; 441 } 442 if ( parent_width >= bwg_params_carousel[bwg]['image_width'] ) { 443 /* Set watermark container size.*/ 444 bwg_carousel_change_watermark_container(bwg); 445 jQuery("#bwg_carousel_play_pause-ico_" + bwg).css({fontSize: bwg_params_carousel[bwg]['carousel_play_pause_btn_size']}); 446 jQuery(".bwg_carousel_watermark_image_" + bwg).css({maxWidth: bwg_params_carousel[bwg]['watermark_width'] * par, maxHeight: b
446wg_params_carousel[bwg]['watermark_height'] * par}); 447 jQuery(".bwg_carousel_watermark_text_" + bwg + ", .bwg_carousel_watermark_text_" + bwg + ":hover").css({fontSize: par * bwg_params_carousel[bwg]['watermark_font_size']}); 448 } 449 else { 450 /* Set watermark container size.*/ 451 var img_width = bwg_params_carousel[bwg]['image_width'] / par; 452 bwg_carousel_change_watermark_container(bwg); 453 jQuery("#bwg_carousel_play_pause-ico_" + bwg).css({fontSize: (parent_width * bwg_params_carousel[bwg]['carousel_play_pause_btn_size'] / img_width )}); 454 jQuery(".bwg_carousel_watermark_image_" + bwg).css({maxWidth: ( parent_width * bwg_params_carousel[bwg]['watermark_width'] / img_width), maxHeight: (parent_width * bwg_params_carousel[bwg]['watermark_height'] / img_width)}); 455 jQuery(".bwg_carousel_watermark_text_" + bwg + ", .bwg_carousel_watermark_text_" + bwg + ":hover").css({fontSize: (parent_width * bwg_params_carousel[bwg]['watermark_font_size'] / img_width )}); 456 } 457} 458 459function bwg_carousel_change_watermark_container(bwg) { 460 jQuery(".bwg_carousel" + bwg).children().each(function() { 461 if (jQuery(this).css("zIndex") == 2) { 462 var bwg_current_image_span = jQuery(this).find("img"); 463 if (!bwg_current_image_span.length) { 464 bwg_current_image_span = jQuery(this).find("iframe"); 465 } 466 var width = bwg_current_image_span.width(); 467 var height = bwg_current_image_span.height(); 468 jQuery(".bwg_carousel_watermark_spun_" + bwg).width(width); 469 jQuery(".bwg_carousel_watermark_spun_" + bwg).height(height); 470 jQuery(".bwg_carousel_title_spun_" + bwg).width(width); 471 jQuery(".bwg_carouel_title_spun_" + bwg).height(height); 472 jQuery(".bwg_carousel_watermark_" + bwg).css({display: 'none'}); 473 } 474 }); 475} 476 477/* Change hidden carousel items to visiblle */ 478function bwg_carousel_preload( bwg, right ) { 479 var preload_images_count = 1; 480 481 var selector = jQuery(".bwg_carousel_preload").get(); 482 if ( !right ) { 483 selector.reverse(); 484 } 485 var i = 0; 486 jQuery(selector).each(function () { 487 if ( ++i > preload_images_count ) { 488 return false; 489 } 490 if ( jQuery(this).parent().hasClass('bwg_carousel_embed_video_' + bwg) 491 || jQuery(this).parent().hasClass('bwg_embed_frame_' + bwg) 492 || jQuery(this).parent().hasClass('bwg_carousel_video') ) { 493 /* Embed. */ 494 jQuery(this).attr('src', jQuery(this).attr('data-src')); 495 jQuery(this).on("load", function () { 496 jQuery(this).removeClass('bwg_carousel_preload'); 497 }); 498 /* Load video after changing source. */ 499 if ( jQuery(this).parent().hasClass('bwg_carousel_video') ) { 500 jQuery(".bwg_carousel_video")[0].load(); 501 jQuery(this).parent().parent().removeClass('bwg_carousel_preload'); 502 } 503 jQuery(this).removeAttr('data-src'); 504 } 505 else { 506 /* Image. */ 507 jQuery(this).css({ 508 'background-image': "url('" + jQuery(this).attr('data-background') + "')", 509 'height': '100%', 510 }); 511 jQuery(this).removeClass('bwg_carousel_preload'); 512 jQuery(this).removeAttr('data-background'); 513 } 514 }); 515} 516 517function bwg_slideshow_ready() { 518 jQuery(".bwg_slideshow").each(function () { 519 var bwg = jQuery(this).data("bwg"); 520 if ( jQuery("#bwg_slideshow_image_container_" + bwg).length ) { 521 bwg_params[bwg] = JSON.parse(jQuery("#bwg_slideshow_image_container_" + bwg).attr("data-params")); 522 bwg_params[bwg]['event_stack'] = []; 523 bwg_container_loaded(bwg); 524 var data = bwg_params[bwg]['data']; 525 if (typeof jQuery().swiperight !== 'undefined') { 526 if (jQuery.isFunction(jQuery().swiperight)) { 527 jQuery("#bwg_container1_" + bwg).swiperight(function () { 528 bwg_change_image(parseInt(jQuery("#bwg_current_image_key_" + bwg).val()), (parseInt(jQuery("#bwg_current_image_key_" + bwg).val()) - bwg_iterator(bwg)) >= 0 ? (parseInt(jQuery("#bwg_current_image_key_" + bwg).val()) - bwg_iterator(bwg)) % data.length : data.length - 1, data, '', bwg); 529 return false; 530 }); 531 } 532 } 533 if (typeof jQuery().swipeleft !== 'undefined') { 534 if (jQuery.isFunction(jQuery().swipeleft)) { 535 jQuery("#bwg_container1_" + bwg).swipeleft(function () {
536 bwg_change_image(parseInt(jQuery("#bwg_current_image_key_" + bwg).val()), (parseInt(jQuery("#bwg_current_image_key_" + bwg).val()) + bwg_iterator(bwg) % data.length), data, '', bwg); 537 return false; 538 }); 539 } 540 } 541 var isMobile = (/android|webos|iphone|ipad|ipod|blackberry|iemobile|opera mini/i.test(navigator.userAgent.toLowerCase())); 542 var bwg_click = isMobile ? 'touchend' : 'click'; 543 bwg_popup_resize(bwg); 544 jQuery(".bwg_slideshow_watermark_" + bwg).css({display: 'none'}); 545 jQuery(".bwg_slideshow_title_text_" + bwg).css({display: 'none'}); 546 jQuery(".bwg_slideshow_description_text_" + bwg).css({display: 'none'}); 547 setTimeout(function () { 548 bwg_change_watermark_container(bwg); 549 }, 500); 550 /* Set image container height.*/ 551 if (bwg_params[bwg]['filmstrip_direction'] == 'horizontal') { 552 jQuery(".bwg_slideshow_image_container_" + bwg).height(jQuery(".bwg_slideshow_image_wrap_" + bwg).height() - bwg_params[bwg]['slideshow_filmstrip_height']); 553 } 554 else { 555 jQuery(".bwg_slideshow_image_container_" + bwg).width(jQuery(".bwg_slideshow_image_wrap_" + bwg).width() - bwg_params[bwg]['slideshow_filmstrip_width']); 556 } 557 var mousewheelevt = (/Firefox/i.test(navigator.userAgent)) ? "DOMMouseScroll" : "mousewheel"; 558 /* FF doesn't recognize mousewheel as of FF3.x */ 559 jQuery(".bwg_slideshow_filmstrip_" + bwg).bind(mousewheelevt, function (e) { 560 var evt = window.event || e; 561 /* Equalize event object.*/ 562 evt = evt.originalEvent ? evt.originalEvent : evt; 563 /* Convert to originalEvent if possible.*/ 564 var delta = evt.detail ? evt.detail * (-40) : evt.wheelDelta; 565 /* Check for detail first, because it is used by Opera and FF.*/ 566 if (delta > 0) { 567 /* Scroll up.*/ 568 jQuery(".bwg_slideshow_filmstrip_left_" + bwg).trigger("click"); 569 } 570 else { 571 /* Scroll down.*/ 572 jQuery(".bwg_slideshow_filmstrip_right_" + bwg).trigger("click"); 573 } 574 return false; 575 }); 576 jQuery(".bwg_slideshow_filmstrip_right_" + bwg).on(bwg_click, function () { 577 jQuery(".bwg_slideshow_filmstrip_thumbnails_" + bwg).stop(true, false); 578 if (bwg_params[bwg]['left_or_top'] == 'left') { /* For left, width */ 579 if (bwg_params[bwg]['width_or_height'] == 'width') { 580 if (jQuery(".bwg_slideshow_filmstrip_thumbnails_" + bwg).position().left >= -(jQuery(".bwg_slideshow_filmstrip_thumbnails_" + bwg).width() - jQuery(".bwg_slideshow_filmstrip_" + bwg).width())) { 581 jQuery(".bwg_slideshow_filmstrip_left_" + bwg).css({opacity: 1, filter: "Alpha(opacity=100)"}); 582 if (jQuery(".bwg_slideshow_filmstrip_thumbnails_" + bwg).position().left < -(jQuery(".bwg_slideshow_filmstrip_thumbnails_" + bwg).width() - jQuery(".bwg_slideshow_filmstrip_" + bwg).width() - (bwg_params[bwg]['filmstrip_thumb_margin_hor'] + bwg_params[bwg]['slideshow_filmstrip_width']))) { 583 jQuery(".bwg_slideshow_filmstrip_thumbnails_" + bwg).animate({left: -(jQuery(".bwg_slideshow_filmstrip_thumbnails_" + bwg).width() - jQuery(".bwg_slideshow_filmstrip_" + bwg).width())}, 500, 'linear'); 584 } 585 else { 586 jQuery(".bwg_slideshow_filmstrip_thumbnails_" + bwg).animate({left: (jQuery(".bwg_slideshow_filmstrip_thumbnails_" + bwg).position().left - (bwg_params[bwg]['filmstrip_thumb_margin_hor'] + bwg_params[bwg]['slideshow_filmstrip_width']))}, 500, 'linear'); 587 } 588 } 589 /* Disable right arrow.*/ 590 window.setTimeout(function () { 591 if ((jQuery(".bwg_slideshow_filmstrip_thumbnails_" + bwg).position().left) == -(jQuery(".bwg_slideshow_filmstrip_thumbnails_" + bwg).width() - jQuery(".bwg_slideshow_filmstrip_" + bwg).width())) { 592 jQuery(".bwg_slideshow_filmstrip_right_" + bwg).css({opacity: 0.3, filter: "Alpha(opacity=30)"}); 593 } 594 }, 500); 595 } 596 else { /* For left, height */ 597 if (jQuery(".bwg_slideshow_filmstrip_thumbnails_" + bwg).position().left >= -(jQuery(".bwg_slideshow_filmstrip_thumbnails_" + bwg).height() - jQuery(".bwg_slideshow_filmstrip_" + bwg).height())) { 598 jQuery(".bwg_slideshow_filmstrip_left_" + bwg).css({opacity: 1, filter: "Alpha(opacity=100)"}); 599 if (jQuery(".bwg_slideshow_filmstrip_thumbnails_" + bwg).position().left < -(jQuery(".bwg_slideshow_filmstrip_thumbnails_" + bwg).height() - jQuery(".bwg_slideshow_filmstrip_" + bwg).height() - (bwg_params[bwg]['filmstrip_thumb_margin_hor'] + bwg_params[bwg]['slideshow_filmstrip_width']))) { 600 jQuery(".bwg_slideshow_filmstrip_thumbnails_" + bwg).animate({left: -(jQuery(".bwg_slideshow_filmstrip_thumbnails_" + bwg).height() - jQuery(".bwg_slideshow_filmstrip_" + bwg).width())}, 500, 'linear'); 601 } 602 else { 603 jQuery(".bwg_slideshow_filmstrip_thumbnails_" + bwg).animate({left: (jQuery(".bwg_slideshow_filmstrip_thumbnails_" + bwg).position().left - (bwg_params[bwg]['filmstrip_thumb_margin_hor'] + bwg_params[bwg]['slideshow_filmstrip_width']))}, 500, 'linear'); 604 } 605 } 606 /* Disable right arrow.*/ 607 window.setTimeout(function () { 608 if ((jQuery(".bwg_slideshow_filmstrip_thumbnails_" + bwg).position().left) == -(jQuery(".bwg_slideshow_filmstrip_thumbnails_" + bwg).height() - jQuery(".bwg_slideshow_filmstrip_" + bwg).height())) { 609 jQuery(".bwg_slideshow_filmstrip_right_" + bwg).css({opacity: 0.3, filter: "Alpha(opacity=30)"}); 610 } 611 }, 500); 612 } 613 } 614 else { 615 if (bwg_params[bwg]['width_or_height'] == 'width') { /* For top, width */ 616 if (jQuery(".bwg_slideshow_filmstrip_thumbnails_" + bwg).position().top >= -(jQuery(".bwg_slideshow_filmstrip_thumbnails_" + bwg).width() - jQuery(".bwg_slideshow_filmstrip_" + bwg).width())) { 617 jQuery(".bwg_slideshow_filmstrip_left_" + bwg).css({opacity: 1, filter: "Alpha(opacity=100)"}); 618 if (jQuery(".bwg_slideshow_filmstrip_thumbnails_" + bwg).position().top < -(jQuery(".bwg_slideshow_filmstrip_thumbnails_" + bwg).width() - jQuery(".bwg_slideshow_filmstrip_" + bwg).width() - bwg_params[bwg]['filmstrip_thumb_margin_hor'] + bwg_params[bwg]['slideshow_filmstrip_width'])) { 619 jQuery(".bwg_slideshow_filmstrip_thumbnails_" + bwg).animate({top: -(jQuery(".bwg_slideshow_filmstrip_thumbnails_" + bwg).width() - jQuery(".bwg_slideshow_filmstrip_" + bwg).width())}, 500, 'linear'); 620 } 621 else { 622 jQuery(".bwg_slideshow_filmstrip_thumbnails_" + bwg).animate({top: (jQuery(".bwg_slideshow_filmstrip_thumbnails_" + bwg).position().top - bwg_params[bwg]['filmstrip_thumb_margin_hor'] + bwg_params[bwg]['slideshow_filmstrip_width'])}, 500, 'linear'); 623 } 624 } 625 /* Disable right arrow.*/ 626 window.setTimeout(function () { 627 if ((jQuery(".bwg_slideshow_filmstrip_thumbnails_" + bwg).position().top) == -(jQuery(".bwg_slideshow_filmstrip_thumbnails_" + bwg).width() - jQuery(".bwg_slideshow_filmstrip_" + bwg).width())) { 628 jQuery(".bwg_slideshow_filmstrip_right_" + bwg).css({opacity: 0.3, filter: "Alpha(opacity=30)"}); 629 } 630 }, 500); 631 } 632 else { /* For top, height */ 633 if (jQuery(".bwg_slideshow_filmstrip_thumbnails_" + bwg).position().top >= -(jQuery(".bwg_slideshow_filmstrip_thumbnails_" + bwg).height() - jQuery(".bwg_slideshow_filmstrip_" + bwg).height())) { 634 jQuery(".bwg_slideshow_filmstrip_left_" + bwg).css({opacity: 1, filter: "Alpha(opacity=100)"}); 635 if (jQuery(".bwg_slideshow_filmstrip_thumbnails_" + bwg).position().top < -(jQuery(".bwg_slideshow_filmstrip_thumbnails_" + bwg).height() - jQuery(".bwg_slideshow_filmstrip_" + bwg).height() - (bwg_params[bwg]['filmstrip_thumb_margin_hor'] + bwg_params[bwg]['slideshow_filmstrip_width']))) { 636 jQuery(".bwg_slideshow_filmstrip_thumbnails_" + bwg).animate({top: -(jQuery(".bwg_slideshow_filmstrip_thumbnails_" + bwg).height() - jQuery(".bwg_slideshow_filmstrip_" + bwg).width())}, 500, 'linear'); 637 } 638 else { 639 jQuery(".bwg_slideshow_filmstrip_thumbnails_" + bwg).animate({top: (jQuery(".bwg_slideshow_filmstrip_thumbnails_" + bwg).position().top - (bwg_params[bwg]['filmstrip_thumb_margin_hor'] + bwg_params[bwg]['slideshow_filmstrip_width']))}, 500, 'linear'); 640 } 641 } 642 /* Disable right arrow.*/ 643 window.setTimeout(function () { 644 if ((jQuery(".bwg_slideshow_filmstrip_thumbnails_" + bwg).position().top) == -(jQuery(".bwg_slideshow_filmstrip_thumbnails_" + bwg).height() - jQuery(".bwg_slideshow_filmstrip_" + bwg).height())) { 645 jQuery(".bwg_slideshow_filmstrip_right_" + bwg).css({opacity: 0.3, filter: "Alpha(opacity=30)"}); 646 } 647 }, 500); 648 } 649 } 650 }); 651 jQuery(".bwg_slideshow_filmstrip_left_" + bwg).on(bwg_click, function () { 652 jQuery(".bwg_slideshow_filmstrip_thumbnails_" + bwg).stop(true, false); 653 if (bwg_params[bwg]['left_or_top'] == 'left') { 654 if (jQuery(".bwg_slideshow_filmstrip_thumbnails_" + bwg).position().left < 0) { 655 jQuery(".bwg_slideshow_filmstrip_right_" + bwg).css({opacity: 1, filter: "Alpha(opacity=100)"}); 656 if (jQuery(".bwg_slideshow_filmstrip_thumbnails_" + bwg).position().left > -bwg_params[bwg]['filmstrip_thumb_margin_hor'] + bwg_params[bwg]['slideshow_filmstrip_width']) { 657 jQuery(".bwg_slideshow_filmstrip_thumbnails_" + bwg).animate({left: 0}, 500, 'linear'); 658 } 659 else { 660 jQuery(".bwg_slideshow_filmstrip_thumbnails_" + bwg).animate({left: (jQuery(".bwg_slideshow_filmstrip_thumbnails_" + bwg).position().left + bwg_params[bwg]['filmstrip_thumb_margin_hor'] + bwg_params[bwg]['slideshow_filmstrip_width'])}, 500, 'linear'); 661 } 662 } 663 /* Disable left arrow.*/ 664 window.setTimeout(function () { 665 if (jQuery(".bwg_slideshow_filmstrip_thumbnails_" + bwg).position().left == 0) { 666 jQuery(".bwg_slideshow_filmstrip_left_" + bwg).css({opacity: 0.3, filter: "Alpha(opacity=30)"}); 667 } 668 }, 500); 669 } 670 else { 671 if (jQuery(".bwg_slideshow_filmstrip_thumbnails_" + bwg).position().top < 0) { 672 jQuery(".bwg_slideshow_filmstrip_right_" + bwg).css({opacity: 1, filter: "Alpha(opacity=100)"}); 673 if (jQuery(".bwg_slideshow_filmstrip_thumbnails_" + bwg).position().top > -bwg_params[bwg]['filmstrip_thumb_margin_hor'] + bwg_params[bwg]['slideshow_filmstrip_width']) { 674 jQuery(".bwg_slideshow_filmstrip_thumbnails_" + bwg).animate({top: 0}, 500, 'linear'); 675 } 676 else { 677 jQuery(".bwg_slideshow_filmstrip_thumbnails_" + bwg).animate({top: (jQuery(".bwg_slideshow_filmstrip_thumbnails_" + bwg).position().top + bwg_params[bwg]['filmstrip_thumb_margin_hor'] + bwg_params[bwg]['slideshow_filmstrip_width'])}, 500, 'linear'); 678 } 679 } 680 /* Disable top arrow.*/ 681 window.setTimeout(function () { 682 if (jQuery(".bwg_slideshow_filmstrip_thumbnails_" + bwg).position().top == 0) { 683 jQuery(".bwg_slideshow_filmstrip_left_" + bwg).css({opacity: 0.3, filter: "Alpha(opacity=30)"}); 684 } 685 }, 500); 686 } 687 }); 688 if (bwg_params[bwg]['width_or_height'] == 'width') { 689 /* Set filmstrip initial position.*/ 690 bwg_set_filmstrip_pos(jQuery(".bwg_slideshow_filmstrip_" + bwg).width(), bwg); 691 } 692 else { 693 /* Set filmstrip initial position.*/ 694 bwg_set_filmstrip_pos(jQuery(".bwg_slideshow_filmstrip_" + bwg).height(), bwg); 695 } 696 /* Play/pause.*/ 697 jQuery("#bwg_slideshow_play_pause_" + bwg).off(bwg_click).on(bwg_click, function () {
698 if (jQuery(".bwg_ctrl_btn_" + bwg).hasClass("fa-play")) { 699 bwg_play(bwg_params[bwg]['data'], bwg); 700 jQuery(".bwg_slideshow_play_pause_" + bwg).attr("title", bwg_objectsL10n.pause); 701 jQuery(".bwg_slideshow_play_pause_" + bwg).attr("class", "bwg_ctrl_btn_" + bwg + " bwg_slideshow_play_pause_" + bwg + " fa fa-pause"); 702 if (bwg_params[bwg]['enable_slideshow_music'] == 1) { 703 document.getElementById("bwg_audio_" + bwg).play(); 704 } 705 } 706 else { 707 /* Pause.*/ 708 window.clearInterval(window['bwg_playInterval' + bwg]); 709 jQuery(".bwg_slideshow_play_pause_" + bwg).attr("title", "Play"); 710 jQuery(".bwg_slideshow_play_pause_" + bwg).attr("class", "bwg_ctrl_btn_" + bwg + " bwg_slideshow_play_pause_" + bwg + " fa fa-play"); 711 if (bwg_params[bwg]['enable_slideshow_music'] == 1) { 712 document.getElementById("bwg_audio_" + bwg).pause(); 713 } 714 } 715 }); 716 if (bwg_params[bwg]['enable_slideshow_autoplay'] != 0) { 717 bwg_play(bwg_params[bwg]['data'], bwg); 718 jQuery(".bwg_slideshow_play_pause_" + bwg).attr("title", bwg_objectsL10n.pause); 719 jQuery(".bwg_slideshow_play_pause_" + bwg).attr("class", "bwg_ctrl_btn_" + bwg + " bwg_slideshow_play_pause_" + bwg + " fa fa-pause"); 720 if (bwg_params[bwg]['enable_slideshow_music'] == 1 && jQuery("#bwg_audio_" + bwg).length) { 721 document.getElementById("bwg_audio_" + bwg).play(); 722 } 723 } 724 if (bwg_params[bwg]['preload_images']) { 725 bwg_preload_images(parseInt(jQuery("#bwg_current_image_key_".$bwg).val()), bwg); 726 } 727 jQuery(".bwg_slideshow_image_" + bwg).removeAttr("width"); 728 jQuery(".bwg_slideshow_image_" + bwg).removeAttr("height"); 729 } 730 }); 731} 732 733function bwg_image_browser_resize() { 734 jQuery(".bwg_image_browser").each(function () { 735 var bwg = jQuery(this).attr('data-bwg'); 736 if (jQuery('.image_browser_images_conteiner_' + bwg).length) { 737 bwg_params_ib[bwg] = JSON.parse(jQuery('#bwg_container1_' + bwg + ' .image_browser_images_conteiner_' + bwg ).attr('data-params')); 738 bwg_image_browser( bwg ); 739 } 740 }); 741} 742 743function bwg_image_browser_ready() { 744 /* For ImageBrowser */ 745 jQuery(".bwg_image_browser").each(function () { 746 var bwg = jQuery(this).attr('data-bwg'); 747 bwg_container_loaded( bwg ); 748 if (jQuery('.image_browser_images_conteiner_' + bwg).length) { 749 bwg_params_ib[bwg] = JSON.parse(jQuery('.image_browser_images_conteiner_' + bwg).attr('data-params')); 750 setTimeout(function () { 751 bwg_image_browser(bwg); 752 }, 3); 753 } 754 }); 755} 756 757/* hide search_placeholder_title class container */ 758function bwg_search_focus(that) { 759 jQuery(that).parent().find('.bwg_search_input').focus(); 760 jQuery(that).hide(); 761} 762 763/* show search and reset icons */ 764function bwg_key_press(that) { 765 jQuery(that).parent().find('.bwg_search_reset_container').removeClass("hidden"); 766 jQuery(that).parent().find('.bwg_search_loupe_container1').removeClass("hidden"); 767} 768 769function bwg_all_thumnails_loaded(that) { 770 var thumbnails_count = 0; 771 var thumbnails_loaded = jQuery(that).find("img").length; 772 if (0 == thumbnails_loaded) { 773 bwg_all_thumbnails_loaded_callback(that); 774 } 775 else { 776 jQuery( that ).find( "img" ).each( function () { 777 var fakeSrc = jQuery( this ).attr( "src" ); 778 jQuery( "<img/>" ).attr( "src", fakeSrc ).on( "load error", function () { 779 if ( ++thumbnails_count >= thumbnails_loaded ) { 780 bwg_all_thumbnails_loaded_callback( that ); 781 } 782 }); 783 }); 784 } 785 786 return thumbnails_loaded == 0; 787} 788 789function bwg_all_thumbnails_loaded_callback(that) { 790 if (jQuery(that).hasClass('bwg-thumbnails')) { 791 bwg_thumbnail( that ); 792 }
793 if (jQuery(that).hasClass('bwg-masonry-thumbnails')) { 794 bwg_thumbnail_masonry( that ); 795 } 796 if (jQuery(that).hasClass('bwg-album-extended')) { 797 bwg_album_extended( that ); 798 } 799} 800 801function bwg_container_loaded(bwg) { 802 jQuery('#gal_front_form_' + bwg).removeClass('bwg-hidden'); 803 jQuery('#ajax_loading_' + bwg).addClass('bwg-hidden'); 804} 805 806function bwg_album_thumbnail(that) { 807 bwg_container_loaded(jQuery(that).data('bwg')); 808} 809 810function bwg_album_extended(that) { 811 var container_width = jQuery(that).width(); 812 var thumb_width = jQuery(that).data("thumbnail-width"); 813 var spacing = jQuery(that).data("spacing"); 814 var max_count = jQuery(that).data("max-count"); 815 var column_count = parseInt(container_width / (2 * thumb_width)); 816 if ( column_count < 1 ) { 817 column_count = 1; 818 } 819 if (column_count > max_count) { 820 column_count = max_count; 821 } 822 var min_width = 100 / column_count; 823 var bwg_item = jQuery(that).find(".bwg-extended-item"); 824 var margin_left = parseInt(bwg_item.css("margin-left")); 825 var margin_right = parseInt(bwg_item.css("margin-right")); 826 bwg_item.css({ 827 width: "calc(" + min_width + "% - " + (margin_left + margin_right) + "px)" 828 }); 829 if ( bwg_item.width() < thumb_width ) { 830 bwg_item.find(".bwg-extended-item0, .bwg-extended-item1").css({ 831 width: 'calc(100% - ' + spacing + 'px)' 832 }); 833 } 834 else if ( bwg_item.width() > 2 * thumb_width ) { 835 bwg_item.find(".bwg-extended-item0").css({ 836 width: 'calc(50% - ' + spacing + 'px)' 837 }); 838 bwg_item.find(".bwg-extended-item1").css({ 839 width: 'calc(100% - ' + (thumb_width + spacing * 2) + 'px)' 840 }); 841 } 842 else { 843 bwg_item.find(".bwg-extended-item0, .bwg-extended-item1").css({ 844 width: 'calc(50% - ' + spacing + 'px)' 845 }); 846 } 847 848 jQuery(that).children(".bwg-extended-item").each(function () { 849 var image = jQuery(this).find("img"); 850 var item0 = jQuery(this).find(".bwg-item0"); 851 var item2 = jQuery(this).find(".bwg-item2"); 852 if ( (item2.width() / item2.height()) > (image.width() / image.height()) ) { 853 if ( item2.width() > image.width() ) { 854 image.css({width: "100%"}); 855 } 856 else { 857 image.css({maxWidth: "100%"}); 858 } 859 } 860 else { 861 if ( item2.height() > image.height() ) { 862 image.css({height: "100%"}); 863 } 864 else { 865 image.css({maxHeight: "100%"}); 866 } 867 } 868 jQuery(this).find(".bwg-item2").css({ 869 marginLeft: (item0.width() - image.width()) / 2, 870 marginTop: (item0.height() - image.height()) / 2 871 }); 872 }); 873 bwg_container_loaded(jQuery(that).data('bwg')); 874} 875 876function bwg_thumbnail(that) { 877 var container_width = jQuery(that).width(); 878 var thumb_width = jQuery(that).data("thumbnail-width"); 879 var max_count = jQuery(that).data("max-count"); 880 var column_count = parseInt(container_width / thumb_width) + 1; 881 if (column_count > max_count) { 882 column_count = max_count; 883 } 884 /*var flex = 1 / column_count;*/ 885 var min_width = 100 / column_count; 886 var bwg_item = jQuery(that).find(".bwg-item"); 887 bwg_item.css({ 888 /*flexGrow: flex,*/ 889 width: min_width + "%" 890 }); 891 jQuery(that).children(".bwg-item").each(function () { 892 var image = jQuery(this).find("img"); 893 var item2 = jQuery(this).find(".bwg-item2"); 894 if ( (item2.width() / item2.height()) > (image.width() / image.height()) ) { 895 if ( item2.width() > image.width() ) { 896 image.css({width: "100%"}); 897 } 898 else { 899 image.css({maxWidth: "100%"}); 900 } 901 } 902 else { 903 if ( item2.height() > image.height() ) { 904 image.css({height: "100%"}); 905 } 906 else { 907 image.css({maxHeight: "100%"}); 908 } 909 } 910 jQuery(this).find(".bwg-item2").css({ 911 marginLeft: (item2.width() - image.width()) / 2, 912 marginTop: (item2.height() - image.height()) / 2 913 }); 914 }); 915 bwg_container_loaded(jQuery(that).data('bwg')); 916} 917 918function bwg_thumbnail_masonry(that) { 919 var container = jQuery(that); 920 container.find('.bwg-empty-item').remove(); 921 var masonry_type = container.data("masonry-type"); 922 if ('horizontal' == masonry_type) { 923 var thumb_height = container.data( "thumbnail-height" ); 924 var max_count = container.data( "max-count" ); 925 var column_widths = []; 926 for ( i = 0; i < max_count; i++ ) { 927 column_widths.push( 0 ); 928 } 929 container.find( ".bwg-item" ).each( function () { 930 var order = column_widths.indexOf( Math.min.apply( Math, column_widths ) ); 931 jQuery( this ).css( { height: thumb_height, order: order + 1 } ); 932 /* Use getBoundingClientRect instead of jQuery.width() to avoid rounding. */ 933 column_widths[order] += jQuery( this )[0].getBoundingClientRect().width; 934 } ); 935 var container_width = Math.max.apply( Math, column_widths ); 936 container.width( container_width ); 937 938 /* Equalize all rows. */ 939 for ( i = 0; i < max_count; i++ ) { 940 if ( column_widths[i] < container_width ) { 941 container.append( jQuery( '<div class="bwg-item bwg-empty-item"></div>' ).css( { 942 height: thumb_height, 943 order: i + 1, 944 width: container_width - column_widths[i] 945 } ) ); 946 } 947 } 948 } 949 else { 950 container.removeAttr('style'); 951 var container_width = container.width(); 952 var thumb_width = container.data( "thumbnail-width" ); 953 var max_count = container.data( "max-count" ); 954 var column_count = parseInt( container_width / thumb_width ) + (container.data('resizable-thumbnails') == '0' ? 0 : 1); 955 if ( column_count > max_count ) { 956 column_count = max_count; 957 } 958 var thumb_count = container.find( ".bwg-item" ).length; 959 if ( thumb_count < column_count ) { 960 column_count = thumb_count; 961 } 962 var min_width = 100 / column_count; 963 var column_heights = []; 964 for ( i = 0; i < column_count; i++ ) { 965 column_heights.push( 0 ); 966 } 967 container.find( ".bwg-item" ).each( function () { 968 var order = column_heights.indexOf( Math.min.apply( Math, column_heights ) ); 969 jQuery( this ).css( { width: min_width + "%", order: order + 1 } ); 970 /* Use getBoundingClientRect instead of jQuery.height() to avoid rounding. */ 971 column_heights[order] += jQuery( this )[0].getBoundingClientRect().height; 972 } ); 973 974 var container_height = Math.max.apply( Math, column_heights ); 975 /* Equalize all columns. */ 976 for ( i = 0; i < column_count; i++ ) { 977 if ( column_heights[i] < container_height ) { 978 container.append( jQuery( '<div class="bwg-item bwg-empty-item"></div>' ).css( { 979 width: min_width + "%", 980 order: i + 1, 981 height: container_height - column_heights[i] 982 } ) ); 983 } 984 } 985 986 container.outerWidth( column_count * thumb_width ); 987 container.height( container_height ); 988 } 989 bwg_container_loaded(container.data('bwg')); 990} 991 992function bwg_thumbnail_mosaic(that) { 993 var container = jQuery(that); 994 var bwg = container.attr('data-bwg'); 995 var block_id = container.attr('data-block-id'); 996 var padding_px = parseInt(container.attr('data-thumb-padding')) / 2; 997 var border_px = parseInt(container.attr('data-thumb-border')); 998 var border_and_padding = border_px + padding_px; 999 if (container.attr('data-mosaic-direction') == 'horizontal') { 1000 var thumb_height = parseInt(container.attr('data-height')); 1001 /*resizable mosaic*/ 1002 if (container.attr('data-resizable') == '1') { 1003 if (jQuery(window).width() >= 1920) { 1004 var thumbnail_height = (1+jQuery(window).width()/1920)*thumb_height; 1005 } 1006 else if (jQuery(window).width() <= 640) { 1007 var thumbnail_height = jQuery(window).width()/640*thumb_height; 1008 } 1009 else { 1010 var thumbnail_height = thumb_height; 1011 } 1012 } 1013 else { 1014 var thumbnail_height = thumb_height; 1015 } 1016 /* initialize */ 1017 var mosaic_pics = jQuery(".bwg_mosaic_thumb_" + bwg); 1018 mosaic_pics.each(function (index) {
1019 var thumb_w = mosaic_pics.get(index).naturalWidth; 1020 var thumb_h = mosaic_pics.get(index).naturalHeight; 1021 thumb_w = thumb_w * thumbnail_height / thumb_h; 1022 mosaic_pics.eq(index).height(thumbnail_height); 1023 mosaic_pics.eq(index).width(thumb_w); 1024 }); 1025 /* resize */ 1026 var divwidth = jQuery("#bwg_mosaic_thumbnails_div_" + bwg).width() / 100 * parseInt(container.attr('data-total-width')); 1027 /*set absolute mosaic width*/ 1028 jQuery("#" + block_id).width(divwidth); 1029 var row_height = thumbnail_height + 2 * border_and_padding; 1030 var row_number = 0; 1031 var row_of_img = []; 1032 /* row of the current image*/ 1033 row_of_img[0] = 0; 1034 var imgs_by_rows = []; 1035 /* number of images in each row */ 1036 imgs_by_rows[0] = 0; 1037 var row_cum_width = 0; 1038 /* width of the current row */ 1039 /* create masonry horizontal */ 1040 mosaic_pics.each(function (index) { 1041 row_cum_width2 = row_cum_width + mosaic_pics.eq(index).width() + 2 * border_and_padding; 1042 if (row_cum_width2 - divwidth < 0) { /* add the image to the row */ 1043 row_cum_width = row_cum_width2; 1044 row_of_img[index] = row_number; 1045 imgs_by_rows[row_number]++; 1046 } 1047 else { 1048 if (index !== mosaic_pics.length - 1) { /* if not last element */ 1049 if ((Math.abs(row_cum_width - divwidth) > Math.abs(row_cum_width2 - divwidth)) || !(!(Math.abs(row_cum_width - divwidth) <= Math.abs(row_cum_width2 - divwidth)) || !(imgs_by_rows[row_number] == 0))) { 1050 if (index !== mosaic_pics.length - 2) { /* add and shrink if not the second */ 1051 row_cum_width = row_cum_width2; 1052 row_of_img[index] = row_number; 1053 imgs_by_rows[row_number]++; 1054 row_number++; 1055 imgs_by_rows[row_number] = 0; 1056 row_cum_width = 0; 1057 } 1058 else { /* add second but NOT shrink and not change row */ 1059 row_cum_width = row_cum_width2; 1060 row_of_img[index] = row_number; 1061 imgs_by_rows[row_number]++; 1062 } 1063 } 1064 else { /* add to new row and stretch prev row (or shrink if even one pic is big) */ 1065 row_number++; 1066 imgs_by_rows[row_number] = 1; 1067 row_of_img[index] = row_number; 1068 row_cum_width = row_cum_width2 - row_cum_width; 1069 } 1070 } 1071 else { /* if the last element, add and shrink */ 1072 row_cum_width = row_cum_width2; 1073 row_of_img[index] = row_number; 1074 imgs_by_rows[row_number]++; 1075 } 1076 } 1077 }); 1078 /* create mosaics */ 1079 var stretch = []; 1080 /* stretch[row] factors */ 1081 var row_new_height = []; 1082 /* array to store height of every column */ 1083 for (var row = 0; row <= row_number; row++) { 1084 stretch[row] = 1; 1085 row_new_height[row] = row_height; 1086 } 1087 /* find stretch factors */ 1088 for (var row = 0; row <= row_number; row++) { 1089 row_cum_width = 0; 1090 mosaic_pics.each(function (index) { 1091 if (row_of_img[index] == row) { 1092 row_cum_width += mosaic_pics.eq(index).width(); 1093 } 1094 }); 1095 stretch[row] = x = (divwidth - imgs_by_rows[row] * 2 * border_and_padding) / row_cum_width; 1096 row_new_height[row] = (row_height - 2 * border_and_padding) * stretch[row] + 2 * border_and_padding; 1097 } 1098 /* stretch and shift to create mosaic horizontal */ 1099 var last_img_index = []; 1100 /* last image in row */ 1101 last_img_index[0] = 0; 1102 /* zero points */ 1103 var img_left = []; 1104 var row_top = []; 1105 img_left[0] = 0; 1106 row_top[0] = 0; 1107 for (var row = 1; row <= row_number; row++) { 1108 img_left[row] = img_left[0]; 1109 row_top[row] = row_top[row - 1] + row_new_height[row - 1]; 1110 } 1111 mosaic_pics.each(function (index) { 1112 var thumb_w = mosaic_pics.eq(index).width(); 1113 var thumb_h = mosaic_pics.eq(index).height(); 1114 mosaic_pics.eq(index).width(thumb_w * stretch[row_of_img[index]]); 1115 mosaic_pics.eq(index).height(thumb_h * stretch[row_of_img[index]]); 1116 mosaic_pics.eq(index).parent().css({ 1117 top: row_top[row_of_img[index]], 1118 left: img_left[row_of_img[index]] 1119 }); 1120 img_left[row_of_img[index]] += thumb_w * stretch[row_of_img[index]] + 2 * border_and_padding; 1121 last_img_index[row_of_img[index]] = index; 1122 }); 1123 jQuery("#" + block_id).height(row_top[row_number] + row_new_height[row_number] - row_top[0]); 1124 } 1125 else { 1126 var thumb_width = parseInt(container.attr('data-width')); 1127 /* Resizable mosaic.*/ 1128 if (container.attr('data-resizable') == '1') { 1129 if (jQuery(window).width() >= 1920) { 1130 var thumbnail_width = (1 + jQuery(window).width() / 1920) * thumb_width; 1131 } 1132 else if (jQuery(window).width() <= 640) { 1133 var thumbnail_width = jQuery(window).width() / 640 * thumb_width; 1134 } 1135 else { 1136 var thumbnail_width = thumb_width; 1137 } 1138 } 1139 else { 1140 var thumbnail_width = thumb_width; 1141 } 1142 /* Initialize.*/ 1143 var mosaic_pics = jQuery(".bwg_mosaic_thumb_" + bwg); 1144 mosaic_pics.each(function (index) {
1145 var thumb_w = mosaic_pics.get(index).naturalWidth; 1146 var thumb_h = mosaic_pics.get(index).naturalHeight; 1147 mosaic_pics.eq(index).height(thumb_h * thumbnail_width / thumb_w); 1148 mosaic_pics.eq(index).width(thumbnail_width); 1149 }); 1150 /* Resize.*/ 1151 var divwidth = jQuery("#bwg_mosaic_thumbnails_div_" + bwg).width() / 100 * parseInt(container.attr('data-total-width')); 1152 /* Set absolute width of mosaic.*/ 1153 jQuery('#' + block_id).width(divwidth); 1154 var col_width = thumbnail_width + 2 * border_and_padding < divwidth ? thumbnail_width : divwidth - 2 * border_and_padding; 1155 var col_number = Math.floor(divwidth / (col_width + 2 * border_and_padding)); 1156 var col_of_img = []; 1157 /*column of the current image*/ 1158 col_of_img[0] = 0; 1159 var imgs_by_cols = []; 1160 /*number of images in each column*/ 1161 /*zero points*/ 1162 var min_top = []; 1163 for (var x = 0; x < col_number; x++) { 1164 min_top[x] = 0; 1165 imgs_by_cols[x] = 0; 1166 } 1167 var img_wrap_left = 0; 1168 /*create masonry vertical*/ 1169 mosaic_pics.each(function (index) { 1170 var col = 0; 1171 var min = min_top[0]; 1172 for (var x = 0; x < col_number; x++) { 1173 if (min > min_top[x]) { 1174 min = min_top[x]; 1175 col = x; 1176 } 1177 } 1178 col_of_img[index] = col; 1179 /*store in which col is arranged*/ 1180 imgs_by_cols[col]++; 1181 img_container_top = min; 1182 img_container_left = img_wrap_left + col * (col_width + 2 * border_and_padding); 1183 mosaic_pics.eq(index).parent().css({top: img_container_top, left: img_container_left}); 1184 min_top[col] += mosaic_pics.eq(index).height() + 2 * border_and_padding; 1185 }); 1186 /*create mosaics*/ 1187 var stretch = []; 1188 stretch[0] = 1; 1189 var sum_col_width = 0; 1190 var sum_col_height = []; 1191 /*array to store height of every column*/ 1192 /*solve equations to calculate stretch[col] factors*/ 1193 var axbx = 0; 1194 var axpxbx = 0; 1195 for (var x = 0; x < col_number; x++) { 1196 sum_col_width += col_width; 1197 sum_col_height[x] = 0; 1198 mosaic_pics.each(function (index) { 1199 if (col_of_img[index] == x) { 1200 sum_col_height[x] += mosaic_pics.eq(index).height(); 1201 } 1202 }); 1203 if (sum_col_height[x] != 0) { 1204 axbx += col_width / sum_col_height[x]; 1205 axpxbx += col_width * imgs_by_cols[x] * 2 * border_and_padding / sum_col_height[x]; 1206 } 1207 } 1208 var common_height = 0; 1209 if (axbx != 0) { 1210 common_height = (sum_col_width + axpxbx) / axbx; 1211 } 1212 for (var x = 0; x < col_number; x++) { 1213 if (sum_col_height[x] != 0) { 1214 stretch[x] = (common_height - imgs_by_cols[x] * 2 * border_and_padding) / sum_col_height[x]; 1215 } 1216 } 1217 var img_container_left = []; 1218 /*position.left of every column*/ 1219 img_container_left[0] = img_wrap_left; 1220 for (var x = 1; x <= col_number; x++) { 1221 img_container_left[x] = img_container_left[x - 1] + col_width * stretch[x - 1] + 2 * border_and_padding; 1222 } 1223 /*reset min_top array to the position.top of #wrap container*/ 1224 var img_container_top = []; 1225 for (var x = 0; x < col_number; x++) { 1226 img_container_top[x] = 0; 1227 } 1228 /*stretch and shift to create mosaic verical*/ 1229 var last_img_index = []; 1230 /* last image in column*/ 1231 last_img_index[0] = 0; 1232 mosaic_pics.each(function (index) { 1233 var thumb_w = mosaic_pics.eq(index).width(); 1234 var thumb_h = mosaic_pics.eq(index).height(); 1235 mosaic_pics.eq(index).width(thumb_w * stretch[col_of_img[index]]); 1236 mosaic_pics.eq(index).height(thumb_h * stretch[col_of_img[index]]); 1237 mosaic_pics.eq(index).parent().css({ 1238 top: img_container_top[col_of_img[index]], 1239 left: img_container_left[col_of_img[index]] 1240 }); 1241 img_container_top[col_of_img[index]] += thumb_h * stretch[col_of_img[index]] + 2 * border_and_padding; 1242 last_img_index[col_of_img[index]] = index; 1243 }); 1244 jQuery("#" + block_id).width(img_container_left[col_number]).height(img_container_top[0]); 1245 } 1246 /*IMPORTANT!*/ 1247 jQuery(".bwg_mosaic_thumbnails_" + bwg).css({visibility: 'visible'}); 1248 jQuery(".tablenav-pages_" + bwg).css({visibility: 'visible'}); 1249 bwg_container_loaded(bwg); 1250 jQuery(".bwg_mosaic_thumb_"+bwg).removeClass("bwg-hidden"); 1251 jQuery("#bwg_mosaic_thumbnails_div_"+bwg).removeClass("bwg-hidden"); 1252 1253 bwg_mosaic_mosaic_play_icons(bwg, container, border_and_padding); 1254 if (container.attr('data-image-title') == 'hover') { 1255 bwg_mosaic_title_on_hover(bwg, container, border_and_padding) 1256 } 1257 if (container.attr('data-ecommerce-icon') == 'hover') { 1258 jQuery(".bwg_mosaic_thumb_spun_" + bwg).on("mouseenter", function() { 1259 var img_w = jQuery(this).parents(".bwg-mosaic-thumb-span").children(".bwg_mosaic_thumb_" + bwg).width(); 1260 var img_h = jQuery(this).parents(".bwg-mosaic-thumb-span").children(".bwg_mosaic_thumb_" + bwg).height(); 1261 jQuery(this).children(".bwg_ecommerce_spun1_" + bwg).width(img_w); 1262 var title_w = jQuery(this).children(".bwg_ecommerce_spun1_" + bwg).width(); 1263 var title_h = jQuery(this).children(".bwg_ecommerce_spun1_" + bwg).height(); 1264 jQuery(this).children(".bwg_ecommerce_spun1_" + bwg).css({ 1265 top: border_and_padding + 0.5 * img_h - 0.5 * title_h, 1266 left: border_and_padding + 0.5 * img_w - 0.5 * title_w, 1267 'opacity': 1, 1268 'filter': 'Alpha(opacity=100)' 1269 }); 1270 }); 1271 jQuery(".bwg_mosaic_thumb_spun_" + bwg).on("mouseleave", function() { 1272 jQuery(this).children(".bwg_ecommerce_spun1_" + bwg).css({ top: 0, left: -10000,'opacity': 0, 1273 'filter': 'Alpha(opacity=0)','padding': container.attr('data-title-margin')}); 1274 }); 1275 } 1276} 1277 1278function bwg_mosaic_title_on_hover(bwg, container, border_and_padding) { 1279 jQuery(".bwg-mosaic-thumb-span").on("mouseenter", function() { 1280 var img_w = jQuery(this).children(".bwg_mosaic_thumb_" + bwg).width(); 1281 var img_h = jQuery(this).children(".bwg_mosaic_thumb_" + bwg).height(); 1282 jQuery(this).find(".bwg_mosaic_title_spun1_" + bwg).width(img_w); 1283 var title_w = jQuery(this).find(".bwg_mosaic_title_spun1_" + bwg).width(); 1284 var title_h = jQuery(this).find(".bwg_mosaic_title_spun1_" + bwg).height(); 1285 jQuery(this).find(".bwg_mosaic_title_spun1_" + bwg).css({ 1286 top: ( (border_and_padding + 0.5 * img_h - 0.5 * title_h) < 0 ) ? border_and_padding : border_and_padding + 0.5 * img_h - 0.5 * title_h, 1287 left: border_and_padding + 0.5 * img_w - 0.5 * title_w, 1288 'opacity': 1, 1289 'filter': 'Alpha(opacity=100)', 1290 'max-height' : 'calc(100% - ' + 2 * border_and_padding + 'px)', 1291 'overflow' : 'hidden' 1292 }); 1293 }); 1294 jQuery(".bwg-mosaic-thumb-span").on("mouseleave", function() { 1295 jQuery(this).find(".bwg_mosaic_title_spun1_" + bwg).css({ 1296 top : 0, 1297 left : -10000, 1298 'opacity' : 0, 1299 'filter' : 'Alpha(opacity=0)', 1300 'padding' : container.attr('data-title-margin'), 1301 'max-height' : 'calc(100% - ' + 2 * border_and_padding + 'px)', 1302 'overflow' : 'hidden' 1303 }); 1304 }); 1305} 1306 1307function bwg_mosaic_mosaic_play_icons(bwg, container, border_and_padding) { 1308 if ( container.attr('data-play-icon') == '1' ) { 1309 jQuery(".bwg_mosaic_play_icon_spun_" + bwg).each(function() { 1310 var img_w = jQuery(this).parent().children(".bwg_mosaic_thumb_" + bwg).width(); 1311 var img_h = jQuery(this).parent().children(".bwg_mosaic_thumb_" + bwg).height(); 1312 jQuery(this).css({ 1313 top: border_and_padding + 0.5 * img_h -0.5 * jQuery(this).height(), 1314 left: border_and_padding + 0.5 * img_w - 0.5 * jQuery(this).width(), 1315 'opacity': 1, 1316 'filter': 'Alpha(opacity=100)' 1317 }); 1318 }); 1319 } 1320} 1321 1322function bwg_mosaic_ajax(bwg, tot_cccount_mosaic_ajax) { 1323 var cccount_mosaic_ajax = 0; 1324 jQuery(".bwg_mosaic_thumb_spun_" + bwg + " img").on("load", function() { 1325 if (++cccount_mosaic_ajax >= tot_cccount_mosaic_ajax) { 1326 bwg_thumbnail_mosaic(jQuery('.bwg-mosaic-thumbnails[data-bwg=' + bwg + ']')); 1327 } 1328 }); 1329 jQuery(".bwg_mosaic_thumb_spun_" + bwg + " img").on("error", function() { 1330 jQuery(this).height(100); 1331 jQuery(this).width(100); 1332 if (++cccount_mosaic_ajax >= tot_cccount_mosaic_ajax) { 1333 bwg_thumbnail_mosaic(jQuery('.bwg-mosaic-thumbnails[data-bwg=' + bwg + ']')); 1334 } 1335 }); 1336} 1337 1338function bwg_add_album() { 1339 var bwg_touch_flag = false;
1340 jQuery( ".bwg-album" ).off("click").on("click", function () { 1341 if ( !bwg_touch_flag ) { 1342 var bwg = jQuery(this).attr("data-bwg"); 1343 bwg_touch_flag = true; 1344 setTimeout(function () { 1345 bwg_touch_flag = false; 1346 }, 100); 1347 bwg_ajax('gal_front_form_' + bwg, bwg, jQuery(this).attr("data-container_id"), jQuery(this).attr("data-alb_gal_id"), jQuery(this).attr("data-album_gallery_id"), jQuery(this).attr("data-def_type"), '', jQuery(this).attr("data-title")); 1348 return false; 1349 } 1350 }); 1351 1352 /* Add description more button event.*/ 1353 jQuery( ".bwg_description_more" ).on("click", function () { 1354 if ( jQuery(this).hasClass("bwg_more") ) { 1355 jQuery(this).parent().find(".bwg_description_full").show(); 1356 jQuery(this).addClass("bwg_hide").removeClass("bwg_more"); 1357 jQuery(this).html(jQuery(this).data("hide-msg")); 1358 } 1359 else { 1360 jQuery(this).parent().find(".bwg_description_full").hide(); 1361 jQuery(this).addClass("bwg_more").removeClass("bwg_hide"); 1362 jQuery(this).html(jQuery(this).data("more-msg")); 1363 } 1364 }); 1365} 1366 1367function bwg_add_lightbox() { 1368 var bwg_touch_flag = false; 1369 jQuery( ".bwg_lightbox .bwg-item0, .bwg_lightbox .bwg_slide, .bwg_lightbox .bwg-carousel-image" ).on("click", function ( event ) { 1370 event.stopPropagation(); 1371 event.preventDefault(); 1372 var that = jQuery(this).parent(); 1373 if ( !bwg_touch_flag ) { 1374 bwg_touch_flag = true; 1375 setTimeout( function () { 1376 bwg_touch_flag = false; 1377 }, 100 ); 1378 bwg_gallery_box( jQuery( that ).attr( "data-image-id" ), jQuery( that ).closest( '.bwg_container' ) ); 1379 return false; 1380 } 1381 }); 1382 1383 jQuery( ".bwg_lightbox .bwg_ecommerce" ).on("click", function ( event ) { 1384 event.stopPropagation(); 1385 if ( !bwg_touch_flag ) { 1386 bwg_touch_flag = true; 1387 setTimeout( function () { 1388 bwg_touch_flag = false; 1389 }, 100 ); 1390 var image_id = jQuery( this ).closest( ".bwg_lightbox" ).attr( "data-image-id" ); 1391 bwg_gallery_box( image_id, jQuery( this ).closest( '.bwg_container' ), true ); 1392 return false; 1393 } 1394 }); 1395} 1396 1397function bwg_document_ready() { 1398 bwg_add_lightbox(); 1399 jQuery( 'div[id^="bwg_container"]' ).each( function () { 1400 var bwg_container = jQuery( this ); 1401 if ( bwg_container.data( 'right-click-protection' ) ) { 1402 bwg_disable_right_click( bwg_container ); 1403 } 1404 1405 /* Add dashicon to select container */ 1406 jQuery(".SumoSelect > .CaptionCont > label > i").addClass("fa fa-angle-down closed"); 1407 1408 var search_tags = bwg_container.find('.search_tags'); 1409 if (search_tags.length) { 1410 search_tags.SumoSelect({ 1411 triggerChangeCombined:true, 1412 placeholder: bwg_objectsL10n.bwg_select_tag, 1413 search: 1, 1414 searchText : bwg_objectsL10n.bwg_search, 1415 forceCustomRendering: true, 1416 noMatch: bwg_objectsL10n.bwg_tag_no_match, 1417 captionFormatAllSelected : bwg_objectsL10n.bwg_all_tags_selected, 1418 captionFormat: '{0} '+ bwg_objectsL10n. bwg_tags_selected, 1419 } ); 1420 } 1421
1422 var bwg_order = bwg_container.find('.bwg_order'); 1423 if (bwg_order.length) { 1424 bwg_order.SumoSelect({ 1425 triggerChangeCombined:true, 1426 forceCustomRendering: true, 1427 } ); 1428 } 1429 1430 /* Show/Hide search_placeholder_title class container */ 1431 if (jQuery(this).find('.bwg_search_input').val() == '') { 1432 jQuery(this).find('search_placeholder_title').show(); 1433 } 1434 else { 1435 jQuery(this).find('search_placeholder_title').hide(); 1436 } 1437 1438 /* Show search_placeholder_title class container on focusout and hide reset, search icons*/ 1439 jQuery(".bwg_thumbnail .bwg_search_container_2").focusout(function (e) { 1440 if (jQuery(this).find('.bwg_search_input').val() == '') { 1441 jQuery(this).find('.search_placeholder_title').show(); 1442 jQuery(this).find('.bwg_search_loupe_container1').addClass("hidden"); 1443 jQuery(this).find('.bwg_search_reset_container').addClass("hidden"); 1444 } 1445 }); 1446 }); 1447 1448 var currentTags; 1449 1450 /* Show No tags text if tags empty */ 1451 jQuery('.search_tags').on('sumo:opened',function(event){ 1452 currentTags = jQuery(this).parent().find('.CaptionCont').attr('title'); 1453 if( jQuery(this).parent().find('ul li').length == 0 ) { 1454 jQuery(".no-match").html(bwg_objectsL10n.bwg_tag_no_match); 1455 jQuery(".no-match").show(); 1456 } 1457 }); 1458 1459 /* Run function of tag filters if select box closed and there are difference between new/old selection */ 1460 jQuery('.bwg_thumbnail .search_tags').on('sumo:closed',function(event){ 1461 var newTags = ''; 1462 var curCont = jQuery(this).parent().parent(); 1463 var current_view = curCont.find('.current_view').val(); 1464 var form_id = curCont.find('.form_id').val(); 1465 var cur_gal_id = curCont.find('.cur_gal_id').val(); 1466 var album_gallery_id = curCont.find('.album_gallery_id').val(); 1467 var type = curCont.find('.type').val(); 1468 1469 jQuery(this).parent().find('.opt.selected').each( function () { 1470 newTags = newTags + jQuery(this).text() + ','; 1471 }); 1472 newTags = newTags.slice(0, -1); 1473 if ( newTags == '' ) { 1474 newTags = bwg_objectsL10n.bwg_select_tag; 1475 } 1476 jQuery(this).parent().find('.CaptionCont').attr('title',newTags); 1477 jQuery(this).parent().find('.CaptionCont .placeholder').html(newTags); 1478 /* Run function if selected */ 1479 if ( currentTags != newTags ) { 1480 jQuery('#bwg_tag_id_' + current_view).val(jQuery('#bwg_tag_id_' + cur_gal_id).val()); 1481 bwg_select_tag(current_view, form_id, cur_gal_id, album_gallery_id, type, false); 1482 } 1483 }); 1484 1485 /* Change dashicon from up arrow to down arrow when select box is close */ 1486 jQuery('.bwg_thumbnail .SumoSelect').on('sumo:closed', function(){ 1487 jQuery(this).find('label i').removeClass('opened fa fa-angle-up'); 1488 jQuery(this).find('label i').addClass("fa fa-angle-down closed"); 1489 }); 1490 1491 /* Change dashicon from down arrow to up arrow when select box is open */ 1492 jQuery('.bwg_thumbnail .SumoSelect').on('sumo:opened', function() { 1493 jQuery(this).find('label i').removeClass('closed fa fa-angle-down'); 1494 jQuery(this).find('label i').addClass("fa fa-angle-up opened"); 1495 }); 1496 1497 bwg_add_album(); 1498 1499 var bwg_hash = window.location.hash.substring( 1 ); 1500 if ( bwg_hash ) { 1501 if ( bwg_hash.indexOf( "bwg" ) != "-1" ) { 1502 bwg_hash_array = bwg_hash.replace( "bwg", "" ).split( "/" );
1503 var bwg_container = jQuery( '.bwg_container' ); 1504 1505 if ( bwg_container ) { 1506 bwg_gallery_box( bwg_hash_array[1], bwg_container, false, bwg_hash_array[0] ); 1507 } 1508 } 1509 } 1510 1511 bwg_blog_style_ready(); 1512 bwg_image_browser_ready(); 1513 bwg_resize_search_line(); 1514} 1515 1516function bwg_clear_search_input (current_view) { 1517 jQuery("#bwg_search_input_" + current_view).val(''); 1518 jQuery("#bwg_search_container_1_" + current_view + " .bwg_search_loupe_container1").addClass("hidden"); 1519 jQuery("#bwg_search_container_1_" + current_view + " .bwg_search_reset_container").addClass("hidden"); 1520} 1521 1522function bwg_check_search_input_enter(that, e) { 1523 var key_code = e.which || e.keyCode; 1524 if (key_code == 13) { 1525 jQuery(that).closest('.bwg_search_container_1').find('.bwg_search').trigger('click'); 1526 return false; 1527 } 1528 return true; 1529} 1530 1531/* Ajax call for filters and pagination.*/ 1532function bwg_ajax(form_id, current_view, id, album_gallery_id, cur_album_id, type, srch_btn, title, sortByParam, load_more, description) { 1533 /* Show loading.*/ 1534 jQuery("#ajax_loading_" + current_view).removeClass('bwg-hidden'); 1535 1536 /* Disable scroll to prevent bugs with load more.*/ 1537 if (typeof bwg_scroll_load_action === "function") { 1538 jQuery(window).off("scroll", bwg_scroll_load_action); 1539 } 1540 1541 /* To prevent bugs with filters.*/ 1542 jQuery(".bwg_thumbnail .search_tags").off("sumo:closed"); 1543 1544 var ajax_url = jQuery('#' + form_id).data("ajax-url"); 1545 1546 var masonry_loaded = 0; 1547 var mosaic_loaded = 0; 1548 if (typeof load_more == "undefined") { 1549 var load_more = false; 1550 } 1551 var page_number = jQuery("#page_number_" + current_view).val(); 1552 1553 var post_data = {}; 1554 1555 var breadcrumb_str = jQuery('#bwg_album_breadcrumb_' + current_view).val(); 1556 if ( breadcrumb_str && load_more !== true ) { /* For album views.*/ 1557 var breadcrumb = JSON.parse(breadcrumb_str); 1558 if (album_gallery_id == 'back') { 1559 /* Remove last element of array.*/ 1560 breadcrumb.splice(-1, 1); 1561 var last_el = breadcrumb.slice(-1)[0]; 1562 album_gallery_id = last_el["id"]; 1563 page_number = last_el["page"]; 1564 post_data["action_" + current_view] = 'back'; 1565 } 1566 else if ( load_more === 'numeric' || srch_btn ) {/* From numeric pagination.*/ 1567 breadcrumb.splice(-1, 1); 1568 breadcrumb.push({id: album_gallery_id, page: page_number}); 1569 } 1570 else { 1571 breadcrumb.push({id: album_gallery_id, page: 1}); 1572 page_number = 1; 1573 } 1574 post_data["bwg_album_breadcrumb_" + current_view] = JSON.stringify(breadcrumb); 1575 } 1576 1577 /** Set values for elementor widget.*/ 1578 post_data['gallery_type'] = jQuery('#' + form_id).data("gallery-type"); 1579 post_data['gallery_id'] = jQuery('#' + form_id).data("gallery-id"); 1580 post_data['tag'] = jQuery('#' + form_id).data("tag"); 1581 post_data['album_id'] = jQuery('#' + form_id).data("album-id"); 1582 post_data['theme_id'] = jQuery('#' + form_id).data("theme-id"); 1583 1584 post_data['shortcode_id'] = jQuery('#' + form_id).data("shortcode-id"); 1585 post_data['bwg'] = current_view; 1586 1587 if ( srch_btn ) { /* Start search. */ 1588 page_number = 1; 1589 } 1590 if (typeof title == "undefined" || title == '') { 1591 var title = ""; 1592 } 1593 if (typeof description == "undefined" || description == '') { 1594 var description = ""; 1595 } 1596 if (typeof sortByParam == "undefined" || sortByParam == '') { 1597 var sortByParam = jQuery(".bwg_order_" + current_view).val(); 1598 } 1599 1600 post_data["page_number_" + current_view] = page_number; 1601 post_data["bwg_load_more_" + current_view] = jQuery("#bwg_load_more_" + current_view).val(); 1602 post_data["album_gallery_id_" + current_view] = album_gallery_id; 1603 post_data["type_" + current_view] = type; 1604 post_data["title_" + current_view] = title; 1605 post_data["description_" + current_view] = description; 1606 post_data["sortImagesByValue_" + current_view] = sortByParam; 1607 if (jQuery("#bwg_search_input_" + current_view).length > 0) { /* Search box exists.*/ 1608 post_data["bwg_search_" + current_view] = jQuery("#bwg_search_input_" + current_view).val(); 1609 } 1610 post_data["bwg_tag_id_" + id] = jQuery("#bwg_tag_id_" + id).val(); 1611 /* Loading.*/ 1612 jQuery('#gal_front_form_' + current_view).addClass('bwg-hidden'); 1613 jQuery("#ajax_loading_" + current_view).removeClass('bwg-hidden'); 1614 1615 jQuery.ajax({ 1616 type: "POST", 1617 url: ajax_url, 1618 data: post_data, 1619 success: function (data) { 1620 masonry_loaded = jQuery(data).find(".bwg_masonry_thumb_spun_" + current_view + " img").length; 1621 mosaic_loaded = jQuery(data).find(".bwg_mosaic_thumb_spun_" + current_view + " img").length; 1622 1623 if ( load_more === true ) { 1624 /* Add next page images after current ones instead of change all container.*/ 1625 if ( id == "bwg_thumbnails_mosaic_" + current_view ) { 1626 /* ToDo: Remove after changing mosaic view.*/ 1627 jQuery('#' + id).append(jQuery(data).closest(".bwg-container-" + current_view).find("#" + id).html()); 1628 } 1629 else if ( id == "bwg_album_compact_" + current_view ) { 1630 jQuery('#' + id).append(jQuery(data).closest(".bwg-album-thumbnails").html()); 1631 } 1632 else { 1633 jQuery('#' + id).append(jQuery(data).closest(".bwg-container-" + current_view).html()); 1634 } 1635 /* Change load more button container withe new one.*/ 1636 jQuery('.bwg_nav_cont_' + current_view).html(jQuery(data).closest('.bwg_nav_cont_' + current_view).html()); 1637 } 1638 else { 1639 /* Change all container with new data.*/ 1640 jQuery('#bwg_container3_' + current_view).html(data); 1641 } 1642 }, 1643 complete: function() { 1644 /* To prevent conflict with lazy load.*/ 1645 jQuery("div[id^='bwg_container1_'] img").each(function () { 1646 if (jQuery(this).attr("data-lazy-src") != undefined && jQuery(this).attr("data-lazy-src") != '') { 1647 jQuery(this).attr("src", jQuery(this).attr("data-lazy-src")); 1648 } 1649 else if (jQuery(this).attr("data-src") != undefined && jQuery(this).attr("data-src") != '') { 1650 jQuery(this).attr("src", jQuery(this).attr("data-src")); 1651 } 1652 }); 1653 jQuery(".blog_style_image_buttons_conteiner_" + current_view).find(jQuery(".bwg_blog_style_img_" + current_view)).on("load", function() { 1654 jQuery(".bwg_blog_style_img_" + current_view).closest(jQuery(".blog_style_image_buttons_conteiner_" + current_view)).show(); 1655 }); 1656 jQuery("#bwg_tags_id_" + id).val(jQuery("#bwg_tag_id_" + id).val()); 1657 1658 if ( jQuery(".pagination-links_" + current_view).length ) { 1659 jQuery("html, body").animate({scrollTop: jQuery('#' + form_id).offset().top - 150}, 500); 1660 } 1661 /* For all views. */ 1662 bwg_document_ready(); 1663 bwg_mosaic_ajax(current_view, mosaic_loaded); 1664 var no_data = bwg_all_thumnails_loaded(".bwg-container-" + current_view); 1665 if ( no_data ) {
1666 /* If there where no data after after ajax request.*/ 1667 bwg_container_loaded(current_view); 1668 } 1669 /* For Blog style view.*/ 1670 jQuery(".blog_style_images_conteiner_" + current_view + " .bwg_embed_frame_16x9_" + current_view).each(function (e) { 1671 jQuery(this).width(jQuery(this).parent().width()); 1672 jQuery(this).height(jQuery(this).width() * 0.5625); 1673 }); 1674 jQuery(".blog_style_images_conteiner_" + current_view + " .bwg_embed_frame_instapost_" + current_view).each(function (e) { 1675 jQuery(this).width(jQuery(this).parent().width()); 1676 /* 16 is 2*padding inside iframe */ 1677 /* 96 is 2*padding(top) + 1*padding(bottom) + 40(footer) + 32(header) */ 1678 jQuery(this).height((jQuery(this).width() - 16) * jQuery(this).attr('data-height') / jQuery(this).attr('data-width') + 96); 1679 }); 1680 /* For Image browser view.*/ 1681 jQuery('#bwg_embed_frame_16x9_' + current_view).width(jQuery('#bwg_embed_frame_16x9_' + current_view).parent().width()); 1682 jQuery('#bwg_embed_frame_16x9_' + current_view).height(jQuery('#bwg_embed_frame_16x9_' + current_view).width() * 0.5625); 1683 jQuery('#bwg_embed_frame_instapost_' + current_view).width(jQuery('#bwg_embed_frame_16x9_' + current_view).parent().width()); 1684 /* 16 is 2*padding inside iframe */ 1685 /* 96 is 2*padding(top) + 1*padding(bottom) + 40(footer) + 32(header) */ 1686 jQuery('.bwg_embed_frame_instapost_' + current_view).height((jQuery('.bwg_embed_frame_instapost_' + current_view).width() - 16) * jQuery('.bwg_embed_frame_instapost_' + current_view).attr('data-height') / jQuery('.bwg_embed_frame_instapost_' + current_view).attr('data-width') + 96); 1687 1688 /* return value to search input field */ 1689 jQuery("#bwg_search_input_" + current_view).val(post_data["bwg_search_" + current_view]); 1690 1691 if ( jQuery("#bwg_search_input_" + current_view).val() != '' ) { 1692 jQuery("#bwg_search_input_" + current_view).parent().find('.search_placeholder_title').hide(); 1693 jQuery("#bwg_search_input_" + current_view).parent().parent().find('.bwg_search_reset_container').show(); 1694 jQuery("#bwg_search_input_" + current_view).parent().parent().find('.bwg_search_loupe_container1').show(); 1695 } else { 1696 jQuery("#bwg_search_input_" + current_view).parent().find('.search_placeholder_title').show(); 1697 } 1698 var cur_gal_id = jQuery("#bwg_container2_"+current_view+" .cur_gal_id").val(); 1699 jQuery('#bwg_tag_id_' + current_view).val(jQuery('#bwg_tag_id_'+cur_gal_id).val()); 1700 } 1701 }); 1702 1703 return false; 1704} 1705 1706function bwg_select_tag(current_view, form_id, cur_gal_id, album_gallery_id, type, reset) { 1707 if ( reset ) { 1708 jQuery("#bwg_tag_id_" + cur_gal_id).val(''); 1709 } 1710 1711 bwg_ajax(form_id, current_view, cur_gal_id, album_gallery_id, '', type, 1, ''); 1712} 1713 1714function bwg_preload_images_lightbox( key ) { 1715 var count_all = data.length; 1716 var preloadCount = ( bwg_param['preload_images_count'] == 0 || bwg_param['preload_images_count'] >= count_all ) ? count_all : bwg_param['preload_images_count']; 1717 var indexedImgCount = 0; 1718 for ( var i = 1; indexedImgCount < preloadCount; i++ ) { 1719 var sign = 1; 1720 do { 1721 var index = ( key + i * sign + count_all ) % count_all; 1722 if ( typeof data[index] != "undefined" ) { 1723 var is_embed = data[index]['filetype'].indexOf( "EMBED_" ) > -1 ? true : false; 1724 if ( !is_embed ) { 1725 jQuery( "<img/>" ).attr( "src", bwg_param['site_url'] + jQuery( '<span style="display: block;" />' ).html( data[index]["image_url"] ).text() ); 1726 } 1727 } 1728 sign *= -1; 1729 indexedImgCount++; 1730 } 1731 while ( sign != 1 ); 1732 } 1733} 1734 1735function bwg_cube(tz, ntx, nty, nrx, nry, wrx, wry, current_image_class, next_image_class, direction, bwg) { 1736 var type_slideshow = false; 1737 var bwg_prefix = ""; 1738 var bwg_transition_dur; 1739 if ( typeof bwg != 'undefined' ) { 1740 type_slideshow = true; 1741 bwg_params[bwg]['bwg_trans_in_progress'] = true; 1742 bwg_prefix = "_"+bwg; 1743 bwg_transition_dur = bwg_params[bwg]['bwg_transition_duration']; 1744 var event_stack = bwg_params[bwg]['event_stack'] 1745 } else { 1746 bwg_transition_dur = bwg_transition_duration; 1747 } 1748 /* If browser does not support 3d transforms/CSS transitions.*/ 1749 if (!bwg_testBrowser_cssTransitions( bwg )) { 1750 return bwg_fallback(current_image_class, next_image_class, direction, bwg); 1751 } 1752 if (!bwg_testBrowser_cssTransforms3d( bwg )) { 1753 return bwg_fallback3d(current_image_class, next_image_class, direction, bwg); 1754 } 1755 if( !type_slideshow) { /* from lightbox */ 1756 bwg_param['bwg_trans_in_progress'] = true; 1757 /* Set active thumbnail.*/ 1758 jQuery(".bwg_filmstrip_thumbnail").removeClass("bwg_thumb_active").addClass("bwg_thumb_deactive"); 1759 jQuery("#bwg_filmstrip_thumbnail_" + bwg_param['bwg_current_key']).removeClass("bwg_thumb_deactive").addClass("bwg_thumb_active"); 1760 jQuery(".bwg_slide_bg").css('perspective', 1000); 1761 } else { /* from slideshow */ 1762 /* Set active thumbnail.*/ 1763 jQuery(".bwg_slideshow_filmstrip_thumbnail_"+bwg).removeClass("bwg_slideshow_thumb_active_"+bwg).addClass("bwg_slideshow_thumb_deactive_"+bwg); 1764 jQuery("#bwg_filmstrip_thumbnail_" + bwg_params[bwg]['bwg_current_key']+ "_"+bwg).removeClass("bwg_slideshow_thumb_deactive_"+bwg).addClass("bwg_slideshow_thumb_active_"+bwg); 1765 jQuery(".bwg_slideshow_dots_"+bwg).removeClass("bwg_slideshow_dots_active_"+bwg).addClass("bwg_slideshow_dots_deactive_"+bwg); 1766 jQuery("#bwg_dots_" + bwg_params[bwg]['bwg_current_key'] + "_" + bwg).removeClass("bwg_slideshow_dots_deactive_"+bwg).addClass("bwg_slideshow_dots_active_"+bwg); 1767 jQuery(".bwg_slide_bg_"+bwg).css('perspective', 1000); 1768 } 1769 jQuery(current_image_class).css({ 1770 transform : 'translateZ(' + tz + 'px)', 1771 backfaceVisibility : 'hidden' 1772 }); 1773 jQuery(next_image_class).css({ 1774 opacity : 1, 1775 filter: 'Alpha(opacity=100)', 1776 backfaceVisibility : 'hidden', 1777 transform : 'translateY(' + nty + 'px) translateX(' + ntx + 'px) rotateY('+ nry +'deg) rotateX('+ nrx +'deg)' 1778 }); 1779 jQuery(".bwg_slider"+bwg_prefix).css({ 1780 transform: 'translateZ(-' + tz + 'px)', 1781 transformStyle: 'preserve-3d' 1782 }); 1783 /* Execution steps.*/ 1784 setTimeout(function () { 1785 jQuery(".bwg_slider"+bwg_prefix).css({ 1786 transition: 'all ' + bwg_transition_dur + 'ms ease-in-out', 1787 transform: 'translateZ(-' + tz + 'px) rotateX('+ wrx +'deg) rotateY('+ wry +'deg)' 1788 }); 1789 }, 20); 1790 /* After transition.*/ 1791 jQuery(".bwg_slider"+bwg_prefix).one('webkitTransitionEnd transitionend otransitionend oTransitionEnd mstransitionend', jQuery.proxy(bwg_after_trans)); 1792 function bwg_after_trans() { 1793 jQuery(current_image_class).removeAttr('style'); 1794 jQuery(next_image_class).removeAttr('style'); 1795 jQuery(".bwg_slider"+bwg_prefix).removeAttr('style'); 1796 jQuery(current_image_class).css({'opacity' : 0, filter: 'Alpha(opacity=0)', 'z-index': 1}); 1797 jQuery(next_image_class).css({'opacity' : 1, filter: 'Alpha(opacity=100)', 'z-index' : 2}); 1798 jQuery(".bwg_image_info").show(); 1799 1800 jQuery(current_image_class).html(''); 1801 1802 if ( type_slideshow ) { /*check if cube works from slideshow*/ 1803 bwg_change_watermark_container( bwg ); 1804 bwg_params[bwg]['bwg_trans_in_progress'] = false;
1805 var data = bwg_params[bwg]['data']; 1806 var event_stack = bwg_params[bwg]['event_stack']; 1807 } else { 1808 bwg_param['bwg_trans_in_progress'] = false; 1809 var event_stack = bwg_param['event_stack']; 1810 } 1811 if (typeof event_stack !== 'undefined') { 1812 if (event_stack.length > 0) { 1813 key = event_stack[0].split("-"); 1814 event_stack.shift(); 1815 bwg_change_image(key[0], key[1], data, true, bwg); 1816 } 1817 } 1818 bwg_change_watermark_container(); 1819 } 1820 if (bwg_transition_dur == 0) { 1821 bwg_after_trans(); 1822 } 1823} 1824 1825function bwg_fade(current_image_class, next_image_class, direction, bwg) { 1826 var type_slideshow = false; 1827 var bwg_transition_dur; 1828 if( typeof bwg != 'undefined' ) { 1829 type_slideshow = true; 1830 bwg_params[bwg]['bwg_trans_in_progress'] = true; 1831 bwg_transition_dur = bwg_params[bwg]['bwg_transition_duration']; 1832 } else { 1833 bwg_param['bwg_trans_in_progress'] = true; 1834 bwg_transition_dur = bwg_param['bwg_transition_duration']; 1835 } 1836 1837 if(type_slideshow) { 1838 /* Set active thumbnail.*/ 1839 jQuery(".bwg_slideshow_filmstrip_thumbnail_"+bwg).removeClass("bwg_slideshow_thumb_active_"+bwg).addClass("bwg_slideshow_thumb_deactive_"+bwg); 1840 jQuery("#bwg_filmstrip_thumbnail_" + bwg_params[bwg]['bwg_current_key'] + "_"+bwg).removeClass("bwg_slideshow_thumb_deactive_"+bwg).addClass("bwg_slideshow_thumb_active_"+bwg); 1841 jQuery(".bwg_slideshow_dots_"+bwg).removeClass("bwg_slideshow_dots_active_"+bwg).addClass("bwg_slideshow_dots_deactive_"+bwg); 1842 jQuery("#bwg_dots_" + bwg_params[bwg]['bwg_current_key'] + "_"+bwg).removeClass("bwg_slideshow_dots_deactive_"+bwg).addClass("bwg_slideshow_dots_active_"+bwg); 1843 } else { 1844 /* Set active thumbnail.*/ 1845 jQuery(".bwg_filmstrip_thumbnail").removeClass("bwg_thumb_active").addClass("bwg_thumb_deactive"); 1846 jQuery("#bwg_filmstrip_thumbnail_" + bwg_param['bwg_current_key']).removeClass("bwg_thumb_deactive").addClass("bwg_thumb_active"); 1847 } 1848 function bwg_after_trans() { 1849 jQuery(".bwg_image_info").show(); 1850 bwg_change_watermark_container( bwg ); 1851 if( type_slideshow ) { 1852 bwg_params[bwg]['bwg_trans_in_progress'] = false; 1853 } else { 1854 bwg_param['bwg_trans_in_progress'] = false; 1855 } 1856 } 1857 if (bwg_testBrowser_cssTransitions()) { 1858 jQuery(next_image_class).css('transition', 'opacity ' + bwg_transition_dur + 'ms linear'); 1859 jQuery(current_image_class).css({'opacity' : 0, 'z-index': 1}); 1860 jQuery(next_image_class).css({'opacity' : 1, 'z-index' : 2}); 1861 jQuery(next_image_class).one('webkitTransitionEnd transitionend otransitionend oTransitionEnd mstransitionend', jQuery.proxy(bwg_after_trans)); 1862 } 1863 else { 1864 jQuery(current_image_class).animate({'opacity' : 0, 'z-index' : 1}, bwg_transition_dur); 1865 jQuery(next_image_class).animate({ 1866 'opacity' : 1, 1867 'z-index': 2 1868 }, { 1869 duration: bwg_transition_dur, 1870 complete: function () { 1871 if( type_slideshow ) { 1872 bwg_params[bwg]['bwg_trans_in_progress'] = false; 1873 } else { 1874 bwg_param['bwg_trans_in_progress'] = false; 1875 } 1876 jQuery(current_image_class).html(''); 1877 bwg_after_trans() 1878 } 1879 }); 1880 /* For IE.*/ 1881 jQuery(current_image_class).fadeTo(bwg_transition_dur, 0); 1882 jQuery(next_image_class).fadeTo(bwg_transition_dur, 1); 1883 } 1884 if (bwg_transition_dur == 0) { 1885 bwg_after_trans(); 1886 } 1887} 1888 1889/* Set watermark container size.*/ 1890function bwg_change_watermark_container( bwg ) { 1891 var defix = ( typeof bwg != 'undefined' ) ? '_'+bwg : ''; 1892 jQuery(".bwg_slider"+defix).children().each(function() { 1893 if (jQuery(this).css("zIndex") == 2) { 1894 /* For images.*/ 1895 var bwg_current_image_span = jQuery(this).find("img"); 1896 if (bwg_current_image_span.length) { 1897 if (bwg_current_image_span.prop('complete')) { 1898 var width = bwg_current_image_span.width(); 1899 var height = bwg_current_image_span.height(); 1900 bwg_change_each_watermark_container(width, height, bwg); 1901 } 1902 else { 1903 bwg_current_image_span.on("load", function () { 1904 var width = bwg_current_image_span.width(); 1905 var height = bwg_current_image_span.height(); 1906 bwg_change_each_watermark_container(width, height, bwg); 1907 }); 1908 } 1909 } 1910 else { 1911 /* For embeds and videos.*/ 1912 bwg_current_image_span = jQuery(this).find("iframe"); 1913 if (!bwg_current_image_span.length) { 1914 bwg_current_image_span = jQuery(this).find("video"); 1915 } 1916 var width = bwg_current_image_span.width(); 1917 var height = bwg_current_image_span.height(); 1918 bwg_change_each_watermark_container(width, height, bwg); 1919 } 1920 } 1921 }); 1922} 1923 1924/* Set each watermark container size.*/ 1925function bwg_change_each_watermark_container(width, height, bwg) { 1926 1927 var defix = ( typeof bwg != 'undefined' ) ? '_'+bwg : ''; 1928 var source = ( typeof bwg != 'undefined' ) ? '_slideshow' : ''; 1929 1930 jQuery(".bwg"+source+"_watermark_spun" + defix).width(width); 1931 jQuery(".bwg"+source+"_watermark_spun" + defix).height(height); 1932 jQuery(".bwg"+source+"_watermark" + defix).css({display: ''}); 1933 1934 if( typeof bwg == 'undefined' ) { 1935 /* Set watermark image size.*/ 1936 var comment_container_width = 0; 1937 if (jQuery(".bwg_comment_container").hasClass("bwg_open") || jQuery(".bwg_ecommerce_container").hasClass("bwg_open")) { 1938 comment_container_width = bwg_param['lightbox_comment_width']; 1939 } 1940 if (width <= (jQuery(window).width() - comment_container_width)) { 1941 jQuery(".bwg_watermark_image").css({ 1942 width: ((jQuery(".spider_popup_wrap").width() - comment_container_width) * bwg_param['watermark_font_size'] / bwg_param['image_width']) 1943 }); 1944 jQuery(".bwg_watermark_text, .bwg_watermark_text:hover").css({ 1945 fontSize: ((jQuery(".spider_popup_wrap").width() - comment_container_width) * bwg_param['watermark_font_size'] / bwg_param['image_width']) 1946 }); 1947 } 1948 } else { 1949 jQuery(".bwg" + source + "_title_spun" + defix).width(width); 1950 jQuery(".bwg" + source + "_title_spun" + defix).height(height); 1951 jQuery(".bwg" + source + "_description_spun" + defix).width(width); 1952 jQuery(".bwg" + source + "_description_spun" + defix).height(height); 1953 } 1954 if (jQuery.trim(jQuery(".bwg"+source+"_title_text" + defix).text())) { 1955 jQuery(".bwg_slideshow_title_text" + defix).css({display: ''}); 1956 } 1957 if (jQuery.trim(jQuery(".bwg"+source+"_description_text" + defix).text())) { 1958 jQuery(".bwg"+source+"_description_text" + defix).css({display: ''}); 1959 } 1960 1961} 1962 1963/* Set filmstrip initial position.*/ 1964function bwg_set_filmstrip_pos( filmStripWidth, bwg ) { 1965 var defix = ( typeof bwg != 'undefined' ) ? '_'+bwg : ''; 1966 var source = ( typeof bwg != 'undefined' ) ? '_slideshow' : ''; 1967 var left_or_top = ( typeof bwg != 'undefined' ) ? bwg_params[bwg]['left_or_top'] : bwg_param['left_or_top'];
1968 var top_bottom_space = parseInt(jQuery(".bwg_filmstrip_thumbnails").attr('data-all-images-top-bottom-space')); 1969 var right_left_space = parseInt(jQuery(".bwg_filmstrip_thumbnails").attr('data-all-images-right-left-space')); 1970 if( typeof bwg == 'undefined' ) { /* for lightbox */ 1971 if ( bwg_param['outerWidth_or_outerHeight'] == 'outerWidth' ) { 1972 var selectedImagePos = -bwg_current_filmstrip_pos - (jQuery(".bwg_filmstrip_thumbnail").outerWidth(true)) / 2; 1973 } else if ( bwg_param['outerWidth_or_outerHeight'] == 'outerHeight' ) { 1974 var selectedImagePos = -bwg_current_filmstrip_pos - (jQuery(".bwg_filmstrip_thumbnail").outerHeight(true)) / 2; 1975 } 1976 if ( bwg_param['width_or_height'] == 'width' ) { 1977 var imagesContainerLeft = Math.min(0, Math.max(filmStripWidth - jQuery(".bwg_filmstrip_thumbnails").width(), selectedImagePos + filmStripWidth / 2)); 1978 } else if (bwg_param['width_or_height'] == 'height') { 1979 var imagesContainerLeft = Math.min(0, Math.max(filmStripWidth - jQuery(".bwg_filmstrip_thumbnails").height(), selectedImagePos + filmStripWidth / 2)); 1980 } 1981 } else { /* for slideshow */ 1982 if (bwg_params[bwg]['width_or_height'] == 'width') { 1983 var selectedImagePos = -bwg_params[bwg]['bwg_current_filmstrip_pos'] - (jQuery(".bwg_slideshow_filmstrip_thumbnail" + defix).width() + bwg_params[bwg]['filmstrip_thumb_margin_hor']) / 2; 1984 var imagesContainerLeft = Math.min(0, Math.max(filmStripWidth - jQuery(".bwg_slideshow_filmstrip_thumbnails" + defix).width(), selectedImagePos + filmStripWidth / 2)); 1985 } 1986 else { 1987 var selectedImagePos = -bwg_params[bwg]['bwg_current_filmstrip_pos'] - (jQuery(".bwg_slideshow_filmstrip_thumbnail" + defix).height() + bwg_params[bwg]['filmstrip_thumb_margin_hor']) / 2; 1988 var imagesContainerLeft = Math.min(0, Math.max(filmStripWidth - jQuery(".bwg_slideshow_filmstrip_thumbnails" + defix).height(), selectedImagePos + filmStripWidth / 2)); 1989 } 1990 } 1991 1992 if ( imagesContainerLeft + right_left_space > 0 ) { 1993 right_left_space = 0; 1994 } 1995 if ( imagesContainerLeft + top_bottom_space > 0 ) { 1996 top_bottom_space = 0; 1997 } 1998 1999 if( left_or_top == 'left' ) { 2000 jQuery(".bwg"+source+"_filmstrip_thumbnails" + defix).animate({ 2001 left: imagesContainerLeft + right_left_space 2002 }, { 2003 duration: 500, 2004 complete: function () { bwg_filmstrip_arrows( bwg ); } 2005 }); 2006 } else { 2007 jQuery(".bwg"+source+"_filmstrip_thumbnails" + defix).animate({ 2008 top: imagesContainerLeft + top_bottom_space 2009 }, { 2010 duration: 500, 2011 complete: function () { bwg_filmstrip_arrows( bwg ); } 2012 }); 2013 } 2014} 2015 2016/* Show/hide filmstrip arrows.*/ 2017function bwg_filmstrip_arrows( bwg ) { 2018 2019 var defix = ( typeof bwg != 'undefined' ) ? '_'+bwg : ''; 2020 var source = ( typeof bwg != 'undefined' ) ? '_slideshow' : ''; 2021 var width_or_height = ( typeof bwg != 'undefined' ) ? bwg_params[bwg]['width_or_heigh'] : bwg_param['width_or_height']; 2022 2023 if ( width_or_height == 'width' ){ 2024 var condition1 = jQuery(".bwg"+source+"_filmstrip_thumbnails"+defix).width(); 2025 var condition2 = jQuery(".bwg"+source+"_filmstrip"+defix).width() 2026 } else { 2027 var condition1 = jQuery(".bwg"+source+"_filmstrip_thumbnails"+defix).height(); 2028 var condition2 = jQuery(".bwg"+source+"_filmstrip"+defix).height() 2029 } 2030 if (condition1 < condition2) { 2031 jQuery(".bwg"+source+"_filmstrip_left" + defix).hide(); 2032 jQuery(".bwg"+source+"_filmstrip_right" + defix).hide(); 2033 } 2034 else { 2035 jQuery(".bwg"+source+"_filmstrip_left" + defix).show(); 2036 jQuery(".bwg"+source+"_filmstrip_right" + defix).show(); 2037 } 2038} 2039 2040function bwg_move_filmstrip( bwg ) { 2041 var bwg_filmstrip_width; 2042 var bwg_filmstrip_thumbnails_width; 2043 var image_left; 2044 var image_right; 2045 var long_filmstrip_cont_left; 2046 var long_filmstrip_cont_right; 2047 2048 var defix = ( typeof bwg != 'undefined' ) ? '_'+bwg : ''; 2049 var source = ( typeof bwg != 'undefined' ) ? '_slideshow' : ''; 2050 var outerWidth_or_outerHeight = ( typeof bwg != 'undefined' ) ? bwg_params[bwg]['outerWidth_or_outerHeight'] : bwg_param['outerWidth_or_outerHeight']; 2051 var left_or_top = ( typeof bwg != 'undefined' ) ? bwg_params[bwg]['left_or_top'] : bwg_param['left_or_top']; 2052 2053 if(outerWidth_or_outerHeight == 'outerWidth') { 2054 bwg_filmstrip_width = jQuery(".bwg" + source + "_filmstrip" + defix).outerWidth(true); 2055 bwg_filmstrip_thumbnails_width = jQuery(".bwg" + source + "_filmstrip_thumbnails" + defix).outerWidth(true); 2056 } else { 2057 bwg_filmstrip_width = jQuery(".bwg" + source + "_filmstrip" + defix).outerHeight(true); 2058 bwg_filmstrip_thumbnails_width = jQuery(".bwg" + source + "_filmstrip_thumbnails" + defix).outerHeight(true); 2059 } 2060 if( left_or_top == 'left' ) { 2061 image_left = jQuery(".bwg" + source + "_thumb_active" + defix).position().left; 2062 if( outerWidth_or_outerHeight == 'outerWidth' ) { 2063 image_right = jQuery(".bwg" + source + "_thumb_active" + defix).position().left + jQuery(".bwg" + source + "_thumb_active" + defix).outerWidth(true); 2064 } else { 2065 image_right = jQuery(".bwg" + source + "_thumb_active" + defix).position().left + jQuery(".bwg" + source + "_thumb_active" + defix).outerHeight(true); 2066 } 2067 long_filmstrip_cont_left = jQuery(".bwg" + source + "_filmstrip_thumbnails" + defix).position().left; 2068 long_filmstrip_cont_right = Math.abs(jQuery(".bwg" + source + "_filmstrip_thumbnails" + defix).position().left) + bwg_filmstrip_width; 2069 } else { 2070 image_left = jQuery(".bwg" + source + "_thumb_active" + defix).position().top; 2071 if( outerWidth_or_outerHeight == 'outerWidth' ) { 2072 image_right = jQuery(".bwg" + source + "_thumb_active" + defix).position().top + jQuery(".bwg" + source + "_thumb_active" + defix).outerWidth(true); 2073 } else { 2074 image_right = jQuery(".bwg" + source + "_thumb_active" + defix).position().top + jQuery(".bwg" + source + "_thumb_active" + defix).outerHeight(true); 2075 } 2076 long_filmstrip_cont_left = jQuery(".bwg" + source + "_filmstrip_thumbnails" + defix).position().top; 2077 long_filmstrip_cont_right = Math.abs(jQuery(".bwg" + source + "_filmstrip_thumbnails" + defix).position().top) + bwg_filmstrip_width; 2078 } 2079 if (bwg_filmstrip_width > bwg_filmstrip_thumbnails_width) { 2080 return; 2081 } 2082 if (image_left < Math.abs(long_filmstrip_cont_left)) { 2083 if ( left_or_top == 'left' ) { 2084 jQuery(".bwg" + source + "_filmstrip_thumbnails" + defix).animate({ 2085 left: -image_left 2086 }, { 2087 duration: 500, 2088 complete: function () { bwg_filmstrip_arrows( bwg ); } 2089 }); 2090 } else { 2091 jQuery(".bwg" + source + "_filmstrip_thumbnails" + defix).animate({ 2092 top: -image_left 2093 }, { 2094 duration: 500, 2095 complete: function () { bwg_filmstrip_arrows( bwg ); } 2096 }); 2097 } 2098 } 2099 else if (image_right > long_filmstrip_cont_right) { 2100 if ( left_or_top == 'left' ) { 2101 jQuery(".bwg" + source + "_filmstrip_thumbnails" + defix).animate({ 2102 left: -(image_right - bwg_filmstrip_width) 2103 }, { 2104 duration: 500, 2105 complete: function () { 2106 bwg_filmstrip_arrows(bwg); 2107 } 2108 }); 2109 } else { 2110 jQuery(".bwg" + source + "_filmstrip_thumbnails" + defix).animate({ 2111 top: -(image_right - bwg_filmstrip_width) 2112 }, { 2113 duration: 500, 2114 complete: function () { 2115 bwg_filmstrip_arrows(bwg); 2116 } 2117 }); 2118 } 2119 } 2120} 2121 2122function bwg_move_dots( bwg ) { 2123 var image_left = jQuery(".bwg_slideshow_dots_active_" + bwg).position().left; 2124 var image_right = jQuery(".bwg_slideshow_dots_active_" + bwg).position().left + jQuery(".bwg_slideshow_dots_active_" + bwg).outerWidth(true); 2125 var bwg_dots_width = jQuery(".bwg_slideshow_dots_container_" + bwg).outerWidth(true); 2126 var bwg_dots_thumbnails_width = jQuery(".bwg_slideshow_dots_thumbnails_" + bwg).outerWidth(false); 2127 var long_filmstrip_cont_left = jQuery(".bwg_slideshow_dots_thumbnails_" + bwg).position().left; 2128 var long_filmstrip_cont_right = Math.abs(jQuery(".bwg_slideshow_dots_thumbnails_" + bwg).position().left) + bwg_dots_width; 2129 if (bwg_dots_width > bwg_dots_thumbnails_width) { 2130 return; 2131 } 2132 if (image_left < Math.abs(long_filmstrip_cont_left)) { 2133 jQuery(".bwg_slideshow_dots_thumbnails_" + bwg).animate({ 2134 left: -image_left 2135 }, {
2136 duration: 500, 2137 complete: function () { } 2138 }); 2139 } 2140 else if (image_right > long_filmstrip_cont_right) { 2141 jQuery(".bwg_slideshow_dots_thumbnails_" + bwg).animate({ 2142 left: -(image_right - bwg_dots_width) 2143 }, { 2144 duration: 500, 2145 complete: function () { } 2146 }); 2147 } 2148} 2149 2150function bwg_testBrowser_cssTransitions( bwg ) { 2151 return bwg_testDom('Transition', bwg); 2152} 2153 2154function bwg_testBrowser_cssTransforms3d( bwg ) { 2155 return bwg_testDom('Perspective', bwg); 2156} 2157 2158function bwg_testDom(prop, bwg) { 2159 /* Browser vendor CSS prefixes.*/ 2160 var browserVendors = ['', '-webkit-', '-moz-', '-ms-', '-o-', '-khtml-']; 2161 /* Browser vendor DOM prefixes.*/ 2162 var domPrefixes = ['', 'Webkit', 'Moz', 'ms', 'O', 'Khtml']; 2163 var i = domPrefixes.length; 2164 while (i--) { 2165 if (typeof document.body.style[domPrefixes[i] + prop] !== 'undefined') { 2166 return true; 2167 } 2168 } 2169 return false; 2170} 2171 2172/* For browsers that does not support transitions.*/ 2173function bwg_fallback(current_image_class, next_image_class, direction, bwg) { 2174 bwg_fade(current_image_class, next_image_class, direction, bwg); 2175} 2176 2177/* For browsers that support transitions, but not 3d transforms (only used if primary transition makes use of 3d-transforms).*/ 2178function bwg_fallback3d(current_image_class, next_image_class, direction, bwg) { 2179 bwg_sliceV(current_image_class, next_image_class, direction, bwg); 2180} 2181 2182function bwg_none(current_image_class, next_image_class, direction, bwg) { 2183 2184 var defix = ( typeof bwg != 'undefined' ) ? '_'+bwg : ''; 2185 2186 jQuery(current_image_class).css({'opacity' : 0, 'z-index': 1}); 2187 jQuery(next_image_class).css({'opacity' : 1, 'z-index' : 2}); 2188 2189 if ( typeof bwg != 'undefined' ) { 2190 var bwg_current_key = bwg_params[bwg]['bwg_current_key']; 2191 bwg_change_watermark_container(bwg); 2192 /* Set active thumbnail.*/ 2193 jQuery(".bwg_slideshow_filmstrip_thumbnail" + defix).removeClass("bwg_slideshow_thumb_active" + defix).addClass("bwg_slideshow_thumb_deactive" + defix); 2194 jQuery("#bwg_filmstrip_thumbnail_" + bwg_current_key + defix).removeClass("bwg_slideshow_thumb_deactive" + defix).addClass("bwg_slideshow_thumb_active" + defix); 2195 jQuery(".bwg_slideshow_dots" + defix).removeClass("bwg_slideshow_dots_active" + defix).addClass("bwg_slideshow_dots_deactive" + defix); 2196 jQuery("#bwg_dots_" + bwg_current_key + defix).removeClass("bwg_slideshow_dots_deactive" + defix).addClass("bwg_slideshow_dots_active" + defix); 2197 } else { 2198 /* Lightbox */ 2199 jQuery(".bwg_image_info").show(); 2200 bwg_param['bwg_trans_in_progress'] = false; 2201 jQuery(current_image_class).html(''); 2202 bwg_change_watermark_container(); 2203 } 2204 2205 2206} 2207 2208function bwg_iterator( bwg ) { 2209 var iterator = 1; 2210 if ( typeof bwg != 'undefined' && typeof bwg_params[bwg] != 'undefined' && bwg_params[bwg]['enable_slideshow_shuffle'] == 1 ) { 2211 iterator = Math.floor((bwg_params[bwg]['data'].length - 1) * Math.random() + 1); 2212 } 2213 return iterator; 2214} 2215 2216function bwg_change_image_slideshow(current_key, key, data, from_effect, bwg) { 2217 var data = bwg_params[bwg]['data']; 2218 /* Pause videos.*/ 2219 jQuery("#bwg_slideshow_image_container_" + bwg).find("iframe").each(function () { 2220 jQuery(this)[0].contentWindow.postMessage('{"event":"command","func":"pauseVideo","args":""}', '*'); 2221 jQuery(this)[0].contentWindow.postMessage('{ "method": "pause" }', "*"); 2222 jQuery(this)[0].contentWindow.postMessage('pause', '*'); 2223 }); 2224 /* Pause videos facebook video.*/ 2225 jQuery('#image_id_' +bwg + '_' + data[current_key]["id"]).find('.bwg_fb_video').each(function () { 2226 jQuery(this).attr('src', jQuery(this).attr('src')); 2227 }); 2228 if (data[key]) { 2229 if (jQuery('.bwg_ctrl_btn_' + bwg).hasClass('fa-pause')) { 2230 bwg_play( bwg_params[bwg]['data'], bwg ); 2231 } 2232 2233 if (!from_effect) { 2234 /* Change image key.*/ 2235 jQuery("#bwg_current_image_key_" + bwg).val(key); 2236 if (current_key == '-1') { /* Filmstrip.*/ 2237 current_key = jQuery(".bwg_slideshow_thumb_active_" + bwg).children("img").attr("image_key"); 2238 } 2239 else if (current_key == '-2') { /* Dots.*/ 2240 current_key = jQuery(".bwg_slideshow_dots_active_" + bwg).attr("image_key"); 2241 } 2242 } 2243 if ( bwg_params[bwg]['bwg_trans_in_progress'] ) { 2244 bwg_params[bwg]['event_stack'].push(current_key + '-' + key); 2245 return; 2246 } 2247 var direction = 'right'; 2248 if (current_key > key) { 2249 var direction = 'left'; 2250 } else if (current_key == key) { 2251 return; 2252 } 2253 2254 jQuery(".bwg_slideshow_watermark_" + bwg).css({display: 'none'}); 2255 jQuery(".bwg_slideshow_title_text_" + bwg).css({display: 'none'}); 2256 jQuery(".bwg_slideshow_description_text_" + bwg).css({display: 'none'}); 2257 /* Set active thumbnail position.*/ 2258 if ( bwg_params[bwg]['width_or_height'] == 'width' ) { 2259 bwg_params[bwg]['bwg_current_filmstrip_pos'] = key * (jQuery(".bwg_slideshow_filmstrip_thumbnail_" + bwg).width() + 2 + 2 * bwg_params[bwg]['lightbox_filmstrip_thumb_border_width']); 2260 } else { 2261 bwg_params[bwg]['bwg_current_filmstrip_pos'] = key * (jQuery(".bwg_slideshow_filmstrip_thumbnail_" + bwg).height() + 2 + 2 * bwg_params[bwg]['lightbox_filmstrip_thumb_border_width']); 2262 } 2263 2264 current_key = key; 2265 bwg_params[bwg]['bwg_current_key'] = current_key; 2266 /* Change image id, title, description.*/ 2267 jQuery("#bwg_slideshow_image_" + bwg).attr('image_id', data[key]["id"]); 2268 jQuery(".bwg_slideshow_title_text_" + bwg).html(jQuery('<span style="display: block;" />').html(data[key]["alt"]).text()); 2269 jQuery(".bwg_slideshow_description_text_" + bwg).html(jQuery('<span style="display: block;" />').html(data[key]["description"]).text()); 2270 var current_image_class = jQuery(".bwg_slideshow_image_spun_" + bwg).css("zIndex") == 2 ? ".bwg_slideshow_image_spun_" + bwg : ".bwg_slideshow_image_second_spun_" + bwg; 2271 var next_image_class = current_image_class == ".bwg_slideshow_image_second_spun_" + bwg ? ".bwg_slideshow_image_spun_" + bwg : ".bwg_slideshow_image_second_spun_" + bwg; 2272 var is_embed = data[key]['filetype'].indexOf("EMBED_") > -1 ? true : false;
2273 var is_embed_instagram_post = data[key]['filetype'].indexOf('INSTAGRAM_POST') > -1 ? true :false; 2274 var is_embed_instagram_video = data[key]['filetype'].indexOf('INSTAGRAM_VIDEO') > -1 ? true :false; 2275 var cur_height = jQuery(current_image_class).height(); 2276 var cur_width = jQuery(current_image_class).width(); 2277 var innhtml = '<span class="bwg_slideshow_image_spun1_' + bwg +'" style="display: ' + (!is_embed ? 'table' : 'block') + ' ;width: inherit; height: inherit;"><span class="bwg_slideshow_image_spun2_' + bwg + '" style="display: ' + (!is_embed ? 'table-cell' : 'block') + '; vertical-align: middle; text-align: center; ">'; 2278 if (!is_embed) { 2279 if (bwg_params[bwg]['thumb_click_action'] != 'do_nothing' ) { 2280 var argument = ''; 2281 if (bwg_params[bwg]['thumb_click_action'] == 'open_lightbox') 2282 { 2283 argument += ' class="bwg_lightbox" data-image-id="' + data[key]["id"] + '"'; 2284 } else { 2285 if ( bwg_params[bwg]["thumb_click_action"] == "redirect_to_url" && data[key]["redirect_url"] ) { 2286 argument += 'href="' + data[key]["redirect_url"] + '"' + ( (bwg_params[bwg]['thumb_link_target'] && bwg_params[bwg]['thumb_link_target'] == 1) ? ' target="_blank"' : '' ); 2287 } 2288 } 2289 innhtml += '<a ' + argument + '>'; 2290 } 2291 innhtml += '<img style="max-height: ' + cur_height + 'px !important; max-width: ' + cur_width + 'px !important; display:inline-block;" '; 2292 innhtml += ' class="bwg_slide bwg_slideshow_image_'+bwg+'" '; 2293 innhtml += ' id="bwg_slideshow_image_' + bwg + '" '; 2294 innhtml += ' src="' + bwg_params[bwg]['upload_url'] + jQuery("<span style=\'display: block;\' />").html(data[key]["image_url"]).text() + '" alt="' + data[key]["alt"] + '" image_id="' + data[key]["id"] + '" /></a>'; 2295 } else { /*is_embed*/ 2296 innhtml += '<span style="height: ' + cur_height + 'px; width: ' + cur_width + 'px;" class="bwg_popup_embed bwg_popup_watermark">'; 2297 if (is_embed_instagram_video ) { 2298 innhtml += '<span class="bwg_inst_play_btn_cont" onclick="bwg_play_instagram_video(this)"><span class="bwg_inst_play"></span></span>'; 2299 } 2300 if (is_embed_instagram_post) { 2301 var post_width = 0; 2302 var post_height = 0; 2303 if (cur_height < cur_width + 88) { 2304 post_height = cur_height; 2305 post_width = post_height - 88; 2306 } 2307 else { 2308 post_width = cur_width; 2309 post_height = post_width + 88; 2310 } 2311 innhtml += spider_display_embed(data[key]['filetype'], data[key]['image_url'], data[key]['filename'], {class:"bwg_embed_frame", 'data-width': data[key]['image_width'], 'data-height': data[key]['image_height'], frameborder: "0", allowfullscreen: "allowfullscreen", style: "width:" + post_width + "px; height:" + post_height + "px; vertical-align:middle; display:inline-block; position:relative;"}); 2312 } else { 2313 innhtml += spider_display_embed(data[key]['filetype'], data[key]['image_url'], data[key]['filename'], {class:"bwg_embed_frame", frameborder:"0", allowfullscreen:"allowfullscreen", style:"width:inherit; height:inherit; vertical-align:middle; display:table-cell;" }); 2314 } 2315 innhtml += "</span>"; 2316 } 2317 innhtml += '</span></span>'; 2318 jQuery(next_image_class).html(innhtml); 2319 if (bwg_params[bwg]['preload_images']) { 2320 bwg_preload_images(key, bwg); 2321 } 2322 window["bwg_" + bwg_params[bwg]['slideshow_effect']](current_image_class, next_image_class, direction, bwg); 2323 if ( bwg_params[bwg]['enable_slideshow_filmstrip'] > 0 ) { 2324 bwg_move_filmstrip( bwg ); 2325 } 2326 else { 2327 bwg_move_dots( bwg); 2328 } 2329 if (data[key]["is_embed_video"]) { 2330 jQuery("#bwg_slideshow_play_pause_" + bwg).css({display: 'none'}); 2331 } 2332 else { 2333 jQuery("#bwg_slideshow_play_pause_" + bwg).css({display: ''}); 2334 } 2335 } 2336 bwg_add_lightbox(); 2337} 2338 2339function bwg_preload_images_slideshow( key, bwg ) { 2340 var data = bwg_params[bwg]['data']; 2341 count = bwg_params[bwg]['preload_images_count'] / 2; 2342 var count_all = data.length; 2343 if (count_all < bwg_params[bwg]['preload_images_count']) { 2344 count = 0; 2345 } 2346 if (count != 0) { 2347 for (var i = key - count; i < key + count; i++) { 2348 var index = parseInt((i + count_all) % count_all); 2349 var is_embed = data[index]['filetype'].indexOf("EMBED_") > -1 ? true : false;
2350 if (typeof data[index] != "undefined") { 2351 if (!is_embed) { 2352 jQuery("<img/>").attr("src", bwg_params[bwg]['upload_url'] + jQuery('<span style="display: block;" />').html(data[index]["image_url"]).text()); 2353 } 2354 } 2355 } 2356 } else { 2357 for (var i = 0; i < data.length; i++) { 2358 var is_embed = data[i]['filetype'].indexOf("EMBED_") > -1 ? true : false; 2359 if (typeof data[i] != "undefined") { 2360 if (!is_embed) { 2361 jQuery("<img/>").attr("src", bwg_params[bwg]['upload_url'] + jQuery('<span style="display: block;" />').html(data[i]["image_url"]).text()); 2362 } 2363 } 2364 } 2365 } 2366} 2367 2368function bwg_preload_images( key, bwg ) { 2369 if ( typeof bwg != 'undefined' ) { /* SLIDESHOW */ 2370 bwg_preload_images_slideshow( key, bwg ); 2371 } else { /* LIGHTBOX */ 2372 bwg_preload_images_lightbox( key ); 2373 } 2374} 2375 2376function bwg_popup_resize_slidshow( bwg ) { 2377 var parent_width = jQuery(".bwg_slideshow_image_wrap_" + bwg).parent().width(); 2378 var data = bwg_params[bwg]['data']; 2379 if (parent_width >= bwg_params[bwg]['image_width']) { 2380 jQuery(".bwg_slideshow_image_wrap_"+bwg).css({width: bwg_params[bwg]['image_width']}); 2381 jQuery(".bwg_slideshow_image_wrap_"+bwg).css({height: bwg_params[bwg]['image_height']}); 2382 jQuery(".bwg_slideshow_image_container_"+bwg).css({width: (bwg_params[bwg]['filmstrip_direction'] == 'horizontal') ? bwg_params[bwg]['image_width'] : (bwg_params[bwg]['image_width'] - bwg_params[bwg]['slideshow_filmstrip_width']) }); 2383 jQuery(".bwg_slideshow_image_container_"+bwg).css({height: (bwg_params[bwg]['filmstrip_direction'] == 'horizontal') ? bwg_params[bwg]['image_height'] - bwg_params[bwg]['slideshow_filmstrip_height'] : bwg_params[bwg]['image_height'] }); 2384 jQuery(".bwg_slideshow_image_"+bwg).css({ 2385 cssText: "max-width: " + (bwg_params[bwg]['filmstrip_direction'] == 'horizontal ') ? bwg_params[bwg]['image_width'] : (bwg_params[bwg]['image_width'] - bwg_params[bwg]['slideshow_filmstrip_width'])+"px !important; max-height: " + (bwg_params[bwg]['filmstrip_direction'] == 'horizontal') ? (bwg_params[bwg]['image_height'] - bwg_params[bwg]['slideshow_filmstrip_height']) : bwg_params[bwg]['image_height']+"px !important;" 2386 }); 2387 jQuery(".bwg_slideshow_embed_"+bwg).css({ 2388 cssText: "width: "+(bwg_params[bwg]['filmstrip_direction'] == 'horizontal') ? bwg_params[bwg]['image_width'] : (bwg_params[bwg]['image_width'] - bwg_params[bwg]['slideshow_filmstrip_width'])+"px !important; height:"+ (bwg_params[bwg]['filmstrip_direction'] == 'horizontal') ? (bwg_params[bwg]['image_height'] - bwg_params[bwg]['slideshow_filmstrip_height']) : bwg_params[bwg]['image_height']+"px !important;" 2389 }); 2390 bwg_resize_instagram_post( bwg ); 2391 /* Set watermark container size. */ 2392 bwg_change_watermark_container( bwg ); 2393 var filmstrip_container_css = (bwg_params[bwg]['filmstrip_direction'] == 'horizontal') ? 'width: ' + bwg_params[bwg]['image_width'] : 'height: ' + bwg_params[bwg]['image_height']; 2394 var filmstrip_css = (bwg_params[bwg]['filmstrip_direction'] == 'horizontal') ? 'width: ' + (bwg_params[bwg]['image_width'] - 40) : 'height: ' + (bwg_params[bwg]['image_height'] - 40); 2395 jQuery(".bwg_slideshow_filmstrip_container_" + bwg).css({ cssText: filmstrip_container_css }); 2396 jQuery(".bwg_slideshow_filmstrip_"+bwg).css({ cssText: filmstrip_css }); 2397 jQuery(".bwg_slideshow_dots_container_"+bwg).css({width: bwg_params[bwg]['image_width'] }); 2398 jQuery("#bwg_slideshow_play_pause-ico_"+bwg).css({fontSize: (bwg_params[bwg]['slideshow_play_pause_btn_size'])}); 2399 if ( bwg_params[bwg]['watermark_type'] == 'image') { 2400 jQuery(".bwg_slideshow_watermark_image_" + bwg).css({ 2401 maxWidth: bwg_params[bwg]['watermark_width'], 2402 maxHeight: bwg_params[bwg]['watermark_height'] 2403 }); 2404 } 2405 if ( bwg_params[bwg]['watermark_type'] == 'text') { 2406 jQuery(".bwg_slideshow_watermark_text_" + bwg + ", .bwg_slideshow_watermark_text_" + bwg + " : hover").css({ 2407 fontSize: (bwg_params[bwg]['watermark_font_size']) 2408 }); 2409 } 2410 jQuery(".bwg_slideshow_title_text_"+bwg).css({fontSize: ( bwg_params[bwg]['slideshow_title_font_size'] * 2 )}); 2411 jQuery(".bwg_slideshow_description_text_"+bwg).css({fontSize: (bwg_params[bwg]['slideshow_description_font_size'] * 2)}); 2412 } 2413 else { 2414 jQuery(".bwg_slideshow_image_wrap_"+bwg).css({width: (parent_width)}); 2415 jQuery(".bwg_slideshow_image_wrap_"+bwg).css({ height: ((parent_width) * bwg_params[bwg]['image_height'] / bwg_params[bwg]['image_width'] )}); 2416 jQuery(".bwg_slideshow_image_container_"+bwg).css({width: (parent_width - (bwg_params[bwg]['filmstrip_direction'] == 'horizontal' ? 0 : bwg_params[bwg]['slideshow_filmstrip_width']))}); 2417 jQuery(".bwg_slideshow_image_container_"+bwg).css({height: ((parent_width) * bwg_params[bwg]['image_height'] / bwg_params[bwg]['image_width'] - (bwg_params[bwg]['filmstrip_direction'] == 'horizontal' ? bwg_params[bwg]['slideshow_filmstrip_he
2417ight'] : 0))}); 2418 jQuery(".bwg_slideshow_image_"+bwg).css({ 2419 cssText: "max-width: " + (parent_width - (bwg_params[bwg]['filmstrip_direction'] == 'horizontal' ? 0 : bwg_params[bwg]['slideshow_filmstrip_width'])) + "px !important; max-height: " + (parent_width * (bwg_params[bwg]['image_height'] / bwg_params[bwg]['image_width']) - (bwg_params[bwg]['filmstrip_direction'] == 'horizontal' ? bwg_params[bwg]['slideshow_filmstrip_height'] : 0) - 1) + "px !important;" 2420 }); 2421 jQuery(".bwg_slideshow_embed_"+bwg).css({ 2422 cssText: "width: " + (parent_width - (bwg_params[bwg]['filmstrip_direction'] == 'horizontal' ? 0 : bwg_params[bwg]['slideshow_filmstrip_width']) ) + "px !important; height: " + (parent_width * (bwg_params[bwg]['image_height'] / bwg_params[bwg]['image_width']) - (bwg_params[bwg]['filmstrip_direction'] == 'horizontal' ? bwg_params[bwg]['slideshow_filmstrip_height'] : 0) - 1) + "px !important;" 2423 }); 2424 bwg_resize_instagram_post( bwg ); 2425 /* Set watermark container size.*/ 2426 bwg_change_watermark_container( bwg ); 2427 if (bwg_params[bwg]['filmstrip_direction'] == 'horizontal') { 2428 jQuery(".bwg_slideshow_filmstrip_container_"+bwg).css({width: (parent_width)}); 2429 jQuery(".bwg_slideshow_filmstrip_"+bwg).css({width: (parent_width - 40)}); 2430 } else { 2431 jQuery(".bwg_slideshow_filmstrip_container_"+bwg).css({height: (parent_width * bwg_params[bwg]['image_height'] / bwg_params[bwg]['image_width'])}); 2432 jQuery(".bwg_slideshow_filmstrip_"+bwg).css({height: (parent_width * bwg_params[bwg]['image_height'] / bwg_params[bwg]['image_width'] - 40)}); 2433 } 2434 jQuery(".bwg_slideshow_dots_container_"+bwg).css({width: (parent_width)}); 2435 jQuery("#bwg_slideshow_play_pause-ico_"+bwg).css({fontSize: ((parent_width) * bwg_params[bwg]['slideshow_play_pause_btn_size'] / bwg_params[bwg]['image_width'])}); 2436 jQuery(".bwg_slideshow_watermark_image_"+bwg).css({maxWidth: ((parent_width) * bwg_params[bwg]['watermark_width'] / bwg_params[bwg]['image_width']), maxHeight: ((parent_width) * bwg_params[bwg]['watermark_height'] / bwg_params[bwg]['image_width'])}); 2437 jQuery(".bwg_slideshow_watermark_text_"+bwg+", .bwg_slideshow_watermark_text_"+bwg+":hover").css({fontSize: ((parent_width) * bwg_params[bwg]['watermark_font_size'] / bwg_params[bwg]['image_width'])}); 2438 jQuery(".bwg_slideshow_title_text_"+bwg).css({fontSize: ((parent_width) * 2 * bwg_params[bwg]['slideshow_title_font_size'] / bwg_params[bwg]['image_width'])}); 2439 jQuery(".bwg_slideshow_description_text_"+bwg).css({fontSize: ((parent_width) * 2 * bwg_params[bwg]['slideshow_description_font_size'] / bwg_params[bwg]['image_width'])}); 2440 jQuery(".bwg_slideshow_image_"+bwg).css({'display':'inline-block'}); 2441 }
2442 if (data[parseInt(jQuery("#bwg_current_image_key_"+bwg).val())]["is_embed_video"]) { 2443 jQuery("#bwg_slideshow_play_pause_"+bwg).css({display: 'none'}); 2444 } 2445 else { 2446 jQuery("#bwg_slideshow_play_pause_"+bwg).css({display: ''}); 2447 } 2448} 2449 2450function bwg_popup_resize( bwg ) { 2451 if ( typeof bwg != 'undefined' ) { /* SLIDESHOW */ 2452 bwg_popup_resize_slidshow( bwg ); 2453 } else { /* LIGHTBOX */ 2454 bwg_popup_resize_lightbox(); 2455 } 2456} 2457 2458function bwg_change_image(current_key, key, data, from_effect, bwg) { 2459 if ( typeof bwg != 'undefined' ) { /* SLIDESHOW */ 2460 bwg_change_image_slideshow(current_key, key, data, from_effect, bwg); 2461 } else { /* LIGHTBOX */ 2462 bwg_change_image_lightbox(current_key, key, data, from_effect); 2463 } 2464} 2465 2466function bwg_resize_instagram_post( bwg ) { 2467 if ( typeof bwg != 'undefined' ) { /* SLIDESHOW */ 2468 if (jQuery(".inner_instagram_iframe_bwg_embed_frame_"+bwg).length) { 2469 var post_width = jQuery(".bwg_slideshow_embed_"+bwg).width(); 2470 var post_height = jQuery(".bwg_slideshow_embed_").height(); 2471 jQuery(".inner_instagram_iframe_bwg_embed_frame_"+bwg).each(function() { 2472 var parent_container = jQuery(this).parent(); 2473 if (post_height / (parseInt(parent_container.attr('data-height')) + 96) < post_width / parseInt(parent_container.attr('data-width'))) { 2474 parent_container.height(post_height); 2475 parent_container.width((parent_container.height() - 96) * parent_container.attr('data-width') / parent_container.attr('data-height') + 16); 2476 } 2477 else { 2478 parent_container.width(post_width); 2479 parent_container.height((parent_container.width() - 16) * parent_container.attr('data-height') / parent_container.attr('data-width') + 96); 2480 } 2481 }); 2482 bwg_change_watermark_container( bwg ); 2483 } 2484 } else { /* LIGHTBOX */ 2485 if (jQuery('.inner_instagram_iframe_bwg_embed_frame').length) { 2486 var post_width = jQuery(".bwg_image_container").width(); 2487 var post_height = jQuery(".bwg_image_container").height(); 2488 var FeedbackSocialProofHeight = 132; 2489 jQuery('.inner_instagram_iframe_bwg_embed_frame').each(function() { 2490 var parent_container = jQuery(this).parent(); 2491 if (post_height / (parseInt(parent_container.attr('data-height')) + FeedbackSocialProofHeight) < post_width / parseInt(parent_container.attr('data-width'))) { 2492 parent_container.height(post_height); 2493 parent_container.width((parent_container.height() - FeedbackSocialProofHeight) * parent_container.attr('data-width') / parent_container.attr('data-height') + 16); 2494 } 2495 else { 2496 parent_container.width(post_width); 2497 parent_container.height((parent_container.width() - 16) * parent_container.attr('data-height') / parent_container.attr('data-width') + 96); 2498 } 2499 parent_container.css({top: 0.5 * (post_height - parent_container.height())}); 2500 }); 2501 bwg_change_watermark_container(); 2502 } 2503 } 2504} 2505 2506function bwg_play( data, bwg ) { 2507 if ( typeof bwg != 'undefined' ) { 2508 var data = bwg_params[bwg]['data']; 2509 } 2510 2511 /* Play.*/ 2512 if ( typeof bwg != 'undefined' ) { /* SLIDESHOW */ 2513 window.clearInterval(window['bwg_playInterval' + bwg]); 2514 window['bwg_playInterval' + bwg] = setInterval(function () { 2515 var iterator = 1; 2516 if (bwg_params[bwg]['enable_slideshow_shuffle'] == 1) { 2517 iterator = Math.floor((data.length - 1) * Math.random() + 1); 2518 } 2519 bwg_change_image( parseInt(jQuery("#bwg_current_image_key_"+bwg).val()), (parseInt(jQuery("#bwg_current_image_key_"+bwg).val()) + iterator) % data.length, data, '', bwg ) 2520 }, bwg_params[bwg]['slideshow_interval'] * 1000); 2521 } else { 2522 window.clearInterval(bwg_param['bwg_playInterval']); 2523 bwg_param['bwg_playInterval'] = setInterval(function () { 2524 /* Stop play of lightbox if comment was opened*/ 2525 if ( jQuery(".bwg_comment_container").hasClass("bwg_open") || (jQuery(".bwg_play_pause").length && jQuery(".bwg_play_pause").hasClass("fa-play"))) { 2526 return; 2527 } 2528 2529 if (typeof data != 'undefined' && typeof data[(parseInt(j
2529Query('#bwg_current_image_key').val()) + 1)] == 'undefined') { 2530 if (bwg_param['enable_loop'] == 1) { 2531 /* Wrap around.*/ 2532 bwg_change_image(parseInt(jQuery('#bwg_current_image_key').val()), 0, data); 2533 } 2534 return; 2535 } 2536 bwg_change_image(parseInt(jQuery('#bwg_current_image_key').val()), parseInt(jQuery('#bwg_current_image_key').val()) + 1, data) 2537 }, bwg_param['slideshow_interval'] * 1000); 2538 } 2539} 2540 2541/*------------------ Image Browser Functions ---------------------------*/ 2542function bwg_image_browser( bwg ) { 2543 jQuery('#bwg_embed_frame_16x9_' + bwg).width(jQuery('#bwg_embed_frame_16x9_' + bwg).parents('.image_browser_image_buttons_' + bwg).width()); 2544 jQuery('#bwg_embed_frame_16x9_' + bwg).height(jQuery('#bwg_embed_frame_16x9_' + bwg).width() * 0.5625); 2545 jQuery('#bwg_embed_frame_instapost_' + bwg).width(jQuery('#bwg_embed_frame_16x9_' + bwg).parents('.image_browser_image_buttons_' + bwg).width()); 2546 /* Conflict with Sydney Theme */ 2547 if ( jQuery('.image_browser_images_conteiner_' + bwg).find('.fluid-width-video-wrapper').length ) { 2548 var content = jQuery('.image_browser_images_conteiner_' + bwg).find('.fluid-width-video-wrapper').contents(); 2549 jQuery('.image_browser_images_conteiner_' + bwg).find('.fluid-width-video-wrapper').replaceWith(content); 2550 } 2551 /* 16 is 2*padding inside iframe */ 2552 /* 96 is 2*padding(top) + 1*padding(bottom) + 40(footer) + 32(header) */ 2553 jQuery('.bwg_embed_frame_instapost_' + bwg).height((jQuery('.bwg_embed_frame_instapost_' + bwg).width() - 16) * jQuery('.bwg_embed_frame_instapost_' + bwg).attr('data-height') / jQuery('.bwg_embed_frame_instapost_' + bwg).attr('data-width') + 96); 2554 2555 var bwg_image_browser_width = jQuery('.image_browser_images_' + bwg).width(); 2556 if (bwg_image_browser_width <= 108) { 2557 jQuery('.paging-input_' + bwg).css('display', 'none'); 2558 } 2559 else if (bwg_image_browser_width <= 200) { 2560 jQuery('.paging-input_' + bwg).css('margin', '0% 0% 0% 0%'); 2561 jQuery('.paging-input_' + bwg).css('display', 'inline'); 2562 jQuery('.tablenav-pages_' + bwg + ' .next-page').css('margin', '0% 0% 0% 0%'); 2563 jQuery('.tablenav-pages_' + bwg + ' .prev-page').css('margin', '0% 0% 0% 0%'); 2564 } 2565 else if (bwg_image_browser_width <= 580) { 2566 jQuery('.paging-input_' + bwg).css('display', 'inline'); 2567 jQuery('.tablenav-pages_' + bwg + ' a').css('font-size', '13px'); 2568 jQuery('.paging-input_' + bwg).css('margin', '0% 7% 0% 7%'); 2569 jQuery('.tablenav-pages_' + bwg + ' .next-page').css('margin', '0% 0% 0% 0%'); 2570 jQuery('.tablenav-pages_' + bwg + ' .prev-page').css('margin', '0% 0% 0% 0%'); 2571 } 2572 else { 2573 jQuery('.tablenav-pages_' + bwg + ' a').css('font-size', '15px'); 2574 jQuery('.paging-input_' + bwg).css('margin', '0% 14% 0% 14%'); 2575 jQuery('.paging-input_' + bwg).css('display', 'inline'); 2576 jQuery('.tablenav-pages_' + bwg + ' .next-page').css('margin', '0% 0% 0% 0%'); 2577 jQuery('.tablenav-pages_' + bwg + ' .prev-page').css('margin', '0% 0% 0% 0%'); 2578 } 2579} 2580 2581/** 2582 * Disable right click. 2583 * 2584 * @param container 2585 */ 2586function bwg_disable_right_click( container ) { 2587 container.bind( "contextmenu", function () { 2588 return false; 2589 }); 2590 container.css( 'webkitTouchCallout', 'none' ); 2591}
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.