App-sitelenmute
view release on metacpan or search on metacpan
share/view/index.js view on Meta::CPAN
function flash()
{
eflash.setStyle('display', 'block');
eflash.tween('opacity', 1, 0);
}
function prev()
{
if(eidx != 0)
switchTo(eidx - 1);
else
{
flash();
switchTo(imgs.data.length - 1);
}
}
function next()
{
if(eidx != imgs.data.length - 1)
switchTo(eidx + 1);
else
{
flash();
switchTo(0);
}
}
function switchTo(i)
{
window.location.replace("#" + i);
}
function load(i)
{
if(i == eidx) return;
var data = imgs.data[i];
var assets = Asset.images([data.img[0], data.blur? data.blur: []],
{
onComplete: function() { if(i == eidx) onMainReady(); }
});
if(!oimg) oimg = eimg;
eimg = assets[0];
eimg.idx = eidx = i;
if(cthumb) cthumb.removeClass('current');
cthumb = imgs.data[eidx].ethumb;
cthumb.addClass('current');
resetTimeout(tthr);
tthr = showThrobber.delay(thrdelay);
}
function getLocationIndex()
{
var hash = window.location.hash;
var idx = parseInt(!hash.indexOf('#')? hash.substr(1): hash);
if(isNaN(idx) || idx < 0)
idx = 0;
else if(idx >= imgs.data.length)
idx = imgs.data.length - 1;
return idx;
}
function change()
{
load(getLocationIndex());
}
function loadThumb(i)
{
var x = imgs.data[i];
x.eimg.setStyle('background-image', 'url("' + x.thumb[0] + '")');
x.thumbLoaded = true;
}
function initGallery(data)
{
// prepare the data
imgs = data;
if(imgs.name) document.title = imgs.name;
imgs.captions = false;
capst = 'normal';
for(var i = 0; i != imgs.data.length; ++i)
{
if(imgs.data[i]['caption'])
{
imgs.captions = true;
break;
}
}
// build the dom
emain = $('gallery');
emain.setStyle('display', 'none');
eback = new Element('img', { id: 'background' });
eback.inject(emain);
enoise = new Element('div', { id: 'noise' });
enoise.inject(emain);
econt = new Element('div', { id: 'content' });
econt.inject(emain);
ebuff = new Element('div');
ebuff.inject(econt);
eflash = new Element('div', { id: 'flash' });
eflash.setStyles({ 'opacity': 0, 'display': 'none' });
eflash.set('tween',
{
duration: duration,
link: 'cancel',
onComplete: function() { eflash.setStyle('display', 'none'); }
});
eflash.inject(econt);
( run in 1.365 second using v1.01-cache-2.11-cpan-5735350b133 )