(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: 'nissan-x-trail-1', title: 'Nissan X-Trail 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/nissan-x-trail-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/Q4BzVevUbGCgKWk2fR09.jpg", ""],["/images/autoua/c128/yuBvFF0vBJYX0vFwOKdg.jpg", ""],["/images/autoua/c128/XDCu5vCupMGpf88g9y4u.jpg", ""],["/images/autoua/c128/wc97PoBUCLtUsRTXFmec.jpg", ""],["/images/autoua/c128/sU4BGgIgXJ3ebMO4it47.jpg", ""],["/images/autoua/c128/YoiUqKhUu533A4PRTWQR.jpg", ""],["/images/autoua/c128/7TRS3HwZnFJaqlmeZOwF.jpg", ""],["/images/autoua/c128/2KOgsX2b38qmoZvgrKZE.jpg", ""],["/images/autoua/c128/TALjnSVX6qcxnRnycOFm.jpg", ""],["/images/autoua/c128/EgXvdl7mcmsExq9Qaz74.jpg", ""],["/images/autoua/c128/0ii5s2l4ExCvMoXTSyMq.jpg", ""],["/images/autoua/c128/FxVzYSINSpE9iEX0g4x9.jpg", ""],["/images/autoua/c128/nRvFtDhTxBOIY0ChzOZi.jpg", ""],["/images/autoua/c128/XiZpFTDPG8VmJqhG9E21.jpg", ""],["/images/autoua/c128/9Og7TroEnDXPEJ2gWY0K.jpg", ""],["/images/autoua/c128/VhuhciENirErz5DW9ciK.jpg", ""],["/images/autoua/c128/g7LhKLoM7tP18QvVT6nm.jpg", ""],["/images/autoua/c128/rjVggUXRPTuwjr4ENOxy.jpg", ""],["/images/autoua/c128/nNpHlT7n9kgcjoBTCvg3.jpg", ""],["/images/autoua/c128/DsuCh9E5mhv6oixqZSNq.jpg", ""],["/images/autoua/c128/5YqMMPBLlLfRLguyVoKj.jpg", ""],["/images/autoua/c128/sVDOViVcSpwbrKgzVhdx.jpg", ""],["/images/autoua/c128/E32LfsRhKirah9Vy1p4h.jpg", ""],["/images/autoua/c128/9UFmurXkiPNhsDeTUSPk.jpg", ""],["/images/autoua/c128/6gCm0X6rB4okKG1HtoKB.jpg", ""],["/images/autoua/c128/eHOi3aUfDIPPgrmHcoo3.jpg", ""],["/images/autoua/c128/W8R44oPW9OZtYVPeotpy.jpg", ""],["/images/autoua/c128/N7ediCDNleFrChHl82nx.jpg", ""],["/images/autoua/c128/adBQo5bRtDTepj9tQdIU.jpg", ""],["/images/autoua/c128/XvUZSNyG2dnNsUHKgLmp.jpg", ""],["/images/autoua/c128/4dUa8slgmrgSF2xJFiV6.jpg", ""],["/images/autoua/c128/B0X5sErWlXUaFppN76Ti.jpg", ""],["/images/autoua/c128/tkxHxroPlj1t85m7alyi.jpg", ""],["/images/autoua/c128/IufsQTTuTw1bL8YoTkHF.jpg", ""],["/images/autoua/c128/zV6yDI8RC3cihCQkovKM.jpg", ""],["/images/autoua/c128/YiXSCao8gre3k27mbixL.jpg", ""],["/images/autoua/c128/WBHCm8t6wjvcXHaPbiNE.jpg", ""],["/images/autoua/c128/09IPImXaaNOz0UyERDMq.jpg", ""],["/images/autoua/c128/NvfAuvzkaL4uNrWfvG7j.jpg", ""],["/images/autoua/c128/wked8gyQZiqwCxqRIuOK.jpg", ""],["/images/autoua/c128/M9nSpwQotGG3U8KSCigK.jpg", ""],["/images/autoua/c128/I3pzmIuYZcBswan2Sh1M.jpg", ""],["/images/autoua/c128/sI6kcsuZII8lTjBvSgi0.jpg", ""],["/images/autoua/c128/xJRduhGy71hm8GRNpfTj.jpg", ""],["/images/autoua/c128/0D7VpgT63bBMYMB0LTgd.jpg", ""],["/images/autoua/c128/HrovGeyDEpItT5TRewLM.jpg", ""],["/images/autoua/c128/cF7BiR91rOaD49m6NFkN.jpg", ""],["/images/autoua/c128/fTBzKXz7JlMRTTnUXA9x.jpg", ""],["/images/autoua/c128/ZutSkQW6tqbJTrhSuhH7.jpg", ""],["/images/autoua/c128/dH4Iiuh82mdJXhxp4g1H.jpg", ""],["/images/autoua/c128/i2wz5bt08tmvTeIPuzQg.jpg", ""],["/images/autoua/c128/uvwzAemcvsZfF6yM7Qe9.jpg", ""],["/images/autoua/c128/XCTmNN5z5ThDjjEYFXxH.jpg", ""],["/images/autoua/c128/igc8NtY8I3nxVTMmyY72.jpg", ""],["/images/autoua/c128/T8zSsH074bfACUOCAzbk.jpg", ""],["/images/autoua/c128/7I634VEWsanbefPcjk6S.jpg", ""],["/images/autoua/c128/ehzTfr3tazhDDW2lJdDS.jpg", ""],["/images/autoua/c128/YvbhL59sQzDBfyeZhnQu.jpg", ""],["/images/autoua/c128/sNPnUeWDopbFWWT4UVYz.jpg", ""],["/images/autoua/c128/i26p7r6Egcjy6IkdyDHx.jpg", ""],["/images/autoua/c128/jaDUM9D3473D0moenQlv.jpg", ""],["/images/autoua/c128/bvUA5LGwX1KGrK3nEoh6.jpg", ""],["/images/autoua/c128/KA1A8r1OoBLDYLcOTETX.jpg", ""],["/images/autoua/c128/f4WnrTR8zenfzfxnWKlE.jpg", ""],["/images/autoua/c128/yJBGDYbgCUsCzfVFUJ9w.jpg", ""],["/images/autoua/c128/EsEWBK1jg7YFgvV515qc.jpg", ""],["/images/autoua/c128/Ryrfx3BYnT93N9JTdZa8.jpg", ""],["/images/autoua/c128/jmJLthv0vRSNw43NJZi1.jpg", ""],["/images/autoua/c128/RSB1nJAAINZCpXatZHTM.jpg", ""],["/images/autoua/c128/b4VuyBbROCsML7abyiQJ.jpg", ""],["/images/autoua/c128/qWuuKsqzUe82UoBi6x4E.jpg", ""],["/images/autoua/c128/8PKBusTchladq3ibvfRx.jpg", ""],["/images/autoua/c128/34yvOzJxem4LaRD2Vkpg.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); }); })();