slimbox/autoload.js

23 lines
820 B
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

// AUTOLOAD CODE BLOCK (MAY BE CHANGED OR REMOVED)
addListener(window, 'load', function(){
if (!/android|iphone|ipod|series60|symbian|windows ce|blackberry/i.test(navigator.userAgent)) {
var as = document.getElementsByTagName('A');
var links = [];
var w = 100*Math.floor((document.documentElement.offsetWidth*0.8)/100);
var h = 100*Math.floor((document.documentElement.offsetHeight*0.8)/100);
var t;
for (var i = 0; i < as.length; i++) {
if (as[i].getAttribute('rel') == 'lightbox') {
t = as[i].title;
t += ' <a href="'+as[i].href+'" target="_blank">'+(t?'(с':'С')+'м. полный размер'+(t?')':'')+'</a>';
links.push({
element: as[i],
url: as[i].href + (as[i].href.indexOf('?') ? '&' : '?') + ('w='+w+'&h='+h),
title: t
});
}
}
setSlimbox(links);
}
});