jQuery.noConflict(); (function ($) { "use strict";function handleBackToTop() { $('#totop p').click(function () { $('html, body').animate({ scrollTop: 0 }, 'slow'); return false; }); } function showHidebackToTop() { if ($(window).scrollTop() > $(window).innerHeight() * 0.5) { $("#totop p").removeClass('gone'); $("#totop p").addClass('visible'); //if(!$("#floating-ads").hasClass('close')){ $("#floating-ads").removeAttr('class'); //} } else { $("#totop p").removeClass('visible'); $("#totop p").addClass('gone'); if(!$("#floating-ads").hasClass('close')){ $("#floating-ads").addClass('hide'); } } if ($(window).scrollTop() + $(window).innerHeight() > Math.floor($('#footer .copy').offset().top)) { $('#totop p').css({ 'bottom': Math.floor($(window).scrollTop() - $('#footer .copy').offset().top + $(window).innerHeight()) + 'px' }); } else { $('#totop p').removeAttr('style'); } $("#floating-ads .close p").click(function(){ $("#floating-ads").addClass('close'); }); } function top_menu_fixed() { var top1_h = $('#header .t1').outerHeight(); var top2_h = $('#header .t2').outerHeight(); var win_top = $(window).scrollTop(); if (win_top > top1_h - 1) { $('#header').addClass("fixed"); $('#header .t3.mobile').css({ 'margin-top': top2_h + 'px' }); } else { $('#header').removeAttr("class"); $('#header .t3.mobile').removeAttr("style"); } } function featured() { $('#cashcard .top .featured .box, #creditcard .top .featured .box, #loan .top .featured .box').hide(); $('#cashcard .top .featured, #creditcard .top .featured, #loan .top .featured').each(function (index, element) { $(element).find('h4, .f1 .title').click(function () { if ($(element).hasClass("active")) { $(element).removeClass("active"); } else { $(element).addClass("active"); } $(element).find('.box, .f2').slideToggle(); }); }); } function images_loaded() { $('html').imagesLoaded({ background: true }, function () { $('html').removeAttr('class'); }); $('#content').imagesLoaded().done(function () { handleBackToTop(); showHidebackToTop(); var top_article_slider = $('#top-article .desktop .slider').bxSlider({ pagerCustom: '#top-article .pager', auto: true, controls: false, infiniteLoop: true, useCSS: false, easing: 'jswing', speed: 500, pause: 3000, onSliderLoad: function () { $("#top-article").css("visibility", "visible"); }, onSlideAfter: function () { top_article_slider.stopAuto(); top_article_slider.startAuto(); } }); var top_article_slider_mobile = $('#top-article .mobile .slider').bxSlider({ auto: true, controls: false, infiniteLoop: true, useCSS: false, easing: 'jswing', speed: 500, pause: 3000, onSliderLoad: function () {}, onSlideAfter: function () { top_article_slider_mobile.stopAuto(); top_article_slider_mobile.startAuto(); } }); var recommend_slider = $('#recommend .slider.mobile ul').bxSlider({ auto: true, controls: false, slideWidth: 175, minSlides: 2, maxSlides: 5, slideMargin: 25, moveSlides: 1, infiniteLoop: true, useCSS: false, easing: 'jswing', speed: 500, pause: 3000, onSlideAfter: function () { recommend_slider.stopAuto(); recommend_slider.startAuto(); } }); var partner_slider = $('#partner .slider.mobile ul').bxSlider({ auto: true, controls: false, slideWidth: 225, minSlides: 2, maxSlides: 4, slideMargin: 25, moveSlides: 1, infiniteLoop: true, useCSS: false, easing: 'jswing', speed: 500, pause: 3000, onSlideAfter: function () { partner_slider.stopAuto(); partner_slider.startAuto(); } }); $('#header .menu .link.mobile').hide(); $('#header .menu').each(function (index, element) { $(element).find('.btn p').click(function () { if ($(element).hasClass("active")) { $(element).removeClass("active"); } else { $(element).addClass("active"); } $(element).find('.link.mobile').slideToggle(); }); }); featured(); }); } function search() { $('#header .search input[type="search"]').on('change', function () { $('#header .search form').submit(); }); } function list_h(target) { $(target).find('.contain').removeAttr('style'); } function banks() { var local = location.pathname; var local_last = window.location.href.substr(window.location.href.lastIndexOf('/') + 1); if (local_last !== 'creditcard') { local = local.split('/'); local = '/' + local[1]; } $('#creditcard .banks input:radio').change(function () { var input_val = $('#creditcard .banks input:checked').val(); var list_h = $('#creditcard .top .list').outerHeight() + 60 + $('#creditcard .top .pagenav').outerHeight(); $('#creditcard .top .contain').css({ 'height': list_h + 'px', 'opacity': '0' }); $('#creditcard .top .list').fadeOut(); $('.spinner.center').hide(); $('.spinner.center').delay(1000).fadeIn(); $.post('/wp-admin/admin-ajax.php', { 'action': 'banks', 'bank': input_val }, function (data) { $('#creditcard .top .pagenav').remove(); $('#creditcard .top .list').replaceWith(data); $.post('/wp-admin/admin-ajax.php', { 'action': 'nav', 'post_title': input_val }, function (data) { $('#header .nav').replaceWith(data); }); $('#creditcard .top .list').imagesLoaded().done(function () { featured(); list_h = $('#creditcard .top .list').outerHeight() + 60 + $('#creditcard .top .pagenav').outerHeight(); $('#creditcard .top .contain').css({ 'height': list_h + 'px', 'opacity': '1' }); $('.spinner.center').hide(); var url = local; if (input_val !== 'all') { url = local + '/' + input_val; } history.replaceState(null, null, url); }); }); }); } jQuery(function($){ $(document).ready(function(){ images_loaded(); search(); banks(); // var submittedCookie = getCookie("_cft_income_survey_submitted"); // if (submittedCookie == 1) {} else { // chua xem // setTimeout(function(){ // $('#survey-contain').remove(); // $("body").append( $("
") ); // $('#ans1, #ans2, #ans3, #ans4').click(function(){ // var expiration_date = new Date(); // var cookie_string = ''; // expiration_date.setFullYear(expiration_date.getFullYear() + 1); // document.cookie = "_cft_income_survey_submitted=1; path=/; expires=" + expiration_date.toUTCString(); // $("#survey-contain").fadeOut(500, function() { $(this).remove(); }); // $(".outer-survey").fadeOut(500, function() { $(this).remove(); }); // }); // }, 30000); // } }); $(window).scroll(function () { showHidebackToTop(); top_menu_fixed(); }); $(window).resize(function () { showHidebackToTop(); top_menu_fixed(); list_h('#creditcard .top'); }); function getCookie(cname) { var name = cname + "="; var ca = document.cookie.split(';'); for (var i = 0; i < ca.length; i++) { var c = ca[i]; while (c.charAt(0) == ' ') c = c.substring(1); if (c.indexOf(name) != -1) return c.substring(name.length, c.length); } return ""; } $(document).ready(function(){ const isshow = sessionStorage.getItem('closed'); if(isshow == null){ $('.sticky-banner').removeClass('hidden'); } $(".sticky-banner .btn-close").click(function(){ if(isshow == null){ sessionStorage.setItem('closed', '1'); $('.sticky-banner').addClass('hidden'); } }); $("#header .icon-search").click(function(){ $(this).toggleClass('active'); $("#header .search").toggleClass('active'); $("#header .menu").removeClass('active'); $("#header .menu .link.mobile").hide(); }); $("#header .menu").click(function(){ $("#header .icon-search").removeClass('active'); $("#header .search").removeClass('active'); }) }); })})(window.jQuery);