Advertisement
Guest User

Custom.js

a guest
Apr 23rd, 2013
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /**
  2.  *  Silicon Theme
  3.  * 
  4.  *  Developed by: Arlind Nushi
  5.  *  Designed by: Art Ramadani
  6.  */
  7.  
  8. ;(function($, window, undefined)
  9. {
  10.     // platform detection
  11.     var html = $('html'),
  12.         os = '';
  13.    
  14.     if (navigator.appVersion.indexOf("Win")!=-1) os = "win";
  15.     if (navigator.appVersion.indexOf("Mac")!=-1) os = "mac";
  16.     if (navigator.appVersion.indexOf("X11")!=-1) os = "unix";
  17.     if (navigator.appVersion.indexOf("Linux")!=-1) os = "linux";
  18.    
  19.     html.addClass(os);
  20.    
  21.     // Site Header Clone for Sticky menu
  22.     var site_header = $(".sticky-menu #site_header"),
  23.         sticky_header = site_header.clone(),
  24.         site_header_height = site_header.outerHeight(),
  25.         win = $(window),
  26.         sticky_menu_interval,
  27.         sticky_menu_timeout = 25;
  28.    
  29.     site_header.after(sticky_header);
  30.     sticky_header.addClass('fixed').wrapInner('<div class="fixed_header"></div>');
  31.    
  32.     site_header_height *= 1.5;
  33.    
  34.     $(window).on({
  35.         scroll: function(e)
  36.         {
  37.             window.clearTimeout(sticky_menu_interval);
  38.            
  39.             sticky_menu_interval = setTimeout(check_sm_pos, sticky_menu_timeout);
  40.         }
  41.     });
  42.    
  43.     function check_sm_pos()
  44.     {
  45.         if(site_header_height < win.scrollTop())
  46.         {
  47.             sticky_header.addClass('visible');
  48.         }
  49.         else
  50.         {
  51.             sticky_header.removeClass('visible');
  52.         }
  53.     }
  54.    
  55.     check_sm_pos();
  56.    
  57.    
  58.     // Menu
  59.     var menu_z_index_count = 150;
  60.     var subMenuHoverSetup = function(item, level)
  61.     {
  62.         if( ! level)
  63.             level = 1;
  64.        
  65.         var sub_menu = item.find('> ul');
  66.        
  67.         var has_sub_menu = sub_menu.length > 0;
  68.        
  69.         var fade_delay = 0.400;
  70.         var easing = 'easeInOutQuad';
  71.         var time_out_delay = 300;
  72.        
  73.        
  74.         // Has Sub Menu (1st level)
  75.         if(has_sub_menu)
  76.         {
  77.             // Timeout (for Hover out delay)
  78.             var time_out_id = 0;
  79.            
  80.             // Set Icon
  81.             if(level == 1)
  82.             {
  83.                 item.find('> a').append('<i class="has_sub"></i>');
  84.             }
  85.  
  86.             item.addClass('has_sub');
  87.            
  88.             // Determine Height
  89.             var sub_menu_height = sub_menu.height();
  90.            
  91.             if(sub_menu_height == 0)
  92.             {
  93.                 var _parent = sub_menu.parent();
  94.                
  95.                 for(var i=1; i<=level; i++)
  96.                 {
  97.                     _parent.show();
  98.                     _parent = _parent.parent();
  99.                 }
  100.                
  101.                 sub_menu_height = sub_menu.height();
  102.             }
  103.            
  104.             sub_menu.data('height', sub_menu_height).addClass('noheight');
  105.            
  106.             // Hover In
  107.             item.on('mouseenter', function(ev)
  108.             {
  109.                 menu_z_index_count++;
  110.                
  111.                 if(time_out_id)
  112.                 {
  113.                     window.clearTimeout(time_out_id);
  114.                     time_out_id = 0;
  115.                     return;
  116.                 }
  117.                
  118.                 var s_height = sub_menu.data('height');
  119.                
  120.                 sub_menu.css({display: 'block', zIndex: menu_z_index_count});
  121.  
  122.                 TweenMax.to(sub_menu.fadeTo(0,0), fade_delay, {css: {autoAlpha: 1, height: s_height}, ease: Power4.easeOut, onComplete: function(){
  123.                     sub_menu.removeClass('noheight').height('auto');
  124.                 }});
  125.             });
  126.            
  127.            
  128.             // Hover Out
  129.             item.on('mouseleave', function(ev)
  130.             {
  131.                 window.clearTimeout(time_out_id);
  132.                
  133.                 time_out_id = setTimeout(function(){
  134.                                    
  135.                     TweenMax.to(sub_menu, fade_delay, {css: {autoAlpha: 0, height: 0}, ease: Power4.easeIn, onComplete: function()
  136.                     {
  137.                         sub_menu.css('display', 'none').addClass('noheight');
  138.                     }});
  139.                    
  140.                     time_out_id = 0;
  141.                    
  142.                 }, time_out_delay);
  143.             });
  144.            
  145.                            
  146.             // Continue Recursion
  147.             var sub_menu_items = sub_menu.find('> li');
  148.            
  149.             sub_menu_items.each(function(i)
  150.             {
  151.                 var sub_menu_item = $(this);
  152.                
  153.                 subMenuHoverSetup(sub_menu_item, parseInt(level, 10)+1);
  154.             });
  155.         }
  156.        
  157.         },
  158.        
  159.     subMenuHoverSetup2 = function(item, level)
  160.     {
  161.         if( ! level)
  162.             level = 1;
  163.        
  164.         var sub_menu = item.find('> ul');
  165.        
  166.         var has_sub_menu = sub_menu.length > 0;
  167.        
  168.         var fade_delay = 0.350;
  169.         var easing = 'easeInOutQuad';
  170.         var time_out_delay = 50;
  171.        
  172.         // Has Sub Menu (1st level)
  173.         if(has_sub_menu)
  174.         {
  175.             // Timeout (for Hover out delay)
  176.             var time_out_id = 0;
  177.            
  178.             // Set Icon
  179.             if(level == 1)
  180.             {
  181.                 item.find('> a').append('<i class="has_sub"></i>');
  182.             }
  183.  
  184.             item.addClass('has_sub');
  185.             sub_menu.css({
  186.                 visibility: 'hidden',
  187.                 opacity: 0
  188.             });
  189.            
  190.            
  191.             // Hover In
  192.             item.on('mouseenter', function(ev)
  193.             {
  194.                 menu_z_index_count++;
  195.                
  196.                 if(time_out_id)
  197.                 {
  198.                     window.clearTimeout(time_out_id);
  199.                     time_out_id = 0;
  200.                     return;
  201.                 }
  202.                
  203.                 sub_menu.css({zIndex: menu_z_index_count});
  204.  
  205.                 TweenMax.to(sub_menu, fade_delay, {css: {autoAlpha: 1}, ease: Sine.easeInOut});
  206.             });
  207.            
  208.            
  209.             // Hover Out
  210.             item.on('mouseleave', function(ev)
  211.             {
  212.                 window.clearTimeout(time_out_id);
  213.                
  214.                 time_out_id = setTimeout(function(){
  215.                                    
  216.                     TweenMax.to(sub_menu, fade_delay, {css: {autoAlpha: 0}, ease: Sine.easeInOut});
  217.                    
  218.                     time_out_id = 0;
  219.                    
  220.                 }, time_out_delay);
  221.             });
  222.            
  223.                            
  224.             // Continue Recursion
  225.             var sub_menu_items = sub_menu.find('> li');
  226.            
  227.             sub_menu_items.each(function(i)
  228.             {
  229.                 var sub_menu_item = $(this);
  230.                
  231.                 subMenuHoverSetup2(sub_menu_item, parseInt(level, 10)+1);
  232.             });
  233.         }
  234.        
  235.     };
  236.    
  237.    
  238.     var main_menu = $("#site_header .main_menu");
  239.     var main_menu_items = main_menu.find(" > li");
  240.    
  241.     if( ! $("#site_header_ul").length )
  242.     {  
  243.         main_menu = $("#site_header .main_menu ul");
  244.         main_menu_items = main_menu.find(" > li");
  245.        
  246.         main_menu.attr('id', 'site_header_ul');
  247.     }
  248.    
  249.     main_menu_items.each(function(i)
  250.     {
  251.         var item = $(this);
  252.        
  253.         subMenuHoverSetup2(item);
  254.     });
  255.    
  256.    
  257.     /* Select Menu */
  258.     selectnav('site_header_ul', {
  259.         activeclass: 'current_page_item',
  260.         label: main_menu.data('title') > 0 ? main_menu.data('title') : ':: Main Menu ::',
  261.         nested: true,
  262.         indent: '-'
  263.     });
  264.    
  265.     var snav = $(".selectnav");
  266.    
  267.     snav.wrap('<div class="mobile_menu"></div>').on({
  268.         change: function()
  269.         {
  270.             mm_placeholder.html(mm_arrow + clearIndenter(snav.find('option:selected').html()));
  271.         }
  272.     });
  273.    
  274.     var mobile_menu = $(".mobile_menu"),
  275.         mm_placeholder = $('<div class="mm_placeholder"></div>'),
  276.         mm_arrow = '<span class="indenter">&raquo;</span> ',
  277.         clearIndenter = function(str)
  278.         {
  279.             if( ! str)
  280.                 return '';
  281.                
  282.             return str.replace(/^-*/, '');
  283.         };
  284.    
  285.     mobile_menu.append(mm_placeholder);
  286.    
  287.     mm_placeholder.html(mm_arrow + clearIndenter(snav.find('option:selected').html()));
  288.    
  289.  
  290.    
  291.    
  292.     /* Outer Title Markup */
  293.     var outer_title_table = $('<table />');
  294.     var outer_title_table_rc = $('<table />');
  295.    
  296.     outer_title_table.addClass('outer_title_table').attr('width', '100%');
  297.     outer_title_table_rc.addClass('outer_title_table').attr('width', '100%');
  298.    
  299.     var otb_row = $('<tr />');
  300.     var otb_row_rc = $('<tr />');
  301.    
  302.     var text_env = $('<td />').addClass('text_env');
  303.     var right_border = $('<td />').addClass('right_border');
  304.     var page_top = $('<td />').html('<a href="#" class="top">Top</a>').addClass('page_top');
  305.     var right_content = $('<td nowrap="nowrap" />').addClass('right_content_title normal');
  306.    
  307.     otb_row.append(text_env).append(right_border).append(page_top);
  308.     otb_row_rc.append(text_env.clone()).append(right_border.clone()).append(right_content.clone());
  309.    
  310.     outer_title_table.append(otb_row);
  311.     outer_title_table_rc.append(otb_row_rc);
  312.    
  313.     $("h1.title, h2.title:not(footer .title), h3.title, h4.title").each(function()
  314.     {
  315.         var $this = $(this);
  316.         var tag_name = $this.get(0).tagName;
  317.        
  318.         var html = $this.html().toString();
  319.         var heading = $('<'+tag_name+' />').html(html);
  320.        
  321.         var right_content = $this.find('.right_content'),
  322.             table_ins,
  323.             classes = $this[0].className.split(' ');
  324.        
  325.         if(right_content && right_content.length > 0)
  326.         {
  327.             table_ins = outer_title_table_rc.clone();  
  328.             $this.after(table_ins).detach();
  329.            
  330.             for(var i=0; i<classes.length; i++)
  331.             {
  332.                 if(classes[i] != 'title')
  333.                 {
  334.                     table_ins.addClass(classes[i]);
  335.                 }
  336.             }
  337.            
  338.             table_ins.find('.text_env').html(heading);
  339.             table_ins.find('.right_content').remove();
  340.             table_ins.find('.right_content_title').append(right_content);
  341.            
  342.             right_content.removeClass('is_hidden');
  343.         }
  344.         else
  345.         {
  346.             table_ins = outer_title_table.clone();
  347.            
  348.             for(var i=0; i<classes.length; i++)
  349.             {
  350.                 if(classes[i] != 'title')
  351.                 {
  352.                     table_ins.addClass(classes[i]);
  353.                 }
  354.             }
  355.            
  356.             if($this.hasClass('no_top'))
  357.             {
  358.                 table_ins.find('.page_top').remove();
  359.             }
  360.            
  361.             $this.after(table_ins).detach();
  362.             table_ins.find('.text_env').html(heading);
  363.         }
  364.        
  365.     });
  366.    
  367.    
  368.     // Back to Top
  369.     $("a.top, .top a").on('click', function(ev)
  370.     {
  371.         ev.preventDefault();
  372.        
  373.         $("html,body").animate({scrollTop: 0}, {duration: 800, easing: 'easeInOutQuad'});
  374.     });
  375.    
  376.    
  377.     // Setup Partners/Client Carousel
  378.     var partners_carousel = $(".partners_carousel"),
  379.         pc_autoswitch = partners_carousel.data('autoswitch');
  380.    
  381.     if($.isFunction(partners_carousel.anCarousel))
  382.     {  
  383.         partners_carousel.anCarousel({
  384.             itemsPerRow: 4,
  385.             autoSlide: pc_autoswitch,
  386.             pauseOnHover: true,
  387.             animationEngine: 'gsap' // jquery or gsap
  388.         });
  389.    
  390.         partnersCarouselFit();
  391.     }
  392.    
  393.    
  394.    
  395.     // Drop Off Effect for Header Social Networks
  396.     var social_networks_dropoff = $(".drop_off_effect");
  397.    
  398.     if(social_networks_dropoff.length > 0)
  399.     {
  400.         var drop_off_delay = 0.3;
  401.         var drop_off_start_from = {left: -40, top: -40, autoAlpha: 0, scale: 2.5};
  402.        
  403.         social_networks_dropoff.each(function(){
  404.            
  405.             var $this = $(this);
  406.             var $items = $this.children();
  407.            
  408.             $items.addClass('relative');
  409.            
  410.             var del = 0, del_step = 0.1;
  411.            
  412.             $items.each(function(){
  413.                 var $item = $(this);
  414.                
  415.                 TweenMax.from($item, drop_off_delay, {css: drop_off_start_from, delay: del});
  416.                
  417.                 del += del_step;
  418.             });
  419.         })
  420.     }
  421.    
  422.     // Slider
  423.     if($.isFunction($.fn.fadeOSlider))
  424.     {
  425.         // Cycle Slider (mostly on homepage)
  426.         var cycle_slider = $("#cycle_slider");
  427.         var nav = cycle_slider.find('.control_nav');
  428.        
  429.         cycle_slider.fadeOSlider({
  430.             numbers: nav,
  431.             selector: '.slide',
  432.             keyboard: true
  433.         });
  434.        
  435.        
  436.         // Slideshow Slider
  437.         var slideshow = $(".slideshow");
  438.        
  439.        
  440.         slideshow.each(function(i)
  441.         {
  442.             var $slideshow = $(this);
  443.            
  444.             $slideshow.fadeOSlider({
  445.                 selector: 'img',
  446.             });
  447.         })
  448.        
  449.         // Portfolio Item Details
  450.         var portfolio_item_details = $(".portfolio_item_details .images");
  451.         var pid_prevnext = $('.portfolio_item_details .prev_next_nav');
  452.        
  453.         portfolio_item_details.fadeOSlider({
  454.             prevNext: pid_prevnext,
  455.             keyboard: true
  456.         });
  457.     }
  458.    
  459.    
  460.     // Touch Carousel - by Arlind Nushi
  461.     if($.isFunction($.fn.anSwiper))
  462.     {
  463.         var features_blocks = $("#features_blocks .features_blocks");
  464.         var features_blocks_nav = $("#features_blocks .features_blocks_nav");
  465.        
  466.         features_blocks.each(function()
  467.         {
  468.             var $this = $(this),
  469.                 _navscope = parseInt($this.data('navscope'), 10),
  470.                 _navstep = parseInt($this.data('navstep'), 10);
  471.            
  472.             if(_navscope == 0)
  473.                 _navscope = 4;
  474.            
  475.            
  476.             $this.anSwiper({
  477.                 selector: '.columns',
  478.                 nextprev: features_blocks_nav,
  479.                 navscope: _navscope,
  480.                 navstep: _navstep,
  481.                 duration: 700,
  482.                 ease: Power4.easeOut
  483.             });
  484.         });
  485.        
  486.         var team_members = $(".team_members");
  487.         var team_members_nav = $(".team_members_nav");
  488.        
  489.         team_members.anSwiper({
  490.             selector: '.columns',
  491.             nextprev: team_members_nav,
  492.             navscope: 4,
  493.             navstep: 1,
  494.             duration: 700,
  495.             ease: Power4.easeOut
  496.         });
  497.     }
  498.    
  499.    
  500.     // Features Tabs Hover Effect
  501.     if(features_blocks)
  502.     {
  503.         var feature_block = features_blocks.find('.feature_block'),
  504.             fb_animation_delay = 0.2,
  505.             fb_ease_1 = Power0.easeInOut,
  506.             fb_ease_2 = Power2.easeInOut;
  507.        
  508.         feature_block.each(function()
  509.         {
  510.             var $block = $(this),
  511.                 $hover_el = $('<div class="on_hover"></div>'),
  512.                 $block_h3 = $block.find('h3'),
  513.                 $block_content = $block.find('.content');
  514.            
  515.             $block.prepend($hover_el);
  516.            
  517.             var def_top = parseInt($hover_el.css('top'), 10),
  518.                 def_height = $hover_el.outerHeight(true),
  519.                 h3_color = $block_h3.css('color'),
  520.                 content_color = $block_content.css('color'),
  521.                 timeline;
  522.                
  523.             $hover_el.data({
  524.                 top: def_top,
  525.                 height: def_height
  526.             });
  527.            
  528.             var textHoverIn = function()
  529.             {
  530.                 TweenMax.to([$block_h3, $block_content], 0.1, {css: {color: '#FFF'}, ease: Sine.easeInOut});
  531.             }
  532.            
  533.             var textHoverOut = function()
  534.             {
  535.                 TweenMax.to($block_h3, 0.1, {css: {color: h3_color}, ease: Sine.easeInOut});
  536.                 TweenMax.to($block_content, 0.1, {css: {color: content_color}, ease: Sine.easeInOut});
  537.             }
  538.            
  539.             $block.on({
  540.                 mouseenter: function()
  541.                 {                  
  542.                     timeline = new TimelineMax({delay: 0.1});
  543.                     timeline.append( TweenMax.to($hover_el, fb_animation_delay, {css: {width: '100%', left: '0%'}, ease: fb_ease_1}) );
  544.                     timeline.append( TweenMax.to($hover_el, fb_animation_delay, {css: {height: '100%', top: 0}, ease: fb_ease_2, onStart: textHoverIn}) );
  545.                 },
  546.                
  547.                 mouseleave: function()
  548.                 {
  549.                     TweenMax.killTweensOf([$hover_el, $block_h3, $block_content, timeline]);
  550.                    
  551.                     timeline = new TimelineMax();
  552.                     timeline.append( TweenMax.to($hover_el, fb_animation_delay, {css: {height: def_height, top: def_top}, ease: fb_ease_1, onStart: textHoverOut}) );
  553.                     timeline.append( TweenMax.to($hover_el, fb_animation_delay, {css: {width: '0%', left: '50%'}, ease: fb_ease_2}) );
  554.                 }
  555.             });
  556.         });
  557.     }
  558.  
  559.    
  560.     // Direction Avare Portfolio Hover (Copyright 2012, Codrops)
  561.     var portfolio_item = $(".portfolio_item");
  562.        
  563.     if($.isFunction($.fn.hoverdir))
  564.     {
  565.         portfolio_item.each(function(i)
  566.         {
  567.             var $item = $(this);
  568.            
  569.             $item.hoverdir();
  570.         });
  571.     }
  572.    
  573.    
  574.     $("#portfolio_items").on('click', '.immediate_open', function(ev)
  575.     {
  576.         ev.preventDefault();
  577.        
  578.         var $this = $(this);
  579.        
  580.         if($this.data('standalone'))
  581.         {
  582.             Shadowbox.open({
  583.                 player: ($this.attr('href').match(/(youtube\.com|vimeo\.com)/) ? 'iframe' : "img"),
  584.                 title: $this.data('title'),
  585.                 content: $this.attr('href')
  586.             });
  587.         }
  588.         else
  589.         if($this.data('gallery'))
  590.         {
  591.             var gallery_list = $this.data('gallery').split(','),
  592.                 gallery_items = [],
  593.                 gallery_item,
  594.                 options = {
  595.                     continuous:     true,
  596.                     counterType:    "skip"
  597.                 };
  598.            
  599.             for(var i in gallery_list)
  600.             {
  601.                 gallery_item = gallery_list[i];
  602.                
  603.                 gallery_item = {
  604.                     player: (gallery_item.match(/(youtube\.com|vimeo\.com)/) ? 'iframe' : "img"),
  605.                     title: $this.data('title'),
  606.                     content: gallery_item,
  607.                     options: options
  608.                 };
  609.                
  610.                 gallery_items.push(gallery_item);
  611.             }
  612.            
  613.             Shadowbox.open(gallery_items);
  614.         }
  615.         else
  616.         if($this.attr('target').length > 0)
  617.         {
  618.             window.open($this.attr('href'));
  619.         }
  620.     });
  621.    
  622.    
  623.     // Blog Hover Images
  624.     var post_image = $(".post_entry .post_image, .member .image"),
  625.         hover_delay = 0.2,
  626.         icons_drop_delay = 0.3,
  627.         delay_incr = 0.2;
  628.    
  629.     post_image.imagesLoaded(function()
  630.     {
  631.         post_image.each(function()
  632.         {
  633.             var $img = $(this),
  634.                 $hover = $img.find('.hover'),
  635.                 $hover_links = $hover.find('a'),
  636.                 links_length = $hover_links.length;
  637.                
  638.             if($hover.length == 0)
  639.                 return;
  640.            
  641.             $img.on({
  642.                 mouseenter: function()
  643.                 {
  644.                     var img_height = $img.height();
  645.                    
  646.                     $hover_links.css({
  647.                         top: -img_height/2
  648.                     });
  649.                    
  650.                     TweenMax.to($hover, hover_delay, {css: {autoAlpha: 1}});
  651.                    
  652.                     $hover_links.each(function(i)
  653.                     {
  654.                         var $this = $(this);
  655.                         var top = img_height / 2 - ($this.outerHeight() / 2);
  656.                        
  657.                         TweenMax.to($this, icons_drop_delay + delay_incr * i, {css: {top: top}, ease: Expo.easeOut});
  658.                     });
  659.                 },
  660.                
  661.                 mouseleave: function()
  662.                 {
  663.                     var img_height = $img.height();
  664.                    
  665.                     TweenMax.killTweensOf([$hover, $hover_links]);
  666.                     TweenMax.to($hover, hover_delay, {css: {autoAlpha: 0}});
  667.                    
  668.                     $hover_links.each(function(i)
  669.                     {
  670.                         var $this = $(this);
  671.                         var top = img_height / 2 - ($this.outerHeight() / 2);
  672.                        
  673.                         TweenMax.to($this, icons_drop_delay + delay_incr * i, {css: {top: top}, ease: Expo.easeIn});
  674.                        
  675.                         $hover_links.each(function(i)
  676.                         {
  677.                             var $this = $(this);
  678.                             var top = -img_height/2;
  679.                            
  680.                             TweenMax.to($this, icons_drop_delay + delay_incr * (links_length - i), {css: {top: top}});
  681.                         });
  682.                     });
  683.                 }
  684.             });
  685.         });
  686.     });
  687.    
  688.     // Testimonials Widget (Footer)
  689.     if($.isFunction($.fn.anTweetRoller))
  690.     {
  691.         var testimonials = $(".testimonials"),
  692.             testimonials_nav = $(".testimonials_nav");
  693.        
  694.         testimonials.anTweetRoller({
  695.             switchDelay: 800,
  696.             puffScale: 1.2,
  697.             numbers: testimonials_nav,
  698.             effect: 'puff'
  699.         });
  700.        
  701.         // Testimonials 2
  702.         var testimonials_2 = $(".testimonials_2");
  703.        
  704.         testimonials_2.anTweetRoller({
  705.             switchDelay: 800,
  706.             effect: 'fade',
  707.             ease: Power0.easeInOut
  708.         });
  709.    
  710.        
  711.         //  Tweets
  712.         var tweets_widget = $(".tweets_widget");
  713.        
  714.         tweets_widget.each(function()
  715.         {          
  716.             var $this = $(this),
  717.                 tweets = $this.find(".tweets"),
  718.                 tweets_nav = $this.find(".tweets_nav"),
  719.                 opts = {
  720.                     switchDelay: 800,
  721.                     puffScale: 1.2,
  722.                     effect: 'puff',
  723.                     ease: Power0.easeInOut,
  724.                     numbers: tweets_nav,
  725.                     num: 3
  726.                 };
  727.            
  728.             if(tweets.data('fetch'))
  729.             {
  730.                 $.getJSON('http://api.twitter.com/1/statuses/user_timeline.json?screen_name=' + tweets.data('user') + '&count=' + tweets.data('count') + '&callback=?', function(resp)
  731.                 {
  732.                     var tweet = {}, tweet_dom, date;
  733.                    
  734.                     tweets.find('li').remove();
  735.                    
  736.                     for(var i in resp)
  737.                     {
  738.                         tweet = resp[i];
  739.                         date = new Date(tweet.created_at);
  740.                        
  741.                         tweet_dom = '<li>';
  742.                         tweet_dom += '<div class="tweet">';
  743.                         tweet_dom += tweet.text;
  744.                         tweet_dom += '<span class="timespan">' + date.getDate() + ' ' + month_names_short[date.getMonth()] + '</span>';
  745.                         tweet_dom += '</div>';
  746.                         tweet_dom += '</li>';
  747.                        
  748.                         tweets.append(tweet_dom);
  749.                     }
  750.                    
  751.                     tweets.anTweetRoller(opts);
  752.                 })
  753.             }
  754.             else
  755.             {  
  756.                 tweets.anTweetRoller(opts);
  757.             }
  758.         });
  759.     }
  760.    
  761.    
  762.    
  763.     // Wide Slider
  764.     if($.isFunction($.fn.wideslider))
  765.     {
  766.         var wideslider_env = $("#wideslider"),
  767.             hh = $("header").outerHeight();
  768.        
  769.    
  770.         wideslider_env.wideslider({
  771.             wrapper: '#wrap',
  772.             delay: 800,
  773.             nextPrev: $(".wideslider_nextprev"),
  774.             prevNextOnKeyboard: true,
  775.             progressTimer: true,
  776.             autoCenterCaptions: true,
  777.             headerHeight: hh,
  778.             autoCenterVerticalOffset: -25,
  779.             //captions: false, // will hide text captions
  780.         });
  781.        
  782.         wideslider_env.wideslider('autoCenter');
  783.     }
  784.    
  785.    
  786.    
  787.     // Sidebar Tabs
  788.     $(".sb_tabs").each(function()
  789.     {
  790.         var $sb_tabs = $(this),
  791.             $sb_tabs_title = $sb_tabs.find('.sb_tabs_title a'),
  792.             $sb_tabs_content = $sb_tabs.find('.sb_tabs_content'),
  793.             current = $sb_tabs_title.filter('.active').attr('href'),
  794.             current_title;
  795.        
  796.         if(current && current.length > 0)
  797.         {
  798.             current_title = $sb_tabs_title.filter('.active');
  799.             current = $sb_tabs_content.find(current);
  800.         }
  801.         else
  802.         {
  803.             current_title = $sb_tabs_title.first();
  804.            
  805.             var first_title = current_title.attr('href');
  806.             current = $sb_tabs_content.find(first_title);
  807.         }
  808.        
  809.         // Set Active
  810.         if(current && current.length)
  811.         {
  812.             $sb_tabs_content.find('> div').not(current).hide();
  813.             current.show();
  814.            
  815.             $sb_tabs_title.not(current_title).removeClass('active');
  816.             current_title.addClass('active');
  817.         }
  818.        
  819.         $sb_tabs_title.on({
  820.             click: function(ev)
  821.             {
  822.                 ev.preventDefault();
  823.                
  824.                 var $title = $(this);
  825.                
  826.                 var id = $title.attr('href');
  827.                 var to_show = $sb_tabs_content.find(id);
  828.                
  829.                 if(id == current_title.attr('href'))
  830.                     return;
  831.                    
  832.                 var masonry = to_show.find('.masonry');
  833.                
  834.                 if(masonry && masonry.length)
  835.                 {
  836.                     to_show.show();
  837.                     masonry.masonry('reload');
  838.                     to_show.hide();
  839.                 }
  840.                
  841.                 if(to_show && to_show.length)
  842.                 {
  843.                     current_title.removeClass('active');
  844.                     $title.addClass('active');
  845.                    
  846.                     current.slideUp('normal');
  847.                     to_show.slideDown('normal');
  848.                    
  849.                     current_title = $title;
  850.                     current = to_show;
  851.                 }
  852.             }
  853.         });
  854.     });
  855.    
  856.    
  857.    
  858.     // Masonry Tags
  859.     if($.isFunction($.fn.masonry))
  860.     {
  861.         $('.sidebar_entry .tagcloud').masonry({
  862.             itemSelector : 'a',
  863.             columnWidth : 7
  864.         });
  865.     }
  866.    
  867.    
  868.     // Separated Lists
  869.     $(".separated_list").each(function()
  870.     {
  871.         var $list = $(this);
  872.         var $items = $list.children();
  873.        
  874.         $items.each(function(i)
  875.         {
  876.             var $item = $(this);
  877.             var sep = $('<li class="list_sep">&ndash;</li>');
  878.            
  879.                 $item.after(sep);
  880.             if(i > 0)
  881.             {
  882.             }
  883.         });
  884.     });
  885.    
  886.    
  887.     // Portfolio Categories
  888.     if($.isFunction($.fn.isotope))
  889.     {
  890.         var portfolio_items = $("#portfolio_items"),
  891.             portfolio_item = $("#portfolio_items .portfolio_item"),
  892.             isotope_options = {
  893.                 masonry:
  894.                 {
  895.                     itemSelector: '.portfolio_item',
  896.                     columnWidth: 1/4,
  897.                     gutterWidth: 0
  898.                 },
  899.                 animationOptions: {
  900.                     duration: 750,
  901.                     easing: 'linear',
  902.                     queue: false
  903.                 }
  904.             };
  905.        
  906.         portfolio_items.isotope(isotope_options);
  907.        
  908.         // Isotope Filter
  909.         var portfolio_filter = $("#portfolio_filter li a");
  910.        
  911.         portfolio_filter.each(function()
  912.         {
  913.             var $category = $(this);
  914.             var $filter = $category.data('filter');
  915.                        
  916.             $category.on({
  917.                 click: function(ev)
  918.                 {
  919.                     ev.preventDefault();
  920.                    
  921.                     portfolio_filter.parent().removeClass('active');
  922.                     $category.parent().addClass('active');
  923.                    
  924.                     window.location.hash = $filter == '*' ? '' : ('category-' + $filter);
  925.                    
  926.                     portfolio_items.isotope({
  927.                         filter: function(index)
  928.                         {
  929.                             var item = $(this),
  930.                                 filters = item.data('filter');
  931.                    
  932.                             if($filter == '*' || filters.match(new RegExp($filter, 'i')))
  933.                             {
  934.                                 return true;
  935.                             }
  936.                            
  937.                             return false;
  938.                         }
  939.                     });
  940.                 }
  941.             });
  942.         });
  943.        
  944.        
  945.         // Show current category from url hash
  946.         var url_hash = window.location.hash.toString().replace('#', '');
  947.        
  948.         if(url_hash.match(new RegExp('^category-(.*?)$', 'i')))
  949.         {
  950.             var category_id = url_hash.replace(/^category-/i, '');
  951.             var filterer = '[data-filter="' + category_id + '"]';
  952.            
  953.             portfolio_filter.parent().removeClass('active');
  954.             portfolio_filter.filter(filterer).parent().addClass('active');
  955.            
  956.             var filter_name = filterer.match(/"(.*?)"/);
  957.            
  958.             if(filter_name.length > 1)
  959.             {
  960.                 filter_name = filter_name[1];
  961.             }
  962.            
  963.             portfolio_items.isotope({filter: function(){
  964.            
  965.                 var item = $(this),
  966.                     filters = item.data('filter');
  967.        
  968.                 if(filter_name == '*' || filters.match(new RegExp(filter_name, 'i')))
  969.                 {
  970.                     return true;
  971.                 }
  972.                
  973.                 return false;
  974.                
  975.             }});
  976.         }
  977.     }
  978.    
  979.    
  980.     /* Infinite Scroll */
  981.     var endless_scrolling = jQuery(".endless_scrolling");
  982.    
  983.     if(jQuery.isFunction(jQuery.fn.infinitescroll) && endless_scrolling.length > 0)
  984.     {
  985.         var pagination_link = jQuery('.endless_scroll_pagination a'),
  986.             child_class = '.portfolio_item';
  987.        
  988.         endless_scrolling.infinitescroll({
  989.             navSelector: pagination_link,
  990.             nextSelector: pagination_link,
  991.             itemSelector: child_class,
  992.             onIsDone: function(){      
  993.                 TweenMax.to(pagination_link, 0.5, {css: {autoAlpha: 0}});
  994.             },
  995.             loading: {
  996.                 finishedMsg: '',
  997.                 img: '',
  998.                 msgText: ''
  999.             }
  1000.             //,debug: true
  1001.         },
  1002.         function(newElements){
  1003.        
  1004.             var new_items = jQuery(newElements);
  1005.             var active_category = jQuery(".is_portfolio_filter .active a").data('filter');
  1006.            
  1007.             new_items.hide();
  1008.            
  1009.             pagination_link.fadeTo(0,0);
  1010.             TweenMax.to(pagination_link, 0.5, {css: {autoAlpha: 1}});
  1011.            
  1012.             new_items.imagesLoaded(function()
  1013.             {
  1014.                 endless_scrolling.isotope('addItems', new_items, function()
  1015.                 {  
  1016.                     new_items.show();
  1017.                    
  1018.                     // Filter Results
  1019.                     endless_scrolling.isotope({filter: function(){
  1020.                
  1021.                             var $this = $(this),
  1022.                                 filters = $this.data('filter');
  1023.                            
  1024.                            
  1025.                             if( ! active_category || active_category == '*' || active_category == 'all')
  1026.                             {
  1027.                                 return true;
  1028.                             }
  1029.                            
  1030.                             return filters.indexOf(active_category) >= 0;
  1031.                         }
  1032.                     });
  1033.                    
  1034.                     new_items.each(function()
  1035.                     {
  1036.                         var $item = $(this);
  1037.                        
  1038.                         $item.imagesLoaded(function()
  1039.                         {
  1040.                             $item.hoverdir();
  1041.                         })
  1042.                     })
  1043.                 });
  1044.                
  1045.             });
  1046.            
  1047.         });
  1048.        
  1049.        
  1050.         // Make Manual Scroller via Button
  1051.         if(endless_scrolling.hasClass('endless_scrolling_manual'))
  1052.         {
  1053.             jQuery(window).unbind('.infscr');
  1054.         }
  1055.        
  1056.        
  1057.         var infscr = endless_scrolling.data('infinitescroll');
  1058.        
  1059.         pagination_link.on('click', function(ev)
  1060.         {
  1061.             ev.preventDefault();
  1062.             infscr.retrieve();
  1063.            
  1064.             if( infscr.options.state.isDone )
  1065.             {
  1066.                 pagination_link.fadeTo(500, 0);
  1067.             }
  1068.         });
  1069.     }
  1070.    
  1071.    
  1072.     // Silicon Placeholders
  1073.     var ph_delay = 0.2;
  1074.     $("form div.placeholder").each(function()
  1075.     {
  1076.         var $placeholder = $(this);
  1077.         var label = $placeholder.find('> label');
  1078.         var input = $placeholder.find('> input, > textarea');
  1079.        
  1080.         input.on({
  1081.             focus: function(ev)
  1082.             {
  1083.                 $placeholder.addClass('focused');
  1084.                 TweenMax.to(label, ph_delay, {css: {autoAlpha: 0}});
  1085.             },
  1086.            
  1087.             blur: function(ev)
  1088.             {
  1089.                 $placeholder.removeClass('focused');
  1090.                
  1091.                 if(input.val().length == 0)
  1092.                     TweenMax.to(label, ph_delay, {css: {autoAlpha: 1}});
  1093.             }
  1094.         });
  1095.        
  1096.         label.on({
  1097.             click: function(ev)
  1098.             {
  1099.                 input.focus();
  1100.             }
  1101.         });
  1102.        
  1103.         if(input.val().length > 0)
  1104.         {
  1105.             label.css('opacity', 0).css('visibility', 'hidden');
  1106.         }
  1107.     });
  1108.    
  1109.    
  1110.    
  1111.     // Block Quotes
  1112.     var blockquotes = $('blockquote');
  1113.    
  1114.     blockquotes.each(function(i)
  1115.     {
  1116.         var blockquote = $(this),
  1117.             quotes_o = $('<div class="quotes open" />'),
  1118.             quotes_c = $('<div class="quotes close" />');
  1119.        
  1120.         blockquote
  1121.             .append(quotes_o)
  1122.             .append(quotes_c);
  1123.     });
  1124.    
  1125.     // Code Blocks
  1126.     var pres = $('pre');
  1127.    
  1128.     pres.each(function(i)
  1129.     {
  1130.         var pre = $(this);
  1131.         var hash = $('<div class="hash" />');
  1132.        
  1133.         pre.append(hash);
  1134.     });
  1135.    
  1136.    
  1137.     if($.isFunction($.fn.tabs))
  1138.     {
  1139.         // Tabs
  1140.         var tabs = $('div.tabs');
  1141.        
  1142.         tabs.each(function()
  1143.         {
  1144.             var tab_env = $(this);
  1145.            
  1146.             tab_env.tabs();
  1147.         });
  1148.        
  1149.        
  1150.         // Accordion
  1151.         var accordion = $('div.accordion');
  1152.        
  1153.         accordion.each(function()
  1154.         {
  1155.             var accordion_env = $(this);
  1156.            
  1157.             accordion_env.accordion();
  1158.         });
  1159.     }
  1160.    
  1161.    
  1162.     // Progress Bars
  1163.     var pb_fill_bar_delay = 1;
  1164.     $(".progress_bars").each(function()
  1165.     {
  1166.         var $progress_bar = $(this);
  1167.        
  1168.         var $bars = $progress_bar.find('.bar');
  1169.        
  1170.         $bars.each(function()
  1171.         {
  1172.             var $bar = $(this);
  1173.             var $pct = $bar.find('span[data-pct]');
  1174.             var pct = parseInt($pct.data('pct'), 10);
  1175.            
  1176.             if(pct > 100)
  1177.                 pct = 100;
  1178.            
  1179.             TweenMax.to($pct, pb_fill_bar_delay, {css: {width: pct + '%'}, ease: Quad.easeOut});
  1180.         });
  1181.     });
  1182.    
  1183.    
  1184.     // Testimonials 2 Arrow
  1185.     $(".testimonials_2 blockquote").each(function()
  1186.     {
  1187.         var $arrow = $('<div class="arrow" />');
  1188.        
  1189.         $(this).append($arrow);
  1190.     });
  1191.    
  1192.    
  1193.     // JQuery Scroll Pane
  1194.     if($.isFunction($.fn.jScrollPane))
  1195.     {
  1196.         $(".scroll-pane").each(function()
  1197.         {
  1198.             var $this = $(this);
  1199.            
  1200.             $this.jScrollPane({
  1201.             Â Â Â Â showArrows: false,
  1202.             Â Â Â Â animateScroll: true,
  1203.             Â Â Â Â animateDuration: 200,
  1204.             Â Â Â Â mouseWheelSpeed: 100,
  1205.             Â Â Â Â keyboardSpeed: 100,
  1206.            
  1207.                 animateSteps: true
  1208.             });
  1209.            
  1210.             var jsp = $this.data('jsp');
  1211.         });
  1212.     }
  1213.    
  1214.    
  1215.     // Portfolio Item Details Effects
  1216.     $(".portfolio_item_details").each(function()
  1217.     {
  1218.         var $this = $(this),
  1219.             $details = $(this),
  1220.            
  1221.             $project_info = $details.find('.project_info'),
  1222.             $project_info_close = $project_info.find('.close'),
  1223.             $info_list = $details.find('.info_list'),
  1224.             $info_link = $details.find('.info_link'),
  1225.             $prev_next_nav = $details.find('.prev_next_nav');
  1226.        
  1227.         $info_link.add($project_info_close).on('click', function(ev)
  1228.         {
  1229.             ev.preventDefault();
  1230.            
  1231.             if($info_link.data('busy'))
  1232.                 return false;
  1233.            
  1234.             $info_link.data('busy', true);
  1235.            
  1236.             var hide_infos = $info_link.hasClass('active') || $info_link.data('no_animation'),
  1237.                
  1238.                 details_width = $details.width(),
  1239.                 pi_height = $project_info.height(),
  1240.                 pi_width = $project_info.outerWidth(),
  1241.                 ilink_height = $info_link.height(),
  1242.                 ilink_offset = $info_link.position().left,
  1243.                 pnn_width = $prev_next_nav.width(),
  1244.                
  1245.                 ilink_bottom = pi_height - ilink_height - 10,
  1246.                 ilink_left = details_width - ilink_offset - 25 - $info_link.width(),
  1247.                
  1248.                 has_animation = 1;
  1249.            
  1250.             if($info_link.data('no_animation'))
  1251.             {
  1252.                 has_animation = 0;
  1253.             }
  1254.                
  1255.            
  1256.             if(hide_infos)
  1257.             {
  1258.                 if(typeof Cookies != 'undefined')
  1259.                 {
  1260.                     Cookies.set('portfolio_info_bar', 'hidden');
  1261.                 }
  1262.                
  1263.                 var timeline = new TimelineMax({
  1264.                     onComplete: function()
  1265.                     {
  1266.                         $info_link.removeClass('active');
  1267.                         $info_link.data('busy', false);
  1268.                     }
  1269.                 });
  1270.                
  1271.                 TweenMax.to($project_info, 0.5 * has_animation, {css: {left: -pi_width}, ease: Back.easeIn});
  1272.                 TweenMax.to($info_list, 0.3 * has_animation, {css: {top: pi_height}, delay: 0.2 * has_animation, ease: Quad.easeIn});
  1273.                 TweenMax.to($prev_next_nav, 0.9 * has_animation, {css: {left: 300 + ($info_list.height() == 0 ? 100 : 0)}, delay: 0.6 * has_animation});
  1274.                
  1275.                 timeline.append( TweenMax.to($info_link, 0.4 * has_animation, {css: {top: ilink_bottom}}) );
  1276.                 timeline.append( TweenMax.to($info_link, 0.4 * has_animation, {css: {left: ilink_left}, onComplete: function()
  1277.                 {                  
  1278.                     if(has_animation == 0)
  1279.                     {
  1280.                         $this.removeClass('is_hidden');
  1281.                     }
  1282.                 }}) );
  1283.             }
  1284.             else
  1285.             {
  1286.                 $info_link.addClass('active');
  1287.                
  1288.                 if(typeof Cookies != 'undefined')
  1289.                 {
  1290.                     Cookies.set('portfolio_info_bar', 'visible');
  1291.                 }
  1292.                        
  1293.                 var timeline = new TimelineMax({
  1294.                     onComplete: function()
  1295.                     {
  1296.                         $info_link.data('busy', false);
  1297.                     }
  1298.                 });
  1299.                
  1300.                 TweenMax.to($project_info, 0.5 * has_animation, {css: {left: 0}, ease: Back.easeIn});
  1301.                 TweenMax.to($info_list, 0.3 * has_animation, {css: {top: 0}, delay: 0.2, ease: Quad.easeIn});
  1302.                 TweenMax.to($prev_next_nav, 0.9 * has_animation, {css: {left: 0}, delay: 0.6});
  1303.                
  1304.                 timeline.append( TweenMax.to($info_link, 0.4 * has_animation, {css: {left: 0}}) );
  1305.                 timeline.append( TweenMax.to($info_link, 0.4 * has_animation, {css: {top: 0}}) );
  1306.             }
  1307.            
  1308.             if(has_animation == 0)
  1309.             {
  1310.                 $info_link.data('no_animation', false);
  1311.             }
  1312.         });
  1313.        
  1314.        
  1315.         // Check Current Visibility Status
  1316.         if($this.hasClass('is_hidden'))
  1317.         {
  1318.             $info_link.data('no_animation', true).removeClass('active').trigger('click');
  1319.         }
  1320.     });
  1321.    
  1322.    
  1323.    
  1324.     // Gallery Plugin by Arlind Nushi
  1325.     if($.isFunction($.fn.anGallery))
  1326.     {
  1327.         var gallery = $("#an_gallery"),
  1328.             hover_delay = 0.5;
  1329.        
  1330.         gallery.anGallery({
  1331.             itemSelector: '.gallery_item',
  1332.             slideShow: $('.showing_image'),
  1333.             detectHashChange: true
  1334.         });
  1335.        
  1336.         gallery.find('.gallery_item').each(function()
  1337.         {
  1338.             var $item = $(this);
  1339.            
  1340.             var $hover_overlay = $('<div class="hover" />');
  1341.            
  1342.             $item.append($hover_overlay).on({
  1343.                 mouseover: function()
  1344.                 {
  1345.                     if( ! $item.hasClass('active'))
  1346.                         TweenMax.to($hover_overlay, hover_delay, {css: {autoAlpha: 1}});
  1347.                 },
  1348.                
  1349.                 mouseout: function()
  1350.                 {
  1351.                     TweenMax.to($hover_overlay, hover_delay, {css: {autoAlpha: 0}});
  1352.                 }
  1353.             });
  1354.         });
  1355.     }
  1356.    
  1357.    
  1358.     // 404 Page Effect
  1359.     var container_404_sad_icon = $(".container_404 .sad_icon");
  1360.    
  1361.     if(container_404_sad_icon.length)
  1362.     {
  1363.         var timeline = new TimelineMax(),
  1364.             ease = Quad.easeInOut,
  1365.             dist = 55;
  1366.        
  1367.        
  1368.         timeline.append( TweenMax.to(container_404_sad_icon, 0.5, {css: {left: -dist}, ease: ease}) );
  1369.         timeline.append( TweenMax.to(container_404_sad_icon, 0.5, {css: {left: dist}, ease: ease}) );
  1370.         timeline.append( TweenMax.to(container_404_sad_icon, 0.5, {css: {left: 0}, ease: ease}) );
  1371.        
  1372.         timeline.totalDuration(.2).repeat(3);
  1373.     }
  1374.    
  1375.    
  1376.     // Post Thumbnails Hover - Hover Up Effect
  1377.     var post_images = $(".post_entry .post_thumb .image:has(.hover_image_up)"),
  1378.         phi_delay = 0.3;
  1379.    
  1380.     post_images.each(function(i)
  1381.     {
  1382.         var post_image = $(this);
  1383.        
  1384.         var img = post_image.find('img');
  1385.         var hover_image_up = post_image.find('.hover.hover_image_up'),
  1386.             hover_height = 0;
  1387.        
  1388.        
  1389.        
  1390.         hover_image_up.css({
  1391.             visibility: 'visible',
  1392.             bottom: -hover_image_up.outerHeight()
  1393.         });
  1394.        
  1395.         post_image.on({
  1396.             mouseenter: function()
  1397.             {
  1398.                 hover_height = hover_image_up.outerHeight();
  1399.                
  1400.                
  1401.                 TweenMax.to(img, phi_delay, {css: {top: -hover_height}});
  1402.                 TweenMax.to(hover_image_up, phi_delay, {css: {bottom: 0}});
  1403.             },
  1404.            
  1405.             mouseleave: function()
  1406.             {
  1407.                 hover_height = hover_image_up.outerHeight();
  1408.                
  1409.                 TweenMax.to(img, phi_delay, {css: {top: 0}});
  1410.                 TweenMax.to(hover_image_up, phi_delay, {css: {bottom: -hover_height}});
  1411.             }
  1412.         });
  1413.     });
  1414.    
  1415.    
  1416.     // Post Thumbnauls Hover - Fade Hover (Blog 1 Column)
  1417.     var post_images_2 = $(".post_entry .post_thumb:has(.fade_hover)"),
  1418.         bpt_delay = 0.35,
  1419.         bpt_direction = 1;
  1420.    
  1421.     post_images_2.imagesLoaded(function(){
  1422.        
  1423.         post_images_2.each(function()
  1424.         {
  1425.             var post_image = $(this);
  1426.            
  1427.             var hover_el = post_image.find('.hover'),
  1428.                 hover_icons = hover_el.find('span'),
  1429.                 hover_move_top;
  1430.            
  1431.             hover_move_top = post_image.height();
  1432.             hover_el.css({visibility: 'visible', marginTop: bpt_direction * hover_move_top});
  1433.             hover_icons.css({marginTop: -bpt_direction * hover_move_top * 1.8});
  1434.            
  1435.            
  1436.             post_image.on({
  1437.                 mouseenter: function()
  1438.                 {
  1439.                     TweenMax.to(hover_el, bpt_delay, {css: {marginTop: 0}, ease: Sine.easeOut});
  1440.                     TweenMax.to(hover_icons, bpt_delay, {css: {marginTop: 0, ease: Sine.easeOut}});
  1441.                 },
  1442.                
  1443.                 mouseleave: function()
  1444.                 {
  1445.                     hover_move_top = post_image.height();
  1446.                    
  1447.                     TweenMax.to(hover_el, bpt_delay, {css: {marginTop: bpt_direction * hover_move_top}});
  1448.                     TweenMax.to(hover_icons, bpt_delay, {css: {marginTop: -bpt_direction * hover_move_top * 1.8}});
  1449.                 }
  1450.             });
  1451.         });
  1452.     });
  1453.    
  1454.    
  1455.     // Gallery Thumbnails Hover
  1456.     var album_images = $(".gallery .album .image:has(.hover_blank)"),
  1457.         ai_delay = 0.3;
  1458.    
  1459.     galleryAlbumHoverEffect(album_images, ai_delay);
  1460.        
  1461.    
  1462.     // Gallery View Options
  1463.     var gallery_container = $("#gallery_container");
  1464.     $("#change_gallery_type").on('click', 'a', function(ev)
  1465.     {
  1466.         ev.preventDefault();
  1467.        
  1468.         var $this = $(this),
  1469.             view_type = $this.data('type');
  1470.        
  1471.        
  1472.         $("#change_gallery_type a").removeClass('active');
  1473.         $this.addClass('active');
  1474.        
  1475.         gallery_container.removeClass('grid').removeClass('list').addClass(view_type);
  1476.        
  1477.         if(typeof Cookies != 'undefined')
  1478.         {
  1479.             Cookies.set('gallery_' + gallery_container.data('id') + '_view_type', view_type);
  1480.         }
  1481.        
  1482.         // Relayout
  1483.         gallery_container
  1484.             .masonry( 'option', { columnWidth: (gallery_container.hasClass('list') ? 1/1 : 1/4), isAnimated: false } )
  1485.             .masonry( 'reload' );
  1486.     });
  1487.    
  1488.    
  1489.     // Gallery Albums
  1490.     if($.isFunction($.fn.masonry))
  1491.     {
  1492.         gallery_container.imagesLoaded(function(){
  1493.             gallery_container.masonry({
  1494.                 columnWidth: gallery_container.hasClass('list') ? 1/1 : 1/4
  1495.             });
  1496.         });
  1497.     }
  1498.    
  1499.    
  1500.     /* Infinite Scroll for Gallery */
  1501.     var endless_scrolling = jQuery(".endless_scrolling");
  1502.    
  1503.     if(jQuery.isFunction(jQuery.fn.infinitescroll) && endless_scrolling.length > 0)
  1504.     {
  1505.         var pagination_link_gallery = jQuery('.endless_scroll_pagination_gallery a'),
  1506.             child_class = '.album';
  1507.        
  1508.        
  1509.         pagination_link_gallery.infinitescroll({
  1510.             navSelector: pagination_link_gallery,
  1511.             nextSelector: pagination_link_gallery,
  1512.             itemSelector: child_class,
  1513.             onIsDone: function(){      
  1514.                 TweenMax.to(pagination_link, 0.5, {css: {autoAlpha: 0}});
  1515.             },
  1516.             loading: {
  1517.                 finishedMsg: '',
  1518.                 img: '',
  1519.                 msgText: ''
  1520.             }
  1521.             //,debug: true
  1522.         },
  1523.         function(newElements){
  1524.        
  1525.             var new_items = jQuery(newElements);
  1526.            
  1527.             galleryAlbumHoverEffect(new_items, ai_delay);
  1528.            
  1529.             gallery_container.append(new_items).masonry('appended', new_items, function()
  1530.             {
  1531.                 gallery_container.masonry( 'option', {isAnimated: true } ).masonry('reload');
  1532.             });
  1533.         });
  1534.     }
  1535.    
  1536.    
  1537.    
  1538.    
  1539.     /* Social Share */
  1540.     if($.isFunction($.fn.socialShare))
  1541.     {
  1542.         var ss = $('.social-share');
  1543.        
  1544.         ss.each(function()
  1545.         {
  1546.             var $this = $(this);
  1547.                
  1548.             $this.socialShare({
  1549.                 social: $this.data('social'),
  1550.                 whenSelect: true,
  1551.                 selectContainer: '.social-share-env'
  1552.             });
  1553.            
  1554.             $this.on('click', function(ev)
  1555.             {
  1556.                 ev.preventDefault();
  1557.             });
  1558.         });
  1559.     }
  1560.    
  1561.    
  1562.     /* ShadowBox */
  1563.     if(typeof window.Shadowbox != 'undefined')
  1564.     {
  1565.         // Post Images Gallery
  1566.         var post_gallery = jQuery(".full_post .gallery .gallery-item");
  1567.        
  1568.         if(post_gallery.length > 0)
  1569.         {
  1570.             var post_gallery_id = jQuery(".blog_post .gallery").attr('id');
  1571.            
  1572.             post_gallery.each(function()
  1573.             {
  1574.                 var image = jQuery(this);
  1575.                
  1576.                 var image_link = image.find('.gallery-icon a');
  1577.                 var image_alt = image_link.find('img').attr('alt');
  1578.                 var caption = image.find('.gallery-caption').text();
  1579.                
  1580.                 // Detect Youtube
  1581.                 var matches;
  1582.                 if(image_alt.length && (matches = image_alt.match(/v=(\w+)/)))
  1583.                 {
  1584.                     var youtube_id = matches[1];
  1585.                    
  1586.                     image_link.attr('href', 'http://www.youtube.com/v/' + youtube_id).attr('rel', 'width=700;height=450');
  1587.                 }
  1588.                 else
  1589.                 // Detect Vimeo
  1590.                 if(image_alt.length && (matches = image_alt.match(/vimeo\.com\/(\d+)/)))
  1591.                 {
  1592.                     var vimeo_id = matches[1];
  1593.                    
  1594.                     image_link.attr('href', 'http://vimeo.com/moogaloop.swf?clip_id=' + vimeo_id).attr('rel', 'width=700;height=450');;
  1595.                 }
  1596.                
  1597.                 image_link.attr('rel', 'shadowbox['+post_gallery_id+'];' + image_link.attr('rel'));
  1598.                 image_link.attr('title', caption)
  1599.             });
  1600.         }
  1601.        
  1602.         Shadowbox.init({
  1603.             handleOversize: 'resize',
  1604.             continuous: true
  1605.         });
  1606.     }
  1607.    
  1608.    
  1609.     // Go Back Button
  1610.     $(".go_back_portfolio").click(function(ev)
  1611.     {  
  1612.    
  1613.         if(window.history.length > 1)
  1614.         {
  1615.             ev.preventDefault();
  1616.             window.history.back();
  1617.         }
  1618.     })
  1619.        
  1620. })(jQuery, window);
  1621.  
  1622.  
  1623. /* Partners Caoursel */
  1624. function partnersCarouselFit()
  1625. {
  1626.     var partners_carousel_instance = jQuery(".partners_carousel").data('ancarouselinstance');;
  1627.    
  1628.     if(typeof partners_carousel_instance != 'undefined')
  1629.     {
  1630.         switch(test_device_type())
  1631.         {
  1632.             case "large_screen":
  1633.                 partners_carousel_instance.updateItemsPerRowNumber(4);
  1634.                 break;
  1635.                
  1636.             case "ipad":
  1637.                 partners_carousel_instance.updateItemsPerRowNumber(3);
  1638.                 break;
  1639.                
  1640.             case "iphone_landscape":
  1641.             case "iphone":
  1642.                 partners_carousel_instance.updateItemsPerRowNumber(2);
  1643.                 break;
  1644.         }
  1645.     }
  1646.    
  1647.    
  1648. }
  1649.  
  1650.  
  1651. /* Gallery Album Hover Effect */
  1652. function galleryAlbumHoverEffect(album_images, ai_delay)
  1653. {
  1654.     album_images.imagesLoaded(function()
  1655.     {
  1656.         album_images.each(function()
  1657.         {
  1658.             var $image = jQuery(this),
  1659.                 hover_blank = $image.find('.hover_blank'),
  1660.                 hover_w = hover_blank.outerWidth(),
  1661.                 hover_h = hover_blank.outerHeight();
  1662.            
  1663.             hover_blank.css({
  1664.                 visibility: 'visible',
  1665.                 left: -hover_w,
  1666.                 bottom: -hover_h
  1667.             });
  1668.            
  1669.             $image.on({
  1670.                 mouseenter: function()
  1671.                 {                  
  1672.                     TweenMax.to(hover_blank, ai_delay, {css: {left: 0, bottom: 0}, ease: Expo.easeOut});
  1673.                 },
  1674.                
  1675.                 mouseleave: function()
  1676.                 {
  1677.                     hover_w = hover_blank.outerWidth();
  1678.                     hover_h = hover_blank.outerHeight();
  1679.                    
  1680.                    
  1681.                     TweenMax.to(hover_blank, ai_delay, {css: {left: -hover_w, bottom: -hover_h}, ease: Expo.easeIn});
  1682.                 }
  1683.             });
  1684.         });
  1685.     });
  1686.  
  1687. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement