(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: 'test-drajv-renault-espace-initiale-paris', title: 'Тест-драйв Renault Espace Initiale Paris', 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/test-drajv-renault-espace-initiale-paris/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/6A4jPBfcxuqiZajl8yr6.jpg", ""],["/images/autoua/c128/XxvAiEiZYuF0sCvXWGXX.jpg", ""],["/images/autoua/c128/ZRsn0Nlt0qITe7N3rpAj.jpg", ""],["/images/autoua/c128/Jt9Zh72ZpJuuo1YA6WJn.jpg", ""],["/images/autoua/c128/dmldRlCkUxab7EQJBV4m.jpg", ""],["/images/autoua/c128/mROgUTQIItIsaHL1hWOj.jpg", ""],["/images/autoua/c128/Sm4AFyzxGDSoSduFiGC1.jpg", ""],["/images/autoua/c128/wLlJCg7ay1B5nYoxo5r2.jpg", ""],["/images/autoua/c128/8y7bWBC4Jt73S1Qja4oA.jpg", ""],["/images/autoua/c128/XMBBBWBNzzvg0T2r7DPj.jpg", ""],["/images/autoua/c128/qRuEfLtCxDFrTPB2trLM.jpg", ""],["/images/autoua/c128/aMlptjykcS9ccwPhszMt.jpg", ""],["/images/autoua/c128/FBfVT1uAzIf2hV26BoI3.jpg", ""],["/images/autoua/c128/Jj840isMrKRVKHME7xwv.jpg", ""],["/images/autoua/c128/94G0S6pv5PMWBMLXAjqy.jpg", ""],["/images/autoua/c128/kA1uvX0grzXeXOWwbUdS.jpg", ""],["/images/autoua/c128/e5FfmVdnd7Ll4CaMFEuO.jpg", ""],["/images/autoua/c128/ppyCTo35NFbw3nCuBAGD.jpg", ""],["/images/autoua/c128/NUOz2wYzg4POYckM3P5Y.jpg", ""],["/images/autoua/c128/rSteIfKHNZ9BboMNwV73.jpg", ""],["/images/autoua/c128/jiBIx2Ps1riGUGGhpqLy.jpg", ""],["/images/autoua/c128/2s7nwWeXboQ2Qxdn28jX.jpg", ""],["/images/autoua/c128/LUyDQP7eDt8YbpAZ5V8d.jpg", ""],["/images/autoua/c128/atMcBAbF1mO8hTu6uCPq.jpg", ""],["/images/autoua/c128/H8jo7yi13tnljVCLUHgm.jpg", ""],["/images/autoua/c128/LUGvjBgjHJ4wZ7MrUBHj.jpg", ""],["/images/autoua/c128/ZdOxcdsiEihghYERSAwq.jpg", ""],["/images/autoua/c128/Yrl0KxHWySUH1Mnmik7B.jpg", ""],["/images/autoua/c128/mQkctweWMlTG3X3Cf9fQ.jpg", ""],["/images/autoua/c128/STUWVoOJuqZx4rfSI1d9.jpg", ""],["/images/autoua/c128/zE84hhRA0vSWYZy5W887.jpg", ""],["/images/autoua/c128/WuCCraSt4jL5lc53rh3B.jpg", ""],["/images/autoua/c128/yGzB8L1MtlNe5RPj35cd.jpg", ""],["/images/autoua/c128/EytCy4ZMvvGnmM3GaPwR.jpg", ""],["/images/autoua/c128/jESr3Gfmf7lxiWn7sWGN.jpg", ""],["/images/autoua/c128/VMkEK3bBe4NEZRiO23bg.jpg", ""],["/images/autoua/c128/GB74mIXBhMvLOz81YaC6.jpg", ""],["/images/autoua/c128/Lht7AP3wwUOUfihpU56Q.jpg", ""],["/images/autoua/c128/OhE8LSzBC9evGOXZAKuj.jpg", ""],["/images/autoua/c128/uRQRHNisKvrdT9UO9juJ.jpg", ""],["/images/autoua/c128/6qJ1dy59w2DG80iFoNzH.jpg", ""],["/images/autoua/c128/9V9Sm7F93t1EV98yHqiK.jpg", ""],["/images/autoua/c128/MwAefN6C4Dd3rXu1Jf2E.jpg", ""],["/images/autoua/c128/vD98obWmCnQuj6LBOAzU.jpg", ""],["/images/autoua/c128/YZmsaKeaXVComHJDEA6X.jpg", ""],["/images/autoua/c128/0HS8HLqiERSwLynli1J2.jpg", ""],["/images/autoua/c128/ZA0BsPX9UBYmLlaF31pa.jpg", ""],["/images/autoua/c128/o08Ecea5K6VKB6ZF5gdZ.jpg", ""],["/images/autoua/c128/zO6Yhi7gDmuUda0EACyP.jpg", ""],["/images/autoua/c128/ROjiuJIvRzHCiKJSAtAg.jpg", ""],["/images/autoua/c128/vkGyFBZ4K8Dlz0ZPD70N.jpg", ""],["/images/autoua/c128/UwrBucABdGTXTRjFuVFX.jpg", ""],["/images/autoua/c128/UnowE5Ed4AtkidA0mBGu.jpg", ""],["/images/autoua/c128/3lP67N682XRFsbzSmJh8.jpg", ""],["/images/autoua/c128/2rpARKOfkDKkM0MqDEr2.jpg", ""],["/images/autoua/c128/7RkVjXET64ZwkNIGAasp.jpg", ""],["/images/autoua/c128/CmiHkmEBZ0LU51W4Pks8.jpg", ""],["/images/autoua/c128/Ft0I4KpWc39sfY4MlIk3.jpg", ""],["/images/autoua/c128/mgRAuQu3gDrJKFln4rpm.jpg", ""],["/images/autoua/c128/KmTIPd3H2WFeHyKvKvDs.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); }); })();