Advertisement
jegtheme

jeggallery.full.js

Jul 31st, 2014
261
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.             $(ele).fotorama({
  94.                 allowfullscreen: true,
  95.                 arrows: 'true',
  96.                 nav: 'dots',
  97.                 fit : 'contain',
  98.                 maxwidth: '100%',
  99.                 ratio: 16/10
  100.             });
  101.         };
  102.        
  103.         var type_audio = function(ele){
  104.             var audioresize = function () {
  105.                 var w = parseInt($(ele).css('width'),10);
  106.                 var h = 30;
  107.                 $('audio', ele).attr('width', '100%').attr('height', h);
  108.             };         
  109.            
  110.             $(window).resize(function(){audioresize();});          
  111.             $(window).resize();
  112.            
  113.             $('audio', ele).mediaelementplayer({
  114.                 pluginPath: template_css + "mediaelement/"
  115.             });
  116.         };
  117.        
  118.         var type_video = function(ele){
  119.             /** set size of video & image **/
  120.             $('video', ele).css({'width' : '100%','height': '100%'});
  121.             $('img', ele).css({'width': '100%','height': '100%'});         
  122.             $('video', ele).mediaelementplayer({});
  123.         };
  124.        
  125.         var youtube_parser = function (url)
  126.         {
  127.             var regExp = /^.*((youtu.be\/)|(v\/)|(\/u\/\w\/)|(embed\/)|(watch\?))\??v?=?([^#\&\?]*).*/;
  128.             var match = url.match(regExp);
  129.            
  130.             if ( match && match[7].length == 11 ) {
  131.                 return match[7];
  132.             } else {
  133.                 alert("Url Incorrect");
  134.             }
  135.         };
  136.        
  137.         var vimeo_parser = function (url)
  138.         {
  139.             var regExp = /http:\/\/(www\.)?vimeo.com\/(\d+)($|\/)/;
  140.             var match = url.match(regExp);
  141.  
  142.             if (match){
  143.                 return match[2];
  144.             }else{
  145.                 alert("not a vimeo url");
  146.             }
  147.  
  148.         };
  149.        
  150.         var type_video_youtube = function(ele){
  151.             var youtube_id = youtube_parser($('.video-container', ele).attr('data-src'));
  152.             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>';
  153.             $('.video-container', ele).append(iframe);
  154.         };
  155.        
  156.         var type_video_vimeo = function(ele){
  157.             var vimeo_id = vimeo_parser($('.video-container', ele).attr('data-src'));
  158.             var iframe = '<iframe src="http://player.vimeo.com/video/' + vimeo_id + '?title=0&byline=0&portrait=0" width="700" height="500" frameborder="0"></iframe>';
  159.             $('.video-container', ele).append(iframe);
  160.         };
  161.        
  162.         var type_ba = function (ele) {
  163.             $('.ba-gallery', ele).wpwBAgallery({
  164.                 height  :   'auto',
  165.                 width   :   'auto'
  166.             });
  167.         };
  168.        
  169.         $(this).each(function(){
  170.             var type = $(this).attr('data-type');  
  171.             switch(type) {
  172.                 case "gallery" :
  173.                     type_gallery(this);
  174.                     break;
  175.                 case "image" :
  176.                     type_image(this);
  177.                     break;
  178.                 case "video" :
  179.                     type_video(this);
  180.                     break;
  181.                 case "youtube" :
  182.                     type_video_youtube(this);
  183.                     break;
  184.                 case "vimeo" :
  185.                     type_video_vimeo(this);
  186.                     break; 
  187.                 case "audio" :
  188.                     type_audio(this);
  189.                     break;
  190.                 case "ba" :
  191.                     type_ba(this);
  192.                     break;
  193.                 default :
  194.                     break;
  195.             };
  196.         });
  197.        
  198.         $(window).bind("jmainremove", function(){          
  199.         });
  200.     };
  201. })(jQuery);
  202.  
  203. function setupCarousel(itemTotal, navstyle, tourl){
  204.     /** carousel **/
  205.     var minItem;
  206.     if(scw(iphonewidth)) {
  207.         minItem = itemTotal;
  208.     } else {
  209.         minItem = 4;
  210.     }
  211.    
  212.     jQuery('.carousel').elastislide({
  213.         imageW          : 180,
  214.         minItems        : minItem,
  215.         navigatorStyle  : navstyle,
  216.         onClick         : function(i){         
  217.             if($('a', i).attr('data-tourl') == "false") {
  218.                 return false;
  219.             } else {
  220.                 if(jcurtain == 1) {
  221.                     window.tourl($('a',i).attr('href'));
  222.                     return false;
  223.                 } else {
  224.                     window.location = $('a',i).attr('href');
  225.                     return true;
  226.                 }
  227.             }
  228.         }
  229.     });
  230. }
  231.  
  232. (function($) {
  233.     $.fn.jegfolio = function( options )
  234.     {
  235.         var settings = {
  236.             minItem         : 6
  237.         };
  238.  
  239.         if (options) {
  240.             var options = $.extend(settings, options); 
  241.         } else {
  242.             var options = $.extend(settings);                  
  243.         }
  244.        
  245.        
  246.         /** public **/
  247.         var touch                   = false;
  248.         if((navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i)) || (navigator.userAgent.match(/iPad/i))) {
  249.             touch = true;
  250.         }
  251.        
  252.        
  253.         /** carousel **/
  254.         setupCarousel(options.minItem, 1, true);
  255.        
  256.         /** jeg gallery **/
  257.         $(".gallery-main").jeggallery({
  258.             direction_nav   :  options.direction_nav,
  259.             control_nav     :  options.control_nav         
  260.         });
  261.        
  262.        
  263.         /** portfolio gallery animation **/
  264.         $(".portfolio-gallery li").hover(function(){
  265.            
  266.             $(this).find('.shadow').stop().animate({
  267.                 'height'    : '100%'
  268.             },'fast');
  269.  
  270.             var h = ( ($(this).height() - $(this).find('.desc-holder').height()) / 2 ) - 5;
  271.            
  272.             $(this).find('.desc-holder').stop().animate({
  273.                 'bottom'    : h
  274.             },'fast');
  275.            
  276.         }, function(){
  277.            
  278.             $(this).find('.shadow').stop().animate({
  279.                 'height'    : '0'
  280.             },'fast');
  281.            
  282.             $(this).find('.desc-holder').stop().animate({
  283.                 'bottom'    : '-100'
  284.             },10); 
  285.         });
  286.        
  287.         var attach_social = function ()
  288.         {                  
  289.             var $this       = $('.single-portfolio-like');
  290.             var shareurl    = $('.single-portfolio-like').attr('data-url');
  291.             var imageurl    = $('.single-portfolio-like').attr('data-cover');
  292.            
  293.             /** facebook like **/
  294.             var fbl = $(document.createElement("fb:like"))
  295.                 .attr("href", shareurl)
  296.                 .attr("send", "false")
  297.                 .attr("layout", "button_count")
  298.                 .attr("show_faces", "false");
  299.            
  300.             var fbl = $("<div class='fblio'></div>").append(fbl);                      
  301.             $(".wrapper-social .facebook-sharer").empty().append(fbl);
  302.             FB.XFBML.parse($(".fblio", $this).get(0));         
  303.            
  304.             /** pinterest button **/
  305.             var pinurl = "http://pinterest.com/pin/create/button/?url="
  306.                 + encodeURIComponent(shareurl) + "&media=" + encodeURIComponent(imageurl);
  307.            
  308.             var pinvar = $(document.createElement("a"))
  309.                     .attr("href", pinurl)
  310.                     .attr("class", "pin-it-button")
  311.                     .attr("count-layout", "horizontal")
  312.                     .html('<img border="0" src="//assets.pinterest.com/images/PinExt.png" title="Pin It" />');
  313.            
  314.             $(".wrapper-social .pinterest-sharer")
  315.                 .append(pinvar)
  316.                 .append('<script type="text/javascript" src="//assets.pinterest.com/js/pinit.js"></script>');                      
  317.            
  318.            
  319.             /** google plus share **/
  320.             var gplusvar = $('<g:plusone size="medium" annotation="bubble" href="'
  321.                     + encodeURIComponent(shareurl) + '"></g:plusone>');
  322.             $(".wrapper-social .google-sharer").append(gplusvar);
  323.             gapi.plusone.go("google-sharer");
  324.            
  325.             /** twitter sharer **/
  326.             var twt = $(document.createElement("a"))
  327.                     .attr("class", "twitter-share-button")
  328.                     .attr("href", "http://twitter.com/share")
  329.                     .attr("data-url", document.URL)
  330.                     .html("Tweet");
  331.            
  332.             var twt = $("<div class='twtlio'></div>").append(twt);
  333.             $(".wrapper-social .twitter-sharer").append(twt);
  334.             twttr.widgets.load();
  335.            
  336.         };
  337.        
  338.        
  339.         attach_social();
  340.        
  341.     };
  342. })(jQuery);
  343.  
  344.  
  345. (function($) {
  346.     $.fn.jegblog = function( options )
  347.     {      
  348.         var settings = {
  349.             minItem         : 4
  350.         };
  351.  
  352.         if (options) {
  353.             var options = $.extend(settings, options); 
  354.         } else {
  355.             var options = $.extend(settings);
  356.         }
  357.        
  358.        
  359.         /** public **/
  360.         var touch                   = false;
  361.         if((navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i)) || (navigator.userAgent.match(/iPad/i))) {
  362.             touch = true;
  363.         }
  364.        
  365.         var body = $(this);
  366.        
  367.         /** gallery **/
  368.         $(".blog-gallery-type", body).jeggallery({
  369.             direction_nav   :  options.direction_nav,
  370.             control_nav     :  options.control_nav
  371.         });
  372.        
  373.        
  374.         /** attach photoswipe **/
  375.         if($('.blog-gallery li a').length > 0 || $('.photoswipe').length > 0) {
  376.            
  377.             $('.blog-gallery li a').click(function() { return false; });
  378.             $('.photoswipe').click(function() { return false; });
  379.            
  380.             if(!options.uselightbox) {
  381.                 (function(PhotoSwipe){
  382.                     $(".blog-gallery").each(function(){
  383.                         $(this).find('a').photoSwipe({
  384.                             backButtonHideEnabled           : false,
  385.                             captionAndToolbarAutoHideDelay  : 0,
  386.                             allowUserZoom                   : true,
  387.                             imageScaleMethod                : 'fitNoUpscale',
  388.                             getImageSource                  : function(obj){ return $(obj).attr('href'); },
  389.                             getImageCaption                 : function(obj){ return $(obj).attr('data-title'); }
  390.                         });
  391.                     });
  392.                    
  393.                     $(".photoswipe").each(function(){
  394.                         $(this).photoSwipe({
  395.                             backButtonHideEnabled           : false,
  396.                             captionAndToolbarAutoHideDelay  : 0,
  397.                             allowUserZoom                   : true,
  398.                             imageScaleMethod                : 'fitNoUpscale',
  399.                             getImageSource                  : function(obj){ return $(obj).attr('href'); },
  400.                             getImageCaption                 : function(obj){ return $(obj).attr('data-title'); }
  401.                         });
  402.                     });
  403.                    
  404.                 }(window.Code.PhotoSwipe));
  405.             } else {
  406.                 $(".blog-gallery").each(function(){
  407.                     $(this).find('a').lightbox();                  
  408.                 });
  409.                 $(".photoswipe").each(function(){
  410.                     $(this).find('a').lightbox();
  411.                 });
  412.             }
  413.            
  414.         }
  415.        
  416.         /** carousel **/
  417.         setupCarousel(options.minItem, 2, false);          
  418.        
  419.         /** comment **/
  420.         $(".replycomment").click(function(){
  421.             var i = $(this).parents(".coment-box").parent();
  422.             var f = $("#respond");
  423.             var x = $("<div id='comment-box-reply'></div>");
  424.             var t = $("<div id='temp-comment-holder' style='display:none;'></div>");
  425.             var p = $("#comment_parent");          
  426.             var c = "data-comment-id";
  427.            
  428.             $(".closecommentform").hide();
  429.             $(".replycomment").show();
  430.             $("#comment-box-reply").remove();
  431.            
  432.             if(!$("#temp-comment-holder").length) {
  433.                 t.insertBefore(f);
  434.             }
  435.  
  436.            
  437.             x.insertAfter($(i).find('.coment-box-inner')).append(f);
  438.             p.val($(this).attr(c));
  439.            
  440.             $(this).hide();
  441.            
  442.             $(i).find(".closecommentform").show().click(function(){
  443.                 f.insertAfter($("#temp-comment-holder"));
  444.                 $("#temp-comment-holder").remove();
  445.                 $("#comment-box-reply").remove();
  446.                 $(this).hide();
  447.                 $(i).find('.replycomment').show();
  448.                 $("#comment_parent").val(0);
  449.             });        
  450.         });
  451.        
  452.     };
  453. })(jQuery);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement