JAVASCRIPT   56
functions js
Guest on 18th August 2022 12:51:21 PM


  1. $.fn.exists = function(){
  2.         return $(this).length>0;
  3. };
  4.  
  5. $.fn.reverse = function(){
  6.     return this.pushStack(this.get().reverse(), arguments);
  7. };
  8.  
  9.  
  10.  
  11.  
  12.  
  13. $(document).ready(function(){
  14.  
  15.     //Full Caption Sliding (Hidden to Visible)
  16.     $('.menuItem.captionfull').hover(function(){
  17.         $(".cover", this).stop().animate({top:'0px'},{queue:false,duration:160});
  18.     }, function() {
  19.         $(".cover", this).stop().animate({top:'160px'},{queue:false,duration:160});
  20.     });
  21.  
  22. });
  23.  
  24.  
  25.  
  26.  
  27.  
  28.  
  29. /*--------------------------------------------------------------------------------------------
  30. *
  31. *       setup_forms
  32. *
  33. *--------------------------------------------------------------------------------------------*/
  34.  
  35. function setup_forms()
  36. {
  37.         $('form').each(function(){
  38.        
  39.                 var form = $(this);
  40.                
  41.                 // focus blur
  42.                 if($(this).hasClass('focus-blur'))
  43.                 {
  44.                         form.focus_blur();
  45.                 }
  46.                
  47.                
  48.                 // validate
  49.                 form.validate({
  50.                         highlight: function(element, errorClass, validClass) {
  51.                             $(element).closest('.field').addClass('error');
  52.                         },
  53.                         unhighlight: function(element, errorClass, validClass) {
  54.                             $(element).closest('.field').removeClass('error');
  55.                         }
  56.                 });
  57.                
  58.                 // style selects
  59.                 form.style_form();
  60.                
  61.         });
  62. }
  63.  
  64.  
  65.  
  66. /*--------------------------------------------------------------------------------------------
  67. *
  68. *       accordion
  69. *
  70. *--------------------------------------------------------------------------------------------*/
  71.  
  72. var accordion_speed = 500;
  73. $('.accordion .toggle').live('click', function(){
  74.        
  75.         var accordion = $(this).closest('.accordion');
  76.        
  77.         if(accordion.hasClass('active'))
  78.         {
  79.                 accordion.removeClass('active').children('.content').css({display : 'block'});
  80.         }
  81.         else
  82.         {
  83.                 $('html, body').animate({scrollTop : accordion.offset().top - 10}, 500);
  84.                 accordion.addClass('active').children('.content').css({display : 'none'});
  85.         }
  86.        
  87.         accordion.children('.content').animate({'height' : 'toggle'}, accordion_speed);
  88.        
  89.         return false;
  90. });
  91.  
  92.  
  93.  
  94. /*--------------------------------------------------------------------------------------------
  95. *
  96. *       setup_hero
  97. *
  98. *-------------------------------------------------------------------------------------------*/
  99.  
  100. function setup_hero(options)
  101. {
  102.        
  103.         if(!$('#hero').exists())
  104.         {
  105.                 return false;
  106.         }
  107.        
  108.        
  109.         // default options
  110.         var defaults = {
  111.                 parallax        :       false,
  112.                 auto_slide      :       true
  113.         };
  114.         options = $.extend(defaults, options);
  115.        
  116.        
  117.         // vars
  118.         var div = $('#hero');
  119.         var nav = div.find('.thumbnail-controls');
  120.         var timer;
  121.         var delay = 8000;
  122.         var i = 1;
  123.        
  124.        
  125.         // stop if no parallax
  126.     if(nav.find('ul li a').length == 1){
  127.         nav.hide();
  128.     }
  129.        
  130.         // set active
  131.         nav.find('ul li a[data-i="'+i+'"]').addClass('active');
  132.  
  133.        
  134.         // click nav
  135.         nav.find('ul li a').click(function(){
  136.                
  137.                 options.auto_slide = true;
  138.                
  139.                 var new_i = parseInt($(this).attr('data-i'));
  140.                
  141.                 if(new_i == i)
  142.                 {
  143.                         return false;
  144.                 }
  145.                
  146.                 var direction = (new_i > i) ? "left" : "right";
  147.  
  148.                 // update nav active
  149.                 nav.find('a[data-i="'+i+'"]').removeClass('active');
  150.                 nav.find('a[data-i="'+new_i+'"]').addClass('active');
  151.                
  152.                 var new_percent = (new_i-1) * 100;
  153.                
  154.                 if(direction == "left")
  155.                 {
  156.                         div.find('.slides-bird').animate({left : -new_percent + '%'}, 1500);
  157.                
  158.                         setTimeout(function(){
  159.                                 div.find('.slides-text').animate({left : -new_percent + '%'}, 1500);
  160.                         }, 100);
  161.                        
  162.                         setTimeout(function(){
  163.                                 div.find('.slides-bg').animate({left : -new_percent + '%'}, 1500);
  164.                         }, 200);
  165.                 }
  166.                 else
  167.                 {
  168.                         div.find('.slides-text').animate({left : -new_percent + '%'}, 1500);
  169.                        
  170.                         setTimeout(function(){ 
  171.                                 div.find('.slides-bird').animate({left : -new_percent + '%'}, 1500);
  172.                         }, 100);
  173.                        
  174.                         setTimeout(function(){
  175.                                 div.find('.slides-bg').animate({left : -new_percent + '%'}, 1500);
  176.                         }, 200);
  177.  
  178.                 }
  179.  
  180.                
  181.                 // set new i
  182.                 i = new_i;
  183.                
  184.                 // set timout for next slide
  185.                 slide_next();
  186.                
  187.                 return false;
  188.         });
  189.        
  190.        
  191.         // click prev
  192.         nav.find('.prev').click(function(){
  193.                
  194.                 options.auto_slide = false;
  195.                
  196.                 if(!nav.find('ul li a[data-i="'+(i-1)+'"]').exists())
  197.                 {
  198.                         return false;
  199.                 }
  200.                
  201.                 nav.find('ul li a[data-i="'+(i-1)+'"]').trigger('click');
  202.                
  203.                 return false;
  204.                
  205.         });
  206.        
  207.        
  208.         // click next
  209.         nav.find('.next').click(function(){
  210.                
  211.                 options.auto_slide = false;
  212.                
  213.                 if(!nav.find('ul li a[data-i="'+(i+1)+'"]').exists())
  214.                 {
  215.                         return false;
  216.                 }
  217.                
  218.                 nav.find('ul li a[data-i="'+(i+1)+'"]').trigger('click');
  219.                
  220.                 return false;
  221.                
  222.         });
  223.        
  224.        
  225.         // auto slide
  226.         function slide_next(new_delay)
  227.         {
  228.                 if(!options.auto_slide){
  229.                         return false;
  230.                 }
  231.                
  232.                 new_delay = (new_delay != null) ? new_delay : delay;
  233.                
  234.                 clearTimeout(timer);
  235.                
  236.                 var a = nav.find('ul li a[data-i="'+(i+1)+'"]').exists() ? nav.find('ul li a[data-i="'+(i+1)+'"]') : false;
  237.                
  238.                 if(a == false){
  239.                         return false;
  240.                 }
  241.                
  242.                 timer = setTimeout(function(){
  243.                        
  244.                         a.trigger('click');
  245.                        
  246.                 }, new_delay);
  247.         }
  248.         slide_next();
  249.        
  250.        
  251.         // hover pause
  252.         var timer_start = 0;
  253.        
  254.         div.hover(function(){
  255.                
  256.                 // stop auto
  257.                 clearTimeout(timer);
  258.                
  259.                 // start timer
  260.                 var newDate = new Date();
  261.                 timer_start = newDate.getTime();
  262.                
  263.         }, function(){
  264.                
  265.                 var newDate = new Date();
  266.                 var hover_length = newDate.getTime() - timer_start;
  267.                 var new_delay = delay - hover_length;
  268.                
  269.                 if(new_delay < 0)
  270.                 {
  271.                         new_delay = 0;
  272.                 }
  273.                
  274.                 slide_next(new_delay);
  275.                
  276.         });
  277.        
  278.            
  279.     // stop if no parallax
  280.     if(!options.parallax){
  281.         return false;
  282.     }
  283.    
  284.     var interval;
  285.     var interval2;
  286.     var mouse_page_x = 0;
  287.    
  288.         var old_x1 = 0;
  289.         var old_x2 = 0;
  290.        
  291.         var new_x1 = 50;
  292.         var new_x2 = 50;
  293.        
  294.     div.mousemove(function(e){
  295.                
  296.                 mouse_page_x = e.pageX;
  297.        
  298.     });
  299.    
  300.     div.hover(function(){
  301.        
  302.         clearInterval(interval2);
  303.        
  304.         interval = setInterval(function(){
  305.                
  306.                 var x = mouse_page_x - div.offset().left;
  307.        
  308.                 var x_percent = x / div.width();
  309.                        
  310.                         // set old values
  311.                         old_x1 = new_x1;
  312.                         old_x2 = new_x2;
  313.                        
  314.                         // new x
  315.                 new_x1 = 50 + ((-20*x_percent) + 10);
  316.                 new_x2 = 50 + ((20*x_percent) - 10);
  317.                
  318.                 // dif
  319.                 var diff_1 = (new_x1 - old_x1);
  320.                 var diff_2 = (new_x2 - old_x2);
  321.                
  322.                 new_x1 = old_x1 + (diff_1 / 3);
  323.                 new_x2 = old_x2 + (diff_2 / 3);
  324.                
  325.                 //console.log(diff_1);
  326.                 //console.log(diff_1);
  327.                 //console.log(diff_2);
  328.                
  329.                 div.find('.slides-bird .slide').css({'background-position' : new_x1 + '% 0%'});
  330.                 div.find('.slides-bg .slide').css({'background-position' : new_x2 + '% 0%'});
  331.                
  332.         }, 30);
  333.        
  334.     }, function(){
  335.        
  336.         clearInterval(interval);
  337.        
  338.         // animate to center
  339.         var reset_speed = 1800;
  340.        
  341.        
  342.         interval2 = setInterval(function(){
  343.                
  344.                 var x_percent = 0.5;
  345.                        
  346.                         // set old values
  347.                         old_x1 = new_x1;
  348.                         old_x2 = new_x2;
  349.                        
  350.                         // new x
  351.                 new_x1 = 50 + ((-20*x_percent) + 10);
  352.                 new_x2 = 50 + ((20*x_percent) - 10);
  353.                
  354.                 // dif
  355.                 var diff_1 = (new_x1 - old_x1);
  356.                 var diff_2 = (new_x2 - old_x2);
  357.                
  358.                 new_x1 = old_x1 + (diff_1 / 3);
  359.                 new_x2 = old_x2 + (diff_2 / 3);
  360.                
  361.                 //console.log(diff_1);
  362.                 //console.log(diff_1);
  363.                 //console.log(diff_2);
  364.                
  365.                 div.find('.slides-bird .slide').css({'background-position' : new_x1 + '% 0%'});
  366.                 div.find('.slides-bg .slide').css({'background-position' : new_x2 + '% 0%'});
  367.                
  368.         }, 30);
  369.        
  370.         setTimeout(function(){
  371.                
  372.                 clearInterval(interval2);
  373.                
  374.         }, reset_speed);
  375.     });
  376.                
  377.        
  378. }
  379.  
  380.  
  381. /*--------------------------------------------------------------------------------------------
  382. *
  383. *       setup_home_projects
  384. *
  385. *-------------------------------------------------------------------------------------------*/
  386.  
  387. function setup_widget_projects()
  388. {
  389.         if(!$('#widget-projects').exists())
  390.         {
  391.                 return false;
  392.         }
  393.        
  394.         // vars
  395.         var div = $('#widget-projects');
  396.         var nav = div.find('.thumbnail-controls');
  397.         var text = div.find('.texts');
  398.         var image = div.find('.images');
  399.         var i = 0;
  400.        
  401.         // set active
  402.         nav.find('ul li a[data-i="'+i+'"]').addClass('active');
  403.         text.find('.text[data-i="'+i+'"]').css({display: 'block', opacity : 1});
  404.         image.find('.image[data-i="'+i+'"]').css({left : 0});
  405.        
  406.         nav.find('ul li a').click(function(){
  407.                
  408.                 var new_i = parseInt($(this).attr('data-i'));
  409.                
  410.                 if(new_i == i)
  411.                 {
  412.                         return false;
  413.                 }
  414.  
  415.                 // update nav active
  416.                 nav.find('ul li a[data-i="'+i+'"]').removeClass('active');
  417.                 nav.find('ul li a[data-i="'+new_i+'"]').addClass('active');
  418.                
  419.                 // fade texts
  420.                 text.find('.text[data-i="'+i+'"]').animate({opacity : 0}, 500);
  421.                 text.find('.text[data-i="'+new_i+'"]').css({display: 'block'}).animate({opacity : 1}, 500);
  422.                
  423.                 // slide image
  424.                 image.find('.image').css({'z-index' : 0})
  425.                 image.find('.image[data-i="'+i+'"]').css({'z-index' : 1});
  426.                
  427.                 var image_css = {'z-index' : 2, 'left' : 298};
  428.                 if(i > new_i)
  429.                 {
  430.                         image_css = {'z-index' : 2, 'left' : -298};
  431.                 }
  432.                 image.find('.image[data-i="'+new_i+'"]').css(image_css).animate({left : 0}, 500);
  433.                
  434.                 i = new_i;
  435.                
  436.                 return false;
  437.         });
  438.        
  439.         // click prev
  440.         nav.find('.prev').click(function(){
  441.                
  442.                 if(!nav.find('ul li a[data-i="'+(i-1)+'"]').exists())
  443.                 {
  444.                         return false;
  445.                 }
  446.                
  447.                 nav.find('ul li a[data-i="'+(i-1)+'"]').trigger('click');
  448.                
  449.                 return false;
  450.                
  451.         });
  452.        
  453.         // click next
  454.         nav.find('.next').click(function(){
  455.                
  456.                 if(!nav.find('ul li a[data-i="'+(i+1)+'"]').exists())
  457.                 {
  458.                         return false;
  459.                 }
  460.                
  461.                 nav.find('ul li a[data-i="'+(i+1)+'"]').trigger('click');
  462.                
  463.                 return false;
  464.                
  465.         });
  466. }
  467.  
  468.  
  469. /*--------------------------------------------------------------------------------------------
  470. *
  471. *       setup_widget_wbit
  472. *
  473. *-------------------------------------------------------------------------------------------*/
  474.  
  475. function setup_widget_wbit()
  476. {
  477.         if(!$('#widget-wbit,#widget-wbit-sidebar,#widget-whatson').exists())
  478.         {
  479.                 return false;
  480.         }
  481.        
  482.         // vars
  483.         $('#widget-wbit,#widget-wbit-sidebar,#widget-whatson').hover(function(){
  484.                
  485.                 $(this).find('img').stop().animate({width : 324, left : -13, top: -10}, 250);
  486.                
  487.         }, function(){
  488.                
  489.                 $(this).find('img').stop().animate({width : 298, left : 0, top: 0}, 500);
  490.                
  491.         });
  492. }
  493.  
  494.  
  495. /*--------------------------------------------------------------------------------------------
  496. *
  497. *       setup_home_news
  498. *
  499. *-------------------------------------------------------------------------------------------*/
  500.  
  501. function setup_home_news()
  502. {
  503.         // vars
  504.         var div = $('#home-news');     
  505.        
  506.         div.find('.tabs li a').click(function(){
  507.                
  508.                 var i = $(this).attr('data-i');
  509.                
  510.                 $(this).parent('li').addClass('active').siblings('li').removeClass('active');
  511.                 div.find('.content .inner').removeClass('active');
  512.                
  513.                 div.find('.content .inner[data-i="'+i+'"]').addClass('active');
  514.                
  515.                 return false;
  516.         });
  517.        
  518. }
  519.  
  520.  
  521. /*--------------------------------------------------------------------------------------------
  522. *
  523. *       setup_featured_birds
  524. *
  525. *-------------------------------------------------------------------------------------------*/
  526.  
  527. function setup_featured_birds()
  528. {
  529.         var i = 1;
  530.         var div = $('#featured-birds');
  531.         var w = 588 + 30;
  532.  
  533.         div.find('.slide:first-child').show();
  534.        
  535.         // fly
  536.         function fly(direction)
  537.         {
  538.                 var slide = div.find('.slide[data-i="'+i+'"]');
  539.                 var delay = 0;
  540.                 var birds = (direction == "right") ? slide.find('a').reverse() : slide.find('a');
  541.                
  542.                 birds.each(function(){
  543.                        
  544.                         var a = $(this);
  545.                         setTimeout(function(){
  546.                                
  547.                                 var css_1 = (direction == "right") ? {'top' : 0, 'right' : w*-1} : {'top' : 0, 'right' : w};
  548.                                 //var css_2 = (direction == "right") ? {'top' : 0, 'right' : 0} : {'top' : 0, 'right' : 0};
  549.                                
  550.                                 a.animate(css_1, 600, function(){
  551.                                         //a.animate(css_2, 600);
  552.                                 });
  553.                                
  554.                        
  555.                         }, delay);
  556.                        
  557.                         delay += 50;
  558.                        
  559.                 });
  560.                
  561.                 // update i for next slide
  562.                 if(direction == "right")
  563.                 {
  564.                         i++;
  565.                 }
  566.                 else
  567.                 {
  568.                         i--;
  569.                 }
  570.                
  571.                
  572.                 // after birds have flown off
  573.                 setTimeout(function(){
  574.                        
  575.                         var slide = div.find('.slide[data-i="'+i+'"]');
  576.                         var delay_2 = 0;
  577.                        
  578.                         var birds = (direction == "right") ? slide.find('a').reverse() : slide.find('a');
  579.                        
  580.                         birds.each(function(){
  581.                        
  582.                                 var a = $(this);
  583.                                
  584.                                 var css_3 = (direction == "right") ? {'top' : 0, 'right' : w} : {'top' : 0, 'right' : (w)*-1};
  585.                                 a.css(css_3);
  586.                                
  587.                                 setTimeout(function(){
  588.                                
  589.                                         a.animate({'top' : 0, 'right' : 0}, 600);
  590.  
  591.                                
  592.                                 }, delay_2);
  593.                                
  594.                                 delay_2 += 50;
  595.                                
  596.                         });
  597.                        
  598.                         slide.show();
  599.                        
  600.                 }, delay + 400);
  601.         }
  602.        
  603.         // next
  604.         div.find('.thumbnail-controls a.next').click(function(){
  605.                
  606.                 div.find('.thumbnail-controls a.prev').css({opacity : 1});
  607.                
  608.                 if(!div.find('.slide[data-i="'+(i+1)+'"]').exists())
  609.                 {
  610.                         return false;
  611.                 }
  612.                
  613.                 fly("right");
  614.                
  615.                 if(!div.find('.slide[data-i="'+(i+1)+'"]').exists())
  616.                 {
  617.                         div.find('.thumbnail-controls a.next').css({opacity : 0.25});
  618.                 }
  619.                
  620.         });
  621.        
  622.         // prev
  623.         div.find('.thumbnail-controls a.prev').click(function(){
  624.                
  625.                 div.find('.thumbnail-controls a.next').css({opacity : 1});
  626.                
  627.                 if(!div.find('.slide[data-i="'+(i-1)+'"]').exists())
  628.                 {
  629.                         return false;
  630.                 }
  631.                
  632.                 fly("left");
  633.                
  634.                 if(!div.find('.slide[data-i="'+(i-1)+'"]').exists())
  635.                 {
  636.                         div.find('.thumbnail-controls a.prev').css({opacity : 0.25});
  637.                 }
  638.                
  639.         });
  640.        
  641.         div.find('.thumbnail-controls a.prev').css({opacity : 0.25});
  642. }
  643.  
  644.  
  645. /*--------------------------------------------------------------------------------------------
  646. *
  647. *       Scroll to
  648. *
  649. *--------------------------------------------------------------------------------------------
  650.  
  651. $('a#download-case-study').live('click', function(){
  652.        
  653.         var id = $(this).attr('href');
  654.         var y = $(id).offset().top - 50;
  655.         $('body, html').stop().animate({scrollTop : y}, 500);
  656.        
  657.         return false;
  658.        
  659. });
  660. */
  661.  
  662.  
  663. /*--------------------------------------------------------------------------------------------
  664. *
  665. *       setup_header
  666. *
  667. *--------------------------------------------------------------------------------------------*/
  668.  
  669. function setup_header()
  670. {
  671.         // vars
  672.         var div = $('#header');
  673.         var toolbar_toggle = div.find('#toolbar-toggle');
  674.         var toolbox = $('#header-toolbox');
  675.         var i = 0;     
  676.        
  677.        
  678.         // toolbar toggle
  679.         toolbar_toggle.find('a:not(.support-link)').click(function(){
  680.                        
  681.                 var new_i = parseInt($(this).attr('data-i'));
  682.                
  683.                 if(new_i == i)
  684.                 {
  685.                         console.log('new_i == i');
  686.                         // if open, close div
  687.                         $(this).removeClass('active');
  688.                         toolbox.children('.mask').stop().animate({height : 'toggle'}, 250);
  689.                         i = 0;
  690.                         return false;
  691.                 }
  692.                 else if(i == 0)
  693.                 {
  694.                         // open up toolbox
  695.                         toolbox.find('.content').hide();
  696.                         toolbox.find('.content[data-i="'+new_i+'"]').show();
  697.                         toolbox.children('.mask').stop().animate({height : 'toggle'}, 250);
  698.                         $(this).addClass('active');
  699.                         i = new_i;
  700.                 }
  701.                 else
  702.                 {
  703.                         console.log('else');
  704.                         // change toolbox content
  705.                         toolbox.find('.content[data-i="'+new_i+'"]').show();
  706.                         var h = toolbox.find('.content[data-i="'+new_i+'"]').outerHeight();
  707.                         toolbox.find('.content[data-i="'+new_i+'"]').hide();
  708.                        
  709.                         toolbox.children('.mask').stop().animate({height : h}, 250, function(){
  710.                                 $(this).css({height : 'auto'});
  711.                         });
  712.                        
  713.                         // fade out old
  714.                         toolbox.find('.content[data-i="'+i+'"]').animate({opacity : 0}, 250, function(){
  715.                                
  716.                                 $(this).css({opacity : 1, display : 'none'});
  717.                                 toolbox.find('.content[data-i="'+new_i+'"]').show();
  718.                                
  719.                         });
  720.                        
  721.                         toolbar_toggle.find('a[data-i="'+i+'"]').removeClass('active');
  722.                         $(this).addClass('active');
  723.                         i = new_i;
  724.                 }
  725.                
  726.                
  727.                
  728.                 return false;
  729.  
  730.         });    
  731.        
  732.        
  733.         // dropdown
  734.         var dropdown;
  735.         var stop_hide = false;
  736.        
  737.         $('#nav li a[data-i]').live('mouseenter', function(){
  738.        
  739.                 stop_hide = true;
  740.                
  741.                 var new_i = $(this).attr('data-i');
  742.                 if(!$('#subnavs .subnav.'+new_i).exists())
  743.                 {
  744.                         return false;
  745.                 }
  746.                
  747.                 // if a dropdown is already active, dont animate
  748.                 if(dropdown != null)
  749.                 {
  750.                         if(dropdown.hasClass(new_i))
  751.                         {
  752.                                 return false;
  753.                         }
  754.                        
  755.                         // hide old dropdown
  756.                         dropdown.css({
  757.                                 display : 'none'
  758.                         });
  759.                         dropdown = null;
  760.                        
  761.                         // load new dropdown
  762.                         dropdown = $('#subnavs .subnav.'+new_i);
  763.                         show_dropdown(false);
  764.                 }
  765.                 else
  766.                 {
  767.                         dropdown = $('#subnavs .subnav.'+new_i);
  768.                
  769.                         show_dropdown();
  770.                 }
  771.                
  772.         }).mouseleave(function(){
  773.                 stop_hide = false;
  774.                
  775.                 setTimeout(function(){
  776.                         if(!stop_hide)
  777.                         {
  778.                                 hide_dropdown();
  779.                         }
  780.                 }, 250);
  781.                
  782.  
  783.                
  784.         });
  785.  
  786.        
  787.         // sub nav mouse enter
  788.         $('#subnavs .subnav').live('mouseenter', function(){
  789.        
  790.                 // you just rolled onto the subnav, dont hide it
  791.                 stop_hide = true;
  792.                
  793.         });
  794.        
  795.        
  796.         // sub nav mouse leave
  797.         $('#subnavs .subnav').live('mouseleave', function(){
  798.        
  799.                 stop_hide = false;
  800.                 setTimeout(function(){
  801.                         if(!stop_hide)
  802.                         {
  803.                                 hide_dropdown();
  804.                         }
  805.                 }, 50);
  806.                
  807.         });
  808.  
  809.        
  810.        
  811.        
  812.         function show_dropdown(animation)
  813.         {
  814.                 // vars
  815.                 var speed = (animation == false) ? 0 : 250;
  816.                
  817.                 if(dropdown == null) return false;
  818.                
  819.                 //console.log('show_dropdown');
  820.                 // clear the previous hover stuff
  821.                 dropdown.unbind('mouseenter').unbind('mouseleave');
  822.                
  823.                 // animate in dropdown
  824.                 dropdown.stop().css({
  825.                         top : -10,
  826.                         display : 'block',
  827.                         opacity : 0
  828.                 }).animate({
  829.                         top : 0,
  830.                         opacity : 1
  831.                 }, speed);
  832.         }
  833.        
  834.         function hide_dropdown()
  835.         {
  836.                 if(dropdown == null) return false;
  837.                
  838.                 //console.log('hide_dropdown');
  839.                 // animate in dropdown
  840.                 dropdown.animate({
  841.                         top : 20,
  842.                         opacity : 0
  843.                 }, 50, function(){
  844.                        
  845.                         $(this).css({
  846.                                 display : 'none'
  847.                         });
  848.                        
  849.                 });
  850.                
  851.                 dropdown = null;
  852.         }
  853.        
  854.         // hover on map
  855.         toolbox.find('#search-map a').hover(function(){
  856.                
  857.                 $(this).parent().attr('class', $(this).attr('class'));
  858.                 toolbox.find('#search-map-location').html($(this).attr('data-location'));
  859.                
  860.         }, function(){
  861.                
  862.                 $(this).parent().attr('class', '');
  863.                 toolbox.find('#search-map-location').html('');
  864.  
  865.         });
  866.        
  867.         // tool tips
  868.         toolbar_toggle.find('li').hover(function(){
  869.                
  870.                 $(this).stop().find('.tool-tip').css({
  871.                         display : 'block',
  872.                         opacity : 0,
  873.                         'margin-top' : '5px'
  874.                 }).animate({
  875.                         opacity : 1,
  876.                         'margin-top' : '0px'
  877.                 }, 250);
  878.                
  879.         }, function(){
  880.                
  881.                 $(this).stop().find('.tool-tip').css({
  882.                         opacity : 1,
  883.                         'margin-top' : '0px'
  884.                 }).animate({
  885.                         opacity : 0,
  886.                         'margin-top' : '5px'
  887.                 }, 250);
  888.                
  889.         });
  890.        
  891. }
  892.  
  893.  
  894. /*--------------------------------------------------------------------------------------------
  895. *
  896. *       define_page_side_height
  897. *
  898. *--------------------------------------------------------------------------------------------*/
  899.  
  900. function define_page_side_height()
  901. {
  902.         if(!$('#page-side').exists())
  903.         {
  904.                 return false;
  905.         }
  906.        
  907.         var side = $('#page-side').height();
  908.         var main = $('#page-main').height();
  909.        
  910.         if(side > main){
  911.                 $('#page-side').addClass('shorter');
  912.         }
  913. }
  914.  
  915.  
  916. /*--------------------------------------------------------------------------------------------
  917. *
  918. *       setup_event_category_graph
  919. *
  920. *--------------------------------------------------------------------------------------------*/
  921.  
  922. function setup_event_category_graph()
  923. {
  924.         var div = $('#event-category-graph');
  925.         var max = 0;
  926.        
  927.         // find max
  928.         div.find('.count').each(function(){
  929.                
  930.                 var new_max = parseFloat($(this).html());
  931.                
  932.                 if(new_max > max)
  933.                 {
  934.                         max = new_max;
  935.                 }
  936.  
  937.         });
  938.        
  939.        
  940.         // set heights
  941.         div.find('.count').each(function(i){
  942.                
  943.                 var bar = $(this).siblings('.bar');
  944.                 var new_max = parseFloat($(this).html());
  945.                 var percent = (new_max / max) * 179;
  946.                
  947.                 bar.css({height : 0});
  948.                
  949.                 setTimeout(function(){
  950.                        
  951.                         bar.animate({height : percent}, 500);
  952.                        
  953.                 }, 100 * i);
  954.                 //$(this).siblings('.bar').css({ height : percent + '%'});
  955.  
  956.         });
  957.  
  958.        
  959. }
  960.  
  961.  
  962. function setup_galleries(){
  963.        
  964.         if(!$('.photo-tiles').exists())
  965.         {
  966.                 return false;
  967.         }
  968.        
  969.         var div = $('.photo-tiles');
  970.        
  971.         div.find('a.gallery').click(function(){
  972.                
  973.                 var images = [];
  974.                
  975.                 $(this).find('span[data-image_url]').each(function(){
  976.                        
  977.                         images.push($(this).attr('data-image_url'));
  978.                        
  979.                 });
  980.                
  981.                 $.fancybox(images, {
  982.                         'padding'                       : 0,
  983.                         'transitionIn'          : 'none',
  984.                         'transitionOut'         : 'none',
  985.                         'type'              : 'image',
  986.                         'changeFade'        : 0
  987.                 });
  988.                
  989.                 return false;
  990.                
  991.         });
  992.        
  993. }
  994.  
  995. /*--------------------------------------------------------------------------------------------
  996. *
  997. *       Calendar
  998. *
  999. *-------------------------------------------------------------------------------------------*/
  1000. $('.calendar').find('.event').live('click', function(){
  1001.  
  1002.         window.location = $(this).attr('data-url');
  1003.  
  1004. });
  1005.  
  1006. $('.calendar').find('select').live('change', function(){
  1007.  
  1008.         window.location = $(this).val();
  1009.  
  1010. });
  1011.  
  1012.  
  1013. /*--------------------------------------------------------------------------------------------
  1014. *
  1015. *       document.ready
  1016. *
  1017. *--------------------------------------------------------------------------------------------*/
  1018.  
  1019. $(document).ready(function()
  1020. {
  1021.         setup_forms();
  1022.         setup_header();
  1023.         //define_page_side_height();
  1024. });
  1025.  
  1026.  
  1027. /*--------------------------------------------------------------------------------------------
  1028. *
  1029. *       window.load
  1030. *
  1031. *--------------------------------------------------------------------------------------------*/
  1032.  
  1033. $(window).load(function()
  1034. {
  1035.  
  1036. });

Raw Paste

Login or Register to edit or fork this paste. It's free.