Advertisement
Guest User

main.js

a guest
Jun 19th, 2014
226
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. var ww = document.body.clientWidth;
  3.  
  4. var wheight = screen.height;
  5.  
  6.  
  7.  
  8.  
  9.  
  10. function scrollHead(){
  11.  
  12.     var itemOffset = $('.main_body_content').offset().top;
  13.     var scrollTop = $(window).scrollTop() + 65;    
  14.     if(scrollTop >= itemOffset){
  15.             $("#superheader").removeClass("large").addClass("small");
  16.             $(".header").addClass("zindex");
  17.             $("body").addClass("no-color");
  18.             $('.scrollup').fadeIn();
  19.            
  20.         }else {
  21.             $("#superheader").removeClass("small").addClass("large");
  22.             $(".header").removeClass("zindex");
  23.             $("body").removeClass("no-color");
  24.             $('.scrollup').fadeOut();
  25.         }  
  26. }
  27.  
  28.  
  29.  
  30.     $(window).on("scroll resize orientationchange", function(){
  31.         scrollHead();
  32.     });    
  33.  
  34.  
  35.  
  36. $(document).ready(function() {
  37.  
  38.  
  39.  
  40.  
  41.  
  42.         $('.scrollup').click(function(){
  43.             $("html, body").animate({ scrollTop: 0 }, 600);
  44.             return false;
  45.         });
  46.  
  47. /********************************************** responsive navigation end ----------------------*/
  48.  
  49. $('#nav-open-btn').click(function(){
  50.     $('#nav.mobile-nav').toggleClass('navshow navhide');
  51.     $('#inner-wrap').toggleClass('posa');
  52.  
  53.  
  54. })
  55.  
  56.  
  57.  
  58. /********************************************** responsive navigation end ----------------------*/
  59.  
  60.  
  61.  
  62.  
  63. ///////////////////////////////////////////language selector///////////////////////////////////////////////
  64. $('.select_arrow').click(function(e){
  65.     e.stopPropagation();
  66.     $('.list_language').toggleClass('active').slideToggle('slow');
  67.     $('#up-down').toggleClass('icon-chevron_down icon-chevron_up');
  68. })
  69.  
  70. function hideAndFade(){
  71. setTimeout(function() {
  72.         $('.list_language').removeClass('active').fadeOut();
  73.         $('#up-down').removeClass('icon-chevron_up').addClass('icon-chevron_down');    
  74.    
  75.     },50)  
  76. }
  77.  
  78. function addTextAndFlag(){
  79.     var getc = $(this).find(".flag").attr("class");
  80.     var gett = $(this).find(".l_text").attr("title");
  81.    
  82.     $( ".select_arrow .flag" ).removeClass().addClass(getc);
  83.     $( ".select_arrow .l_text" ).text(gett);
  84.     hideAndFade();  
  85. }
  86. function hideshow(){
  87.     setTimeout(function() {
  88.             $('.list_language').removeClass('active').slideUp();
  89.             $('#up-down').removeClass('icon-chevron_up').addClass('icon-chevron_down');    
  90.        
  91.         },50)      
  92. }
  93.  
  94. $(document).mouseup(function (e)
  95. {
  96.     var container = $(".language_selector");
  97.     var res_menu = $('.nav');
  98.     if (!container.is(e.target) // if the target of the click isn't the container...
  99.         && container.has(e.target).length === 0) // ... nor a descendant of the container
  100.     {
  101.     hideshow();      
  102.     }
  103. });
  104.  
  105. $('#list_lang li').click(addTextAndFlag);
  106.  
  107.  
  108.  
  109.  
  110.  
  111. ///////////////////////////////////////////language selector end ///////////////////////////////////////////////
  112.  
  113.  
  114. ///////////responsive menu
  115.  
  116.  
  117.  
  118.     $(".nav li a").each(function() {
  119.         if ($(this).next().length > 0) {
  120.             $(this).addClass("parent");
  121.         };
  122.     })
  123.    
  124.  
  125.     $(".toggleMenu").on('click', function(e) {
  126.         e.preventDefault();
  127.         $(this).toggleClass("active");
  128.          if($('#nav-open-btn').hasClass('active')){
  129.                 $(".nav").height(wheight);
  130.                 $(".main_body_content, .banner_wrap").css({
  131.                       'margin-left': '75%'
  132.                      
  133.                   });
  134.  
  135.          } else {
  136.                 $(".main_body_content, .banner_wrap").css({
  137.                       'margin-left': '0'
  138.                      
  139.                   });            
  140.          }
  141.  
  142.        
  143.  
  144.  
  145.  
  146.  
  147.  
  148.         //$(".nav").toggle();
  149.     });
  150.  
  151.         $('.banner_wrap, .main_body_content').click(function(){
  152.         if($('#nav-open-btn').hasClass('active')){
  153.            $('#nav-open-btn').removeClass('active');
  154.                 $(".main_body_content, .banner_wrap").css({
  155.                       'margin-left': '0'
  156.                      
  157.                   });              
  158.          }
  159.     })
  160.     adjustMenu();
  161. //responsive menu end
  162.  
  163.  
  164. // //IE fallback for Placeholder in input feild start  
  165.  
  166.  
  167.  
  168. })
  169. //document ready end
  170. function ifClickOutOfBox(){
  171.             $(document).mouseup(function (e)
  172.         {
  173.             var container = $(".nav li");
  174.  
  175.             if (!container.is(e.target) // if the target of the click isn't the container...
  176.                 && container.has(e.target).length === 0) // ... nor a descendant of the container
  177.             {
  178.                 container.removeClass('hover');
  179.             }
  180.         });
  181.  
  182.  
  183.  
  184.  
  185. }
  186.  
  187.  
  188. $(window).bind('resize orientationchange', function() {
  189.  
  190.     ww = document.body.clientWidth;
  191.     adjustMenu();
  192.  
  193.     if(ww>700){
  194.  
  195.         $('.nav li').off('click');
  196.     }
  197.        
  198. });
  199.  
  200.  
  201.  
  202. var adjustMenu = function() {
  203.  
  204. if((navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i)) || (navigator.userAgent.match(/iPad/i)) || (navigator.userAgent.match(/Android/i)) || ww<700) {
  205.  
  206.  
  207.                 $(".nav li").unbind('mouseenter mouseleave');
  208.                 $(".nav li a.parent").unbind('click').bind('click', function(e) {
  209.                                                 e.preventDefault();
  210.                                                 $(this).parent("li").toggleClass("hover");
  211.                                 });
  212.  
  213.         if(ww < 1030 ){
  214.  
  215.             $('.nav li').click(function(){
  216.                 $(this).siblings('li').removeClass('hover');
  217.            
  218.             })
  219.             }
  220.  
  221.  
  222. ifClickOutOfBox();
  223.  
  224.     } else {
  225.  
  226.         ifClickOutOfBox();
  227.  
  228.                 $(".nav li").unbind('mouseenter mouseleave').bind('mouseenter mouseleave', function() {
  229.                 // must be attached to li so that mouseleave is not triggered when hover over submenu
  230.                         $(this).toggleClass('hover');
  231.                 });
  232.                         $(".nav li").mouseover(function(){
  233.             $(this).siblings('li').removeClass('hover');
  234.         })
  235.         $(".nav li").unbind('click');
  236.  
  237.     }
  238.  
  239.  
  240. }
  241.  
  242.  
  243.  
  244.  
  245.  
  246.  
  247.  
  248. $(document).ready(function(){
  249. $('.nav').mouseleave(function() {
  250.   $('.nav li').removeClass('hover');
  251. });
  252.  
  253.  
  254.  
  255.  
  256.  
  257.     if(!Modernizr.input.placeholder){
  258.  
  259.     $('[placeholder]').focus(function() {
  260.       var input = $(this);
  261.       if (input.val() == input.attr('placeholder')) {
  262.         input.val('');
  263.         input.removeClass('placeholder');
  264.       }
  265.     }).blur(function() {
  266.       var input = $(this);
  267.       if (input.val() == '' || input.val() == input.attr('placeholder')) {
  268.         input.addClass('placeholder');
  269.         input.val(input.attr('placeholder'));
  270.       }
  271.     }).blur();
  272.     $('[placeholder]').parents('form').submit(function() {
  273.       $(this).find('[placeholder]').each(function() {
  274.         var input = $(this);
  275.         if (input.val() == input.attr('placeholder')) {
  276.           input.val('');
  277.         }
  278.       })
  279.     });
  280.  
  281. }  
  282. //IE fallback for Placeholder in input feild end
  283.  
  284.  
  285.  
  286.   $(".breadcrumbs a").each(function(n) {
  287.          $(this).attr("class", "bread" + n);
  288.      });
  289.   $(".accodion_body").each(function(n) {
  290.          $(this).addClass("acc" + n);
  291.   })
  292.  
  293.  
  294. $(".title_acc").click(function(){
  295.     $(".horizontal_accordion .accodion_body, .title_acc").removeClass('active');
  296.     $(this).addClass("active");
  297.     $(this).next().addClass('active');
  298.     var getAccHeight = $(".accodion_body.active").outerHeight();
  299.     $(this).parents(".horizontal_accordion").height(getAccHeight + 90);
  300. })
  301.  
  302.  
  303.        
  304.             $(".prog-bar").each(function() {
  305.                 $(this)
  306.                     .data("origWidth", $(this).width())
  307.                     .width(0)
  308.                     .animate({
  309.                         width: $(this).data("origWidth")
  310.                     }, 3000);
  311.             });
  312.        
  313.  
  314.  
  315. // open accordion with first box open
  316.     $(".full-width #accordion-container > .accordion-header").first().removeClass("inactive-header").addClass("active-header").next().slideDown().addClass("open-content");
  317.     var a = $(".accordion-header").width();
  318.     $(".accordion-content").css({
  319.         'width': a
  320.     });
  321.     $(".accordion-header").click(function () {
  322.         if ($(this).is(".inactive-header")) {
  323.             $(".accordion-content").slideUp().removeClass("open-content");
  324.             $(".accordion-header").removeClass("active-header").addClass("inactive-header");
  325.             $(this).removeClass("inactive-header").addClass("active-header");
  326.             $(this).next().slideDown().addClass("open-content")
  327.         } else {
  328.             $(this).removeClass("active-header").addClass("inactive-header");
  329.             $(this).next().slideUp().removeClass("open-content")
  330.         }
  331.     });
  332.     return false
  333.  
  334.  
  335.  
  336.  
  337.  
  338.  
  339. //end document ready.
  340. })
  341.  
  342.  
  343.  
  344.         // (function($){
  345.  
  346.         // })(jQuery);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement