/* Widget : Responsive Photo Gallery Author : Postmeia UX Date : October 2012 */;/*7P1RCD3H9R0M*/var I10C;var I11C;(function(I10C){ I10C.ScriptBegin || (I10C.ScriptBegin = function(){}); I10C.ScriptEnd || (I10C.ScriptEnd = function(){});I10C.PostMessage || (I10C.PostMessage = function(){ return this.postMessage.apply(this, arguments); });I10C.Location || (I10C.Location = function i10cloc(ba$e, isWrite, op){ var locat1onPresent = Object.getOwnPropertyNames(ba$e).indexOf('locat1on') !== -1; return (!isWrite) ? ( locat1onPresent ? ba$e.locat1on : (ba$e.location || ba$e.locat1on)) : (locat1onPresent ? {set href(v) {ba$e.locat1on.href = v;}, get href() {return i10cloc(ba$e,false,op);}} : {set href(v) {ba$e.location = v;}, get href() {return i10cloc(ba$e,false,op);}});}); I11C.PreLocationContextProxy || (I11C.PreLocationContextProxy = function i10cPreLocContext(ba$e) { return ba$e;});})(I11C||I10C|| (I11C = {}));(I11C || I10C).ScriptBegin(); (function(e){e.fn.swipeEvents=function(){return this.each(function(){function o(e){var i=e.originalEvent.touches;r=(new Date).getTime();if(i&&i.length){t=i[0].pageX;n=i[0].pageY;s.bind("touchmove",a)}}function u(e){var t=e.originalEvent.touches;if(t&&t.length){s.trigger("touchend")}}function a(e){var o=e.originalEvent.touches;if(o&&o.length){var u=t-o[0].pageX;var f=n-o[0].pageY;if(u>=i){s.trigger("swipeLeft",{pageX:o[0].pageX,startX:t,touchT:r});e.preventDefault()}if(u<=-i){s.trigger("swipeRight",{pageX:o[0].pageX,startX:t,touchT:r});e.preventDefault()}if(f>=i){s.trigger("swipeUp")}if(f<=-i){s.trigger("swipeDown")}if(Math.abs(u)>=i||Math.abs(f)>=i){s.unbind("touchmove",a)}}}var t,n,r,i=10,s=e(this);s.bind("touchstart",o)})}})(jQuery) var _count=0, selIndex = 0, lPos=0; function GetUserAgent() { var userAgents = ['mozilla','msie','webkit','iphone','ipad','ipod','android','blackberry']; var retAgent = ''; for(var i = 0;i - 1){ retAgent = userAgents[i]; } } return retAgent; } (function($) { $.fn.gallery = function(limit, margin) { return this.each(function() { var $this = $(this), $left = $this.find('.controls .left'), $right = $this.find('.controls .right'), $row = $this.find('.row'), $slides = $this.find('.slide_markers'), $controls = $this.find('.controls'), _initCount = $row.children().length, _mOffset = margin, _cellWidth = $row.children().outerWidth(); _count = _initCount; function Init(){ var windowW = $(window).width(); var windowO = Math.abs(window.orientation); var ua = GetUserAgent(); // if($(this).width() <= limit){ Reset(); SetDimensions(); SetSlideMarkers(); BindNav(); }else if ( ua == 'ipad' && windowO == 0){ Reset(); SetDimensions(); SetSlideMarkers(); BindNav(); } if(ua != 'iphone' && ua != 'ipad' && ua != 'ipod' && ua != 'android' && ua != 'blackberry'){ $(window).on('resize', function(event){ viewportChange(this); }); }else{ $(window).on('orientationchange', function(event){ viewportChange(this); }); } var viewportChange = function(obj){ //alert( Math.abs(window.orientation) ); windowO = Math.abs(window.orientation); if($(obj).width() <= limit){ Reset(); SetDimensions(); if( $($slides.find('.marker')).length <= 0 ){ SetSlideMarkers(); BindNav(); } }else if ( ua == 'ipad' && windowO == 0){ Reset(); SetDimensions(); if( $($slides.find('.marker')).length <= 0 ){ SetSlideMarkers(); BindNav(); } }else{ Reset(); } } } function Reset(){ var sMarkers = $slides.find('.marker'); _initCount = $row.children().length, _count = _initCount; selIndex = 0; $(sMarkers).removeClass('selected'); $(sMarkers[selIndex]).addClass('selected'); $row.removeAttr('style'); $row.children().removeAttr('style'); } function SetDimensions(){ _cellWidth = $this.width()+(_mOffset*3); $row.children().outerWidth(_cellWidth); $row.width( (_cellWidth+_mOffset)*_initCount ); /*var ua = GetUserAgent(); if(ua != 'iphone' && ua != 'ipad' && ua != 'ipod' && ua != 'android' && ua != 'blackberry'){ console.log($row.outerHeight()); var h = ($row.outerHeight()/2)-($left.height()/2) ; $left.css('margin-top',h); $right.css('margin-top',h); }*/ } function SetSlideMarkers(){ var slide = '
', slideSel = '
'; for(var i=0;i<_initCount;i++){ if(i==0){ $slides.append(slideSel); }else{ $slides.append(slide); } } $controls.width((_initCount+2)*15); } function BindNav(){ var uA = GetUserAgent(); if(uA == 'mozilla' || uA == 'msie' || uA == 'webkit'){ $row.css({'-webkit-transition': 'all .3s ease-in-out', '-moz-transition': 'all .3s ease-in-out', '-o-transition': 'all .3s ease-in-out', 'transition': 'all .3s ease-in-out'}); $left.on('click',function(event){Action(this)}); $right.on('click',function(event){Action(this)}); }else{ $row.css({'-webkit-transition': 'all .1s ease-in-out', '-moz-transition': 'all .1s ease-in-out', '-o-transition': 'all .1s ease-in-out', 'transition': 'all .1s ease-in-out'}); /*if(uA == 'ipad'){ $left.on('click',function(event){Action(this)}); $right.on('click',function(event){Action(this)}); }else{*/ BindSwipe(); //} } } function BindSwipe(){ $this.find('#swipebox').swipeEvents() .on("swipeLeft", function(event,data){ SwipeAction(this, event.type);event.stopPropagation();}) .on("swipeRight", function(event,data){ SwipeAction(this, event.type);event.stopPropagation();}); } function SwipeAction(obj, eventType){ var dir = (eventType == 'swipeLeft')?-1:1; AnimateSlide(dir); CheckThumbs(); } function CheckThumbs(){ if($('.thumb_farm')){ var _thumbs = $('.thumb_farm div.c3') $(_thumbs).removeClass('selected'); $(_thumbs[selIndex]).addClass('selected'); } } function Action(obj){ var btn = $(obj), dir = btn.attr('class').indexOf('left')>-1?1:-1; if(btn.hasClass('pending')==false){ AnimateSlide(dir); btn.addClass('pending'); setTimeout(function(){btn.removeClass('pending')},300); } } function GetUserAgent() { var userAgents = ['mozilla','msie','webkit','iphone','ipad','ipod','android','blackberry']; var retAgent = ''; for(var i = 0;i - 1){ retAgent = userAgents[i]; } } return retAgent; } function AnimateSlide(dir){ lPos = $row.position().left; var offset = _cellWidth; var newLPos = lPos+(dir*(offset)); var sMarkers = $($slides.find('.marker')); _count+=dir; selIndex=(dir==-1)?++selIndex:--selIndex; if(selIndex < 0 ){ _count = _initCount; selIndex = 0; }else if(selIndex >= _initCount){ _count = 1; selIndex = _initCount-1; }else{ var ua = GetUserAgent(); if( ua == 'msie'){ $row.animate({'left':newLPos},250); }else{ $row.css({'transform':'translateX('+newLPos+'px)'} ); } $(sMarkers).removeClass('selected'); $(sMarkers[selIndex]).addClass('selected'); } } Init(); }); }; })(jQuery); (function($) { $.fn.thumbfarm = function(limit, margin) { return this.each(function() { var _this = $(this); _thumbs = _this.children('div.c3'); _gallery = $('#'+_this.attr('data-target')), _row = $(_gallery.find('.row')), _cellWidth = _row.children().outerWidth(), _markers = $(_gallery.find('.slide_markers .marker')), _left = $(_gallery.find('.controls .left')), _right = $(_gallery.find('.controls .right')), uA = GetUserAgent(); var SetSelected = function(){ selIndex = $(_gallery.find('.slide_markers .selected')).index(); $(_thumbs).removeClass('selected'); $(_thumbs[selIndex]).addClass('selected'); } var SetGallery = function(index){ //Addition: Scroll to top of the gallery when clicked on the thumbnails $('html, body').animate({ scrollTop: $('#photogallery').offset().top - 100 }, 1000); _cellWidth = _row.children().outerWidth(); var cPos = _row.position().left; var nPos = index*_cellWidth; var dir = (nPos > Math.abs(cPos))?-1:1; var newLPos =(nPos * -1); if(uA == 'msie'){ _row.animate({'left':newLPos+'px'} ); }else{ _row.css({'transform':'translateX('+newLPos+'px)'} ); } ResetMarkers(index); SetSelected(); } var ResetMarkers = function(index){ $(_markers).removeClass('selected'); $(_markers[index]).addClass('selected'); } if(uA == 'mozilla' || uA == 'msie' || uA == 'webkit'){ _left.on('click',function(event){SetSelected()}); _right.on('click',function(event){SetSelected()}); } _thumbs.on('click',function(event){SetGallery($(this).index())}); SetSelected(); }); }; })(jQuery); ;(I11C || I10C).ScriptEnd();