(function() {
var mobile = (/iphone|ipod|android|blackberry|mini|windows\sce|palm/i.test(navigator.userAgent.toLowerCase()));
var ipad = (/ipad/i.test(navigator.userAgent.toLowerCase()));
var t = function(str, data) {
// template helper
for (var i in data) {
str = str.replace(new RegExp('{ ' + i + ' }', 'g'), data[i]);
}
return str;
}
// Global options
var options = {
user: 'user539',
album: 'peugeot-rcz-diesel',
title: 'Peugeot RCZ Diesel',
base_url: 'https://photo.torba.com',
css_url: 'https://photo.torba.com/media/lightbox2/light.css?v1',
default_size: '128',
preview_size: 128,
preview_css: 'display:inline; margin:0 3px 0 0; border:1px solid #ccc;',
image_size: 1000,
image_crop_type: (false) ? 'c': 'f',
popup_html: '\u0009\u0009\u003Cdiv id\u003D\u0022torba\u002Dfader\u0022\u003E\u003C/div\u003E\u000A\u0009\u0009\u003Cdiv id\u003D\u0022torba\u002Dlightbox\u0022\u003E\u000A\u0009\u0009\u0009\u003Cdiv class\u003D\u0022torba\u002Dlightbox\u002Dside\u002Dwrap\u0022\u003E\u000A\u0009\u0009\u0009\u0009\u003Cdiv class\u003D\u0022torba\u002Dlightbox\u002Dside\u0022\u003E\u000A\u0009\u0009\u0009\u0009\u0009\u003Cdiv class\u003D\u0022torba\u002Dlightbox\u002Dside\u002Dcont\u0022\u003E\u000A\u0009\u0009\u0009\u0009\u0009\u0009\u003Ca class\u003D\u0022torba\u002Dlightbox\u002Dclose\u0022\u003E\u003C/a\u003E\u000A\u0009\u0009\u0009\u0009\u0009\u0009\u003Cspan class\u003D\u0022torba\u002Dlightbox\u002Dimg\u002Dnum\u0022\u003E\u003C/span\u003E\u000A\u0009\u0009\u0009\u0009\u0009\u0009\u003Cdiv class\u003D\u0022torba\u002Dlightbox\u002Dtitle\u0022\u003E\u003C/div\u003E\u000A\u0009\u0009\u0009\u0009\u0009\u0009\u003Cdiv class\u003D\u0022torba\u002Dlightbox\u002Ddescr\u0022\u003E\u003C/div\u003E\u000A\u0009\u0009\u0009\u0009\u0009\u003C/div\u003E\u000A\u0009\u0009\u0009\u0009\u0009\u003Cdiv class\u003D\u0022torba\u002Dlightbox\u002Dbanner\u0022\u003E\u000A\u0009\u0009\u0009\u0009\u0009\u0009\u003Ciframe id\u003D\u0022torba\u002Dlightbox\u002Diframe\u0022 style\u003D\u0022border: 0\u003B\u0022 width\u003D\u0022300\u0022 height\u003D\u0022610\u0022 src\u003D\u0022https://photo.torba.com/media/lightbox2/banner.html\u0022\u003E\u003C/iframe\u003E\u000A\u0009\u0009\u0009\u0009\u0009\u003C/div\u003E\u000A\u0009\u0009\u0009\u0009\u003C/div\u003E\u000A\u0009\u0009\u0009\u003C/div\u003E\u000A\u0009\u0009\u0009\u003Cdiv class\u003D\u0022torba\u002Dlightbox\u002Dcont\u002Dwrap\u0022\u003E\u000A\u0009\u0009\u0009\u0009\u003Cdiv class\u003D\u0022torba\u002Dlightbox\u002Dcont\u0022\u003E\u000A\u0009\u0009\u0009\u0009\u0009\u003Cimg id\u003D\u0022torba\u002Dlightbox\u002Dimage\u0022 src\u003D\u0022\u0022 alt\u003D\u0022\u0022 /\u003E\u000A\u000A\u0009\u0009\u0009\u0009\u0009\u003Cdiv class\u003D\u0022torba\u002Dlightbox\u002Dnav\u002Dwrap\u0022\u003E\u000A\u0009\u0009\u0009\u0009\u0009\u0009\u003Cdiv class\u003D\u0022torba\u002Dlightbox\u002Dnav\u0022\u003E\u000A\u0009\u0009\u0009\u0009\u0009\u0009\u0009\u003Cspan class\u003D\u0022torba\u002Dlightbox\u002Dnav\u002Dleft\u0022\u003E\u000A\u0009\u0009\u0009\u0009\u0009\u0009\u0009\u0009\u003Cspan class\u003D\u0022torba\u002Dlightbox\u002Dnav\u002Dleft\u002Dshad\u0022\u003E\u000A\u0009\u0009\u0009\u0009\u0009\u0009\u0009\u0009\u0009\u003Cspan class\u003D\u0022torba\u002Dlightbox\u002Dnav\u002Dleft\u002Dimg\u0022\u003E\u003C/span\u003E\u000A\u0009\u0009\u0009\u0009\u0009\u0009\u0009\u0009\u003C/span\u003E\u000A\u0009\u0009\u0009\u0009\u0009\u0009\u0009\u003C/span\u003E\u000A\u0009\u0009\u0009\u0009\u0009\u0009\u0009\u003Cspan class\u003D\u0022torba\u002Dlightbox\u002Dnav\u002Dright\u0022\u003E\u000A\u0009\u0009\u0009\u0009\u0009\u0009\u0009\u0009\u003Cspan class\u003D\u0022torba\u002Dlightbox\u002Dnav\u002Dright\u002Dshad\u0022\u003E\u000A\u0009\u0009\u0009\u0009\u0009\u0009\u0009\u0009\u0009\u003Cspan class\u003D\u0022torba\u002Dlightbox\u002Dnav\u002Dright\u002Dimg\u0022\u003E\u003C/span\u003E\u000A\u0009\u0009\u0009\u0009\u0009\u0009\u0009\u0009\u003C/span\u003E\u000A\u0009\u0009\u0009\u0009\u0009\u0009\u0009\u003C/span\u003E\u000A\u0009\u0009\u0009\u0009\u0009\u0009\u003C/div\u003E\u000A\u0009\u0009\u0009\u0009\u0009\u003C/div\u003E\u000A\u0009\u0009\u0009\u0009\u003C/div\u003E\u000A\u0009\u0009\u0009\u003C/div\u003E\u000A\u0009\u0009\u003C/div\u003E\u000A',
url_template: 'user539/peugeot-rcz-diesel/photo{ number }',
url_re: new RegExp('(user\\d+)\/([\\w-]+)\/photo(\\d+)')
}
// append album container after script
document.write(t(
'',
{user: options.user, album: options.album}
));
// TorbaAlbum class
var TorbaAlbum = function(options) {
var self = this;
self.options = options;
self.album_name = self.options.user + '-' + self.options.album;
self.init();
}
TorbaAlbum.prototype.init = function() {
var self = this;
// init album container & album wrapper
self.album = $('#' + self.album_name);
self.album.css({
width: '100%',
overflow: 'hidden',
margin:'10px 0',
position: 'relative'
});
self.album_inner = $('div.torba-album-inner', self.album);
if (!self.album_inner.length) {
self.album.append('');
self.album_inner = $('div.torba-album-inner', self.album);
}
self.parse([["/images/taranenko/c128/G3E4REX2wuLwhgE1FIFr.jpg", ""],["/images/taranenko/c128/tb6qrplXi1Wr4uHJc4pq.jpg", ""],["/images/taranenko/c128/TlyuJbY8qbQ7rNj1alOh.jpg", ""],["/images/taranenko/c128/RtbEL60v5Xeo4Ea7XP5f.jpg", ""],["/images/taranenko/c128/ZB998RYTvKtjGS3wi3pC.jpg", ""],["/images/taranenko/c128/oaEJmVHD5QW2tEoWSwfk.jpg", ""],["/images/taranenko/c128/Gab9X7BXpoLj34VGXAqj.jpg", ""],["/images/taranenko/c128/8Qgkawn6uIp0b5rhA24O.jpg", ""],["/images/taranenko/c128/DbtQZ8Czyvjn0Oi97hze.jpg", ""],["/images/taranenko/c128/r7rcAhgj8Uqarp8nmI9h.jpg", ""],["/images/taranenko/c128/J6SObKroQn83I28kwMar.jpg", ""],["/images/taranenko/c128/WcmJtHb5UBaj2wGU1Dz0.jpg", ""],["/images/taranenko/c128/Nh2E1jAeu34w60PYBVcf.jpg", ""],["/images/taranenko/c128/kTDvTS6ei2ikOoQgaL0x.jpg", ""],["/images/taranenko/c128/GXhAgYBbeEiUsIwPOi7M.jpg", ""],["/images/taranenko/c128/TqFPifZFKzszk5RNseZh.jpg", ""],["/images/taranenko/c128/gf2Psx0umUlfeJyniLkI.jpg", ""],["/images/taranenko/c128/fxX90xqT3RCAEe7dgBrz.jpg", ""],["/images/taranenko/c128/Vzn7GUnVMgj0Yccd1R4R.jpg", ""],["/images/taranenko/c128/uZ7MUwZ4F5FNNT3OS8wI.jpg", ""],["/images/taranenko/c128/cPbqj7y6uXjPYCbvzwVt.jpg", ""],["/images/taranenko/c128/fXBHjU7olHIW0T279iM6.jpg", ""],["/images/taranenko/c128/rPh8znfXB6ev0DcLsTBe.jpg", ""],["/images/taranenko/c128/MNw9lTnkOQyMuXqOdc7e.jpg", ""],["/images/taranenko/c128/KzgdqzS9Lhrs4oKTfJSc.jpg", ""],["/images/taranenko/c128/H8U1U9jjPWEGpCBBliyt.jpg", ""],["/images/taranenko/c128/pEdk4V8z9FZ3TnJnLPfF.jpg", ""],["/images/taranenko/c128/m8ZSygZCEmXXacVtSP6i.jpg", ""],["/images/taranenko/c128/JwLvFopzr6iXnIP3s2sI.jpg", ""],["/images/taranenko/c128/u0YwuekdxchTnfrTsVU5.jpg", ""],["/images/taranenko/c128/Vfo5REObwyES7dYjGAJz.jpg", ""],["/images/taranenko/c128/JpCFKFvdAR7aFamkVQFq.jpg", ""],["/images/taranenko/c128/qwZ7x09d1pJSStnui68l.jpg", ""],["/images/taranenko/c128/XQ8blBvDSLHv84Stf0Vl.jpg", ""],["/images/taranenko/c128/F30IHsO1n8x4UMjEAnO6.jpg", ""],["/images/taranenko/c128/6Dly3Gpk8SJZBpbb1TAJ.jpg", ""],["/images/taranenko/c128/8T27R9U4H4loF456e7x1.jpg", ""],["/images/taranenko/c128/bdKl8W7hMDwn56xg8GBU.jpg", ""],["/images/taranenko/c128/igAsoUSTkjiAcumbongd.jpg", ""],["/images/taranenko/c128/DCzc5vtVr3cEmv7q8KYQ.jpg", ""],["/images/taranenko/c128/YP0wTkiy625e7LdxJnIg.jpg", ""],["/images/taranenko/c128/YaRC9wit9ttdUFQ7NRnO.jpg", ""],["/images/taranenko/c128/ejlz3joTb8PPG9elZPww.jpg", ""],["/images/taranenko/c128/PYDVgzG9gpMpkaIgAFWV.jpg", ""],["/images/taranenko/c128/nFy4VVpTybHlX1cwWs9D.jpg", ""],["/images/taranenko/c128/l0LHaU14OJMiUv1WyWu0.jpg", ""],["/images/taranenko/c128/beZzQnw4LLMbFSuy4Cb7.jpg", ""],["/images/taranenko/c128/UWvCk65QxOwIRGsMjpgC.jpg", ""],["/images/taranenko/c128/uDv5zQFOiMRP9u933Si8.jpg", ""],["/images/taranenko/c128/fqQ0CcC6Vhf1sX1cUpxF.jpg", ""]]);
}
TorbaAlbum.prototype.parse = function(photos) {
var self = this;
var photos_html = '';
var re = new RegExp('c' + self.options.default_size);
var preview_size = 'c' + self.options.preview_size;
var image_size = self.options.image_crop_type + self.options.image_size;
var gallery_photos = [];
// parse photos, generate html
for (var i = 0; i < photos.length; i += 1) {
// Task #6137
var photo = photos[i];
var title = '';
if (typeof(photo) != 'string') {
title = photo[1];
photo = photo[0];
}
var template = ' \
\
';
photos_html += t(template, {
photo: photo.replace(re, image_size),
url: self.options.base_url + photo.replace(re, image_size),
title: title,
preview_css: self.options.preview_css,
preview_url: self.options.base_url + photo.replace(re, preview_size)
});
gallery_photos.push(photo.replace(re, image_size));
}
// append generated html to album container
self.album_inner.html(photos_html);
// init gallery
if (!mobile) {
self.album_inner.find('a').click(function() {
self.init_gallery(gallery_photos, $(this).attr('data-src'));
return false;
});
}
var hash = window.location.hash;
var result = self.options.url_re.exec(hash);
if (result) {
// hash requires to init torba album
if (result[1] == self.options.user && result[2] == self.options.album) {
self.album_inner.find('a').eq(result[3] - 1).click();
}
}
}
TorbaAlbum.prototype.init_gallery = function(gallery_photos, initial_photo) {
var self = this;
self.index = gallery_photos.indexOf(initial_photo);
self.photos = gallery_photos;
$('#torba-fader, #torba-lightbox').remove();
$('body').append(self.options.popup_html);
self.show();
}
TorbaAlbum.prototype.show = function() {
var self = this;
var photo = self.photos[self.index];
var number = self.index + 1;
if (mobile || ipad) {
$('.torba-lightbox-nav').show();
}
$('#torba-lightbox-iframe').each(function() {
$(this).attr({
src: $(this).attr("src")
});
});
$('#torba-lightbox-image').attr('src', self.options.base_url + photo);
$('span.torba-lightbox-img-num').text(
t('{ number } из { count }', {
number: number,
count: self.photos.length
})
);
window.location.hash = t(self.options.url_template, {
number: number
});
// bind close
$('div.torba-lightbox-title').text(self.options.title);
$('div.torba-lightbox-descr').text(
self.album.find('img').eq(self.index).attr('alt')
);
$('a.torba-lightbox-close, #torba-fader').unbind('click').click(function() {
$('#torba-fader, #torba-lightbox').remove();
window.location.hash = '!';
return false;
});
$(document).unbind('keydown').keydown(function(e) {
if (e.keyCode == 27) {
$('#torba-fader, #torba-lightbox').remove();
window.location.hash = '!';
return false;
}
});
$('span.torba-lightbox-nav-left, span.torba-lightbox-nav-right').show();
if (number == 1) {
$('span.torba-lightbox-nav-left').hide();
}
if (number == self.photos.length) {
$('span.torba-lightbox-nav-right').hide();
}
// bind move left
$('span.torba-lightbox-nav-left').unbind('click').click(function() {
self.prev();
return false;
});
// bind move right
$('span.torba-lightbox-nav-right').unbind('click').click(function() {
self.next();
return false;
});
}
TorbaAlbum.prototype.prev = function() {
var self = this;
self.index -= 1;
self.show();
}
TorbaAlbum.prototype.next = function() {
var self = this;
self.index += 1;
self.show();
}
$(function() {
// Load css
$("", {
rel: "stylesheet",
type: "text/css",
href: options.css_url
}).appendTo('head');
new TorbaAlbum(options);
});
})();