Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Sep 17th, 2012  |  syntax: PHP  |  size: 32.09 KB  |  hits: 17  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. <?php
  2.    
  3.     global $data;
  4.     require_once('../../../../wp-load.php');
  5.  
  6.     $dynamic_header = $data['ab_enable_dynamic_header'];
  7.  
  8.     $about_page = $data['ab_about_page'];
  9.     $about_page_title = get_page_by_path( $about_page );
  10.     $about_page_id = $about_page_title->ID;
  11.  
  12.     $cpone_page = $data['ab_custom_page_one'];
  13.     $cpone_page_title = get_page_by_path( $cpone_page );
  14.     $cpone_page_id = $cpone_page_title->ID;
  15.  
  16.     $cptwo_page = $data['ab_custom_page_two'];
  17.     $cptwo_page_title = get_page_by_path( $cptwo_page );
  18.     $cptwo_page_id = $cptwo_page_title->ID;
  19.  
  20.     $cpthree_page = $data['ab_custom_page_three'];
  21.     $cpthree_page_title = get_page_by_path( $cpthree_page );
  22.     $cpthree_page_id = $cpthree_page_title->ID;
  23.  
  24.     $use_custom_font = $data['ab_use_custom_font'];
  25.     $custom_font = $data['ab_standard_font'];
  26.     $use_custom_tagline_font = $data['ab_use_custom_tagline_font'];
  27.     $tagline_font = $data['ab_tagline_font'];
  28.  
  29.     $portfolio_upload_bg = $data['ab_portfolio_bg_upload'];
  30.     $portfolio_preset_bg = $data['ab_preset_portfolio_bg'];
  31.  
  32. ?>
  33. /* ==================================================
  34.  
  35. Custom jQuery functions.
  36.  
  37. ================================================== */
  38.  
  39. /////////////////////////////////////////////
  40. // NO CONFLICT
  41. /////////////////////////////////////////////
  42.  
  43. var $j = jQuery.noConflict();
  44.  
  45. var onLoad = {
  46.     init: function(){
  47.         var deviceAgent = navigator.userAgent.toLowerCase();
  48.         var agentID = deviceAgent.match(/(iphone|ipad|ipod|android)/);
  49.         if (!agentID) {
  50.             header.init();
  51.         }
  52.         nav.init();
  53.         portfolioAjax.init();
  54.         onePageAjax.init();
  55.         slider.init();
  56.         portfolioSorting.init();
  57.         prettyPhoto.init();
  58.         contactForm.init();
  59.         reloadFunctions.init();
  60.         baseFunctions.init();
  61.     }
  62. };
  63.  
  64.  
  65. /////////////////////////////////////////////
  66. // HEADER
  67. /////////////////////////////////////////////
  68.  
  69. var header = {
  70. init: function () {
  71.         var $header = $j('#header-section'),
  72.             $logo = $j('#logo').find('img'),
  73.             $nav = $j('#main-navigation'),
  74.             $window = $j(window),
  75.             $headerIsDynamic = true;
  76.             <?php if ($dynamic_header) { ?>
  77.                 $headerIsDynamic = true;
  78.             <?php } else { ?>
  79.                 $headerIsDynamic = false;
  80.             <?php } ?>
  81.             if ($headerIsDynamic) {
  82.                 $window.scroll(function () {
  83.                     if ($window.scrollTop() > 70 && $window.width() > 959) {
  84.                         header.animate($header, $logo, $nav);
  85.                     } else {
  86.                         setTimeout(function () {
  87.                             if ($window.scrollTop() < 70) {
  88.                                 header.reset($header, $logo, $nav);
  89.                             }
  90.                         }, 700);
  91.                     }
  92.                 });
  93.             }
  94.         },
  95.         animate: function ($header, $logo, $nav) {
  96.             $header.filter(':not(:animated)').animate({
  97.                     "height": 53,
  98.                     "borderTopWidth": 5
  99.             });
  100.             $logo.filter(':not(:animated)').animate({
  101.                 "height": 31
  102.             });
  103.             $nav.filter(':not(:animated)').animate({
  104.                 "marginTop": 16,
  105.                 "marginBottom": 16
  106.             });
  107.         },
  108.         reset: function ($header, $logo, $nav) {
  109.             $header.filter(':not(:animated)').animate({
  110.                 "height": 95,
  111.                 "borderTopWidth": 10
  112.             });
  113.             $logo.filter(':not(:animated)').animate({
  114.                 "height": 75
  115.             });
  116.             $nav.filter(':not(:animated)').animate({
  117.                 "marginTop": 38,
  118.                 "marginBottom": 38
  119.         });
  120.     }
  121. };
  122.  
  123.  
  124. /////////////////////////////////////////////
  125. // NAVIGATION
  126. /////////////////////////////////////////////
  127.  
  128. var nav = {
  129.     init: function(){
  130.  
  131.         // Main Nav
  132.      
  133.         var $body = $j('body'), $current_page = $j('.current-menu-item'), $header = $j('#header-section'), $logo = $j('#logo').find('img'), $nav = $j('#main-navigation').find('ul.menu'), $window = $j(window);
  134.         var $offset = 0, $standard_offset = 0, $home_offset = -145; $headerIsDynamic = true;
  135.        
  136.         <?php if ($dynamic_header) { ?>
  137.             $headerIsDynamic = true;
  138.         <?php } else { ?>
  139.             $headerIsDynamic = false;
  140.         <?php } ?>
  141.        
  142.         if ($window.width() < 1024) {
  143.             $standard_offset = -15;
  144.         } else if (!$headerIsDynamic) {
  145.             $standard_offset = -70;
  146.             $j('.section').css('padding-top', '30px');
  147.         }else {
  148.             $standard_offset = -45;
  149.         }
  150.         $current_page.addClass('current');
  151.        
  152.         if ($body.hasClass('home')) {
  153.  
  154.             var $nav_link_parent = $j('.menu').find('li');
  155.             $nav_link_parent.on('click', 'a', function(e) {
  156.  
  157.                 var $nav_link_title = $j(this).attr('title');
  158.  
  159.                 if ($nav_link_title) {
  160.                     e.preventDefault();
  161.                 }
  162.  
  163.                 if ($j(this).parent().is(':first-child')) {
  164.                     $offset = $home_offset;      
  165.                 } else {
  166.                     $offset = $standard_offset;
  167.                 }
  168.  
  169.                 $j.smoothScroll({
  170.                     scrollTarget: '#' + $nav_link_title,
  171.                     offset: $offset,
  172.                     easing: 'easeInOutExpo',
  173.                     speed: 700
  174.                 });
  175.  
  176.                 var $current = $j(this);
  177.                 $nav_link_parent.removeClass('current');
  178.                 $current.parent().addClass('current');
  179.             });
  180.         }
  181.  
  182.         // Mobile Nav
  183.         var $mobile_select = $j('.dropdown-menu');
  184.  
  185.         if ($body.hasClass('home')) {
  186.  
  187.             $mobile_select.change(function(e) {
  188.                 e.preventDefault();
  189.  
  190.                 var $mob_nav_selected = '#' + $j('.dropdown-menu option:selected').attr('class');
  191.                                
  192.                                 if ($mob_nav_selected == '#') {
  193.                                
  194.                                         window.location = $j(this).find("option:selected").val();
  195.                                
  196.                                 } else {
  197.                                
  198.                         var $offset = -20;
  199.        
  200.                         $j.smoothScroll({
  201.                             scrollTarget: $mob_nav_selected,
  202.                             offset: $offset,
  203.                             easing: 'easeInOutExpo',
  204.                             speed: 700
  205.                         });
  206.                 }
  207.             });
  208.        
  209.         } else {
  210.  
  211.             $mobile_select.change(function() {
  212.                 window.location = $j(this).find("option:selected").val();
  213.             });
  214.  
  215.         }
  216.     }  
  217. };
  218.  
  219. // Change menu active when scroll through sections
  220. $j(window).scroll(function () {
  221.     var $inview = $j('#content > section:in-viewport:first').attr('id');
  222.     var $menu_item = $j('.menu li a');
  223.     var $link = $menu_item.filter('[title=' + $inview + ']');
  224.  
  225.     if ($link.length && !$link.is('.current')) {
  226.         $menu_item.parent().removeClass('current');
  227.         $link.parent().addClass('current');
  228.     }
  229. });
  230.  
  231. /////////////////////////////////////////////
  232. // PORTFOLIO AJAX FUNCTIONS
  233. /////////////////////////////////////////////
  234.  
  235. var portfolioAjax = {
  236.     init: function(){
  237.         var $portfolio_section = $j('#portfolio'), $portfolio_items = $j('.portfolio-items'), $cont = $j('.portfolio-ajax-drawer'), $loading_bay = $j('.loading-bay'), $controls = $j('.controls'), $loading = $j('#portfolio').find('.loading'), $small_loading = $j('#portfolio').find('.small-loading');
  238.         var $current = null, $current_item = null, $currentPostID  = null, $nextPortfolioPost = null, $prevPortfolioPost = null, $prevPortfolioPostID = null, $nextPortfolioPostID = null;
  239.         var $offset = -55, $window_width = $j(window).width();
  240.  
  241.         function itemChanged() {
  242.             $current_item = $j($current).parent().parent();
  243.             $current_item.addClass('current-item');
  244.             $currentPostID = $j($current).attr('href');
  245.             $nextPost = $j($current_item).closest('li.item').next('li.item').find('a.link');
  246.             $prevPost = $j($current_item).closest('li.item').prev('li.item').find('a.link');
  247.             $prevPostID = $j($prevPost).attr('href');
  248.             $nextPostID = $j($nextPost).attr('href');
  249.             $controls.find('#portfolio-prev').attr('href', $prevPostID);
  250.             $controls.find('#portfolio-next').attr('href', $nextPostID);
  251.             if(typeof $nextPostID  == 'string') {
  252.                 $j('a#portfolio-next').show();
  253.             } else {
  254.                 $j('a#portfolio-next').hide();
  255.             }
  256.             if(typeof $prevPostID  == 'string') {
  257.                 $j('a#portfolio-prev').show();
  258.             } else {
  259.                 $j('a#portfolio-prev').hide();
  260.             }
  261.         }
  262.  
  263.         function countItems() {
  264.             var $count = $cont.children().length;
  265.             if ($count > 1) {
  266.                 $cont.find('article:first-child').remove();
  267.             }
  268.         }
  269.  
  270.         function onAfter(curr, next, opts, fwd) {
  271.             var index = opts.currSlide;
  272.  
  273.             //get the height of the current slide
  274.             var $slide_height = $j(this).outerHeight(true);
  275.  
  276.             //set the container's height to that of the current slide
  277.             $cont.animate({height: $slide_height});
  278.            
  279.             $cont.find('img.size-full').each(function() {
  280.                 $j(this).css("height", "auto");
  281.             });
  282.  
  283.             setTimeout(function() {
  284.                 $controls.css('display', 'inline-block');
  285.                 $small_loading.hide();
  286.             }, 1000);
  287.         }
  288.  
  289.         $portfolio_items.on('click','a.link',function(e){
  290.             e.preventDefault();
  291.             if ($current_item) {
  292.                 $current_item.removeClass('current-item');
  293.             }
  294.  
  295.             $j.smoothScroll({
  296.                 scrollTarget: $portfolio_section,
  297.                 offset: $offset
  298.             });
  299.  
  300.             // Set current item and next/prev controls
  301.             $current = $j(this);
  302.             itemChanged();
  303.            
  304.             if ($cont.is(":visible")) {
  305.                 countItems();
  306.                 $controls.hide();
  307.                 $small_loading.css('display', 'inline-block');
  308.                 $loading_bay.load($currentPostID + ' article.type-portfolio', function(response, status, xhr){
  309.                     var $error = $j("#error");
  310.                     if (status != 'error') {
  311.                         $cont.append($loading_bay.find('article'));
  312.                         $cont.cycle({
  313.                             fx: "scrollUp",
  314.                             delay: -4000,
  315.                             autostop: 1,
  316.                             after: onAfter
  317.                         });
  318.                         slider.init();                    
  319.                         prettyPhoto.init();
  320.                         reloadFunctions.init();
  321.                     } else {
  322.                         $error.html('Error: ' + xhr.status + ' ' + xhr.statusText);
  323.                     }
  324.                 });
  325.            
  326.             } else {
  327.  
  328.                 $loading.slideDown(400);
  329.  
  330.                 $cont.load($currentPostID + ' article.type-portfolio', function(response, status, xhr){
  331.                     var $error = $j("#error");
  332.                     if (status != 'error') {
  333.                         $loading.hide();
  334.  
  335.                         var $bg_image;
  336.  
  337.                         <?php if ($portfolio_preset_bg) { ?>
  338.                             $bg_image = '<?php echo $portfolio_preset_bg; ?>';
  339.                         <?php } else if ($portfolio_upload_bg) { ?>
  340.                             $bg_image = '<?php echo $portfolio_upload_bg; ?>';
  341.                         <?php } else { ?>
  342.                             $bg_image = '<?php echo get_bloginfo('template_directory'); ?>/images/portfolio_bg/wood.jpg';
  343.                         <?php } ?>
  344.  
  345.                         $cont.css('background-image', 'url(' + $bg_image + ')');
  346.                        
  347.                         $cont.slideDown(600);
  348.                        
  349.                         //get the height of the current slide
  350.                         var $slide_height = $cont.find('article').outerHeight(true);
  351.  
  352.                         //set the container's height to that of the current slide
  353.                         $cont.animate({height: $slide_height});
  354.                                                
  355.                                                 $cont.find('img.size-full').each(function() {
  356.                                                         $j(this).css("height", "auto");
  357.                                                 });
  358.                                                
  359.                         $controls.css('display', 'inline-block');
  360.                         slider.init();
  361.                         prettyPhoto.init();
  362.                         reloadFunctions.init();
  363.                     } else {
  364.                         $error.html('Error: ' + xhr.status + ' ' + xhr.statusText);
  365.                     }
  366.                 });
  367.  
  368.             }
  369.  
  370.          });
  371.        
  372.        
  373.         $controls.on('click', 'a#portfolio-close',function(e) {
  374.             e.preventDefault();
  375.             $cont.slideUp(600);
  376.             $controls.hide();
  377.             $current_item.removeClass('current-item');
  378.             $j.smoothScroll({
  379.                 scrollTarget:$portfolio_section,
  380.                 offset: $offset
  381.             });
  382.         });
  383.  
  384.         $controls.on('click', 'a#portfolio-prev',function(e) {
  385.             e.preventDefault();
  386.             $current_item.removeClass('current-item');
  387.             $j.smoothScroll({
  388.                 scrollTarget: $portfolio_section,
  389.                 offset: $offset
  390.             });
  391.             countItems();
  392.             $controls.hide();
  393.             $small_loading.css('display', 'inline-block');
  394.             $loading_bay.load($prevPostID + ' article.type-portfolio', function(response, status, xhr){
  395.                 var $error = $j("#error");
  396.                 if (status != 'error') {
  397.                     $cont.append($loading_bay.find('article'));
  398.                     $cont.cycle({
  399.                         fx: "scrollRight",
  400.                         delay: -4000,
  401.                         autostop: 1,
  402.                         after: onAfter
  403.                     });
  404.                     slider.init();                    
  405.                     prettyPhoto.init();
  406.                     reloadFunctions.init();
  407.                 } else {
  408.                     $error.html('Error: ' + xhr.status + ' ' + xhr.statusText);
  409.                 }
  410.                 $current = $j($prevPost);
  411.                 itemChanged();
  412.             });
  413.         });
  414.  
  415.         $controls.on('click', 'a#portfolio-next',function(e) {
  416.             e.preventDefault();
  417.             $current_item.removeClass('current-item');
  418.             $j.smoothScroll({
  419.                 scrollTarget: $portfolio_section,
  420.                 offset: $offset
  421.             });
  422.             countItems();
  423.             $controls.hide();
  424.             $small_loading.css('display', 'inline-block');
  425.             $loading_bay.load($nextPostID + ' article.type-portfolio', function(response, status, xhr){
  426.                 var $error = $j("#error");
  427.                 if (status != 'error') {
  428.                     $cont.append($loading_bay.find('article'));
  429.                     $cont.cycle({
  430.                         fx: "scrollLeft",
  431.                         delay: -4000,
  432.                         autostop: 1,
  433.                         after: onAfter
  434.                     });
  435.                     slider.init();                    
  436.                     prettyPhoto.init();
  437.                     reloadFunctions.init();
  438.                 } else {
  439.                     $error.html('Error: ' + xhr.status + ' ' + xhr.statusText);
  440.                 }
  441.                 $current = $j($nextPost);
  442.                 itemChanged();
  443.             });
  444.         });
  445.  
  446.     }
  447. };
  448.  
  449.  
  450.  
  451. /////////////////////////////////////////////
  452. // ONE PAGE AJAX FUNCTION
  453. /////////////////////////////////////////////
  454.  
  455. var onePageAjax = {
  456.     init: function(){
  457.  
  458.         <?php if ($about_page) { ?>
  459.  
  460.         var $about_section = $j('#about');
  461.         var $about_cont = $j('#about .ajax-content');
  462.         var $about_loading = $j('#about .loading');
  463.  
  464.         $about_loading.show();
  465.         $about_cont.load('<?php echo get_permalink( $about_page_id ); ?>' + ' .ajax-load-content', function(response, status, xhr){
  466.             var $error = $j("#error");
  467.             if (status != 'error') {
  468.                 $about_loading.hide();
  469.                 $about_cont.fadeIn(600);
  470.                 reloadFunctions.init();
  471.                 prettyPhoto.init();
  472.             } else {
  473.                 $error.html('Error: ' + xhr.status + ' ' + xhr.statusText);
  474.             }
  475.         });
  476.  
  477.         <?php } ?>
  478.  
  479.         <?php if($cpone_page) { ?>
  480.  
  481.                 var $cpone_section = $j('#custom-page-one');
  482.                 var $cpone_cont = $j('#custom-page-one .ajax-content');
  483.                 var $cpone_loading = $j('#custom-page-one .loading');
  484.  
  485.                 $cpone_loading.show();
  486.                 $cpone_cont.load('<?php echo get_permalink( $cpone_page_id ); ?>' + ' .ajax-load-content', function(response, status, xhr){
  487.                     var $error = $j("#error");
  488.                     if (status != 'error') {
  489.                         $cpone_loading.hide();
  490.                         $cpone_cont.fadeIn(600);
  491.                         reloadFunctions.init();
  492.                         prettyPhoto.init();
  493.                     } else {
  494.                         $error.html('Error: ' + xhr.status + ' ' + xhr.statusText);
  495.                     }
  496.                 });
  497.                
  498.         <?php } ?>
  499.  
  500.         <?php if($cptwo_page) { ?>
  501.  
  502.                 var $cptwo_section = $j('#custom-page-two');
  503.                 var $cptwo_cont = $j('#custom-page-two .ajax-content');
  504.                 var $cptwo_loading = $j('#custom-page-two .loading');
  505.  
  506.                 $cptwo_loading.show();
  507.                 $cptwo_cont.load('<?php echo get_permalink( $cptwo_page_id ); ?>' + ' .ajax-load-content', function(response, status, xhr){
  508.                     var $error = $j("#error");
  509.                     if (status != 'error') {
  510.                         $cptwo_loading.hide();
  511.                         $cptwo_cont.fadeIn(600);
  512.                         reloadFunctions.init();
  513.                         prettyPhoto.init();
  514.                     } else {
  515.                         $error.html('Error: ' + xhr.status + ' ' + xhr.statusText);
  516.                     }
  517.                 });
  518.                
  519.         <?php } ?>
  520.  
  521.         <?php if($cpthree_page) { ?>
  522.  
  523.                 var $cpthree_section = $j('#custom-page-three');
  524.                 var $cpthree_cont = $j('#custom-page-three .ajax-content');
  525.                 var $cpthree_loading = $j('#custom-page-three .loading');
  526.  
  527.                 $cpthree_loading.show();
  528.                 $cpthree_cont.load('<?php echo get_permalink( $cpthree_page_id ); ?>' + ' .ajax-load-content', function(response, status, xhr){
  529.                     var $error = $j("#error");
  530.                     if (status != 'error') {
  531.                         $cpthree_loading.hide();
  532.                         $cpthree_cont.fadeIn(600);
  533.                         reloadFunctions.init();
  534.                         prettyPhoto.init();
  535.                     } else {
  536.                         $error.html('Error: ' + xhr.status + ' ' + xhr.statusText);
  537.                     }
  538.                 });
  539.                
  540.         <?php } ?>
  541.  
  542.     }  
  543. };
  544.  
  545.  
  546. /////////////////////////////////////////////
  547. // Flexslider
  548. /////////////////////////////////////////////
  549.  
  550. var slider = {
  551.     init: function() {
  552.         $j('.flexslider').flexslider({
  553.             animation: "fade",             //String: Select your animation type, "fade" or "slide"
  554.             slideDirection: "horizontal",   //String: Select the sliding direction, "horizontal" or "vertical"
  555.             slideshow: true,                //Boolean: Animate slider automatically
  556.             slideshowSpeed: 5000,           //Integer: Set the speed of the slideshow cycling, in milliseconds
  557.             animationDuration: 400,         //Integer: Set the speed of animations, in milliseconds
  558.             directionNav: true,             //Boolean: Create navigation for previous/next navigation? (true/false)
  559.             controlNav: true,               //Boolean: Create navigation for paging control of each clide? Note: Leave true for manualControls usage
  560.             keyboardNav: true,              //Boolean: Allow slider navigating via keyboard left/right keys
  561.             mousewheel: false,              //Boolean: Allow slider navigating via mousewheel
  562.             prevText: "Previous",           //String: Set the text for the "previous" directionNav item
  563.             nextText: "Next",               //String: Set the text for the "next" directionNav item
  564.             pausePlay: false,               //Boolean: Create pause/play dynamic element
  565.             pauseText: 'Pause',             //String: Set the text for the "pause" pausePlay item
  566.             playText: 'Play',               //String: Set the text for the "play" pausePlay item
  567.             randomize: false,               //Boolean: Randomize slide order
  568.             slideToStart: 0,                //Integer: The slide that the slider should start on. Array notation (0 = first slide)
  569.             animationLoop: true,            //Boolean: Should the animation loop? If false, directionNav will received "disable" classes at either end
  570.             pauseOnAction: true,            //Boolean: Pause the slideshow when interacting with control elements, highly recommended.
  571.             pauseOnHover: false,            //Boolean: Pause the slideshow when hovering over slider, then resume when no longer hovering
  572.             controlsContainer: "",          //Selector: Declare which container the navigation elements should be appended too. Default container is the flexSlider element. Example use would be ".flexslider-container", "#container", etc. If the given element is not found, the default action will be taken.
  573.             manualControls: "",             //Selector: Declare custom control navigation. Example would be ".flex-control-nav li" or "#tabs-nav li img", etc. The number of elements in your controlNav should match the number of slides/tabs.
  574.             start: function(slider){
  575.                 $j(slider).css('background-image', 'none');
  576.             },                              //Callback: function(slider) - Fires when the slider loads the first slide
  577.             before: function(){},           //Callback: function(slider) - Fires asynchronously with each slider animation
  578.             after: function(){},            //Callback: function(slider) - Fires after each slider animation completes
  579.             end: function(){}               //Callback: function(slider) - Fires when the slider reaches the last slide (asynchronous)
  580.         });
  581.     }
  582. }
  583.  
  584. /////////////////////////////////////////////
  585. // Portfolio Sorting
  586. /////////////////////////////////////////////
  587.  
  588. var portfolioSorting = {
  589.     init: function() {
  590.  
  591.         (function($j) {
  592.             $j.fn.sorted = function(customOptions) {
  593.                 var options = {
  594.                   reversed: false,
  595.                   by: function(a) { return a.text(); }
  596.                 };
  597.  
  598.                 $j.extend(options, customOptions);
  599.  
  600.                 $data = $j(this);
  601.                 arr = $data.get();
  602.  
  603.                 return $j(arr);
  604.        
  605.             };
  606.  
  607.         })($j);
  608.  
  609.         $j(function() {
  610.  
  611.             var read_button = function(class_names) {
  612.                
  613.                 var r = {
  614.                     selected: false,
  615.                     type: 0
  616.                 };
  617.                
  618.                 for (var i=0; i < class_names.length; i++) {
  619.                    
  620.                     if (class_names[i].indexOf('selected-') == 0) {
  621.                         r.selected = true;
  622.                     }
  623.                
  624.                     if (class_names[i].indexOf('segment-') == 0) {
  625.                         r.segment = class_names[i].split('-')[1];
  626.                     }
  627.                 };
  628.                
  629.                 return r;
  630.                
  631.             };
  632.        
  633.             var sort = function($buttons) {
  634.                 var $selected = $buttons.parent().filter('[class*="selected"]');
  635.                 return $selected.find('a').attr('data-value');
  636.             };
  637.  
  638.             // get the first collection
  639.             var $portfolio_items = $j('.portfolio-items');
  640.  
  641.             // clone applications to get a second collection
  642.             var $data = $portfolio_items.clone();
  643.  
  644.             var $filter_selection = $j('#portfolio-filter')
  645.  
  646.             $filter_selection.each(function(i) {
  647.  
  648.                 var $selection = $j(this);
  649.                 var $buttons = $selection.find('a');
  650.  
  651.                 $buttons.bind('click', function(e) {
  652.            
  653.                     var $button = $j(this);
  654.                     var $button_container = $button.parent();
  655.                     var button_properties = read_button($button_container.attr('class').split(' '));
  656.                     var selected = button_properties.selected;
  657.  
  658.                     if (!selected) {
  659.  
  660.                         $buttons.parent().removeClass();
  661.                         $button_container.addClass('selected');
  662.  
  663.                         var sorting = sort($filter_selection.eq(0).find('a'));
  664.  
  665.                         if (sorting == 'all') {
  666.                             var $filtered_data = $data.find('li');
  667.                         } else {
  668.                             var $filtered_data = $data.find('li.' + sorting);
  669.                         }
  670.  
  671.                         var $sorted_data = $filtered_data.sorted({
  672.                             by: function(v) {
  673.                                 return $j(v).find('strong').text().toLowerCase();
  674.                             }
  675.                         });
  676.  
  677.                         $portfolio_items.quicksand($sorted_data, {
  678.                           duration: 1000,
  679.                           adjustHeight: 'dynamic',
  680.                           easing: 'easeOutQuint'
  681.                         }, function(){prettyPhoto.init();});
  682.            
  683.                     }
  684.                
  685.                     e.preventDefault();
  686.  
  687.                 });
  688.  
  689.             });
  690.  
  691.         });        
  692.  
  693.     }
  694. }
  695.  
  696.  
  697. /////////////////////////////////////////////
  698. // PrettyPhoto Functions
  699. /////////////////////////////////////////////
  700.  
  701. var prettyPhoto = {
  702.     init: function() {
  703.                
  704.                 $j("a[data-gal^='prettyPhoto']").prettyPhoto({
  705.                     animation_speed: 'fast', /* fast/slow/normal */
  706.                     slideshow: 5000, /* false OR interval time in ms */
  707.                     autoplay_slideshow: false, /* true/false */
  708.                     opacity: 0.80, /* Value between 0 and 1 */
  709.                     show_title: true, /* true/false */
  710.                     allow_resize: true, /* Resize the photos bigger than viewport. true/false */
  711.                     default_width: 500,
  712.                     default_height: 344,
  713.                     counter_separator_label: '/', /* The separator for the gallery counter 1 "of" 2 */
  714.                     // theme: 'light_square', /* light_rounded / dark_rounded / light_square / dark_square / facebook */
  715.                     horizontal_padding: 20, /* The padding on each side of the picture */
  716.                     hideflash: false, /* Hides all the flash object on a page, set to TRUE if flash appears over prettyPhoto */
  717.                     wmode: 'opaque', /* Set the flash wmode attribute */
  718.                     autoplay: true, /* Automatically start videos: True/False */
  719.                     modal: false, /* If set to true, only the close button will close the window */
  720.                     deeplinking: false, /* Allow prettyPhoto to update the url to enable deeplinking. */
  721.                     overlay_gallery: true, /* If set to true, a gallery will overlay the fullscreen image on mouse over */
  722.                     keyboard_shortcuts: true, /* Set to false if you open forms inside prettyPhoto */
  723.                     changepicturecallback: function(){}, /* Called everytime an item is shown/changed */
  724.                     callback: function(){}, /* Called when prettyPhoto is closed */
  725.                     ie6_fallback: true
  726.                 });
  727.     }
  728. }
  729.  
  730.  
  731. /////////////////////////////////////////////
  732. // Contact Form Functions
  733. /////////////////////////////////////////////
  734.  
  735. var contactForm = {
  736.     init: function() {
  737.  
  738.         $j('form#contactForm').submit(function() {
  739.            
  740.             $j('form#contactForm label.error').remove();
  741.             $j('form#contactForm span.error').remove();
  742.             var hasError = false;
  743.            
  744.             $j('.requiredField').each(function() {
  745.                 $this = $j(this);
  746.                 if($j.trim($this.val()) == '') {
  747.                     $this.addClass('invalid');
  748.                     hasError = true;
  749.                 } else if($this.hasClass('email-input')) {
  750.                     var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
  751.                     if(!emailReg.test($j.trim($this.val()))) {
  752.                         $this.addClass('invalid');
  753.                         hasError = true;
  754.                     } else {
  755.                         $this.removeClass('invalid');
  756.                     }
  757.                 } else {
  758.                     $this.removeClass('invalid');
  759.                 }
  760.             });
  761.            
  762.             if(!hasError) {
  763.                 $j('form#contactForm li.buttons button').fadeOut('normal', function() {
  764.                     $j(this).parent().append('<span class="form-loading"></span>');
  765.                 });
  766.                 var formInput = $j(this).serialize();
  767.                 $j.post($j(this).attr('action'),formInput, function(data){
  768.                     $j('form#contactForm').slideUp("fast", function() {                
  769.                         $j('p.thanks').fadeIn(1000);
  770.                     });
  771.                 });
  772.             }
  773.            
  774.             return false;
  775.            
  776.         });
  777.  
  778.     }
  779. }
  780.  
  781.  
  782. /////////////////////////////////////////////
  783. // Reload Functions
  784. /////////////////////////////////////////////
  785.  
  786. var reloadFunctions = {
  787.     init:function() {
  788.  
  789.         // Remove title attributes from images to avoid showing on hover
  790.         $j('img[title]').each(function() {
  791.             $j(this).removeAttr('title');
  792.         });
  793.  
  794.         $j('.gallery-icon a[title]').each(function() {
  795.             $j(this).removeAttr('title');
  796.         });
  797.  
  798.         // Tabs Shortcode Function
  799.         $j('.tabbed-asset').tabs();
  800.        
  801.         // Accordion Shortcode Function
  802.         $j('.accordion').accordion({
  803.             collapsible: true,
  804.             autoHeight: false
  805.         });
  806.  
  807.     }
  808. }
  809.  
  810.  
  811. /////////////////////////////////////////////
  812. // Base Functions
  813. /////////////////////////////////////////////
  814.  
  815. var baseFunctions = {
  816.     init: function() {
  817.  
  818.         // Back to top scroll button
  819.         $j('.back-to-top').click(function() {
  820.             $j('body,html').animate({scrollTop:0},800);
  821.         });
  822.  
  823.         // Site loading
  824.         $j('.site-loading').fadeOut(200);
  825.         $j('.nav-wrap').fadeIn(1000);
  826.  
  827.         // Remove last divider on homepage
  828.         $j('.home').find('.divider:last').hide();
  829.     }
  830. }
  831.  
  832.  
  833. $j(document).ready(onLoad.init);
  834.  
  835. <?php if (($use_custom_font) || ($use_custom_tagline_font)) { ?>
  836.  
  837. /////////////////////////////////////////////
  838. // GOOGLE WEB FONT FUNCTION
  839. /////////////////////////////////////////////
  840.  
  841. <?php if ($use_custom_font && $use_custom_tagline_font) { ?>
  842.  
  843. WebFontConfig = {
  844.     google: { families: ['<?php echo $custom_font; ?>', '<?php echo $tagline_font; ?>'] }
  845. };
  846.  
  847. <?php } else if ($use_custom_font) { ?>
  848.  
  849. WebFontConfig = {
  850.     google: { families: [ '<?php echo $custom_font; ?>'] }
  851. };
  852.  
  853. <?php } else if ($use_custom_tagline_font) { ?>
  854.  
  855. WebFontConfig = {
  856.     google: { families: [ '<?php echo $tagline_font; ?>'] }
  857. };
  858.  
  859. <?php } ?>
  860.  
  861. (function() {
  862.     var webfontscript = document.createElement('script');
  863.     webfontscript.src = ('https:' == document.location.protocol ? 'https' : 'http') + '://ajax.googleapis.com/ajax/libs/webfont/1/webfont.js';
  864.     webfontscript.type = 'text/javascript';
  865.     webfontscript.async = 'true';
  866.     var script = document.getElementsByTagName('script')[0];
  867.     script.parentNode.insertBefore(webfontscript, script);
  868. })();
  869.  
  870. <?php } ?>