1import device from './device.js'; 2import contact_form_popup from './contact_form_popup.js' 3import cycle from '../plugins/jquery.cycle2.min.js' 4import jscroller_start from './jscroller_start.js' 5 6var image_gallery = { 7 8 init: function () { 9 10 var first_load = true 11 12 if (h.element_exists('.image_gallery_multiple') && h.element_exists('#secondary_image_thumbnails')) { 13 window.galleries.image_gallery.standard(); 14 } 15 16 if (h.element_exists('#ig_slideshow')) { 17 window.galleries.image_gallery.dynamic(); 18 } 19 20 if (h.element_exists('#ig_slider') || h.element_exists('.ig_slider')) { 21 window.galleries.image_gallery.slider.init(); 22 } 23 24 if (h.element_exists('.detail_expand_grid') || h.element_exists('.detail_expand_grid')) { 25 window.galleries.image_gallery.detail_expand_grid.init(); 26 } 27 28 }, 29 30 standard: function () { 31 var overrideSettings; 32 if ($('.image_gallery_multiple').attr('data-cycle-custom-settings')) { 33 var overrideSettings = JSON.parse($('.image_gallery_multiple').attr('data-cycle-custom-settings')); 34 } 35 36 var masterSettings = { 37 fx: 'fade', 38 speed: 600, 39 timeout: 12000, 40 paused: true, 41 slides: '>', 42 autoHeight: 'container', 43 swipe: true 44 }; 45 46 for (var overrideSetting in overrideSettings) { 47 masterSettings[overrideSetting] = overrideSettings[overrideSetting]; 48 } 49 50 $('.image_gallery_multiple').cycle(masterSettings); 51 52 // Accessibility - cycle sentinel slide should be ignored by focus trapping. 53 setTimeout(function () { 54 $('#popup_content .image_gallery_multiple .item.cycle-sentinel a').removeClass('focustrap-first focustrap-focusable focustrap-item').addClass('focustrap-ignore'); 55 }, 500); 56 57 // remove roomview attributes from cycle sentinels 58 setTimeout(function () { 59 $('.image_gallery_multiple .cycle-sentinel img').removeAttr('data-roomview-id data-roomview-artwork-cm-width data-roomview-custom-config').removeClass('roomview-image roomview-initialised'); 60 }, 500); 61 62 var currenltySelectedMessage = '<span class="screen-reader-only active-thumbnail-message">, currently selected.</span>' 63 64 $('#secondary_image_thumbnails a') 65 .click(function () { 66 var scroll_context = 'html,body'; 67 var element_offset_scroll = $(window).scrollTop(); 68 var element_offset_top = $('.image_gallery_multiple').offset().top; 69 if ($(this).closest('#popup_content').length) { 70 var scroll_context = '#popup_content'; 71 var element_offset_scroll = $('#popup_content').scrollTop(); 72 var element_offset_top = 0; 73 } 74 if (element_offset_scroll > element_offset_top) { 75 $(scroll_context).animate( 76 {scrollTop: element_offset_top + (-20)}, 77 300, 78 'easeInOutQuad' 79 ); 80 } 81 $('.image_gallery_multiple').cycle(parseInt($(this).attr('data-index'))); 82 $('#secondary_image_thumbnails a .active-thumbnail-message').remove(); 83 $(currenltySelectedMessage).insertAfter($(this).find(".screen-reader-only")); 84 85 // Accessibility - Update focus trapping when a different image is selected to show in the slideshow if it is the first focus item 86 if (!$(this).hasClass('active') && $('#popup_content .image_gallery_multiple .item a').hasClass('focustrap-first')) { 87 $('#popup_content .image_gallery_multiple .item:not(.cycle-sentinel) a').removeClass('focustrap-ignore'); 88 $('#popup_content .image_gallery_multiple .item:not(.cycle-slide-active) a').addClass('focustrap-ignore'); 89 h.accessibility.focus_untrap(); 90 h.accessibility.focus_trap('#popup_box .inner', false, '#popup_container .close'); 91 } 92 93 $('#secondary_image_thumbnails a').removeClass('active'); 94 $(this).addClass('active'); 95 96 if ($(this).parent('.video_embed').length) { 97 $(window).trigger('resize.fitvids'); 98 } 99 100 return false;
101 }) 102 .attr("role", "button"); 103 $(currenltySelectedMessage).insertAfter("#secondary_image_thumbnails a:first .screen-reader-only"); 104 $('#secondary_image_thumbnails a:first').addClass('active'); 105 }, 106 107 detail_expand_grid: { 108 109 init: function () { 110 var selectors = '.detail_expand_grid'; 111 112 $('li a', selectors).click(function () { 113 var wrapper = $(this).closest('li'); 114 var hash = $(this).attr('href'); 115 if ($(window).width() < 459) { 116 $.pageload.load($(this).attr('href'), true, false); 117 } else { 118 if (!$(wrapper).hasClass('active')) { 119 window.galleries.image_gallery.detail_expand_grid.load_work(wrapper, $(this).attr('href')); 120 } 121 } 122 return false; 123 }); 124 var original_browser_width = $(window).width(); 125 $(window).resize(function () { 126 if ($(window).width() != original_browser_width) { 127 $('.detail_expand_grid').each(function () { 128 if ($('.expander_detail', this).length > 0) { 129 $('.expander_detail', this).remove(); 130 } 131 if ($('li', this).attr('style') && $('li', this).attr('style') != 'undefined') { 132 $('li', this).removeClass('active').removeAttr('style'); 133 } 134 }); 135 } 136 }); 137 //$('> ul', selectors).addClass('loading'); 138 //$(window).on("load", function() { 139 // $('> ul', selectors).removeClass('loading'); 140 //}); 141 }, 142 143 load_work: function (wrapper, link) { 144 console.log('do ajax'); 145 146 if ($(wrapper).closest('ul').hasClass('loading')) { 147 148 $(window).off("load.load_work_pre_click"); 149 $(window).on("load.load_work_pre_click", function () { 150 window.galleries.image_gallery.detail_expand_grid.load_work(wrapper, link); 151 }); 152 153 } else { 154 console.log('do ajax'); 155 156 $(wrapper).closest('ul').find('li').removeClass('active'); 157 $(wrapper).addClass('active').addClass('loading'); 158 159 if (typeof detail_expand_load_work_ajax_request != 'undefined') { 160 detail_expand_load_work_ajax_request.abort(); 161 } 162 163 var detail_expand_load_work_ajax_request = $.ajax({ 164 url: link, 165 data: {'modal': '1'}, 166 cache: false, 167 success: function (data) { 168 169 $(wrapper).closest('ul').find('li').not(wrapper).find('.expander_detail').css('opacity', '0'); 170 $(wrapper).append('<div class="expander_detail">' + data + '</div>'); 171 window.galleries.contact_form_popup.init(); 172 $(".expander_detail #image_container a, #secondary_image_thumbnails a").fancybox({ 173 'overlayShow': true, 174 'overlayOpacity': 0.7, 175 'overlayColor': '#d9d9d9', 176 'imageScale': 'true', 177 'zoomOpacity': 'true', 178 prevEffect: 'fade', 179 nextEffect: 'fade', 180 closeEffect: 'fade', 181 openEffect: 'fade', 182 helpers: { 183 title: { 184 type: 'inside' 185 } 186 } 187 }); 188 189 190 $('.expander_detail', wrapper).waitForImages({ 191 finished: function () { 192 window.setTimeout(function () { 193 194 console.log(link); 195 history.replaceState(null, null, link); 196 //should clear on scroll - to be built 197 198 window.galleries.contact_form_popup.init(); 199 window.galleries.sharing.init(
199); 200 if (typeof window.addthis === 'undefined') { 201 } else { 202 window.addthis.toolbox('#social_sharing_links,.social_sharing_links'); 203 window.addthis.update('share', 'url', $('#social_sharing_params').attr('data-url')); 204 //addthis.url = $('#social_sharing_params').attr('data-url'); 205 206 } 207 $(".expander_detail #content").each(function () { 208 var id = $(this).attr('id') 209 $(this).attr('id', 'ajax_' + id) 210 }); 211 212 //change .image class to prevent dynamic grid sizing 213 $(".expander_detail .image").each(function () { 214 var base_class = $(this).attr('class') 215 $(this).attr('class', 'ajax_' + base_class) 216 }); 217 //scroll to show only half of clicked grid item 218 var scroll_offset = $(wrapper).offset().top + ($(wrapper).height() / 2); 219 if ($(window).width() <= 459) { 220 scroll_offset = $(wrapper).offset().top - 70; 221 } 222 var detail_above = $(wrapper).prevAll().find('.expander_detail'); 223 var existing_detail = $(wrapper).closest('ul').find('li').not(wrapper).find('.expander_detail'); 224 225 // If there is already an expanded area above, work out the final scroll position once this area is removed 226 if (detail_above.length > 0 && detail_above.closest('li').offset().top != $(wrapper).offset().top) { 227 scroll_offset = scroll_offset - $(wrapper).prevAll().find('.expander_detail').height(); 228 } 229 if (existing_detail.length > 0 && existing_detail.closest('li').offset().top == $(wrapper).offset().top) { 230 $(wrapper).addClass('no-animation'); 231 } 232 233 $(wrapper).closest('ul').find('li').not(wrapper).find('.expander_detail').remove(); 234 235 var wrapper_height = $(wrapper).height(); 236 $(wrapper).closest('ul').find('li').css('height', wrapper_height); 237 $(wrapper).css('height', $('#image_gallery', wrapper).outerHeight() + wrapper_height); 238 239 $('.expander_detail,.expander_detail #content_module:not(.content_module), .expander_detail .content_module,', wrapper).css({ 240 'height': $('.expander_detail #image_gallery', wrapper).outerHeight(), 241 'opacity': '1' 242 }); 243 $('.expander_detail #image_gallery', wrapper).append('<button class="close" aria-label="Close expanded detail view">Close</button>'); 244 $('.expander_detail .close', wrapper).click(function () { 245 window.galleries.image_gallery.detail_expand_grid.close_work($(wrapper).closest('ul')); 246 }); 247 $('html,body').animate( 248 {scrollTop: scroll_offset}, 249 400, 250 'easeInOutQuad' 251 ); 252 $(wrapper).removeClass('loading'); 253 $(wrapper).closest('ul').find('li').removeClass('no-animation'); 254 $('.expander_detail .ps_item a', wrapper).click(function (e) { 255 e.preventDefault(); 256 if ($(this).hasClass('ps_next')) { 257 $(this).closest('.detail_expand_grid').find('ul li.active').next('li').find('a').trigger('click'); 258 } else if ($(this).hasClass('ps_previous')) { 259 $(this).closest('.detail_expand_grid').find('ul li.active').prev('li').find('a').trigger('click'); 260 } 261 }); 262 $(".expander_detail #content_module #secondary_image_thumbnails a").attr('rel', 'group'); 263 264 window.galleries.artworks.init(); 265 }, 200); 266 267 268 detail_expand_load_work_ajax_request = undefined; 269 }, 270 waitForAll: true 271 }); 272 273 $("#ajax_content_module #secondary_image_thumbnails a").fancybox({ 274 'overlayShow': true, 275 'overlayOpacity': 0.7, 276 'overlayColor': '#d9d9d9', 277 'imageScale': 'true', 278 'zoomOpacity': 'true', 279 prevEffect: 'fade', 280 nextEffect: 'fade', 281 closeEffect: 'fade', 282 openEffect: 'fade', 283 afterLoad: function () { 284 $(".fancybox-overlay").addClass("fancybox-overlay-image"); 285 }, 286 helpers: { 287 title: { 288 type: 'inside' 289 } 290 } 291 }); 292 //window.galleries.image_gallery.standard(); 293 if (h.element_exists('.store_item')) { 294 window.cart.add_to_cart($('.store_item .store_item_add_to_cart')); 295 window.cart.remove_from_cart($('.store_item .store_item_remove_from_cart')); 296 } 297 298 /* 299 Placeholder function to call after the AJAX event completes. 300 Functionality can be added in main.js with window.galleries.image_gallery.detail_expand_grid.afterLoadWork = function(){...} 301 */ 302 window.galleries.image_gallery.detail_expand_grid.afterLoadWork(); 303 304 } 305 }); 306 } 307 }, 308 309 afterLoadWork: function () { 310 311 h.accessibility.closeWithEscapeKey('.expander_detail .close'); 312 $('.detail_expand_grid ul li.active > a:first-child').attr("aria-expanded", "true").focus() 313 314 }, 315 316 close_work: function (artworks_wrapper) {
317 if ($(artworks_wrapper).length > 0) { 318 $(artworks_wrapper).find('.expander_detail').closest('li').each(function () { 319 $('.detail_expand_grid ul li.active > a:first-child').attr("aria-expanded", "false") 320 $('.expander_detail', this).css('height', '0').css('opacity', '0'); 321 $('.expander_detail', this).remove(); 322 $(this).removeClass('active').height($('> a', this).height()); 323 }); 324 $(artworks_wrapper).find('.expander_detail'); 325 $('.detail_expand_grid ul li.active .artwork_detail_wrapper').removeAttr("tabindex"); 326 } 327 } 328 329 }, 330 331 slider: { 332 333 init: function () { 334 $('#ig_slider, .ig_slider').each(function () { 335 if (!$(this).hasClass('ig_slider_single_image') && !$(this).hasClass('slick-slider')) { 336 window.galleries.image_gallery.slider.load(this); 337 window.galleries.image_gallery.slider.max_height(); 338 $(window).resize(function () { 339 window.galleries.image_gallery.slider.max_height(); 340 Artlogic.import('plugins/slick.js').then(function (m) { 341 if ($('#ig_slider, .ig_slider').hasClass('slick-initialized')) { 342 $('#ig_slider, .ig_slider').slick('setPosition'); 343 } 344 }); 345 }); 346 } else { 347 window.galleries.image_gallery.slider.max_height(); 348 $(window).resize(function () { 349 window.galleries.image_gallery.slider.max_height(); 350 }); 351 } 352 }); 353 }, 354 355 load: function (ig_instance) { 356 var slide_count = $('.item', ig_instance).length; 357 var variable_width = true; 358 if (slide_count <= 2) { 359 variable_width = false; 360 } 361 var startingSlide = 0; 362 if ($(ig_instance).find('.item.starting_slide').length) { 363 startingSlide = $(ig_instance).find('.item.starting_slide').index(); 364 } 365 Artlogic.import('plugins/slick.js').then(function (m) { 366 $(ig_instance).slick({ 367 infinite: true, 368 speed: 300, 369 slidesToShow: 1, 370 accessibility: true, //left right arrow keys 371 centerMode: true, 372 variableWidth: variable_width, 373 autoplay: false, 374 autoplaySpeed: 6000, 375 arrows: true, 376 centerPadding: '0', 377 lazyLoad: 'progressive', 378 initialSlide: startingSlide, 379 focusOnChange: true 380 }); 381 window.galleries.image_gallery.slider.max_height(); 382 }); 383 384 385 // Before slide change 386 $(ig_instance).on('beforeChange', function (slick, currentSlide) { 387 var ig_slideshow_wrapper = $(slick.target).closest('.ig_slider_container_wrapper'); 388 if ($('#ig_slider_caption, .ig_slider_caption', ig_slideshow_wrapper).length) { 389 $('#ig_slider_caption, .ig_slider_caption', ig_slideshow_wrapper).addClass('transition'); 390 } 391 }); 392 $(ig_instance).on('afterChange', function (slick, currentSlide) { 393 var ig_slideshow_wrapper = $(slick.target).closest('.ig_slider_container_wrapper'); 394 if ($('#ig_slider_caption, .ig_slider_caption', ig_slideshow_wrapper).length) { 395 window.galleries.image_gallery.slider.caption(ig_slideshow_wrapper); 396 window.galleries.image_gallery.slider.form_image(ig_slideshow_wrapper); 397 } 398 399 $(window).trigger('resize'); 400 }); 401 402 }, 403 404 max_height: function () { 405 $('#ig_slider, .ig_slider').each(function () { 406 var slick_carousel_container = $(this); 407 ////Use original image dimensions to scale proportionally 408 var slideshow_width = $(slick_carousel_container).width(); 409 var windowHeight = $(window).height(); 410 411 412 var slideshow_ratio = 1.8;
413 if ($(this).attr('data-slideshow-ratio')) { 414 slideshow_ratio = $(this).attr('data-slideshow-ratio'); 415 } 416 //ideal slideshow height, a ratio of the width 417 var proportional_height = Math.floor(slideshow_width / slideshow_ratio); 418 419 var upperLimit = 550; 420 if ($(slick_carousel_container).attr('data-carousel-max-height')) { 421 upperLimit = $(slick_carousel_container).attr('data-carousel-max-height'); 422 } 423 424 var set_height = upperLimit; 425 //if the proportional height can't fit into the window height, use the window height instead 426 if (proportional_height > windowHeight) { 427 proportional_height = windowHeight; 428 } 429 //allow the slideshow to scale proportionately, up to the upper limit 430 if (proportional_height < upperLimit) { 431 set_height = proportional_height; 432 } else { 433 set_height = upperLimit; 434 } 435 436 $('.item', this).each(function (i) { 437 var scaleRatio = set_height / $(this).data('imgheight'); 438 var scaledHeight = Math.round($(this).data('imgheight') * scaleRatio); 439 var scaledWidth = Math.round($(this).data('imgwidth') * scaleRatio); 440 if (isNaN($(this).data('imgheight'))) { 441 scaledHeight = set_height; 442 } 443 $(this).height(scaledHeight).width(scaledWidth).find('img').height(scaledHeight).width(scaledWidth); 444 }); 445 $('#ig_slider_container_outer, #ig_slider_container, #ig_slider, .ig_slider_container_outer, .ig_slider_container, .ig_slider, .ig_slider_container .slick-list, .ig_slider_container .slick-track, .feature_panels .panel_slider .slider_panel_fill').height(set_height); 446 }); 447 }, 448 449 caption: function (slick_carousel_wrapper) { 450 $('#ig_slider_caption, .ig_slider_caption', slick_carousel_wrapper).removeClass('transition'); 451 ////Load the caption into the caption space, from data attribute 452 var caption = $(".slick-slide.slick-center", slick_carousel_wrapper).attr('data-caption'); 453 $('#ig_slider_caption, .ig_slider_caption', slick_carousel_wrapper).html(caption); 454 slick_carousel_wrapper.find(".ig_slider_tools").find(".enquire_button_container").find(".button").find("a").attr("data-contact-form-details", caption); 455 //change to support multi slider and enquiry form caption 456 }, 457 458 form_image: function (slick_carousel_wrapper) { 459 var current_image_path = slick_carousel_wrapper.find(".slick-current").find('img').attr("src"); 460 slick_carousel_wrapper.find(".ig_slider_tools").find(".enquire_button_container").find(".button").find("a").attr("data-contact-form-image", current_image_path); 461 //change to support multi slider and enquiry form image 462 }, 463 override_settings: function (target, data) { 464 //console.log("override setings"); 465 466 Artlogic.import('plugins/slick.js').then(function (m) { 467 $(target).slick('unslick'); 468 $(target).slick({data}); 469 }); 470 471 //console.log("override done"); 472 473 } 474 475 476 }, 477 478 dynamic: function () { 479 var slideshow_selector = '.ig_slideshow_container'; 480 if ($(slideshow_selector).length < 1) { 481 slideshow_selector = '#ig_slideshow_container'; 482 } 483 484 $(slideshow_selector).each(function () { 485 486 var onfunction = $('#ig_slideshow', this).on; 487 if (onfunction) { 488 // Method for jQuery Cycle 2 ONLY 489 // Function fired directly after the slideshow is initialized 490 $('#ig_slideshow', this).on('cycle-post-initialize', function (event, optionHash) { 491 492 var this_instance = $(this).closest('#ig_slideshow_container'); 493 window.setTimeout(function () { 494 495 //console.log("find height = " + $('#ig_slideshow > .item:eq(0)', this_instance).find('img').height()); 496 if ($('#ig_slideshow .item.cycle-slide:eq(0)', this_instance).find('img').height() > 0 && $('#ig_slideshow .item.cycle-slide:eq(0)', this_instance).find('img').height() > $('#ig_slideshow', this_instance).height()) { 497 $('#ig_slideshow', this_instance).height($('#ig_slideshow .item.cycle-slide:eq(0)', this_instance).find('img').height()); 498 499 } 500 501 }, 400); 502 }); 503 504 // Display the controller count 505 if ($('#ig_slideshow_controller_count').length > 0) { 506 $('#ig_slideshow_controller_count').html('1 ' + $('#ig_slideshow_controller_count').attr('data-separator') + ' ' + $('#ig_slideshow >').not('cycle-sentinel').length); 507 if ($('#ig_slideshow >').not('cycle-sentinel').length < 2) { 508 $('#ig_slideshow_controller').addClass('ig_slideshow_controller_single_item'); 509 } 510 } 511 512 // Display the first caption 513 // Dan - I have started working on adding an enquire button for the works slideshow layout 514 var initial_caption = ($('#ig_slideshow > :eq(0)', this).attr('data-rel') && typeof $('#ig_slideshow > :eq(0)', this).attr('data-rel') != 'undefined' ? $('#ig_slideshow > :eq(0)', this).attr('data-rel') : $('#ig_slideshow > :eq(0)', this).attr('rel')); 515 // var initial_enquire_button = $('#ig_slideshow > :eq(0)', this).find('.enquire').clone(); 516 if ($('#ig_slideshow .item.item_starting_slide').length) { 517 initial_caption = ($('#ig_slideshow .item.item_starting_slide', this).attr('data-rel') && typeof $('#ig_slideshow .item.item_starting_slide', this).attr('data-rel') != 'undefined' ? $('#ig_slideshow .item.item_starting_slide', this).attr('data-rel') : $('#ig_slideshow .item.item_starting_slide', this).attr('rel')); 518 // var initial_enquire_button = $('#ig_slideshow .item.item_starting_slide', this).find('.enquire').clone(); 519 }
520 if (initial_caption && typeof initial_caption != 'undefined') { 521 initial_caption = initial_caption.replace(/\n/g, ''); 522 } 523 524 $('#ig_slideshow_caption, .ig_slideshow_caption', this).html(initial_caption); 525 526 // Optional: Some sites can include an external custom defined caption area, this doesn't relate to the current slideshow instance 527 $('#ig_slideshow_caption_external').html(initial_caption); 528 529 // $('#ig_slideshow_enquire').html(initial_enquire_button); 530 531 // Function fired directly before the slide changes 532 $('#ig_slideshow', this).on('cycle-before', function (event, optionHash, outgoingSlideEl, incomingSlideEl, forwardFlag) { 533 var this_instance = $(this).closest('#ig_slideshow_container'); 534 var this_caption = ($(incomingSlideEl, this_instance).attr('data-rel') && typeof $(incomingSlideEl, this_instance).attr('data-rel') != 'undefined' ? $(incomingSlideEl, this_instance).attr('data-rel') : $(incomingSlideEl, this_instance).attr('rel')); 535 if (this_caption && typeof this_caption != 'undefined') { 536 this_caption = this_caption.replace(/\n/g, ''); 537 } 538 $('#ig_slideshow_caption, .ig_slideshow_caption', this_instance).html(this_caption); 539 // Optional: Some sites can include an external custom defined caption area, this doesn't relate to the current slideshow instance 540 $('#ig_slideshow_caption_external').html(this_caption); 541 542 // var this_enquire_button = $(incomingSlideEl, this_instance).find('.enquire').clone(); 543 // console.log(this_enquire_button); 544 // $('#ig_slideshow_enquire').html(this_enquire_button); 545 // window.galleries.contact_form_popup.init(); 546 547 if ($('#ig_slideshow_controller_count').length > 0) { 548 $('#ig_slideshow_controller_count').html(optionHash.nextSlide + 1 + ' ' + $('#ig_slideshow_controller_count').attr('data-separator') + ' ' + optionHash.slideCount); 549 } 550 $('#ig_slideshow_thumbnails a', this_instance).removeClass('active'); 551 552 var selected_slide_index = $('#ig_slideshow >', this_instance).not('.cycle-sentinel').index(incomingSlideEl); 553 554 // Use data-rel if available (changed for W3C compliance), otherwise fall-back to rel 555 if ($('#ig_slideshow_thumbnails a[data-rel=' + selected_slide_index + ']').length) { 556 var active_thumbnail = $('#ig_slideshow_thumbnails a[data-rel=' + selected_slide_index + ']'); 557 } else { 558 var active_thumbnail = $('#ig_slideshow_thumbnails a[rel=' + selected_slide_index + ']'); 559 } 560 active_thumbnail.addClass('active'); 561 }); 562 563 // Function fired directly after the slide has changed 564 $('#ig_slideshow', this).on('cycle-after', function (event, optionHash, outgoingSlideEl, incomingSlideEl, forwardFlag) { 565 566 }); 567 } 568 569 570 var autoHeight = 'container'; 571 if ($('#ig_slideshow', this).attr('data-cycle-autoheight-setting')) { 572 autoHeight = $("#ig_slideshow", this).attr('data-cycle-autoheight-setting'); 573 } 574 575 var cycleSpeed = 1200; 576 if ($('#ig_slideshow', this).attr('data-cycle-speed-setting')) { 577 cycleSpeed = $("#ig_slideshow", this).attr('data-cycle-speed-setting'); 578 } 579 580 var cycleFx = 'fade'; 581 if ($('#ig_slideshow', this).attr('data-cycle-fx-setting')) { 582 cycleFx = $("#ig_slideshow", this).attr('data-cycle-fx-setting'); 583 } 584 585 var startingSlide = 0; 586 if ($('#ig_slideshow .item.item_starting_slide').length) { 587 startingSlide = $('#ig_slideshow .item.item_starting_slide').index(); 588 } 589 590 var newsettings; 591 if ($('#ig_slideshow', this).attr('data-cycle-custom-sett
591ings')) { 592 newsettings = JSON.parse($('#ig_slideshow', this).attr('data-cycle-custom-settings').replace(/'/g, '"')); 593 } 594 595 var mastersettings = { 596 fx: cycleFx, 597 speed: cycleSpeed, 598 timeout: 6000, 599 pause: 0, 600 601 slides: '>', 602 //autoHeight: 'calc', 603 autoHeight: autoHeight, 604 swipe: true, 605 startingSlide: startingSlide 606 } 607 608 for (var newkey in newsettings) { 609 mastersettings[newkey] = newsettings[newkey]; 610 } 611 612 $('#ig_slideshow', this) 613 .cycle(mastersettings) 614 .each(function () { 615 console.log('found a show') 616 if ($('.artwork_video_link', this).length > 0) { 617 var artwork_video_object = $('.artwork_video_object', this); 618 $('.artwork_video_link', this).click(function () { 619 $(this).hide(); 620 artwork_video_object.html($(this).attr('rel')); 621 return false; 622 }); 623 } 624 625 $(this).on('cycle-initialized', function (event, optionHash, outgoingSlideEl, incomingSlideEl, forwardFlag) { 626 if ($('.artwork_video_link', this).length > 0) { 627 var artwork_video_object = $('.artwork_video_object', this); 628 $('.artwork_video_link', this).click(function () { 629 $(this).hide(); 630 artwork_video_object.html($(this).attr('rel')); 631 return false; 632 }); 633 } 634 }); 635 636 // NEW CODE //// 637 var onfunction = $(this).on; 638 if (onfunction) { 639 $(this).on('cycle-post-initialize', function (event, optionHash) { 640 window.galleries.image_gallery.initialized(event, optionHash); 641 }); 642 // Function fired directly before the slide has changed 643 $(this).on('cycle-before', function (event, optionHash, outgoingSlideEl, incomingSlideEl, forwardFlag) { 644 window.galleries.image_gallery.after(event, optionHash, outgoingSlideEl, incomingSlideEl, forwardFlag); 645 if (history.replaceState && $(incomingSlideEl).attr('data-href')) { 646 var new_url = $(incomingSlideEl).attr('data-href'); 647 history.replaceState(null, null, new_url); 648 } 649 }); 650 } 651 652 653 }) 654 ; 655 656 657 $('#ig_slideshow_thumbnails a:eq(0)', this).addClass('active'); 658 659 // Accessibility - Make the links act as buttons 660 $('#ig_slideshow_thumbnails a', this).attr("role", "button"); 661 h.accessibility.role_button(); 662 663 $('#ig_slideshow_thumbnails a', this).click(function () { 664 var this_instance = $(this).closest('#ig_slideshow_container'); 665 $('#ig_slideshow .artwork_video_object', this_instance).html(''); 666 $('#ig_slideshow .artwork_video_link', this_instance).show(); 667 $('#ig_slideshow', this_instance).cycle('pause'); 668 669 var slide_index = false; 670 if ($(this).attr('data-rel') && typeof $(this).attr('data-rel') != 'undefined') { 671 slide_index = $(this).attr('data-rel'); 672 } else if ($(this).attr('rel') && typeof $(this).attr('rel') != 'undefined') { 673 slide_index = $(this).attr('rel'); 674 } 675 if (slide_index) { 676 $('#ig_slideshow', this_instance).cycle(parseInt(slide_index)); 677 } 678 return false; 679 }); 680 681 if ($("#ig_slideshow_thumbnails_container", this).hasClass('ig_thumbnails_type_scroller')) { 682 if (!$("#ig_slideshow_thumbnails_container", this).hasClass('ig_thumbnails_type_scroller_disabled')) { 683 684 var scroller_type = ''; 685 if ($("#ig_slideshow_thumbnails_container", this).hasClass('ig_thumbnails_type_scroller_click')) { 686 scroller_type = 'clickButtons'; 687 } 688 689 if (!window.galleries.device.handheld()) { 690 691 window.galleries.jscroller_start.init($("#ig_slideshow_thumbnails_container", this), scroller_type); 692 693 } else { 694 695 $("#ig_slideshow_thumbnails_container", this).addClass('ig_thumbnails_type_scroller_handheld'); 696 697 } 698 699 if ($('#ig_slideshow_thumbnails', this).width() < $('#ig_slideshow_thumbnails_container', this).width()) { 700 $('#ig_slideshow_thumbnails_container', this).addClass('ig_slideshow_thumbnails_inactive'); 701 } 702 703 } 704 } else { 705 706 //count the ul's and add first and last classes 707 var ul_count = parseInt($('#ig_slideshow_thumbnails', this).find('ul').length) - 1; 708 $('#ig_slideshow_thumbnails ul', this).eq(0).addClass('first'); 709 $('#ig_slideshow_thumbnails ul', this).eq(ul_count).addClass('last'); 710 //check if support for on method 711 if (onfunction) { 712 $('#ig_slideshow_thumbnails', this).on('cycle-update-view', function (event, optionHash, slideOptionsHash, currentSlideEl) { 713 var this_instance = $(this).closest('#ig_slideshow_container'); 714 $('#ig_slideshow_thumbnails_container', this_instance).removeClass('last_slide_active').removeClass('first_slide_active'); 715 //slidecount 716 //optionHash.slideCount 717 //optionHash.currSlide 718 //console.log(optionHash.slideCount); 719 if (optionHash && typeof optionHash != 'undefined') { 720 if (optionHash.slideCount > 1) { 721 //check if current slide is last and add class 722 if (optionHash.currSlide == optionHash.slideCount - 1) { 723 $('#ig_slideshow_thumbnails_container', this_instance).addClass('last_slide_active'); 724 } 725 //check if current slide is the first add class first 726 if (optionHash.currSlide == 0) { 727 $('#ig_slideshow_thumbnails_container', this_instance).addClass('first_slide_active'); 728 } 729 } 730 } 731 }); 732 }//end of if onfunction 733 734 735 $('#ig_slideshow_thumbnails', this).cycle({ 736 fx: 'scrollHorz', 737 speed: 500, 738 timeout: 1000, 739 slides: '>' 740 }); 741 $('#ig_slideshow_thumbnails', this).cycle('pause'); 742 $('#ig_slideshow_thumbnails_prev a', this).click(function () { 743 var this_instance = $(this).closest('#ig_slideshow_container'); 744 $('#ig_slideshow_thumbnails', this_instance).cycle('prev'); 745 return false;
746 }); 747 $('#ig_slideshow_thumbnails_next a', this).click(function () { 748 var this_instance = $(this).closest('#ig_slideshow_container'); 749 $('#ig_slideshow_thumbnails', this_instance).cycle('next'); 750 return false; 751 }); 752 } 753 754 $('#ig_slideshow_controller').each(function () { 755 $('#ig_slideshow_controller_prev a').click(function () { 756 var this_instance = $('#ig_slideshow_container'); 757 $('#ig_slideshow').cycle('pause').cycle('prev'); 758 return false; 759 }); 760 $('#ig_slideshow_controller_next a').click(function () { 761 var this_instance = $('#ig_slideshow_container'); 762 $('#ig_slideshow').cycle('pause').cycle('next'); 763 return false; 764 }); 765 }); 766 767 }); 768 769 }, 770 771 initialized: function () { 772 773 }, 774 775 after: function () { 776 777 } 778 779}; 780 781window.galleries = window.galleries || {}; 782window.galleries.image_gallery = image_gallery; 783export default image_gallery;
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.