| 1 |
import {Lightbox} from "./Lightbox"; |
| 2 |
|
| 3 |
export class PhotonicPrettyPhoto extends Lightbox { |
| 4 |
constructor($) { |
| 5 |
super(); |
| 6 |
this.$ = $; |
| 7 |
} |
| 8 |
|
| 9 |
swipe() { |
| 10 |
const $ = this.$; |
| 11 |
$('.pp_hoverContainer').remove(); |
| 12 |
$("#pp_full_res") |
| 13 |
.on('swipeleft', function() { $.prettyPhoto.changePage('next'); }) |
| 14 |
.on('swiperight', function() { $.prettyPhoto.changePage('previous'); }); |
| 15 |
}; |
| 16 |
|
| 17 |
soloImages() { |
| 18 |
const $ = this.$; |
| 19 |
$('a[href]').filter(function() { |
| 20 |
return /(\.jpg|\.jpeg|\.bmp|\.gif|\.png)/i.test( $(this).attr('href')); |
| 21 |
}).filter(function() { |
| 22 |
const res = new RegExp('photonic-prettyPhoto').test($(this).attr('rel')); |
| 23 |
return !res; |
| 24 |
}).attr("rel", 'photonic-prettyPhoto'); |
| 25 |
}; |
| 26 |
|
| 27 |
changeVideoURL(element, regular, embed) { |
| 28 |
this.$(element).attr('href', regular); |
| 29 |
}; |
| 30 |
|
| 31 |
initialize(e) { |
| 32 |
const $ = this.$; |
| 33 |
// this.handleSolos(); // Can't do this here since initialize is not called directly |
| 34 |
const self = this; |
| 35 |
|
| 36 |
$("a[rel^='photonic-prettyPhoto']").prettyPhoto({ |
| 37 |
theme: Photonic_JS.pphoto_theme, |
| 38 |
autoplay_slideshow: Photonic_JS.slideshow_mode, |
| 39 |
slideshow: Photonic_JS.slideshow_interval, |
| 40 |
show_title: false, |
| 41 |
social_tools: '', |
| 42 |
deeplinking: false, |
| 43 |
changepicturecallback: function() { |
| 44 |
const img = $('#fullResImage'); |
| 45 |
if (e !== undefined && e['deep'] === undefined) { |
| 46 |
const clicked_thumb = $(e.target).parent(), |
| 47 |
clicked_div = $(clicked_thumb).parent(), |
| 48 |
current_stream = $(clicked_div).parent(); |
| 49 |
|
| 50 |
let active_node = $(current_stream).find('a[href="' + $(img).attr('src') + '"]'); |
| 51 |
|
| 52 |
if (active_node.length === 0) { |
| 53 |
$.each($('div.title-display-regular, div.title-display-below, div.title-display-tooltip, div.title-display-hover-slideup-show, div.title-display-slideup-stick, '+ |
| 54 |
'ul.title-display-regular, ul.title-display-below, ul.title-display-tooltip, ul.title-display-hover-slideup-show, ul.title-display-slideup-stick'), function(key, value) { |
| 55 |
active_node = $(this).find('a[href="' + $(img).attr('src') + '"]'); |
| 56 |
if (active_node.length !== 0) { |
| 57 |
return false; |
| 58 |
} |
| 59 |
}); |
| 60 |
} |
| 61 |
|
| 62 |
if (active_node.length > 0) { |
| 63 |
self.setHash(active_node[0]); |
| 64 |
} |
| 65 |
} |
| 66 |
else if (e['deep'] !== undefined) { |
| 67 |
const idx = e['images'].indexOf($(img).attr('src')); |
| 68 |
if (idx > -1) { |
| 69 |
self.setHash(e['deep'][idx]); |
| 70 |
} |
| 71 |
} |
| 72 |
|
| 73 |
const shareable = { |
| 74 |
'url': location.href, |
| 75 |
'title': $('.pp_description').text(), |
| 76 |
'image': img.attr('src') |
| 77 |
}; |
| 78 |
self.addSocial('#pp_full_res', shareable); |
| 79 |
|
| 80 |
self.swipe(); |
| 81 |
}, |
| 82 |
callback: function() { |
| 83 |
self.unsetHash(); |
| 84 |
} |
| 85 |
}); |
| 86 |
}; |
| 87 |
|
| 88 |
initializeForExisting() { |
| 89 |
const $ = this.$; |
| 90 |
const self = this; |
| 91 |
|
| 92 |
$(document).on('click', "a[rel^='photonic-prettyPhoto']", function(e) { |
| 93 |
e.preventDefault(); |
| 94 |
self.initialize(e); |
| 95 |
this.click(); |
| 96 |
}); |
| 97 |
|
| 98 |
$("a[rel^='photonic-prettyPhoto-video'],a[rel^='photonic-prettyPhoto-html5-video']").prettyPhoto({ |
| 99 |
theme: Photonic_JS.pphoto_theme, |
| 100 |
autoplay_slideshow: Photonic_JS.slideshow_mode, |
| 101 |
slideshow: Photonic_JS.slideshow_interval, |
| 102 |
show_title: false, |
| 103 |
social_tools: '', |
| 104 |
deeplinking: false |
| 105 |
}); |
| 106 |
}; |
| 107 |
} |