Files
intern2020/static/init.js
2020-12-07 09:57:30 +00:00

39 lines
1.1 KiB
JavaScript

$(
function(){
console.log("init loaded")
})
$(function (){
document.getElementById('links').onclick = function(event) {
event = event || window.event
var target = event.target || event.srcElement,
link = target.src ? target.parentNode : target,
options = { index: link, event: event },
links = this.getElementsByTagName('a')
options['onslide']=function(index,slide) {
console.log(index)
console.log($(`#links a:nth-child(${index})`).attr('id'))
history.replaceState(null,null,'#'+$(`#links a:nth-child(${index+1})`).attr('id'))
}
options['onclose']=function(){
history.pushState(null,null,'#')
}
blueimp.gallery=blueimp.Gallery(links, options)
}
window.onpopstate = function(){
console.log(`popped state ${$(location).attr('hash')}`)
if($(location).attr('hash')=="") {
blueimp.gallery.close()
}else {
$($(location).attr('hash')).trigger('click');
}
}
console.log($(location).attr('hash').substr(1))
$($(location).attr('hash')).trigger('click');
})