$(window).load(function() { $('body').removeClass('preload'); }); $(document).ready(function(){ // FloatingBlock $('.floating_block').css('opacity',0); $('.floating_block .gotop').click(function(){ $('html,body').animate( {'scrollTop': $('body').offset().top }, {'duration':'normal','easing':'swing','queue':false} ); return false; }); $(window).scroll(function(){ moveGoTop(); }); function moveGoTop(){ var x = $(".l-footer_bottom").offset().top - $(window).scrollTop(); if( x <= $(window).height() ){ $(".floating_block").css( "position", "absolute" ); $(".floating_block").addClass("change"); } else{ $(".floating_block").css( "position", "fixed" ); $(".floating_block").removeClass("change"); } if( $(window).scrollTop() < 200 ) $(".floating_block").animate({"opacity":0}, {"duration":"fast","easing":"linear","queue":false}); else $(".floating_block").animate({"opacity":1}, {"duration":"fast","easing":"linear","queue":false}); } // img switch var $setElem = $('.switch'), pcName = '_pc', spName = '_sp', replaceWidth = 641; $setElem.each(function(){ var $this = $(this); function imgSize(){ var windowWidth = parseInt($(window).width()); if(windowWidth >= replaceWidth) { $this.attr('src',$this.attr('src').replace(spName,pcName)).css({visibility:'visible'}); } else if(windowWidth < replaceWidth) { $this.attr('src',$this.attr('src').replace(pcName,spName)).css({visibility:'visible'}); } } $(window).resize(function(){imgSize();}); imgSize(); }); $('#nav-icon').click(function(){ $(this).toggleClass('open'); $('.nav_menu').toggleClass('active'); }); $('.sp_search_btn,.l-header_info_search_close').on('click',function(){ $('.l-header_info_search').fadeToggle(300, 'linear'); }); $(window).on('load resize',function(){ $('.news_img').each(function(){ var imgHeight = $(this).find('img').height(); $(this).css('height',imgHeight); }); }); $('.l-header_gnav li a, .in-page-nav a').each(function(){ var $href = $(this).attr('href'); if(location.href.match($href)) { $(this).addClass('active'); $(this).closest("li").children("a").addClass("active"); } else { $(this).removeClass('active'); } }); $('.side-nav a').each(function(){ var $href = $(this).attr('href'); if(location.href.match($href)) { $(this).addClass('active'); } else { $(this).removeClass('active'); } }); if(window.location.href.indexOf("events/") > -1) { $(".events-nav").addClass('active'); } if(window.location.href.indexOf("policy-briefs-and-resources") > -1) { $(".policy-briefs-resources-nav").addClass('active'); } if(window.location.href.indexOf("global-outlook") > -1) { $(".global-outlook-nav").addClass('active'); } if(window.location.href.indexOf("tirac") > -1) { $(".tirac-nav").addClass('active'); } $('.l-side_news_list > ul > li a').on('click',function(){ $(this).next('ul').slideToggle(); if ($(this).next('ul').length !== 0) { $(this).toggleClass('on'); } return false; }); $('.l-side_news_list > ul > li a').each(function(){ if ($(this).next('ul').length === 0) { $(this).addClass('disable'); } }); $(window).on('load resize',function(){ $('.text_overflow').each(function(){ var ellipsisWrapper = $(this).height(); var ellipsis = $(this).find('p').height(); console.log(ellipsisWrapper); console.log(ellipsis); if (ellipsisWrapper <= ellipsis) { $(this).addClass('ellipsis'); } else { $(this).removeClass('ellipsis'); } }); }); $('.nav_menu_nav > ul li > ul').parent().addClass('has_subnav'); $('.nav_menu_nav > ul li.has_subnav > a').each(function() { var $this = $(this); var myClone = $this.clone(); var myCloneParent = $this.next('ul'); myClone.prependTo(myCloneParent).addClass('back_track').wrap('
  • '); }); $('.nav_menu_nav > ul li.has_subnav > a').click(function() { var $this = $(this); $this.next('ul').addClass('active'); return false; }); $('.nav_menu_nav > ul a.back_track').click(function() { var $this = $(this); $this.parent().parent().removeClass('active'); return false; }); objectFitImages('.img_scale img'); $(".l-header_gnav ul li").hover(function(){ $(this).children("a").addClass("hover"); $(this).find(".sub-nav-container").stop(true,true).fadeIn(200); }, function(){ $(this).children("a").removeClass("hover"); $(this).find(".sub-nav-container").stop(true,true).fadeOut(200); }); $(window).scroll(function(){ var topPosition = $(window).scrollTop(), headerHeight = $("header").height(); if (topPosition >= headerHeight) { $(".l-header_gnav").addClass("fixed"); } else { $(".l-header_gnav").removeClass("fixed"); } }); $(".tabs .tab-buttons button").click(function(){ var target = $(this).data("href"); $(this).closest(".tabs").find(".tab-content").removeClass("show").addClass("hide"); $(target).removeClass("hide").addClass("show"); $(".tabs .tab-buttons button").removeClass("selected"); $(this).addClass("selected"); }); $(".about-us-block .about-us-inner a, .expert-block .expert-inner a").each(function(){ if ($(window).width() >= 850) { var containerHeight = $(this).closest(".container").height(); if (!$(this).hasClass("no-container")) { $(this).css({"height": containerHeight}); } } }); $(".research-area-block .research-area-inner a").each(function(){ if ($(window).width() >= 1040) { var containerHeight = $(this).closest(".container").height(); if (!$(this).hasClass("no-container")) { $(this).css({"height": containerHeight}); } } }); var resizeTimer; $(window).on('resize', function(e) { $(".about-us-block .about-us-inner a, .research-area-block .research-area-inner a, .expert-block .expert-inner a").each(function(){ $(this).css({"height": "auto"}); $(this).closest(".container").css({"height": "auto"}); }); clearTimeout(resizeTimer); resizeTimer = setTimeout(function() { if ($(window).width() >= 850) { $(".about-us-block .about-us-inner a, .expert-block .expert-inner a").each(function(){ var containerHeight = $(this).closest(".container").height(); if (!$(this).hasClass("no-container")) { $(this).css({"height": containerHeight}); } }); } if ($(window).width() >= 1040) { $(".research-area-block .research-area-inner a").each(function(){ var containerHeight = $(this).closest(".container").height(); if (!$(this).hasClass("no-container")) { $(this).css({"height": containerHeight}); } }); } }, 250); }); });