(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: 'user144', album: 'citroen-c4-1', title: 'Citroen C4 1', 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: 'user144/citroen-c4-1/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/autoua/c128/TNJr9zV3y9XMh849sw0X.jpg", ""],["/images/autoua/c128/1rr93VORRdbyKNC8V8HE.jpg", ""],["/images/autoua/c128/XbVTQnO6Byo2DLvdydXd.jpg", ""],["/images/autoua/c128/v15cLmfwJSuSlF3dpBUf.jpg", ""],["/images/autoua/c128/l2GV3XOD4Brh6WKSRsEh.jpg", ""],["/images/autoua/c128/MD72b8h3EfWVF4dWv4es.jpg", ""],["/images/autoua/c128/N9ehtfiPrRhtTMWYu8ar.jpg", ""],["/images/autoua/c128/W7c69TZ4ifnH0cUkCG7S.jpg", ""],["/images/autoua/c128/60vQQ7qhusIjsm1PhHUu.jpg", ""],["/images/autoua/c128/uaRBIrFwPtNzMYl5HOiW.jpg", ""],["/images/autoua/c128/gNoVb3jwoFdfbok1UKw8.jpg", ""],["/images/autoua/c128/OJ1fneacgTGSj3xvd6fj.jpg", ""],["/images/autoua/c128/A0iYIJHGzXIM1HtHViaz.jpg", ""],["/images/autoua/c128/vHS4oDuSZt0Fzk1RPzLj.jpg", ""],["/images/autoua/c128/pxHvDVpBMsytZN2LuXeR.jpg", ""],["/images/autoua/c128/HsTUdoZ0J8hp50OJZDr0.jpg", ""],["/images/autoua/c128/m1WnZEbUzZxXaUSptx7G.jpg", ""],["/images/autoua/c128/Y8XSQU1YhcaHzTLpcpyY.jpg", ""],["/images/autoua/c128/0MCMezMZglFX2VXCJume.jpg", ""],["/images/autoua/c128/Bber2LTX5EvEKoLRHMJm.jpg", ""],["/images/autoua/c128/MFGhDsMD1eeqAYe2YRIw.jpg", ""],["/images/autoua/c128/LD3BlTU2BK40FLpnR10i.jpg", ""],["/images/autoua/c128/fpoVCtlC0SazFsOGnGqE.jpg", ""],["/images/autoua/c128/lyTAuH8DIJa5di3YYzuB.jpg", ""],["/images/autoua/c128/LfxCqKPuS96IwzdBtf8m.jpg", ""],["/images/autoua/c128/FZRvAPzqKeAnSWszhZfy.jpg", ""],["/images/autoua/c128/ZBjrubchkhb8a3f9M9wA.jpg", ""],["/images/autoua/c128/HuSYx2grobSLbsIL0WgR.jpg", ""],["/images/autoua/c128/YHqfJXvBAOAvd6Lu2jiI.jpg", ""],["/images/autoua/c128/H5Fwz2Zu7iZxFgwxCRMU.jpg", ""],["/images/autoua/c128/zlQEIY0HJbTiOdS8XZ9V.jpg", ""],["/images/autoua/c128/3JpiDOLTgwuV9favkbnV.jpg", ""],["/images/autoua/c128/KfGbDN4piqJ4IaFDB9VI.jpg", ""],["/images/autoua/c128/xR6dHfCGpeECHu80fKrP.jpg", ""],["/images/autoua/c128/prjwsQ8DmJhWh3T9PolK.jpg", ""],["/images/autoua/c128/UHXKtiVu1PUN4FmtSlKU.jpg", ""],["/images/autoua/c128/TghZigCOa6gEh9tq3Rli.jpg", ""],["/images/autoua/c128/m5Um0Pjt49K3pEG18DUN.jpg", ""],["/images/autoua/c128/noyAwG5et17Mm8yI4CeC.jpg", ""],["/images/autoua/c128/Shvmkue2DnfnLuFmT2xb.jpg", ""],["/images/autoua/c128/OHCi9qKPZfAalDw9ivNR.jpg", ""],["/images/autoua/c128/GGxJtyxfR7fkY8037Efi.jpg", ""],["/images/autoua/c128/LspQPpC2m4vCRjNj8pbv.jpg", ""],["/images/autoua/c128/0BFFRoSC0IbepnwgpGf4.jpg", ""],["/images/autoua/c128/CSKPUdDxCdjHOem8wKBp.jpg", ""],["/images/autoua/c128/rBapWD43lzotXTXN510W.jpg", ""],["/images/autoua/c128/vRMBs6ynxCEhsXsLXm8F.jpg", ""],["/images/autoua/c128/CiOYBL9tHsqXCdDQLMjU.jpg", ""],["/images/autoua/c128/AuSbr5FtS5RkOxanyxQ0.jpg", ""],["/images/autoua/c128/P3sKhsIqz8RtwduoIcP4.jpg", ""],["/images/autoua/c128/yFFxhZydngitLhasRG6v.jpg", ""],["/images/autoua/c128/ea9QPXLZPYY7mx7UIZzC.jpg", ""],["/images/autoua/c128/Kf2S2gNh6FER9H8UsPsO.jpg", ""],["/images/autoua/c128/kVhLFzSOoQgbgbIHKxMQ.jpg", ""],["/images/autoua/c128/gr9dssXq5isFmx2YF0Sv.jpg", ""],["/images/autoua/c128/CvZ5Yh3r2UfVZk1OIIz0.jpg", ""],["/images/autoua/c128/AC9a0QkX6Euhf8LfcLnJ.jpg", ""],["/images/autoua/c128/BRnh6EzNTpOMr5meMQNU.jpg", ""],["/images/autoua/c128/SpWdasdsPTErccpJDktg.jpg", ""],["/images/autoua/c128/50SpLeHF3LIJOf0UNoHr.jpg", ""],["/images/autoua/c128/JU0smPOtHm3i8oCZofoN.jpg", ""],["/images/autoua/c128/qpuKPRWATaHgRSgMpjJ9.jpg", ""],["/images/autoua/c128/oHP6W74yXc1Im9PCev8h.jpg", ""],["/images/autoua/c128/HYqTvjp6ko9HecB0MmcJ.jpg", ""],["/images/autoua/c128/wfNLxITLbVC7EHnJ1PHQ.jpg", ""],["/images/autoua/c128/VKlW5w0EaqftTWCpaD1I.jpg", ""],["/images/autoua/c128/rPXLvx2lAoW1opwvoyG8.jpg", ""],["/images/autoua/c128/HCqfuI0VaLjpeeMV9SLJ.jpg", ""],["/images/autoua/c128/xTkFtJ3CwkkxkE3FlRFW.jpg", ""],["/images/autoua/c128/AxiTbt5Cuw0XkCyCkqzX.jpg", ""],["/images/autoua/c128/ra7JfO4hPyXtQjxtBpRf.jpg", ""],["/images/autoua/c128/jCW66j89LCYiRcWxW8sC.jpg", ""],["/images/autoua/c128/BSMRvNFgH4ZaX8JRUG8O.jpg", ""],["/images/autoua/c128/LBsyRyCoeEtpDsJ1npTx.jpg", ""],["/images/autoua/c128/fbDNVN7ZCyuF9ommpXUb.jpg", ""],["/images/autoua/c128/BBbkZWase6rQSFhK7L4O.jpg", ""],["/images/autoua/c128/fnoEH8mzvQ4N9PzbvkU5.JPG", ""],["/images/autoua/c128/XqrkKGiabhj7wucj4GRB.JPG", ""],["/images/autoua/c128/L3d1TdXQWBKiOKdG7yOc.JPG", ""],["/images/autoua/c128/Gw3qq3dqzTBCq48uwUMk.JPG", ""],["/images/autoua/c128/16wMOYnd0JvQoqGd5Wub.JPG", ""],["/images/autoua/c128/RhXLHIidghmsWD7iS6M8.JPG", ""],["/images/autoua/c128/DV4bv0Is4CLqP2X20G2h.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 = ' \ { title } \ '; 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); }); })();