(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-patrol-1', title: 'Nissan Patrol 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-patrol-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/t6iBh1LS3Xvlbz4vAAi7.jpg", ""],["/images/autoua/c128/YwyEIIuBHMzGdZLomvPc.jpg", ""],["/images/autoua/c128/hrlZFE2fxvfs7Q4IjCRG.jpg", ""],["/images/autoua/c128/UhE48Fqgqq1aljkPEYcI.jpg", ""],["/images/autoua/c128/oap1rujLL5DbyDGbxd8k.jpg", ""],["/images/autoua/c128/xrcnvxzdD5zUGvhWeXzc.jpg", ""],["/images/autoua/c128/Mc4t1Rz1u5kPiUvxwQj7.jpg", ""],["/images/autoua/c128/UAtw44W3u4VtCrBJKLsZ.jpg", ""],["/images/autoua/c128/RiKe5WrzwShDIPnneTOF.jpg", ""],["/images/autoua/c128/MkYsMTCm4DAIN0aBoUhv.jpg", ""],["/images/autoua/c128/Sdt6LHXpU2Oa6sct0eIw.jpg", ""],["/images/autoua/c128/EzJZTiCmoYzc3Bjqoeny.jpg", ""],["/images/autoua/c128/i6dHoPm5WshJXtMSDdCc.jpg", ""],["/images/autoua/c128/wvmydZFYvmMYdKM0UUd3.jpg", ""],["/images/autoua/c128/1YNifF2kiUwp2jluXyWk.jpg", ""],["/images/autoua/c128/TQB3HDbCluQUjmzzN9Pn.jpg", ""],["/images/autoua/c128/r4aWVzjGwhuEthfaFI3I.jpg", ""],["/images/autoua/c128/rsKxoslJu9vPtqvyngns.jpg", ""],["/images/autoua/c128/UbPva0m2HPCBrQgwW2Z2.jpg", ""],["/images/autoua/c128/Mdn6lOdYqlTrEEDAWOAc.jpg", ""],["/images/autoua/c128/bYWFsg8doOfvIAk6HheL.jpg", ""],["/images/autoua/c128/p3kYuHRf27avEj0a362k.jpg", ""],["/images/autoua/c128/Jdkx2X5uTMvqq1OGfih2.jpg", ""],["/images/autoua/c128/Hhkvlj9Lj215OeywTjS7.jpg", ""],["/images/autoua/c128/Hgv7kcLqTCD44p0cYvG6.jpg", ""],["/images/autoua/c128/NhjyLt6i9KhfZNVoSq8Y.jpg", ""],["/images/autoua/c128/ncfe2qwJ4XV0byISdajj.jpg", ""],["/images/autoua/c128/SkRkAu106I1OTCpCcgab.jpg", ""],["/images/autoua/c128/wocXb8fiAsegYZgm1hFH.jpg", ""],["/images/autoua/c128/x3PniGVbqlGzz7hc5zmX.jpg", ""],["/images/autoua/c128/HXwEiSETyC4S2Po2Lih7.jpg", ""],["/images/autoua/c128/uf8CYAcqZI92E4WIkAWh.jpg", ""],["/images/autoua/c128/uO3ZFzOBJWTCxXS0rOD9.jpg", ""],["/images/autoua/c128/mYt624SoprRZNo0fZipt.jpg", ""],["/images/autoua/c128/hMghHJ3kxqqr9eyNfiv0.jpg", ""],["/images/autoua/c128/S5COCyHj9tZ8zAXjX2DW.jpg", ""],["/images/autoua/c128/nDTvBLTsZHb92ByBJoe3.jpg", ""],["/images/autoua/c128/ffaddvvAsyMZxzfZB1PB.jpg", ""],["/images/autoua/c128/71JPSEayDD7GT6FmW1EO.jpg", ""],["/images/autoua/c128/Cpu9iH5h4IQq9qa2DBbC.jpg", ""],["/images/autoua/c128/JtrvGhzobCPR1sObZkPj.jpg", ""],["/images/autoua/c128/hh0WXttezgNZFSJwidhR.jpg", ""],["/images/autoua/c128/WeXJ3sciv1bzjTFyv4Nv.jpg", ""],["/images/autoua/c128/jtNt4XPT4dAb1ZjJqZmZ.jpg", ""],["/images/autoua/c128/M6YBJOgllnZh4PLjbQIv.jpg", ""],["/images/autoua/c128/oExtMsBTkhYog2PyIRS4.jpg", ""],["/images/autoua/c128/trTon94TtstzR4tTGfAy.jpg", ""],["/images/autoua/c128/LNLJUigyplISTJ3zP1lr.jpg", ""],["/images/autoua/c128/AwaNEnyenTsQyTgBa74d.jpg", ""],["/images/autoua/c128/Aty6Z1ff6C88W5pEBXtO.jpg", ""],["/images/autoua/c128/MbHl1Z8RvAnNihFpgkxS.jpg", ""],["/images/autoua/c128/kZOteb9ho8rJLMgm0vmc.jpg", ""],["/images/autoua/c128/sYGvJNAOwj0fZYfwHqp3.jpg", ""],["/images/autoua/c128/X3RNLJpZQsV7oqlT7czK.jpg", ""],["/images/autoua/c128/2INJIY2vmswBfvkYoDeo.jpg", ""],["/images/autoua/c128/wOj0BoBN4ERtnTVw2bMF.jpg", ""],["/images/autoua/c128/3TVQbEm3pcVbgxFldq5d.jpg", ""],["/images/autoua/c128/VjNnEv4AHid4qILRKG7m.jpg", ""],["/images/autoua/c128/O9BV0E8jxI8MxWHa9jaS.jpg", ""],["/images/autoua/c128/Isb3eaFC4qTfNt97I8X8.jpg", ""],["/images/autoua/c128/Vjvee4baWHdfvd6oIDh8.jpg", ""],["/images/autoua/c128/SzFKU8YqG2c7ahVPspX9.jpg", ""],["/images/autoua/c128/EZNE5jj8SHE82uuUtJXg.jpg", ""],["/images/autoua/c128/CputacTGTBoaVE9si4xP.jpg", ""],["/images/autoua/c128/YfPyOCuGMJYKcIzSK9kZ.jpg", ""],["/images/autoua/c128/TE9FDuErroeyIOnvhPZt.jpg", ""],["/images/autoua/c128/FAlZpKWPnqkxfV7pdKMv.jpg", ""],["/images/autoua/c128/hCYwOA6UB0zU7rxTPpn3.jpg", ""],["/images/autoua/c128/wqTEAcswcWEBg2xP2VdJ.jpg", ""],["/images/autoua/c128/XDKLuu3h3TIDnlq0F6xR.jpg", ""],["/images/autoua/c128/Xb4QXLPtv5TwfC5X0aBZ.jpg", ""],["/images/autoua/c128/VuPQkldmnCNq4EmH62ku.jpg", ""],["/images/autoua/c128/2PEnyi6vwXpsr4dQn8dP.jpg", ""],["/images/autoua/c128/zck9gyOgWgBEDF77u9aC.jpg", ""],["/images/autoua/c128/292Qumec2LBJK3uy5QCn.jpg", ""],["/images/autoua/c128/tEHPReeFDH5P2hdl7Tzy.jpg", ""],["/images/autoua/c128/jQPgQfhBKndOyPAUXRYa.jpg", ""],["/images/autoua/c128/mgl21AIG046U69gx32mo.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); }); })();