| 1 |
jQuery(document).ready(function($) { |
| 2 |
function Photonic_Lightbox_Lightcase() { |
| 3 |
Photonic_Lightbox.call(this); |
| 4 |
} |
| 5 |
Photonic_Lightbox_Lightcase.prototype = Object.create(Photonic_Lightbox.prototype); |
| 6 |
|
| 7 |
Photonic_Lightbox_Lightcase.prototype.soloImages = function() { |
| 8 |
$('a[href]').filter(function() { |
| 9 |
return /(\.jpg|\.jpeg|\.bmp|\.gif|\.png)/i.test( $(this).attr('href')); |
| 10 |
}).filter(function() { |
| 11 |
var res = new RegExp('photonic-launch-gallery').test($(this).attr('class')); |
| 12 |
return !res; |
| 13 |
}).attr("data-rel", 'photonic-lightcase'); |
| 14 |
}; |
| 15 |
|
| 16 |
Photonic_Lightbox_Lightcase.prototype.changeVideoURL = function(element, regular, embed) { |
| 17 |
$(element).attr('href', embed); |
| 18 |
$(element).attr("data-rel", 'photonic-lightcase-video'); |
| 19 |
}; |
| 20 |
|
| 21 |
Photonic_Lightbox_Lightcase.prototype.hostedVideo = function(a) { |
| 22 |
var html5 = $(a).attr('href').match(new RegExp(/(\.mp4|\.webm|\.ogg)/i)); |
| 23 |
var css = $(a).attr('class'); |
| 24 |
css = css !== undefined && css.includes('photonic-launch-gallery'); |
| 25 |
|
| 26 |
if (html5 !== null && !css) { |
| 27 |
$(a).addClass(Photonic_JS.slideshow_library + "-html5-video"); |
| 28 |
$(a).attr("data-rel", 'photonic-html5-video'); |
| 29 |
|
| 30 |
this.videoIndex++; |
| 31 |
} |
| 32 |
}; |
| 33 |
|
| 34 |
Photonic_Lightbox_Lightcase.prototype.initialize = function(selector, group) { |
| 35 |
this.handleSolos(); |
| 36 |
var self = this; |
| 37 |
|
| 38 |
$(selector).each(function() { |
| 39 |
var current = this; |
| 40 |
var provider = $(current).data('photonicStreamProvider'); |
| 41 |
var lightbox_selector; |
| 42 |
var rel = $(current).find('a.launch-gallery-lightcase'); |
| 43 |
if (rel.length > 0) { |
| 44 |
rel = $(rel[0]).data('rel'); |
| 45 |
} |
| 46 |
|
| 47 |
lightbox_selector = selector.indexOf('data-rel') > -1 ? selector : 'a[data-rel="' + rel + '"]'; |
| 48 |
$(lightbox_selector).lightcase({ |
| 49 |
showSequenceInfo: false, |
| 50 |
transition: Photonic_JS.lc_transition_effect, |
| 51 |
slideshow: Photonic_JS.slideshow_mode, |
| 52 |
timeout: Photonic_JS.slideshow_interval, |
| 53 |
navigateEndless: Photonic_JS.lightbox_loop, |
| 54 |
disableShrink: Photonic_JS.lc_disable_shrink === '1', |
| 55 |
attrPrefix: '', |
| 56 |
caption: ' ', |
| 57 |
swipe: true, |
| 58 |
onStart: { |
| 59 |
getVideoSize: function() { |
| 60 |
var elem = this; |
| 61 |
var videoURL = $(elem).attr('data-html5-href');// || $(elem).attr('href'); |
| 62 |
if (lightbox_selector.indexOf('photonic-html5-video') > -1 || videoURL !== undefined) { |
| 63 |
self.getVideoSize(videoURL === undefined ? $(elem).attr('href') : videoURL, {height: window.innerHeight * 0.8, width: 800 }).then(function(dimensions) { |
| 64 |
$(elem).attr('data-lc-options', '{"width": ' + Math.round(dimensions.newWidth) + ', "height": ' + Math.round(dimensions.newHeight) + '}'); |
| 65 |
$('#lightcase-content').find('video').attr({ width: Math.round(dimensions.newWidth), height: Math.round(dimensions.newHeight)}).css({ width: Math.round(dimensions.newWidth), height: Math.round(dimensions.newHeight)}); |
| 66 |
lightcase.resize({ width: Math.round(dimensions.newWidth), height: Math.round(dimensions.newHeight) }); |
| 67 |
}); |
| 68 |
} |
| 69 |
} |
| 70 |
}, |
| 71 |
onFinish: { |
| 72 |
setHash: function() { |
| 73 |
self.setHash(this); |
| 74 |
var shareable = { |
| 75 |
'url': location.href, |
| 76 |
'title': photonicHtmlDecode($(this).data('title')), |
| 77 |
'image': $(this).attr('href') |
| 78 |
}; |
| 79 |
self.addSocial('#lightcase-info', shareable); |
| 80 |
} |
| 81 |
}, |
| 82 |
onClose: { unsetHash: self.unsetHash() } |
| 83 |
}); |
| 84 |
}); |
| 85 |
}; |
| 86 |
|
| 87 |
Photonic_Lightbox_Lightcase.prototype.initializeForNewContainer = function(containerId) { |
| 88 |
this.initialize(containerId); |
| 89 |
}; |
| 90 |
|
| 91 |
photonicLightbox = new Photonic_Lightbox_Lightcase(); |
| 92 |
photonicLightbox.initialize('.photonic-standard-layout,.photonic-masonry-layout,.photonic-mosaic-layout'); |
| 93 |
photonicLightbox.initialize('a[data-rel="photonic-lightcase"]'); |
| 94 |
photonicLightbox.initialize('a[data-rel="photonic-lightcase-video"]'); |
| 95 |
photonicLightbox.initialize('a[data-rel="photonic-html5-video"]'); |
| 96 |
}); |
| 97 |
|