jegtheme

photoswipe all item

Apr 19th, 2013
286
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /**
  2.  * jeggallery.full.js
  3.  *  
  4.  * simple fragment of jeglio, uses only for load gallery
  5.  **/
  6. (function($) {
  7.     $.fn.jeggallery = function( options )
  8.     {
  9.         var settings = {};
  10.  
  11.         if (options) {
  12.             var options = $.extend(settings, options); 
  13.         } else {
  14.             var options = $.extend(settings);                  
  15.         }
  16.        
  17.         /** public **/
  18.         var touch                   = false;
  19.         if((navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i)) || (navigator.userAgent.match(/iPad/i))) {
  20.             touch = true;
  21.         }
  22.        
  23.         var type_image = function(ele){
  24.             /** add tooltips for tips **/
  25.             if(!touch) {
  26.                 $('a.item-gallery-image', ele).jtooltip({});
  27.             }
  28.            
  29.             /** photo swipe **/        
  30.             (function(PhotoSwipe){
  31.                 photoswipe = $('a.item-gallery-image',ele).photoSwipe({
  32.                     backButtonHideEnabled           : false,
  33.                     captionAndToolbarAutoHideDelay  : 0,
  34.                     imageScaleMethod                : 'fitNoUpscale',
  35.                     allowUserZoom                   : true,
  36.                     getImageSource                  : function(obj){ return $(obj).attr('data'); }
  37.                 });
  38.                 photoswipe.addEventHandler(PhotoSwipe.EventTypes.onHide, function(e){
  39.                     $container.isotope("reLayout");
  40.                 });
  41.             }(window.Code.PhotoSwipe));        
  42.            
  43.             $('a', ele).click(function(){
  44.                 return false;
  45.             });
  46.         };
  47.        
  48.        
  49.         /** lazy load flex slider **/
  50.         var loadotherimage = function(sel) {
  51.             var datasrc = $('img',sel).attr('data-src');
  52.             if(datasrc != undefined) {                         
  53.                 var img = new Image();
  54.                 $(img).css("opacity" , 0);
  55.                 $('a', sel).html('').append(img);
  56.                 $(img).load(function(){
  57.                     $('img', sel).stop().animate({"opacity" : 1}, "fast");
  58.                 }).attr('src', datasrc);
  59.             }
  60.         };
  61.        
  62.         var loadnextprev = function(slider) {                  
  63.             // load next slide
  64.             var next = $('.flex-active-slide', slider).next();
  65.             loadotherimage(next);
  66.            
  67.             // load prev slide
  68.             var prev = $('.flex-active-slide', slider).prev();
  69.             loadotherimage(prev);
  70.         };
  71.        
  72.         var lazyloadflex = function(slider) {                  
  73.             var datasrc = $('.flex-active-slide img', slider).attr('data-src');
  74.             if(datasrc != undefined){
  75.                 var img = new Image();
  76.                 $(img).css("opacity" , 0);
  77.                 $('.flex-active-slide a', slider).html('').append(img);
  78.                
  79.                 $(img).load(function(){
  80.                     $('.flex-active-slide img', slider).stop().animate({"opacity" : 1}, "fast");
  81.                     loadnextprev(slider);
  82.                 }).attr('src', datasrc);
  83.             } else {
  84.                 if($('.flex-active-slide img', slider).css('opacity') == 0) {
  85.                     $('.flex-active-slide img', slider).animate({"opacity" : 1}, "fast");
  86.                 }
  87.                 loadnextprev(slider);
  88.             }
  89.         };
  90.         /** lazy load flex slider **/
  91.        
  92.         var type_gallery = function(ele){
  93.            
  94.             /** add tooltips for tips **/
  95.             type_image(ele);
  96.            
  97.             $(ele).flexslider({
  98.                 animation: "slide",              
  99.                 slideDirection: "horizontal",  
  100.                 slideshow: true,                
  101.                 slideshowSpeed: 7000,          
  102.                 animationDuration: 300,        
  103.                 directionNav: options.direction_nav,
  104.                 controlNav: options.control_nav,
  105.                 keyboardNav: true,              
  106.                 mousewheel: false,              
  107.                 prevText: "Previous",          
  108.                 nextText: "Next",              
  109.                 pausePlay: false,              
  110.                 pauseText: 'Pause',            
  111.                 playText: 'Play',              
  112.                 randomize: false,              
  113.                 slideToStart: 0,                
  114.                 animationLoop: true,            
  115.                 pauseOnAction: true,            
  116.                 pauseOnHover: false,            
  117.                 controlsContainer: "",          
  118.                 manualControls: "",            
  119.                 start: function(slider) {
  120.                     lazyloadflex(slider);
  121.                 },
  122.                 end: function(slider){},
  123.                 before: function(slider){},
  124.                 after: function(slider){
  125.                     lazyloadflex(slider);
  126.                 }                    
  127.             });
  128.            
  129.         };
  130.        
  131.         var type_audio = function(ele){
  132.             var audioresize = function () {
  133.                 var w = parseInt($(ele).css('width'),10);
  134.                 var h = 30;
  135.                 $('audio', ele).attr('width', '100%').attr('height', h);
  136.             };         
  137.            
  138.             $(window).resize(function(){audioresize();});          
  139.             $(window).resize();
  140.            
  141.             $('audio', ele).mediaelementplayer({
  142.                 pluginPath: template_css + "mediaelement/"
  143.             });
  144.         };
  145.        
  146.         var type_video = function(ele){
  147.             /** set size of video & image **/
  148.             $('video', ele).css({'width' : '100%','height': '100%'});
  149.             $('img', ele).css({'width': '100%','height': '100%'});         
  150.             $('video', ele).mediaelementplayer({});
  151.         };
  152.        
  153.         var youtube_parser = function (url)
  154.         {
  155.             var regExp = /^.*((youtu.be\/)|(v\/)|(\/u\/\w\/)|(embed\/)|(watch\?))\??v?=?([^#\&\?]*).*/;
  156.             var match = url.match(regExp);
  157.            
  158.             if ( match && match[7].length == 11 ) {
  159.                 return match[7];
  160.             } else {
  161.                 alert("Url Incorrect");
  162.             }
  163.         };
  164.        
  165.         var vimeo_parser = function (url)
  166.         {
  167.             var regExp = /http:\/\/(www\.)?vimeo.com\/(\d+)($|\/)/;
  168.             var match = url.match(regExp);
  169.  
  170.             if (match){
  171.                 return match[2];
  172.             }else{
  173.                 alert("not a vimeo url");
  174.             }
  175.  
  176.         };
  177.        
  178.         var type_video_youtube = function(ele){
  179.             var youtube_id = youtube_parser($('.video-container', ele).attr('data-src'));
  180.             var iframe = '<iframe width="700" height="500" src="http://www.youtube.com/embed/' + youtube_id +  '?showinfo=0&theme=light&autohide=1&rel=0&wmode=opaque" frameborder="0" allowfullscreen></iframe>';
  181.             $('.video-container', ele).append(iframe);
  182.         };
  183.        
  184.         var type_video_vimeo = function(ele){
  185.             var vimeo_id = vimeo_parser($('.video-container', ele).attr('data-src'));
  186.             var iframe = '<iframe src="http://player.vimeo.com/video/' + vimeo_id + '?title=0&byline=0&portrait=0" width="700" height="500" frameborder="0"></iframe>';
  187.             $('.video-container', ele).append(iframe);
  188.         };
  189.        
  190.         var type_ba = function (ele) {
  191.             $('.ba-gallery', ele).wpwBAgallery({
  192.                 height  :   'auto',
  193.                 width   :   'auto'
  194.             });
  195.         };
  196.        
  197.         $(this).each(function(){
  198.             var type = $(this).attr('data-type');  
  199.             switch(type) {
  200.                 case "gallery" :
  201.                     type_gallery(this);
  202.                     break;
  203.                 case "image" :
  204.                     type_image(this);
  205.                     break;
  206.                 case "video" :
  207.                     type_video(this);
  208.                     break;
  209.                 case "youtube" :
  210.                     type_video_youtube(this);
  211.                     break;
  212.                 case "vimeo" :
  213.                     type_video_vimeo(this);
  214.                     break; 
  215.                 case "audio" :
  216.                     type_audio(this);
  217.                     break;
  218.                 case "ba" :
  219.                     type_ba(this);
  220.                     break;
  221.                 default :
  222.                     break;
  223.             };
  224.         });
  225.        
  226.         $(window).bind("jmainremove", function(){          
  227.         });
  228.     };
  229. })(jQuery);
  230.  
  231. function setupCarousel(itemTotal, navstyle, tourl){
  232.     /** carousel **/
  233.     var minItem;
  234.     if(scw(iphonewidth)) {
  235.         minItem = itemTotal;
  236.     } else {
  237.         minItem = 4;
  238.     }
  239.    
  240.     jQuery('.carousel').elastislide({
  241.         imageW          : 180,
  242.         minItems        : minItem,
  243.         navigatorStyle  : navstyle,
  244.         onClick         : function(i){         
  245.             if($('a', i).attr('data-tourl') == "false") {
  246.                 return false;
  247.             } else {
  248.                 if(jcurtain == 1) {
  249.                     window.tourl($('a',i).attr('href'));
  250.                     return false;
  251.                 } else {
  252.                     window.location = $('a',i).attr('href');
  253.                     return true;
  254.                 }
  255.             }
  256.         }
  257.     });
  258. }
  259.  
  260. (function($) {
  261.     $.fn.jegfolio = function( options )
  262.     {
  263.         var settings = {
  264.             minItem         : 6
  265.         };
  266.  
  267.         if (options) {
  268.             var options = $.extend(settings, options); 
  269.         } else {
  270.             var options = $.extend(settings);                  
  271.         }
  272.        
  273.        
  274.         /** public **/
  275.         var touch                   = false;
  276.         if((navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i)) || (navigator.userAgent.match(/iPad/i))) {
  277.             touch = true;
  278.         }
  279.        
  280.        
  281.         /** carousel **/
  282.         setupCarousel(options.minItem, 1, true);
  283.        
  284.         /** jeg gallery **/
  285.         $(".gallery-main").jeggallery({
  286.             direction_nav   :  options.direction_nav,
  287.             control_nav     :  options.control_nav         
  288.         });
  289.        
  290.        
  291.         /** portfolio gallery animation **/
  292.         $(".portfolio-gallery li").hover(function(){
  293.            
  294.             $(this).find('.shadow').stop().animate({
  295.                 'height'    : '100%'
  296.             },'fast');
  297.  
  298.             var h = ( ($(this).height() - $(this).find('.desc-holder').height()) / 2 ) - 5;
  299.            
  300.             $(this).find('.desc-holder').stop().animate({
  301.                 'bottom'    : h
  302.             },'fast');
  303.            
  304.         }, function(){
  305.            
  306.             $(this).find('.shadow').stop().animate({
  307.                 'height'    : '0'
  308.             },'fast');
  309.            
  310.             $(this).find('.desc-holder').stop().animate({
  311.                 'bottom'    : '-100'
  312.             },10); 
  313.         });
  314.        
  315.         var attach_social = function ()
  316.         {                  
  317.             var $this       = $('.single-portfolio-like');
  318.             var shareurl    = $('.single-portfolio-like').attr('data-url');
  319.             var imageurl    = $('.single-portfolio-like').attr('data-cover');
  320.            
  321.             /** facebook like **/
  322.             var fbl = $(document.createElement("fb:like"))
  323.                 .attr("href", shareurl)
  324.                 .attr("send", "false")
  325.                 .attr("layout", "button_count")
  326.                 .attr("show_faces", "false");
  327.            
  328.             var fbl = $("<div class='fblio'></div>").append(fbl);                      
  329.             $(".wrapper-social .facebook-sharer").empty().append(fbl);
  330.             FB.XFBML.parse($(".fblio", $this).get(0));         
  331.            
  332.             /** pinterest button **/
  333.             var pinurl = "http://pinterest.com/pin/create/button/?url="
  334.                 + encodeURIComponent(shareurl) + "&media=" + encodeURIComponent(imageurl);
  335.            
  336.             var pinvar = $(document.createElement("a"))
  337.                     .attr("href", pinurl)
  338.                     .attr("class", "pin-it-button")
  339.                     .attr("count-layout", "horizontal")
  340.                     .html('<img border="0" src="//assets.pinterest.com/images/PinExt.png" title="Pin It" />');
  341.            
  342.             $(".wrapper-social .pinterest-sharer")
  343.                 .append(pinvar)
  344.                 .append('<script type="text/javascript" src="//assets.pinterest.com/js/pinit.js"></script>');                      
  345.            
  346.            
  347.             /** google plus share **/
  348.             var gplusvar = $('<g:plusone size="medium" annotation="bubble" href="'
  349.                     + encodeURIComponent(shareurl) + '"></g:plusone>');
  350.             $(".wrapper-social .google-sharer").append(gplusvar);
  351.             gapi.plusone.go("google-sharer");
  352.            
  353.             /** twitter sharer **/
  354.             var twt = $(document.createElement("a"))
  355.                     .attr("class", "twitter-share-button")
  356.                     .attr("href", "http://twitter.com/share")
  357.                     .attr("data-url", document.URL)
  358.                     .html("Tweet");
  359.            
  360.             var twt = $("<div class='twtlio'></div>").append(twt);
  361.             $(".wrapper-social .twitter-sharer").append(twt);
  362.             twttr.widgets.load();
  363.            
  364.         };
  365.        
  366.        
  367.         attach_social();
  368.        
  369.     };
  370. })(jQuery);
  371.  
  372.  
  373. (function($) {
  374.     $.fn.jegblog = function( options )
  375.     {      
  376.         var settings = {
  377.             minItem         : 4
  378.         };
  379.  
  380.         if (options) {
  381.             var options = $.extend(settings, options); 
  382.         } else {
  383.             var options = $.extend(settings);
  384.         }
  385.        
  386.        
  387.         /** public **/
  388.         var touch                   = false;
  389.         if((navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i)) || (navigator.userAgent.match(/iPad/i))) {
  390.             touch = true;
  391.         }
  392.        
  393.         var body = $(this);
  394.        
  395.         /** gallery **/
  396.         $(".blog-gallery-type", body).jeggallery({
  397.             direction_nav   :  options.direction_nav,
  398.             control_nav     :  options.control_nav
  399.         });
  400.        
  401.        
  402.         /** attach photoswipe **/
  403.         if($('.blog-gallery li a').length > 0 || $('.photoswipe').length > 0) {
  404.            
  405.             $('.blog-gallery li a').click(function() { return false; });
  406.             $('.photoswipe').click(function() { return false; });
  407.            
  408.             if(!options.uselightbox) {
  409.                 (function(PhotoSwipe){
  410.                      photoswipe = $('.blog-gallery li a , .photoswipe').photoSwipe({
  411.                         $(this).photoSwipe({
  412.                             backButtonHideEnabled           : false,
  413.                             captionAndToolbarAutoHideDelay  : 0,
  414.                             allowUserZoom                   : true,
  415.                             imageScaleMethod                : 'fitNoUpscale',
  416.                             getImageSource                  : function(obj){ return $(obj).attr('href'); },
  417.                             getImageCaption                 : function(obj){ return $(obj).attr('data-title'); }
  418.                         });
  419.                     });
  420.                    
  421.                 }(window.Code.PhotoSwipe));
  422.             } else {
  423.                 $(".blog-gallery").each(function(){
  424.                     $(this).find('a').lightbox();                  
  425.                 });
  426.                 $(".photoswipe").each(function(){
  427.                     $(this).find('a').lightbox();
  428.                 });
  429.             }
  430.            
  431.         }
  432.        
  433.         /** carousel **/
  434.         setupCarousel(options.minItem, 2, false);          
  435.        
  436.         /** comment **/
  437.         $(".replycomment").click(function(){
  438.             var i = $(this).parents(".coment-box").parent();
  439.             var f = $("#respond");
  440.             var x = $("<div id='comment-box-reply'></div>");
  441.             var t = $("<div id='temp-comment-holder' style='display:none;'></div>");
  442.             var p = $("#comment_parent");          
  443.             var c = "data-comment-id";
  444.            
  445.             $(".closecommentform").hide();
  446.             $(".replycomment").show();
  447.             $("#comment-box-reply").remove();
  448.            
  449.             if(!$("#temp-comment-holder").length) {
  450.                 t.insertBefore(f);
  451.             }
  452.  
  453.            
  454.             x.insertAfter($(i).find('.coment-box-inner')).append(f);
  455.             p.val($(this).attr(c));
  456.            
  457.             $(this).hide();
  458.            
  459.             $(i).find(".closecommentform").show().click(function(){
  460.                 f.insertAfter($("#temp-comment-holder"));
  461.                 $("#temp-comment-holder").remove();
  462.                 $("#comment-box-reply").remove();
  463.                 $(this).hide();
  464.                 $(i).find('.replycomment').show();
  465.                 $("#comment_parent").val(0);
  466.             });        
  467.         });
  468.        
  469.     };
  470. })(jQuery);
Advertisement
Add Comment
Please, Sign In to add comment