jegtheme

jeglio.js

Jan 18th, 2013
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. jQuery(document).ready(function(e){e.Isotope.prototype._getCenteredMasonryColumns=function(){this.width=this.element.width();var e=this.element.parent().width();var t=this.options.masonry&&this.options.masonry.columnWidth||this.$filteredAtoms.outerWidth(true)||e;var n=Math.floor(e/t);n=Math.max(n,1);this.masonry.cols=n;this.masonry.columnWidth=t};e.Isotope.prototype._masonryReset=function(){this.masonry={};this._getCenteredMasonryColumns();var e=this.masonry.cols;this.masonry.colYs=[];while(e--){this.masonry.colYs.push(0)}};e.Isotope.prototype._masonryResizeChanged=function(){var e=this.masonry.cols;this._getCenteredMasonryColumns();return this.masonry.cols!==e};e.Isotope.prototype._masonryGetContainerSize=function(){var e=0,t=this.masonry.cols;while(--t){if(this.masonry.colYs[t]!==0){break}e++}return{height:Math.max.apply(Math,this.masonry.colYs),width:(this.masonry.cols-e)*this.masonry.columnWidth+5}}});(function(e){e.fn.jeglio=function(t){var n={itemWidth:180,itemHeight:210,itemMode:0,itemHeightWide:550,galleryDim:3,descDim:1,theatherMode:false,scrolltop:50,flexDelay:7e3,zoomDelay:7e3,direction_nav:0,control_nav:1,newgallery:1,loadAnimation:"sequpfade"};if(t){var t=e.extend(n,t)}else{var t=e.extend(n)}var r=e(this);var i=undefined;var s=undefined;var o=undefined;var u=undefined;var a=undefined;var f=undefined;var l=false;var c=undefined;var h=undefined;var p=undefined;var d=document.title;var v=150;var m=true;var g=undefined;var y=undefined;if(navigator.userAgent.match(/iPhone/i)||navigator.userAgent.match(/iPod/i)||navigator.userAgent.match(/iPad/i)){l=true}var b=parseInt(t.galleryDim);var w=parseInt(t.descDim);var E=false;var S=function(t){var n=e(t.currentTarget);var r=n.height();var i=n.find("i");e(i.get(0)).addClass("display-inline-table");n.find(".shadow").stop().animate({height:r},"fast");var s=n.find(".desc-holder");var o=(r-s.height())/2;n.find(".desc-holder").stop().animate({bottom:o},"fast",function(){if(l){link=e(n.find("a").get(0)).attr("href");window.location=link}})};var x=function(t){var n=e(t.currentTarget);var r=n.height();var i=n.find("i");e(i.get(0)).removeClass("display-inline-table");n.find(".shadow").stop().animate({height:0},"fast");n.find(".desc-holder").stop().animate({bottom:0},"fast")};var T=function(t){var n=e(t.itemGallery).css("width");var r=e(t.itemGallery).css("height");e("video",t.itemGallery).attr("width",n).attr("height",r);e("img",t.itemGallery).css("width",n).css("height",r);e("video",t.itemGallery).mediaelementplayer({})};var N=function(e){var t=/^.*((youtu.be\/)|(v\/)|(\/u\/\w\/)|(embed\/)|(watch\?))\??v?=?([^#\&\?]*).*/;var n=e.match(t);if(n&&n[7].length==11){return n[7]}else{alert("Url Incorrect")}};var C=function(e){var t=/http:\/\/(www\.)?vimeo.com\/(\d+)($|\/)/;var n=e.match(t);if(n){return n[2]}else{alert("not a vimeo url")}};var k=function(t){var n=e(t.itemGallery).css("width");var r=e(t.itemGallery).css("height");var i=N(e(".video-youtube-container",t.itemGallery).attr("src"));var s='<iframe width="'+n+'" height="'+r+'" src="http://www.youtube.com/embed/'+i+'?showinfo=0&theme=light&autohide=1&rel=0&wmode=opaque" frameborder="0" allowfullscreen></iframe>';e(".video-youtube-container",t.itemGallery).append(s)};var L=function(t){var n=e(t.itemGallery).css("width");var r=e(t.itemGallery).css("height");var i=C(e(".video-vimeo-container",t.itemGallery).attr("src"));var s='<iframe src="http://player.vimeo.com/video/'+i+'?title=0&byline=0&portrait=0" width="'+n+'" height="'+r+'" frameborder="0"></iframe>';e(".video-vimeo-container",t.itemGallery).append(s)};var A=function(t){var n=e(t.itemGallery).css("width");var r=30;e("audio",t.itemGallery).attr("width",n).attr("height",r);e("audio",t.itemGallery).mediaelementplayer({pluginPath:template_css+"mediaelement/"})};var O=function(n){if(t.newgallery==1){Galleria.loadTheme(t.themesurl);e("#galleria").show();Galleria.run("#galleria",{transition:"fade",imageCrop:false})}else{var r=function(t){var n=e("img",t).attr("data-src");if(n!=undefined){e("img",t).removeAttr("data-src").attr("src",n)}};var i=function(t){var n=e(".flex-active-slide",t).next();r(n);var i=e(".flex-active-slide",t).prev();r(i)};var s=function(t){var n=e(".flex-active-slide img",t).attr("data-src");if(n!=undefined){var r=new Image;e(r).load(function(){e(r).css("opacity",0);e(".flex-active-slide a",t).html("").append(r);e(".flex-active-slide img",t).animate({opacity:1},"fast");i(t)}).attr("src",n)}else{i(t)}};e(n.itemGallery).flexslider({animation:"slide",slideDirection:"horizontal",slideshow:true,animationDuration:300,slideshowSpeed:t.flexDelay,directionNav:t.direction_nav,controlNav:t.control_nav,keyboardNav:true,mousewheel:false,prevText:"Previous",nextText:"Next",pausePlay:false,pauseText:"Pause",playText:"Play",randomize:false,slideToStart:0,animationLoop:true,pauseOnAction:true,pauseOnHover:false,controlsContainer:"",manualControls:"",start:function(e){s(e)},end:function(e){},before:function(e){},after:function(e){s(e)}});M(n)}};var M=function(n){if(!l){e(n.itemGallery).find(".item-gallery-image").jtooltip({})}(function(i){c=e(n.itemGallery).find(".item-gallery-image").photoSwipe({backButtonHideEnabled:false,captionAndToolbarAutoHideDelay:0,slideshowDelay:t.zoomDelay,slideSpeed:500,imageScaleMethod:"fitNoUpscale",allowUserZoom:false,getImageSource:function(t){return e(t).attr("data")},getImageCaption:function(t){return e(t).attr("data-title")}});c.addEventHandler(i.EventTypes.onHide,function(e){r.isotope("reLayout")})})(window.Code.PhotoSwipe);e(".item-gallery-image").click(function(){return false})};var _=function(t){e(".ba-gallery",t.itemGallery).wpwBAgallery({height:"auto",width:"auto"})};var D=function(t){e(".love-this",t).each(function(){e(this).click(function(){if(!e(this).hasClass("voted")){var t=e(this);t.addClass("locked");var n=t.find(".love-counter");e(n).text("Loading ...").addClass("italic");e.ajax({url:admin_url,type:"post",dataType:"json",data:{postid:e(this).attr("data-id"),action:"vote_post"},success:function(r){e(n).text(r.msg);setTimeout(function(){if(r.id==3){t.attr("data-counter",r.total);e(n).removeClass("italic");t.addClass("voted")}t.removeClass("locked");e(n).text(t.attr("data-counter")).removeClass("italic")},1500)}})}else{var r=e(this).attr("data-voted")}}).hover(function(){if(e(this).hasClass("voted")){var t=e(this).attr("data-voted");var n=e(this).find(".love-counter");n.text(t)}else{if(!e(this).hasClass("locked")){var t=e(this).attr("data-vote");var n=e(this).find(".love-counter");n.text(t)}}},function(){if(!e(this).hasClass("locked")){var t=e(this).attr("data-counter");var n=e(this).find(".love-counter");n.text(t)}})})};var P=function(t,n,s){I(s);if(i){e(i.i).find(".love-this").replaceWith(function(){return e("<div>").append(e(t).find(".love-this").clone()).html()});D(i.i)}e("video, audio",n).each(function(){e(this)[0].pause()});e(t).fadeOut("fast",function(){e(n).remove();e("html").css("overflow-y","auto");r.css({"max-height":"100%"})})};var H=function(t,n,s,c,h){var p=e("#item-theater-overlay");var v=e("#item-theater-detail",p);var m=e(".item-detail",p);var b=F(m);var w=false;var S=0;if(i!=undefined){I(false)}e("html, body").animate({scrollTop:0},function(){setTimeout(function(){if(!S){x();S++}},500)});var x=function(){if(l){var c=e(window).height();var h=r.offset();var w=parseInt(r.css("margin-bottom"),10);ch=c-h.top-w;r.css({"max-height":ch})}else{e("html").css("overflow-y","hidden")}e(m).show().css({opacity:1});e(v).css({display:"block"});e(p).fadeIn("fast",function(){e(v).css({width:o,height:u,top:g,left:y,position:"absolute"});document.title=n.unescapeHtml()+" - "+d.unescapeHtml();e(b.itemGallery).css("width",a).css("height",u);e(b.itemDescription).css("width",f);var r=B(t);e(p).find(".item-prev").parent().attr("href",r.prev);e(p).find(".item-next").parent().attr("href",r.next);e(p).find(".love-this").replaceWith(function(){return e("<div>").append(t.find(".love-this").clone()).html()});D(p);var l=f-parseInt(b.descWrapper.css("margin-left"),10)-parseInt(b.descWrapper.css("margin-right"),10);e(b.descWrapper).css({height:u-50,width:l}).jScrollPane();switch(s){case"gallery":O(b);break;case"image":M(b);break;case"video":T(b);break;case"youtube":k(b);break;case"vimeo":L(b);break;case"audio":A(b);break;case"ba":_(b);break;default:break}E=false;i={i:t,t:s};setTimeout(function(){var t=location.hash.replace("#!/","");var n=t.split(":");var r=n[1];if(r!=undefined){(function(t){e(t.instances[0].originalImages[r]).trigger("click")})(window.Code.PhotoSwipe)}},500);e(p).click(function(e){if(e.target==this){P(p,m,true)}});e(".closeme",v).show().bind("click",function(){P(p,m,true)})})}};var B=function(t){var n=undefined;var i=undefined;var s=t;while(s=e(s).prev()){if(!s.hasClass("isotope-hidden")){break}}var o=t;while(o=e(o).next()){if(!o.hasClass("isotope-hidden")){break}}n=e(e(s).find("a").get(0)).attr("href");i=e(e(o).find("a").get(0)).attr("href");if(n===undefined){s=e(".item:last-child",r);while(s){if(!s.hasClass("isotope-hidden")){break}s=e(s).prev()}n=e(e(s).find("a").get(0)).attr("href")}if(i===undefined){o=e(".item:first-child",r);while(o){if(!o.hasClass("isotope-hidden")){break}o=e(o).next()}i=e(e(o).find("a").get(0)).attr("href")}t.find(".item-prev").parent().attr("href",n);t.find(".item-next").parent().attr("href",i);return{next:i,prev:n}};var j=function(n,s,l,c){var h=F(n);if(i!=undefined){I(false)}n.animate({width:o,height:u},400,function(){e(h.itemWrapper).hide();e(h.closeme).show().bind("click",function(){I(true)});n.addClass("unfolded");var o=B(n);n.find(".item-prev").parent().attr("href",o.prev);n.find(".item-next").parent().attr("href",o.next);r.isotope("reLayout",function(r){e(h.itemGallery).css("width",a).css("height",u);e(h.itemDescription).css("width",f);e(h.itemDetail).show().animate({opacity:"1"});if(s){n.attr("data-title",l);n.attr("data-type",c);var o=h.descWrapper.css("width");var p=f-parseInt(h.descWrapper.css("margin-left"),10)-parseInt(h.descWrapper.css("margin-right"),10);e(h.descWrapper).css({height:u-50,width:p}).jScrollPane();switch(c){case"gallery":setTimeout(function(){O(h)},1e3);break;case"image":M(h);break;case"video":T(h);break;case"youtube":k(h);break;case"vimeo":L(h);break;case"audio":A(h);break;case"ba":_(h);break;default:break}}document.title=l.unescapeHtml()+" - "+d.unescapeHtml();E=false;setTimeout(function(){e("html, body").animate({scrollTop:n.offset().top-t.scrolltop},500,function(){i={i:n,t:c};setTimeout(function(){var t=location.hash.replace("#!/","");var n=t.split(":");var r=n[1];if(r!=undefined){(function(t){e(t.instances[0].originalImages[r]).trigger("click")})(window.Code.PhotoSwipe)}},500)})},500)})})};var F=function(e){return{me:e,shadow:e.find(".shadow"),itemWrapper:e.find(".item-wrapper"),closeme:e.find(".closeme"),itemDetail:e.find(".item-detail"),itemGallery:e.find(".item-gallery"),itemDescription:e.find(".item-description"),descWrapper:e.find(".item-desc-wrapper")}};var I=function(t){document.title=d.unescapeHtml();if(i===undefined){return false}var n=i.i;e(n).find(".item-detail").animate({opacity:0},100).hide();var s={width:e(n).attr("data-width"),height:e(n).attr("data-height")};e(n).animate(s,"fast",function(){e(n).find(".closeme").hide();e(n).find(".item-wrapper").show("fast");e(n).removeClass("unfolded");e(n).find(".item-detail").remove();e(n).find(".desc-holder").css({bottom:0}).find("i").removeClass("display-inline-table");e(n).find(".shadow").removeClass("shadowload").height("0");i=undefined;r.isotope("reLayout")});if(t){window.location="#!/"}};var q=function(t){var n=t.find(".small-loader");var r=e(n).width();var i=e(n).height();var s=t.width();var o=t.height();var u=s/2-r/2;var a=o/2-i/2;t.find(".small-loader").show().css("margin-left",u).css("margin-top",a)};var R=function(e){e.find(".small-loader").hide()};var U=function(n){if(E){return}else{E=true;n.find(".shadow").addClass("shadowload");n.attr("data-width",n.width());n.attr("data-height",n.height());if(n.find(".item-detail").length<=0){q(n);var r={id:n.attr("data-id"),width:a,height:Math.floor(u),theater:t.theatherMode,action:"get_portfolio_item"};if(t.theatherMode){if(i!=undefined){var s=e("#item-theater-overlay");var o=e(".item-detail",s);P(s,o,false)}}var f=function(i){if(!e(".portopwd").length){var s='<div class="portopwd">'+'<div class="portopwd-wrapper">'+"<h2>"+t.lang.portfoliotitle+" </h2> "+"<div>"+'<input type="password" class="pwdtxt" placeholder="'+t.lang.passwordplaceholder+'"/>'+'<button href="#" class="btn btn-inverse pwdbtn">'+t.lang.submit+"</button>"+"</div>"+'<div class="pwderr"></div>'+'<div alt="Close" class="pwdcls" style="display: block;">'+'<div class="icon-remove icon-white"></div>'+"</div>"+"</div>"+"</div>";e("body").append(s)}e(".pwdcls").click(function(){n.find(".small-loader").hide();e(".portopwd").remove();window.location="#!/";E=false;n.find(".shadow").removeClass("shadowload")});var o=function(){r.password=e(".pwdtxt").val();e(".portopwd").remove();h()};e(".pwdtxt").keypress(function(e){if(e.which==13){o()}});e(".pwdbtn").click(function(){o()})};var l=function(){var t=e(n.get(0)).attr("data-src");var r=n.find(".item-detail").attr("data-cover");var i=e(document.createElement("fb:like")).attr("href",t).attr("send","false").attr("layout","button_count").attr("show_faces","false");var i=e("<div class='fblio'></div>").append(i);e(".wrapper-social .facebook-sharer").empty().append(i);FB.XFBML.parse(e(".fblio",n).get(0));var s=e(document.createElement("a")).attr("class","twitter-share-button").attr("href","http://twitter.com/share").attr("data-url",document.URL).html("Tweet");var s=e("<div class='twtlio'></div>").append(s);e(".wrapper-social .twitter-sharer").append(s);twttr.widgets.load();var o="http://pinterest.com/pin/create/button/?url="+encodeURIComponent(t)+"&media="+encodeURIComponent(r);var u=e(document.createElement("a")).attr("href",o).attr("class","pin-it-button").attr("count-layout","horizontal").html('<img border="0" src="//assets.pinterest.com/images/PinExt.png" title="Pin It" />');e(".wrapper-social .pinterest-sharer").append(u).append('<script type="text/javascript" src="//assets.pinterest.com/js/pinit.js"></script>');var a=e('<g:plusone size="medium" annotation="bubble" href="'+encodeURIComponent(t)+'"></g:plusone>');e(".wrapper-social .google-sharer").append(a);gapi.plusone.go("google-sharer")};var c=function(r){n.find(".small-loader").hide();if(r.type=="video"||r.type=="youtube"||r.type=="vimeo"||r.type=="audio"){muteplayer()}else{unmuteplayer()}if(t.theatherMode){e("#item-theater-detail").append(r.content);H(n,r.title,r.type,r.love,r.voted)}else{n.append(r.content);j(n,true,r.title,r.type)}l();R(n)};var h=function(){e.ajax({url:admin_url,type:"post",dataType:"json",data:r,success:function(e){if(e.status==1){c(e)}else if(e.status==2){f(0)}else if(e.status==3){f(1)}else if(e.status==4){}}})};h()}else{}}};var z=function(){};var W=function(){};r.imagesLoaded(function(n,i,s){e(".lio-loader").fadeOut("fast");r.isotope({animationEngine:"jquery",itemSelector:".item",masonry:{columnWidth:1}});D(r);tt(false);X(t.loadAnimation);setTimeout(function(){e(window).hashchange()},500)});var X=function(t){if(t=="normal"){e("#liofilter").fadeIn();r.find(".item").each(function(){e(this).show()});V()}else if(t=="fade"){e("#liofilter").fadeIn("slow");r.find(".item").each(function(){e(this).fadeIn("slow")});V()}else if(t=="seqfade"){e("#liofilter").fadeIn(1e3);r.find(".item").each(function(t){var n=e(this);setTimeout(function(){n.fadeIn(300)},100+t*100)});setTimeout(function(){V()},100+r.find(".item").length*100)}else if(t=="upfade"){e("#liofilter").fadeIn(2e3);r.find(".item").each(function(t){var n=e(this),r=parseInt(n.css("top"),10)+n.height()/2;n.css({top:r+"px",opacity:0})});r.find(".item").each(function(t){var n=e(this);n.show();n.stop().animate({top:parseInt(n.css("top"),10)-n.height()/2,opacity:1},1e3)});setTimeout(function(){V()},1e3)}else if(t=="sequpfade"){e("#liofilter").fadeIn(2e3);J();r.find(".item").each(function(t){var n=e(this);setTimeout(function(){n.show();n.stop().animate({top:parseInt(n.css("top"),10)-n.height()/2,opacity:1},300)},100+t*100)});setTimeout(function(){V()},100+r.find(".item").length*100)}else if(t=="randomfade"){e("#liofilter").fadeIn(2e3);var n=K();for(var i=0;i<n.length;i++){setTimeout(function(){var e=n.pop();e.fadeIn(200)},75+i*75)}setTimeout(function(){V()},100+r.find(".item").length*100)}else if(t=="randomupfade"){e("#liofilter").fadeIn(2e3);var n=K();J();for(var i=0;i<n.length;i++){setTimeout(function(){var e=n.pop();e.show();e.stop().animate({top:parseInt(e.css("top"),10)-e.height()/2,opacity:1},300)},75+i*75)}setTimeout(function(){V()},100+r.find(".item").length*100)}r.find(".item").each(function(){e(this).hover(S,x)})};var V=function(){setTimeout(function(){ot();st()},300)};var J=function(){r.find(".item").each(function(t){var n=e(this),r=parseInt(n.css("top"),10)+n.height()/2;n.css({top:r+"px",opacity:0})})};var K=function(){var t=new Array;r.find(".item").each(function(n){t[n]=e(this)});t.sort(function(){return Math.round(Math.random())});return t};var Q=function(){var n=e(window).width()-50;var r=e(window).height()-e("header").height()-e("footer").height()-50;var i={};if(e(window).width()>e(window).height()){var s=11/5}else{var s=6/5}if(n/s<r){i.w=n;i.h=n/s}else{i.h=r;i.w=r*s}i.topPos=(e(window).height()-e("header").height()-e("footer").height()-i.h)/2+e("header").height();i.leftPos=(e(window).width()-i.w)/2;i.descriptionWidth=i.w*.2;i.descriptionWidth=i.descriptionWidth<200?200:i.descriptionWidth;i.galleryWidth=i.w-i.descriptionWidth;if(t.descDim==0){i.galleryWidth=i.w;i.descriptionWidth=0}return i};var G=e(window).width(),Y=e(window).height();e(window).resize(function(){if(this.resizeTo)clearTimeout(this.resizeTo);this.resizeTo=setTimeout(function(){if(G!=e(window).width()){G=e(window).width();e(this).trigger("windowWidthResize")}if(Y!=e(window).height()){e(this).trigger("windowHeightResize")}},250)});var Z=function(){if(t.theatherMode){if(i!=undefined){var n=i;var r=e("#item-theater-overlay");var s=e(".item-detail",r);P(r,s,true)}}};var et=function(){};var tt=function(n){var i=e(window).width();var s=r.find(".item").get(0);var l=parseInt(e(s).css("margin-bottom"),10);var c=parseInt(e(s).css("margin-left"),10);h=t.itemWidth;if(t.theatherMode){var p=Q();o=p.w;u=p.h;f=p.descriptionWidth;a=p.galleryWidth;g=p.topPos;y=p.leftPos}else{a=h*b+c*(b-1);f=h*w+c*w;for(var d=b+w;d>1;d--){var v=h*d+c*d-c;if(v+10<=i){o=v;u=t.itemHeightWide;break}}}if(n){r.isotope("reLayout")}else{}};var nt=function(){if(t.theatherMode){var n=e("#item-theater-overlay");var r=e(".item-detail",n);P(n,r,false)}else{I()}};var rt=function(t){for(var n=0;n<e(".item").length;n++){var r=e(".item").get(n);if(t==e(r).attr("data-url")){return e(r)}}};var it=function(){if(window.Code.PhotoSwipe.activeInstances[0]==undefined){}else{window.Code.PhotoSwipe.activeInstances[0].instance.hide(0)}};var st=function(){var n=location.hash.replace("#!/","");var r=n.split(":");n=r[0];if(n===""||n=="#!"){nt();unmuteplayer()}else{var i=rt(n);if(scw(mediaquerywidth)){if(i){if(!t.theatherMode){setTimeout(function(){e("html, body").animate({scrollTop:e(i).offset().top-t.scrolltop})},500)}U(i)}}else{var s=i.attr("data-src");tourl(s,true)}}it()};e("#liofilter .apply-filter").click(function(){e("#liofilter .apply-filter").removeClass("filter-select");var t=e(this).attr("data-filter");e(this).addClass("filter-select");I(true);r.isotope({filter:t});return false});e(".lio-loader").fadeIn("fast");var ot=function(){e(window).bind("hashchange",function(){st()})};e(window).bind("resize",function(){if(!m){tt(true)}else{tt(false)}m=false});e(window).bind("windowWidthResize",function(){Z()});e(window).bind("windowHeightResize",function(){et()});e(window).bind("jmainremove",function(){e(window).unbind("hashchange");e(window).unbind("resize");e("html").css("overflow-y","auto");delete e.fn.jeglio})}})(jQuery)
Advertisement
Add Comment
Please, Sign In to add comment