Advertisement
Guest User

Custom

a guest
Jul 29th, 2012
209
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /* JS DOCUMENTATION:
  2.  
  3. * FOLIO Ner2 *
  4.  
  5. */
  6.  
  7. /*********************************************
  8. * ON READY
  9. *********************************************/
  10.  
  11. var donde = null;
  12.  
  13. jQuery(document).ready(function($){
  14.  
  15. mode = 0;
  16.  
  17. var thumbOpacity = $('body').attr('class').split('thumb-opacity-')[1];
  18.  
  19. if($('body').hasClass('layout-2')){
  20.     $("a[data-gal^='prettyPhoto']").prettyPhoto({ default_width: 650, default_height: 425 });
  21. }
  22.  
  23. /**********************************
  24.  ADJUST DINAMIC HEIGHT FOR HEADER
  25. ***********************************/
  26. var topSection = $("#top-title-bar").height();
  27. $("#thumb-wrapper").css("margin-top", topSection);
  28. if($(window).width() < 480){
  29.     $("#top-title-bar-sdevice").height() == topSection/2;
  30.     $("#thumb-wrapper").css("margin-top", topSection/2);
  31.     }
  32. if ( $('body.fixed-nav').length){
  33.     var topSection = 0;
  34.     }
  35.  
  36. /*Displace the navigation bar on iPhone*/  
  37. (function($) {
  38.    $(document).ready(function() {
  39.       setTimeout(function () {
  40.          window.scrollTo(0, 0);
  41.       }, 100);
  42.    });
  43. })(jQuery);
  44.  
  45. $(window).bind('orientationchange resize', function(event){
  46.       var orient = window.orientation;
  47.       if(orient == 0) { //0 = portrait, -90 or 90 = landscape
  48.          window.scrollTo(0, 0);
  49.       } else {
  50.          window.scrollTo(0, 0);
  51.       }
  52.   });
  53.  
  54. /***************************
  55.  MULTIDISPLAY SMART COLLUMS
  56. ***************************/
  57.  
  58. function smartColumns(colSize) {
  59.     //Create a function that calculates the smart columns | First we need to check if it is a mobile device
  60.         if($(window).width() < 680){
  61.         //Reset column size to a 100% once view port has been adjusted
  62.         $("ul#thumbs").css({ 'width' : "100%"});
  63.         var colWrap = $("ul#thumbs").width(); //Get the width of row
  64.         var colNum = Math.floor(colWrap / 85); //Find how many columns of 200px can fit per row / then roundit down to a whole number
  65.         var colFixed = Math.floor(colWrap / colNum); //Get the width of the row and divide it by the number of columns it can fit / then roundit down to a whole number. This value will be the exact width of the re-adjusted column
  66.         $("ul#thumbs").css({ 'width' : colWrap}); //Set exact width of row in pixels instead of using % - Prevents cross-browser bugs that appear in certain view port resolutions.
  67.         $("ul#thumbs li").css({ 'width' : colFixed}); //Set exact width of the re-adjusted column
  68.            
  69.         }else{ //If not a mobile device
  70.        
  71.         //Reset column size to a 100% once view port has been adjusted
  72.         $("ul#thumbs").css({ 'width' : "100%"});
  73.         var colWrap = $("ul#thumbs").width(); //Get the width of row
  74.         var colNum = Math.floor(colWrap / colSize); //Find how many columns of colSize value set in option panel can fit per row / then roundit down to a whole number
  75.         var colFixed = Math.floor(colWrap / colNum); //Get the width of the row and divide it by the number of columns it can fit / then roundit down to a whole number. This value will be the exact width of the re-adjusted column
  76.         $("ul#thumbs").css({ 'width' : colWrap}); //Set exact width of row in pixels instead of using % - Prevents cross-browser bugs that appear in certain view port resolutions.
  77.         $("ul#thumbs li").css({ 'width' : colFixed}); //Set exact width of the re-adjusted column
  78.         }
  79. }
  80. smartColumns($('body').attr('class').split('col-size-')[1].split(' ')[0]);//Run the function when page loads
  81.  
  82.  
  83. /*******************
  84. // SLIDE NAV
  85. *******************/
  86. var navigationWidth = $("#main-nav").width();
  87.  
  88. if ( $('body.fixed-nav').length ){
  89.     $("#wrapper").css('margin-left', navigationWidth);
  90.     $('#tab-nav').css('display', 'none');
  91.     $("#top-title-bar, #top-title-bar-sdevice").css('display', 'none').css('height', 0+'px');
  92.     $("#thumb-wrapper").css('margin-top', 0+'px');
  93.     smartColumns($('body').attr('class').split('col-size-')[1].split(' ')[0]);//Run the function when page loads
  94.     }else{
  95.         if(navigator.userAgent.match(/like Mac OS X/i)
  96.            ){
  97.                function checkTopNavMobile() {
  98.                 if ($(".top-nav").length > 0){
  99.                 $(".tab-nav").remove();
  100.                 }
  101.                 else {
  102.                     barra = $('nav'); // nav
  103.                     trabajos = $('#wrapper'); // contents
  104.                     loquedura = {queue:true, duration:1250, easing: 'easeInOutExpo'}; // .animate() style
  105.                     // slideNav animations
  106.                     function para(){ barra.stop(); trabajos.stop(); };
  107.                     // return pixels number to move
  108.                     function mide(){    return ($('nav').width()-10)+'px'; };
  109.                    
  110.                     function slideNav(e){
  111.                         para();
  112.                         // moves nav
  113.                         barra.animate({  left: (e) ? '-'+mide() : 0 }, loquedura);
  114.                         // moves contents
  115.                         trabajos.animate({ left: (e) ? 0 : mide() }, loquedura);
  116.                     };
  117.                     $('nav').touchwipe({
  118.                         wipeLeft: function(){slideNav(1); },
  119.                         wipeRight: function(){slideNav();}
  120.                     })
  121.                
  122.                     $("#tap-close").click(function(){ slideNav(1); });
  123.                     var initBar = setTimeout(slideNav(1), 500);
  124.                  }
  125.                }
  126.                checkTopNavMobile();
  127.                
  128.         }else{
  129.                 function checkTopNav() {
  130.                 //First we need to detect if top navigation mode is active. If it is, remove lateral navigation behaviors for hover states
  131.                 if ($(".top-nav").length > 0){
  132.                   $(".tab-nav").remove();
  133.                 }
  134.                 else {
  135.                
  136.                     barra = $('nav'); // nav
  137.                     trabajos = $('#wrapper'); // contents
  138.                     loquedura = {queue:true, duration:1250, easing: 'easeInOutExpo'}; // .animate() style
  139.                     // slideNav animations
  140.                     function para(){ barra.stop(); trabajos.stop(); };
  141.                     // return pixels number to move
  142.                     function mide(){    return ($('nav').width()-10)+'px'; };
  143.                    
  144.                     function slideNav(e){
  145.                         para();
  146.                         // moves nav
  147.                         barra.animate({  left: (e) ? '-'+mide() : 0 }, loquedura);
  148.                         // moves contents
  149.                         trabajos.animate({ left: (e) ? 0 : mide() }, loquedura);
  150.                     };
  151.                     barra.mouseenter(function(){ slideNav();});
  152.                     barra.mouseleave(function(){ slideNav(1); });
  153.                     $("#tap-close").click(function(){ slideNav(1); });
  154.                     var initBar = setTimeout('barra.mouseleave()',1000);
  155.                     }
  156.                 }
  157.                 checkTopNav();
  158.             }
  159. }
  160. //iOS control bug zoom
  161. var mobile_timer = false;
  162. if(navigator.userAgent.match(/iPhone/i)) {
  163.     $('#viewport').attr('content','width=device-width,minimum-scale=1.0,maximum-scale=1.0,initial-scale=1.0');
  164.     $(window).bind('gesturestart',function () {
  165.         clearTimeout(mobile_timer);
  166.         $('#viewport').attr('content','width=device-width,minimum-scale=1.0,maximum-scale=10.0');
  167.     }).bind('touchend',function () {
  168.         clearTimeout(mobile_timer);
  169.         mobile_timer = setTimeout(function () {
  170.             $('#viewport').attr('content','width=device-width,minimum-scale=1.0,maximum-scale=1.0,initial-scale=1.0');
  171.         },1000);
  172.     });
  173. }
  174.  
  175. /*******************
  176. // PRELOADER
  177. *******************/
  178. spinnerWrapper = $('<div id="spinnerWrapper"></div>');
  179. $("body").append(spinnerWrapper);
  180.  
  181. function setPreloader(){
  182.         var wrapper = $("body");
  183.         var theItem = $("#spinnerWrapper");
  184.         var contWidth = $(wrapper).width();
  185.         var contMiddleW = contWidth/2;
  186.         var locMiddleW = theItem.width()/2;
  187.         var theMiddleW = contMiddleW-(locMiddleW+9);
  188.         var contHeight = $(window).height();
  189.         var contMiddleH = contHeight/2;
  190.         var locMiddleH = theItem.height()/2;
  191.         var theMiddleH = contMiddleH-locMiddleH;
  192.         $("#spinnerWrapper").css("left", theMiddleW).css("top", theMiddleH);
  193. }
  194. setPreloader();
  195.  
  196. var opts = {
  197.   lines: 13, // The number of lines to draw
  198.   length: 6, // The length of each line
  199.   width: 4, // The line thickness
  200.   radius: 10, // The radius of the inner circle
  201.   rotate: 0, // The rotation offset
  202.   color: '#000', // #rgb or #rrggbb
  203.   speed: 1.7, // Rounds per second
  204.   trail: 35, // Afterglow percentage
  205.   shadow: false, // Whether to render a shadow
  206.   hwaccel: false, // Whether to use hardware acceleration
  207.   className: 'spinner', // The CSS class to assign to the spinner
  208.   zIndex: 2e9, // The z-index (defaults to 2000000000)
  209.   top: 'auto', // Top position relative to parent in px
  210.   left: 'auto' // Left position relative to parent in px
  211. };
  212.  
  213. var div = document.getElementById('spinnerWrapper');
  214. var spinner = new Spinner(opts).spin(div);
  215. spinner.stop();div.parentNode.removeChild(div);
  216.  
  217. function addPreloader(){
  218.     document.body.appendChild(div);
  219.     spinner.spin(div);
  220.     setPreloader();
  221.     }
  222.    
  223. function removePreloader(){
  224.     spinner.stop();
  225.     div.parentNode.removeChild(div);
  226.     }
  227.  
  228. //appending the loader to the mouse
  229. //var el = $(new Spinner(opts).spin().el).css('position', 'absolute').appendTo('body');
  230. //$(document).mousemove(function(e) {
  231. //  el.css('top', e.clientY).css('left', e.clientX);
  232. //});
  233.  
  234.  
  235. /******************************************
  236. // HISTORY | URL CONTROL
  237. *******************************************/
  238. var controlPath = "";
  239.  
  240. // Prepare our Variables
  241.     var
  242.         History = window.History,
  243.         State = History.getState(),
  244.         rootPath = History.getState().url,
  245.         $mainContent = $("#work-detail-wrapper"),
  246.         $pageWrap    = $("#thumb-wrapper"),
  247.         $el,
  248.         scrollOptions = {
  249.             duration: 800,
  250.             easing:'swing'
  251.         }; 
  252.  
  253.         if(rootPath != rootUrl){
  254.             $mainContent.slideDown(750, function() {
  255.                 var viewportHeight = $(window).height();
  256.                 $mainContent.height(viewportHeight);
  257.                 $('html,body, #wrapper').animate({scrollTop: $("#work-detail-wrapper").offset().top-topSection}, "slow");
  258.                 slideWorks();
  259.                 loadWorkHistory();
  260.                 addPreloader();
  261.                 hideHome();
  262.             });
  263.         }else{
  264.             closeSlideWork();
  265.             showHome();
  266.             }
  267.        
  268.         $("#works a").click(function(){
  269.             //Check if lightbox mode is enabled, if it is
  270.             //galleries behaviors are disabled
  271.             if($('body').hasClass('layout-1')){
  272.                 prevPath = History.getState();
  273.                 checkPath = History.getState().url;
  274.                 valURL = $(this).attr("href");
  275.                 donde = 1;
  276.                 mode = 1;
  277.    
  278.                 var path = $(this).attr('href');
  279.                 var title = $(this).attr('title');
  280.                 History.pushState({state:1},title,path);
  281.                
  282.                
  283.                 $mainContent.slideDown(750, function() {
  284.                     var viewportHeight = $(window).height();
  285.                     $mainContent.height(viewportHeight);
  286.                     $('html,body, #wrapper').animate({scrollTop: $("#work-detail-wrapper").offset().top-topSection}, "slow");
  287.                     slideWorks();
  288.                 });
  289.             }
  290.            
  291.             return false;
  292.                    
  293.         });
  294.          
  295.          $("#sections a:not(#filters-launcher)").click(function() {
  296.             var checkPath = History.getState().url;
  297.             var valURL = $(this).attr("href");
  298.             donde = 1;
  299.             mode = 1;
  300.            
  301.             var path = $(this).attr('href');
  302.             var title = $(this).text();
  303.             History.pushState({state:1},title,path);
  304.                        
  305.             $mainContent.slideDown(500, function(){
  306.                 var viewportHeight = $(window).height();
  307.                 $mainContent.height(viewportHeight);
  308.                 $('html,body, #wrapper').animate({scrollTop: $("#work-detail-wrapper").offset().top-topSection}, "slow");
  309.                 slideWorks();
  310.             });
  311.                
  312.             /*     
  313.             if ( $.browser.msie ) {
  314.                 if(parseInt($.browser.version, 10) <=7){
  315.                     window.location.reload();
  316.                 } ;
  317.             }
  318.             */  
  319.             return false;
  320.            
  321.         });
  322.  
  323.  
  324.         // Hook into State Changes
  325.         History.Adapter.bind(window,'statechange',function() { // Note: Using statechange instead of popstate
  326.              State = History.getState(); // Note: Using History.getState() instead of event.state
  327.              addPreloader();
  328.              if(donde==1){
  329.              loadWorkHistory();
  330.              }
  331.              
  332.              var tempPath = History.getState().url;
  333.              
  334.              //If it is the start, close with works grid
  335.              if(tempPath == rootUrl){
  336.                  closeStartHistory();
  337.               }
  338.         });
  339.                
  340.         function scrollableArea(){
  341.             if(!navigator.userAgent.match(/iPhone/i) ||
  342.                !navigator.userAgent.match(/iPod/i)
  343.                ){
  344.                   $(window).load(function(){
  345.                         $(function()
  346.                         {
  347.                             $('.scrollable').jScrollPane();
  348.                         });
  349.                     })
  350.                    $(window).resize(function(){
  351.                         $('.scrollable').jScrollPane();
  352.                        });
  353.                    
  354.                     $(function()
  355.                         {
  356.                             $('.scrollable').jScrollPane();
  357.                     });
  358.                    
  359.                     $('.scrollable').hover(function(){
  360.                             $(".jspVerticalBar").fadeIn("fast")
  361.                        
  362.                         }, function(){
  363.                             $(".jspVerticalBar").fadeOut("fast")
  364.                     })             
  365.                 }
  366.             }
  367.        
  368.         function loadWorkHistory(){
  369.            
  370.             $mainContent.load(History.getState().url+' .item-wrapper', function(response, status, xhr) {
  371.                 donde = 1;
  372.                
  373.                 function isWork(){
  374.                     if(response.indexOf('<div class="info-work">')==-1){ return false; } else { return true; }
  375.                 }
  376.                                
  377.                 if(status == "error") {
  378.                     alert("Error loading work");
  379.                     removePreloader();
  380.                 }      
  381.                
  382.                 removePreloader();
  383.                 // slides on
  384.                
  385.                 if(isWork()==true){
  386.                     $('#prev').click(function(){
  387.                         activeSlides();
  388.                     });
  389.                     $('#next').click(function(){
  390.                         activeSlides(1);
  391.                     });
  392.                 }
  393.                
  394.                 checkContentInfo();
  395.                
  396.                 $mainContent.slideDown(300, function() {
  397.                     var viewportHeight = $(window).height();
  398.                     $mainContent.height(viewportHeight);
  399.                 });
  400.                
  401.                 $('html,body').animate({scrollTop: $("#work-detail-wrapper").offset().top-topSection},'slow');
  402.                
  403.                 slideWorks();
  404.                 if(isWork()==true){
  405.                     centerWork();
  406.                     if($('body').hasClass('gal-v2')){centerGallery();}
  407.                 }
  408.                 closeSlideWork();
  409.                 fadeSection();
  410.            
  411.                
  412.                 if(isWork()==true){
  413.                     $('#slideshow').fullDivGal();
  414.                     scrollableArea();
  415.                     checkContentInfo()
  416.                 } else {
  417.                
  418.                     if($(response).find('.section').attr('id')=='about'){
  419.                         scrollableArea();
  420.                         checkContentInfo()
  421.                      }
  422.                    
  423.                     if($(response).find('.tweet')){ runTwitter(); }
  424.                    
  425.                     if($(response).find('.section').attr('id')=='mydribbble'){
  426.                         $("#slider").carouFredSel({
  427.                             width: "variable",
  428.                             height: "auto",
  429.                             items: {
  430.                                 visible: 3,
  431.                                 width: "variable",
  432.                                 height: "variable"
  433.                             },
  434.                             scroll: {
  435.                                 mousewheel: true,
  436.                                 items: 3,
  437.                                 pauseOnHover: true
  438.                             },
  439.                             prev: {
  440.                                 button: ".btn-prev",
  441.                                 key: "left"
  442.                             },
  443.                             next: {
  444.                                 button: ".btn-next",
  445.                                 key: "right"
  446.                             }
  447.                         });
  448.                     }
  449.                    
  450.                     if($(response).find('.section').attr('id')=='contact'){
  451.                         $("a[data-gal^='prettyPhoto']").prettyPhoto();
  452.                        
  453.                         $('form#ajax_form .submit').click(function(){
  454.                        
  455.                             $('#ajax_form .error').hide();  //if error visibile, hide on new click
  456.                            
  457.                             var name = $('input#name').val();
  458.                             if (name == "" || name == " " || name == "Name") {
  459.                                 $('input#name').focus().before('<div class="error">Hey, what´s your name...?</div>');
  460.                                 return false;
  461.                             }
  462.                            
  463.                             var email_test = /^([a-z0-9_\.-]+)@([\da-z\.-]+)\.([a-z\.]{2,6})$/;
  464.                             var email = $('input#email').val();
  465.                             if (email == "" || email == " ") {
  466.                                $('input#email').focus().before('<div class="error">Psssst. You missed one...</div>');
  467.                                return false;
  468.                             } else if (!email_test.test(email)) {
  469.                                $('input#email').select().before('<div class="error">I think your mail is wrong</div>');
  470.                                return false;
  471.                             }
  472.                            
  473.                             var message = $('#message').val();
  474.                             if (message == "" || message == " " || message == "Message") {
  475.                                 $('#message').focus().fadeIn('slow').before('<div class="error">Remember your message!</div>');
  476.                                 return false;
  477.                             }
  478.                            
  479.                        
  480.                             $.post(rootUrl+'/wp-admin/admin-ajax.php', { action:"two2_send_contact_form", email:email, name:name, message:message }, function(data){
  481.                                 $('form#ajax_form').slideUp('fast').before('<div id="success"></div>');
  482.                                 $('#success').html(data).slideDown(9000);
  483.                             });
  484.                        
  485.                             return false;
  486.                        
  487.                        
  488.                         }); //end click function
  489.                        
  490.                         var current_data = new Array();
  491.                        
  492.                         $('.clear').each(function(i){
  493.                             $(this).removeClass('clear').addClass('clear'+i);
  494.                             current_data.push($(this).val());
  495.                        
  496.                             $(this).focus(function(){
  497.                                 if($(this).val() == current_data[i]) {
  498.                                     $(this).val('');
  499.                                 }
  500.                             });
  501.                             $(this).blur(function(){
  502.                                 var stored_data = current_data[i];
  503.                                 if($(this).val()==''){
  504.                                     $(this).val(stored_data);
  505.                                 }
  506.                             })
  507.                         });
  508.                     }
  509.                    
  510.                 }  
  511.                                
  512.             });
  513.         }
  514.        
  515.  
  516. /**************************************************
  517.  FADE SECTIONS
  518. ********************************************************/
  519. function fadeSection(){
  520.     setTimeout("$('.item-wrapper').animate({opacity: 1},750)", 750);
  521.     setTimeout("$('#divThumbs').animate({opacity: 1},750)", 750);
  522.  
  523. }
  524.  
  525. function fadeOnCloseSection(){
  526.     $('.item-wrapper').fadeOut("fast");
  527.     $('#divThumbs').fadeOut("fast");
  528.  
  529. }
  530.  
  531. /**************************************************
  532.  SLIDE WORK WRAPPER
  533. ********************************************************/
  534. var navigationWidth = $("#main-nav").width();
  535.  
  536. var workWrapper = $('#work-detail-wrapper');
  537. function viewportHeight(){
  538.     return $(window).height();
  539. };
  540. function viewportWidth(){
  541.     if ( $('body.fixed-nav').length ){
  542.         return $(window).width()-navigationWidth;
  543.     }else{
  544.         return $(window).width();
  545.     }
  546. };
  547. function slideWorks() {
  548.     if($('body').hasClass('gal-v1')){
  549.    
  550.         if( navigator.userAgent.match(/Android/i) ||
  551.            navigator.userAgent.match(/webOS/i) ||
  552.            navigator.userAgent.match(/iPhone/i) ||
  553.            navigator.userAgent.match(/iPod/i) ||
  554.            navigator.userAgent.match(/WP7/i) ||
  555.            navigator.userAgent.match(/BlackBerry/)
  556.            ){
  557.              workWrapper.height(viewportHeight()-(topSection-80));                     
  558.           }
  559.           else{
  560.              workWrapper.height(viewportHeight()-topSection);
  561.           }
  562.          
  563.     workWrapper.width(viewportWidth());
  564.     }
  565.     else{
  566.         workWrapper.height(viewportHeight()-topSection);
  567.         workWrapper.width(viewportWidth());
  568.         }
  569.        
  570.     if($('body').hasClass('gal-v2')){
  571.    
  572.     if( navigator.userAgent.match(/Android/i) ||
  573.        navigator.userAgent.match(/webOS/i) ||
  574.        navigator.userAgent.match(/iPhone/i) ||
  575.        navigator.userAgent.match(/iPod/i) ||
  576.        navigator.userAgent.match(/WP7/i) ||
  577.        navigator.userAgent.match(/BlackBerry/)
  578.        ){
  579.           workWrapper.height(viewportHeight()-(topSection-80));
  580.       }
  581.       else{
  582.          workWrapper.height(viewportHeight()-topSection);
  583.       }
  584.     workWrapper.width(viewportWidth());
  585.     }
  586.     else{
  587.         workWrapper.height(viewportHeight()-topSection);
  588.         workWrapper.width(viewportWidth());
  589.         }
  590.        
  591. }
  592. slideWorks();//Run the function when page loads
  593.  
  594. function showHome(){
  595.     $('.hidehome').show('slow');
  596.     }
  597. function hideHome(){
  598.     $('.hidehome').hide('slow');
  599.     }
  600.  
  601. function closeSlideWork(){
  602.     $('#closebt a, #closebt-section a, #top-title-bar figure').click(function () {
  603.        
  604.         fadeOnCloseSection();
  605.        
  606.         if(donde==1){
  607.             var checkVideos = $(".wrapper-embed-video").length;
  608.            
  609.             if(checkVideos > 0){
  610.                
  611.                 var divGal = $('#work-detail-wrapper');
  612.                 var videos = divGal.find('iframe');
  613.                 var nvideos = videos.length;
  614.                 var videoshtml5 = divGal.find('video'); //get html5 videos
  615.                 var nvideoshtml5 = videoshtml5.length;
  616.                
  617.                 for ( n = 0 ; n < nvideos ; n++ ){         
  618.                     var source = videos.eq(n).attr("src");
  619.                     videos.eq(n).attr("src","");
  620.                     videos.eq(n).attr("src",source);
  621.                
  622.                 };
  623.                
  624.                 function pausePlayer() {
  625.                   for(var i = 0; i < nvideoshtml5; i++){
  626.                       videoshtml5[i].pause();
  627.                         //In order to don´t add youtube&vimeo APIs (overload global js code)
  628.                         //this method let you stop all videos when
  629.                         //close btn is clicked. A 2000ms delay is needed
  630.                         //to reload the src, close and don´t lose sizes
  631.                   }
  632.                 }
  633.                 pausePlayer();
  634.                
  635.                 $("#work-detail-wrapper").slideUp();
  636.                 $('html,body, #wrapper').animate({scrollTop: 0}, 500);
  637.                 donde = null;
  638.                 mode = 0;
  639.                 History.replaceState({state:-1},rootTitle,rootUrl);
  640.                 return false;
  641.                
  642.             } else{
  643.                
  644.                 $("#work-detail-wrapper").slideUp();
  645.                 $('html,body, #wrapper').animate({scrollTop: 0}, 500);
  646.                 donde = null;
  647.                 mode = 0;
  648.                 History.replaceState({state:-1},rootTitle,rootUrl);
  649.                 return false;
  650.             }
  651.         }
  652.        
  653.     });
  654. };
  655.  
  656. function closeStartHistory(){
  657.             $("#work-detail-wrapper").slideUp();
  658.             $('html,body, #wrapper').animate({scrollTop: 0}, 500);
  659.             donde = null;
  660.             mode = 0;
  661.             History.pushState({state:0},rootTitle,rootUrl);
  662.             removePreloader();
  663.             return false;
  664.     }
  665.  
  666. /*************************************************
  667.  * FIX DEEPS FOR YOUTUBE VIDEOS
  668.  ************************************************/
  669. function fixVideoDeep() {
  670.     $(".video-container iframe").each(function(){
  671.           var ifr_source = $(this).attr('src');
  672.           var wmode = "wmode=transparent";
  673.           if(ifr_source.indexOf('?') != -1){ $(this).attr('src',ifr_source+'?'+wmode);}
  674.           else $(this).attr('src',ifr_source+'?'+wmode);
  675.     });
  676. }
  677.  
  678. /*************************************************
  679.  * CENTERWORK
  680.  ************************************************/
  681. function centerWork() {
  682.     function wrapper (){
  683.         return $("#work-detail-wrapper");
  684.     }
  685.     var itemW = $(".item-wrapper");
  686.     var theItem = $('.item-wrapper .item');
  687.    
  688.     //here you can control the galv1 height info
  689.     if($('body').hasClass('gal-v1')){
  690.     theItem.css('height', itemW.height() - 230 +'px');
  691.     }
  692.     else{
  693.         theItem.css('height', itemW.height());
  694.         }
  695.     //Size for the info in mobile devices
  696.     if($(window).width() < 480){
  697.        if($('body').hasClass('gal-v1')){
  698.           theItem.css('height', itemW.height() - 10 +'px');
  699.        }
  700.       }
  701. };
  702.  
  703. if($('body').hasClass('gal-v2')){
  704. function centerGallery() { 
  705.         var wrapper = $("#work-detail-wrapper");
  706.         var theItem = $("#slideshow");
  707.         var contHeight = $(wrapper).height();
  708.         var contMiddle = contHeight/2;
  709.         var locMiddle = theItem.height()/2;
  710.         var theMiddle = contMiddle-locMiddle;
  711.  
  712.             var wh = $("#work-detail-wrapper").height();
  713.             var ih = $('#slideshow').height();
  714.            
  715.             if (wh > ih) {
  716.             $('#slideshow').css('margin-top', theMiddle-20 + 'px');
  717.             } else {
  718.             $('#slideshow').css('margin-top',0);
  719.             }
  720.       }
  721. }
  722.  
  723. /*************************************************
  724.  * SET MODE
  725.  ************************************************/
  726. function setMode() {
  727.     if ($('.item').height() > 0){
  728.         mode = 1;
  729.     }
  730.     else{
  731.         mode = 0;
  732.         }      
  733. }
  734.  
  735. /**************************************************
  736.  * REMOVING SCROLLABLE AREA IF EMPTY or iOS DEVICE
  737.  **************************************************/
  738. function checkContentInfo(){
  739.    
  740.     if( navigator.userAgent.match(/Android/i) ||
  741.        navigator.userAgent.match(/webOS/i) ||
  742.        navigator.userAgent.match(/iPhone/i) ||
  743.        navigator.userAgent.match(/iPod/i) ||
  744.        navigator.userAgent.match(/iPad/i) ||
  745.        navigator.userAgent.match(/WP7/i) ||
  746.        navigator.userAgent.match(/BlackBerry/)
  747.        ){
  748.            //In order to get a smoother scroll in mobile and touch devices
  749.            //we remove the scrollable feature and we use all the native
  750.            //behaviors for scrolling for each device
  751.            
  752.            //Scroll area for info work in gal-v1
  753.            $('#scrollArea').removeClass('scrollable');
  754.            //Scroll area for info work in about page
  755.            $('#about>div').removeClass('scrollable');
  756.            //Scroll area for info work in info gal-v2
  757.            $('#info').removeClass('scrollable');
  758.         }
  759. }
  760.  
  761.  
  762. /************
  763.  ON LOAD
  764. *************/
  765. $(window).load(function(){
  766. (function(){
  767.         $('.thumb').fadeTo(250, thumbOpacity);
  768.     });
  769.     setTimeout((function(){
  770.     slideWorks();
  771.     centerWork();
  772.     if($('body').hasClass('gal-v2')){centerGallery();}
  773.     setMode();
  774.     }), 750);
  775. });
  776.  
  777. /***************************************
  778.  ON RESIZE ADJUST IMAGES
  779. *********************************************/
  780. $(window).resize(function(){
  781.     centerTopNavControls();
  782.     slideWorks(); //Esential for calculate sizes in iPad landscape/portrait modes.
  783.     centerWork();
  784.     if($('body').hasClass('gal-v2')){centerGallery();}
  785.     smartColumns($('body').attr('class').split('col-size-')[1].split(' ')[0]);
  786.     //slideNav(1);  //Run the function when page loads
  787. });
  788.  
  789. function centerOnOrientationChange(){
  790.     centerWork();
  791.     if($('body').hasClass('gal-v2')){centerGallery();}
  792.     if ($('body.fixed-nav').length == false){
  793.     checkTopNavMobile();
  794.     }
  795. }
  796.  
  797. //check for the orientation event and bind accordingly
  798. if (window.DeviceOrientationEvent) {
  799.   window.addEventListener('orientationchange', centerOnOrientationChange, false);
  800. } ;
  801.  
  802. /**********************************************
  803. //NAVIGATION       
  804. ************************************************/
  805. $('#filters-launcher').click(function(){
  806.     $('#filters').fadeIn(375);
  807.     $('#sections').fadeOut(100);
  808.     function altoScroll(){
  809.         return $('#work-detail-wrapper').height();
  810.     };
  811.     $('html,body,#wrapper').animate({scrollTop: (donde) ? altoScroll() : 0}, 500);
  812.     return false;
  813.  
  814. });
  815.  
  816. var cat = "none";
  817. if(cat == "none" )
  818.         $(".thumb").fadeTo(100, thumbOpacity);
  819.  
  820. /*******************************************
  821. //FILTERS
  822. ********************************************/
  823. $("#filter-menu a").click(function(e) {
  824.     cat = $(this).attr("class");
  825.     $("#works .thumb").not("."+cat).fadeTo(100, 0.1);
  826.     $("#works .thumb").filter("."+cat).fadeTo(100, 1);
  827.     $("#filter-menu a").parent().removeClass("active");
  828.     $(this).parent().addClass("active");
  829.     function altoScroll(){
  830.        
  831.         if ($(".top-nav").length > 0){
  832.             var navHeight = $("#main-nav").height();
  833.             var altoTopNav = $('#work-detail-wrapper').height()+(navHeight-topSection); //-40 is the margin top for wrapper. This compensate this margin.
  834.             return altoTopNav;
  835.         }
  836.         else{
  837.             return $('#work-detail-wrapper').height();
  838.             }
  839.    
  840.     };
  841.    
  842.    
  843.     $('html,body,#wrapper').animate({scrollTop: (donde) ? altoScroll() : 0}, 500);
  844.    
  845.     e.preventDefault();
  846.     e.stopPropagation();
  847. });
  848. $("#filter-menu a.none").click(function() {
  849.     $("#works .thumb").animate({ opacity: thumbOpacity },{queue:true, duration:250, easing: 'easeInOutExpo'});
  850. });
  851.  
  852. $('.close-sub').click(function(){
  853.     $('#filters').fadeOut(500);
  854.     $('#sections').fadeIn(500);
  855.     return false;
  856. });
  857.  
  858.  
  859.  
  860. /*******************************************
  861. // TOP NAVIGATION CONTROLS
  862. ********************************************/
  863.  
  864. function centerTopNavControls(){
  865. var winWidth = $(window).width();
  866. var sizeButton = $("#slide-controls").width()/2;
  867. var posMiddle = winWidth/2-(sizeButton+5);
  868.  $("#slide-controls").css("margin-left", posMiddle);
  869. }
  870. centerTopNavControls();
  871.  
  872.  
  873. // Check if user is in top navigation mode. If he is, show the smart controls
  874. if ($(".top-nav").length > 0){         
  875.     $("#slide-controls")
  876.             .css("display", "block")
  877.             .fadeOut(10)
  878.             .delay(1000)
  879.             .fadeIn(500);
  880.     }
  881.            
  882.            
  883. //Checkpoints to change controls when user scrolls. Smart control for top navigation mode
  884. function getPixels(){
  885.         var pos = $(window).scrollTop(); //position of the scrollbar
  886.         var navigationHeight = $("#main-nav").height();
  887.         var trueHeigh = navigationHeight-(topSection+1);
  888.         //$('#pixels').html(pos);
  889.        
  890.         if ($(".open-nav").length > 0){
  891.             if(pos > trueHeigh){
  892.                     $(".scroll-to-menu").fadeIn(500);
  893.                 }
  894.                 else{
  895.                     $(".scroll-to-menu").fadeOut(500)
  896.                     }
  897.         }
  898.             else{
  899.                 return false;
  900.                 }
  901. };
  902.  
  903. $(window).bind('scroll', function(){ //when the user is scrolling...
  904.         getPixels(); //check if nav is open and controls the scroll in order to change the buttons
  905.     });
  906.  
  907.  
  908. $(".launch-nav").click(function(){
  909.         $("nav#main-nav").slideToggle("slow");
  910.         $(this).toggleClass("open-nav");
  911.         $("#thumb-wrapper").toggleClass("the-margin");
  912.         $('html,body,#wrapper').animate({scrollTop:0}, 500);
  913.         return false;
  914.     });
  915.  
  916. //$('.launch-nav').click(function() {
  917. //  $("#thumb-wrapper").animate({
  918. //    marginTop: 0,
  919. //  }, 1000, function() {
  920. //    $("#thumb-wrapper").animate({
  921. //    marginTop: 40,
  922. //  }, 1000)
  923. //  });
  924. //});
  925.  
  926.    
  927.     $(".scroll-to-menu").click(function(){
  928.         $('html,body,#wrapper').animate({scrollTop:0}, 500);
  929.         return false;
  930.         })
  931.  
  932. /*Preventing "ajaxify" for social links*/
  933. $("#network-menu li a").click(function() {
  934.     window.open(this.href);
  935.     return false;
  936. });
  937.  
  938. // SOCIAL BUTTONS
  939. $("a.external").click(function() {
  940. window.open(this.href);
  941. return false;
  942. });
  943.    
  944. /*******************************************
  945.  * THUMBS HOVER FIX
  946.  ********************************************/
  947. $('.thumb').hover(function(){
  948.     if(cat== null || cat == "none" )
  949.         $(this).fadeTo(100, 1);
  950. }, function(){
  951.     if(cat== null || cat == "none" )
  952.         $(this).fadeTo(100, thumbOpacity)
  953. });
  954.  
  955. }); // End document ready
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement