PageSourceSearch

https://pso.edu.vn/wp-content/themes/psomba_2024/assets/js/functions.js?ver=1787305195

js pso.edu.vn collected 2026-10-07 22:36:22 UTC 49,906 bytes, 1,655 lines download raw bytes

1var $ = jQuery.noConflict();
2// Xử lý header
3$(function () {
4  $(".header-search a>i").attr(
5    "class",
6    "fa-sharp fa-solid fa-magnifying-glass",
7  );
8  $(".mega-button.button.white.is-outline").each(function () {
9    var $this = $(this);
10    $this.find(".mega-menu-link").html("<span>" + $this.text() + "</span>");
11  });
12});
13
14// Thay thế icon cơ bản của flatsome
15$(function () {
16  if ($(".icon-angle-right").length > 0) {
17    $(".icon-angle-right").each(function () {
18      var $this = $(this);
19      $this.attr("class", "fa-regular fa-arrow-right");
20    });
21  }
22  if ($(".icon-angle-left").length > 0) {
23    $(".icon-angle-left").each(function () {
24      var $this = $(this);
25      $this.attr("class", "fa-regular fa-arrow-left");
26    });
27  }
28});
29
30// Xử lý di chuyển i của button is-link vào bên trong nội dung
31$(function () {
32  if ($(".button:not(.icon):not(.back-to-top)").length > 0) {
33    $(".button:not(.icon):not(.back-to-top)").each(function () {
34      $this = $(this);
35      $span = $this.children("span");
36      $i = $this.children("i");
37      if ($span.length > 0 && $i.length > 0) {
38        $this.addClass("fix-i-by-js");
39        $i.appendTo($span);
40      }
41    });
42  }
43});
44
45jQuery(document).ready(function ($) {
46  setup();
47  changeText();
48  slick($);
49  getChangeTab();
50  // Xử lý Banner màn hình dưới 1100px
51  $(function () {
52    if ($(".banner-cth").length > 0) {
53      $(".banner-cth").each(function () {
54        $this = $(this);
55        $banner = $this.find(".banner");
56        $textBox = $this.find(".text-box");
57        $bannerInner = $this.find(".banner-inner");
58        if (jQuery(window).width() <= 1100) {
59          $("#content").addClass("fix-by-jquery");
60          $banner.find(".button:first-of-type").attr("class", "button primary");
61          $banner
62            .find(".button:last-of-type")
63            .attr("class", "button light-blue");
64          $bannerInner.remove();
65          $banner.find("style").remove();
66          $textBox.appendTo($banner);
67        } else {
68          $banner.css(
69            "min-height",
70            $textBox.children(".text-box-content").height() + 40,
71          );
72        }
73      });
74    }
75  });
76
77  // Xử lý pages-cth và row-content cho page-template-chuong-trinh-hoc ở chế độ Tablet/Mobile
78  $(function () {
79    var activeElement = jQuery('.pages-cth a[aria-current="page"]');
80    if (jQuery(".pages-cth").length) {
81      jQuery(".pages-cth").animate(
82        {
83          scrollLeft:
84            activeElement.offset().left -
85            jQuery(".pages-cth").offset().left +
86            jQuery(".pages-cth").scrollLeft() -
87            15,
88        },
89        200,
90      );
91    }
92    if (
93      isTablets() &&
94      $(".banner-cth").length > 0 &&
95      $(".row-content").length > 0
96    ) {
97      $(".row-content").each(function () {
98        $this = $(this);
99        $banner = $(".banner-cth");
100        $col1 = $this.children(":first-child");
101        $col1.appendTo($banner);
102      });
103    }
104  });
105
106  $(function () {
107    let initialWidth = $(window).width();
108    let currentMode = initialWidth <= 1100 ? "mobile" : "desktop";
109    let isReloading = false;
110
111    $(window).on("resize", function () {
112      if (isReloading) return;
113
114      const w = $(window).width();
115      const newMode = w <= 1100 ? "mobile" : "desktop";
116
117      // Chỉ reload khi vượt breakpoint
118      if (newMode !== currentMode) {
119        isReloading = true;
120        location.reload();
121      }
122    });
123  });
124
125  // Slick
126  $(".logo-carousel .col-inner").slick({
127    dots: false,
128    infinite: true,
129    speed: 300,
130    slidesToShow: 5,
131    slidesToScroll: 1,
132    // autoplay: true,
133    responsive: [
134      {
135        breakpoint: 850,
136        settings: {
137          slidesToShow: 2,
138        },
139      },
140      {
141        breakpoint: 550,
142        settings: {
143          slidesToShow: 1,
144        },
145      },
146    ],
147  });
148  // adjustLogoSizes();
149  // Banners carousel
150  var sync1 = jQuery("#sync1"),
151    sync2 = jQuery("#sync2");
152  sync1.owlCarousel({
153    items: 1,
154    pagination: false,
155    navigation: false,
156    singleItem: true,
157
158    afterAction: function () {
159      var n = this.currentItem;
160
161      jQuery("#sync2")
162        .find(".owl-item")
163        .removeClass("synced")
164        .eq(n)
165        .addClass("synced");
166      jQuery("#sync2").data("owlCarousel") !== undefined;
167
168      if (n > 3) sync2.trigger("owl.goTo", n + 1);
169      else sync2.trigger("owl.goTo", n - 1);
170    },
171    responsiveRefreshRate: 200,
172    lazyLoad: !0,
173    stopOnHover: !0,
174  });
175  sync2.owlCarousel({
176    items: 5,
177    itemsDesktop: [1199, 5],
178    itemsDesktopSmall: [979, 5],
179    itemsTablet: [768, 4],
180    pagination: !1,
181    responsiveRefreshRate: 100,
182    onChange: function (event) {
183      alert(1);
184    },
185    afterInit: function (n) {
186      n.find(".owl-item").eq(0).addClass("synced");
187    },
188  });
189  jQuery("#sync2").on("click", ".owl-item", function (sync2) {
190    sync2.preventDefault();
191
192    var i = jQuery(this).data("owlItem");
193    sync1.trigger("owl.goTo", i);
194  });
195  sync2.on("changed.owl.carousel", function (e) {
196    alert("vis: ", e.relatedTarget.settings.items);
197  });
198  $(".slick-3-2-1").slick({
199    infinite: true,
200    speed: 300,
201    slidesToShow: 3,
202    slidesToScroll: 3,
203    responsive: [
204      {
205        breakpoint: 850,
206        settings: {
207          slidesToShow: 2,
208          slidesToScroll: 2,
209        },
210      },
211      {
212        breakpoint: 550,
213        settings: {
214          slidesToShow: 1,
215          slidesToScroll: 1,
216          arrows: false,
217          dots: false,
218        },
219      },
220    ],
221  });
222  $(".slick-3-2-0").slick({
223    infinite: true,
224    speed: 300,
225    slidesToShow: 3,
226    slidesToScroll: 3,
227    responsive: [
228      {
229        breakpoint: 850,
230        settings: {
231          slidesToShow: 2,
232          slidesToScroll: 2,
233          arrows: false,
234          dots: true,
235        },
236      },
237      {
238        breakpoint: 550,
239        settings: "unslick",
240      },
241    ],
242  });
243
244  fix_icon_box();
245
246  var $selectedElements = $(".single-event article, .single-post article");
247  if ($selectedElements.length > 0) {
248    $selectedElements.each(function () {
249      var $this = $(this);
250      $this.addClass("content-has-fix-by-js");
251      $this.find("img").each(function () {
252        var $img = $(this);
253        var $parent = $img.parent();
254        if ($img.closest("dl").length > 0) {
255          if ($img.closest("dl").parent().is("div")) {
256            $img.parent("figure").unwrap().unwrap().unwrap();
257          } else {
258            $img.parent("figure").unwrap().unwrap();
259          }
260        } else {
261          if ($parent.is("p, h1, h2, h3, h4, h5, h6")) {
262            $img.unwrap();
263          }
264        }
265      });
266    });
267  }
268  // accordion
269  if (!isTablets()) {
270    $(".accordion-title").on("click", function (e) {
271      var $this = $(this);
272
273      var $parentAccordionItem = $this.parent(".accordion-item");
274
275      if (!$(this).hasClass("active")) {
276        setTimeout(() => {
277          $("body, html").animate(
278            {
279              scrollTop:
280                $parentAccordionItem.offset().top -
281                (jQuery("header").height() + 80),
282            },
283            "slow",
284          );
285        }, 400);
286      }
287    });
288  }
289
290  // Slick
291  if (isMobile()) {
292    $(".slick-2-rows.slick-only-mobile").slick({
293      rows: 2,
294      dots: true,
295      arrows: false,
296      infinite: true,
297      speed: 300,
298      slidesToShow: 1,
299      slidesToScroll: 1,
300      loop: true,
301    });
302    $(".logo-grid>.col-inner").slick({
303      rows: 3,
304      dots: false,
305      arrows: false,
306      infinite: true,
307      speed: 300,
308      slidesToShow: 2,
309      slidesToScroll: 2,
310      loop: true,
311    });
312  }
313  // box-overlay
314  $(".box-overlay").each(function () {
315    var parentBox = $(this).closest(".box");
316    var anchorTag = parentBox.find("a");
317
318    if (anchorTag.length > 0 && anchorTag.attr("href")) {
319      var href = anchorTag.attr("href");
320      var titleText = parentBox
321        .find(".box-text-inner")
322        .children()
323        .first()
324        .text();
325      var newAnchorTag = $("<a></a>")
326        .attr("href", href)
327        .attr("title", titleText);
328
329      anchorTag.contents().unwrap();
330      parentBox.children(".box-image, .box-text").wrapAll(newAnchorTag);
331    }
332  });
333
334  // href
335  if ($("#frmSubmit").length > 0) {
336    $(".mega-menu-link[href*='dang-ky-tu-van']").each(function () {
337      $(this).attr("href", "#frmSubmit");
338    });
339
340    setTimeout(function () {
341      $('.mega-menu-link[href="#frmSubmit"]').click(function (event) {
342        event.preventDefault();
343        $("html, body").animate(
344          {
345            scrollTop:
346              $("#frmSubmit").offset().top - (jQuery("header").height() + 150),
347          },
348          "slow",
349        );
350      });
351    }, 200);
352  }
353  // Change background banner when is mobile
354  if (isTablets()) {
355    $(".banners-carousel__content .owl-item").each(function () {
356      $_this = $(this);
357      $item = $_this.find(".item");
358      $url_img = $item.attr("data-image");
359      $banner = $_this.find(".banner");
360
361      if ($url_img && $banner.length > 0) {
362        console.log("banner-bg: ", $_this.find(".banner-bg"));
363        $_this.find(".banner-bg").css({
364          "background-image": `url(${$url_img})`,
365          "background-repeat": "no-repeat",
366          "background-position": "top center",
367          "background-size": "cover",
368        });
369        // $_this.find(".bg").css({
370        //   "background-image": `url(${$url_img})`,
371        // });
372      }
373    });
374  }
375
376  support_khoa_hoc();
377
378  var $sliderDotsCaption = jQuery(".slider-dots-caption");
379  $sliderDotsCaption
380    .children(".slider")
381    .flickity({})
382    .on("ready.flickity", function () {
383      $sliderDotsCaption.find(".box").each(function (index) {
384        var $this = jQuery(this);
385        var $index = index + 1;
386        var $text = jQuery.trim($this.find(".text.caption").text());
387        $sliderDotsCaption
388          .find(".flickity-page-dots .dot:nth-child(" + $index + ")")
389          .attr("caption-label", $text);
390      });
391
392      var maxWidth = 0;
393
394      $sliderDotsCaption.find(".flickity-page-dots .dot").each(function () {
395        var $this = jQuery(this);
396        var width = $this.outerWidth();
397
398        if (width > maxWidth) {
399          maxWidth = width;
400        }
401      });
402      $sliderDotsCaption
403        .find(".flickity-page-dots .dot")
404        .css("min-width", maxWidth + 30 + "px");
405    });
406
407  // Xử lý cho shortcode box_image_content_viewmore ---- wp-content\themes\kfo-2024\efw\ux-builder\bldr_common.php
408  if ($(".box-image-content-viewmore").length > 0) {
409    $(".box-image-content-viewmore:has(.button-toggle-content)").each(
410      function () {
411        var $this = $(this);
412        var $content_show = $this.find(".show");
413
414        // Tính toán chiều cao của phần tử và chuyển đổi sang rem
415        var heightInPx = $content_show.outerHeight();
416        var heightInRem = heightInPx / parseFloat($("html").css("font-size"));
417
418        // Thiết lập min-height bằng rem
419        $content_show.css({ "min-height": heightInRem + "rem" });
420
421        var $content_show_backup = $content_show.html();
422        var $content_hidden = $this.find(".button-toggle-content>.hidden");
423        var $content_hidden_backup = $content_hidden.html();
424        $content_hidden.remove();
425
426        $this.find(".button-toggle-content>.button").on("click", function () {
427          var $this = $(this);
428          var $parent = $this.closest(".box-image-content-viewmore_inner");
429          var $text_button = $this.find("[data-text]");
430          $parent.toggleClass("active");
431          if ($parent.hasClass("active")) {
432            $content_show.html($content_hidden_backup);
433            $text_button.text($text_button.data("text-active"));
434          } else {
435            $content_show.html($content_show_backup);
436            $text_button.text($text_button.data("text"));
437          }
438        });
439      },
440    );
441  }
442});
443
444function getIntrinsicSize(img) {
445  return { width: img.naturalWidth, height: img.naturalHeight };
446}
447function adjustLogoSizes() {
448  $(".logo-carousel img, .logos-intrinsicSize img").each(function () {
449    var img = $(this)[0];
450    var intrinsicSize = getIntrinsicSize(img);
451    $(this).css({ width: intrinsicSize.width, height: "auto" });
452    // $(this).closest('.img').css({ 'width': intrinsicSize.width, 'height': intrinsicSize.height });
453  });
454}
455function setup() {
456  jQuery(function () {
457    jQuery(".row-single .large-2 .col-inner").prepend(
458      jQuery(".row-single .large-7 #toc_container"),
459    );
460    jQuery('#toc_container a[href^="#"]').click(function () {
461      return false;
462    });
463    if ($(".Module-Tooltip").length > 0) {
464      const tip3 = new TextTip({
465        scope: ".Module-Tooltip",
466        iconFormat: "font",
467        buttons: [
468          {
469            title: "Share on Twitter",
470            icon: "fa-brands fa-twitter",
471            callback: function (e, ob, _this) {
472              callbackTooltip(e, ob, _this, "twitter");
473            },
474          },
475          {
476            title: "Share on Facebook",
477            icon: "fa-brands fa-facebook-f",
478            callback: function (e, ob, _this) {
479              callbackTooltip(e, ob, _this, "facebook");
480            },
481          },
482          {
483            title: "Share on LinkedIn",
484            icon: "fa-brands fa-linkedin-in",
485            callback: function (e, ob, _this) {
486              callbackTooltip(e, ob, _this, "linkedin");
487            },
488          },
489          // {
490          //     title: 'Share on Messenger',
491          //     icon: 'fa-brands fa-facebook-messenger',
492          //     callback: function (e, ob, _this) {
493          //         callbackTooltip(e, ob, _this, 'messenger');
494          //     }
495          // },
496          {
497            title: "Share on WhatsApp",
498            icon: "fa-brands fa-whatsapp",
499            callback: function (e, ob, _this) {
500              callbackTooltip(e, ob, _this, "whatsapp");
501            },
502          },
503          {
504            title: "Share via Email",
505            icon: "fa-solid fa-envelope",
506            callback: function (e, ob, _this) {
507              callbackTooltip(e, ob, _this, "envelope");
508            },
509          },
510          {
511            title: "Copy Selected Text",
512            icon: "fa-solid fa-copy",
513            callback: function (e, ob, _this) {
514              callbackTooltip(e, ob, _this, "copy");
515            },
516          },
517          {
518            key: "xmark",
519            title: "Copy Selected Text",
520            icon: "fa-solid fa-xmark",
521            callback: function (e, ob, _this) {
522              callbackTooltip(e, ob, _this, "xmark");
523            },
524          },
525        ],
526      });
527    }
528  });
529  jQuery(function () {
530    jQuery(function () {
531      jQuery('a[href="#"]').each(function () {
532        var link = jQuery(this);
533        link.removeAttr("href");
534        link.css("cursor", "pointer");
535      });
536    });
537  });
538  jQuery(function () {
539    jQuery(".event-simple.row-2").slick({
540      slidesToShow: 2,
541      slidesToScroll: 2,
542      autoplay: true,
543      dots: false,
544      autoplaySpeed: 5000,
545      responsive: [
546        {
547          breakpoint: 850,
548          settings: {
549            slidesToShow: 2,
550            slidesToScroll: 2,
551            dots: true,
552          },
553        },
554        {
555          breakpoint: 550,
556          settings: {
557            slidesToShow: 1,
558            slidesToScroll: 1,
559            dots: true,
560          },
561        },
562      ],
563    });
564  });
565  if (isTablets()) {
566    $(".sec-footer .section-content .r-2 .col:nth-child(2)>.col-inner").prepend(
567      '<span class="toggle-menu-row-2">
567Tìm hiểu thêm</span>',
568    );
569    $("body").on("click", ".sec-footer .toggle-menu-row-2", function () {
570      var $this = $(this);
571      $this.toggleClass("active").next(".ux-menu").slideToggle("fast");
572    });
573  }
574}
575
576function isTablets() {
577  if (jQuery(window).width() <= 849) return true;
578  return false;
579}
580
581function isMobile() {
582  if (jQuery(window).width() <= 549) return true;
583  return false;
584}
585
586function slick($) {
587  $arg = {};
588  $class = "";
589  if ($(".list-video .item-video").length > 3) {
590    $arg = { centerMode: true };
591    $class = "centerMode";
592  }
593  $arg = { centerMode: true };
594  var $slickEl = $(".list-video");
595
596  $slickEl.addClass($class).slick({
597    ...$arg,
598    focusOnSelect: false,
599    centerPadding: "0px",
600    infinite: true,
601    slidesToShow: 3,
602    slidesToScroll: 1,
603    arrows: true,
604
605    responsive: [
606      {
607        breakpoint: 849,
608        settings: {
609          arrows: false,
610          centerMode: true,
611          centerPadding: "80px",
612          slidesToShow: 1,
613        },
614      },
615      {
616        breakpoint: 549,
617        settings: {
618          arrows: false,
619          centerMode: true,
620          centerPadding: "60px",
621          slidesToShow: 1,
622        },
623      },
624    ],
625  });
626
627  if (!window.matchMedia("(max-width: 849px)").matches) {
628    $(".slick-img .col-inner").slick({
629      infinite: true,
630      slidesToShow: 3,
631      slidesToScroll: 3,
632    });
633  }
634  if (window.matchMedia("(max-width: 449px)").matches) {
635    if ($(".activities-grid .item-activity").length > 3) {
636      $arg = { centerMode: true };
637      $class = "centerMode";
638      $(".activities-grid").addClass($class).slick({
639        arrows: false,
640        centerMode: true,
641        centerPadding: "60px",
642        slidesToShow: 1,
643      });
644    }
645  }
646  // Fancybox Config
647  $('[data-fancybox="gallery"]').fancybox({
648    buttons: ["slideShow", "thumbs", "zoom", "fullScreen", "share", "close"],
649    loop: true,
650    protect: true,
651  });
652}
653function slice_more(t, a, s, e) {
654  $this = jQuery(t);
655  $blog = $this.closest(".load_more").prev(".blog_post_custom");
656  if (s + a >= e) $this.parent(".load_more").remove();
657  $blog.children(":nth-child(-n+" + (s + a) + ")").addClass("active");
658  $this.attr("onclick", "slice_more(this," + a + "," + (s + a) + "," + e + ")");
659  return false;
660}
661// Video Player fancybox
662jQuery(document).ready(function ($) {
663  // var height = screen.height / 1.5;
664
665  $(".fancybox").fancybox({
666    beforeLoad: function (instance, slide) {
667      $(slide.$slide).addClass("custom-fancybox-video");
668    },
669    // 'width': 16 / 9. * height,
670    // 'height': height,
671    // 'autoDimensions': false,
672    hideOnContentClick: false,
673    helpers: {
674      media: true,
675    },
676    youtube: {
677      autoplay: 1,
678    },
679  });
680});
681
682function changeText() {
683  if (!isMobile()) return false;
684  jQuery(".sec-image-text").each(function () {
685    $this = jQuery(this);
686    $title = $this.find(".box-text h2");
687    if ($title.length > 0) {
688      $h2 = $title.prop("outerHTML");
689      $title.remove();
690      $this.find(".box-image").prepend($h2);
691    }
692  });
693
694  return false;
695}
696
697function copyToClipboard(t, url) {
698  var dummy = document.createElement("input");
699  var $this = jQuery(t);
700  document.body.appendChild(dummy);
701  dummy.value = url;
702  dummy.select();
703  document.execCommand("copy");
704  document.body.removeChild(dummy);
705  $this.children("span").text("Đã Copy");
706  $this.addClass("active");
707  setTimeout(() => {
708    $this.children("span").text("Copy URL");
709    $this.removeClass("active");
710  }, 2500);
711}
712
713function copyToClipboard_ForTooltip(ele, text) {
714  var $this = $(ele);
715  var $i = $this.children("i");
716  // Tạo một phần tử textarea ẩn để chứa văn bản cần sao chép
717  var textArea = document.createElement("textarea");
718  textArea.value = text;
719  // console.log(text)
720  // Thêm phần tử textarea vào trang web
721  document.body.appendChild(textArea);
722
723  // Chọn toàn bộ văn bản trong phần tử textarea
724  textArea.select();
725
726  // Sao chép văn bản vào clipboard
727  document.execCommand("copy");
728
729  // Loại bỏ phần tử textarea khỏi trang web
730  document.body.removeChild(textArea);
731
732  if ($i.hasClass("fa-solid fa-link")) {
733    $i.attr("class", "fa-solid fa-check");
734    setTimeout(() => {
735      $i.attr("class", "fa-solid fa-link");
736    }, 1000);
737  }
738}
739
740function click_img_play_iframe(t) {
741  var iframe = $(t).siblings("iframe");
742  var src = iframe.attr("src");
743  if (src.indexOf("&autoplay=1") === -1) {
744    // Kiểm tra nếu chưa có autoplay thì thêm vào
745    iframe.attr("src", src + "&autoplay=1");
746  }
747  $(t).fadeOut("slow");
748  iframe.css("opacity", "1");
749}
750
751function click_img_play_video(t) {
752  var videoElement = $(t).siblings("video"); // Lấy jQuery object của video
753  if (videoElement[0].paused) {
754    // Kiểm tra nếu video đang bị tạm dừng
755    videoElement.prop("muted", false);
756    videoElement[0].play(); // Bắt đầu phát video
757    videoElement.css("opacity", "1"); // Đặt opacity cho video
758    $(t).fadeOut("slow"); // Ẩn nút play
759  }
760}
761
762//Scroll back to top
763(function ($) {
764  "use strict";
765  $(document).ready(function () {
766    "use strict";
767
768    //Scroll back to top
769
770    var progressPath = document.querySelector(".progress-wrap path");
771    var pathLength = progressPath.getTotalLength();
772    progressPath.style.transition = progressPath.style.WebkitTransition =
773      "none";
774    progressPath.style.strokeDasharray = pathLength + " " + pathLength;
775    progressPath.style.strokeDashoffset = pathLength;
776    progressPath.getBoundingClientRect();
777    progressPath.style.transition = progressPath.style.WebkitTransition =
778      "stroke-dashoffset 10ms linear";
779    var updateProgress = function () {
780      var scroll = $(window).scrollTop();
781      var height = $(document).height() - $(window).height();
782      var progress = pathLength - (scroll * pathLength) / height;
783      progressPath.style.strokeDashoffset = progress;
784    };
785    updateProgress();
786    $(window).scroll(updateProgress);
787    var offset = 50;
788    var duration = 550;
789    $(window).on("scroll", function () {
790      if ($(this).scrollTop() > offset) {
791        $(".progress-wrap").addClass("active-progress");
792      } else {
793        $(".progress-wrap").removeClass("active-progress");
794      }
795    });
796    $(".progress-wrap").on("click", function (event) {
797      event.preventDefault();
798      $("html, body").animate({ scrollTop: 0 }, duration);
799      return false;
800    });
801  });
802})($);
803
804// Slick - 2024
805$(function ($) {
806  $(".event-one-column.slick").slick({
807    dots: false,
808    infinite: true,
809    speed: 500,
810    responsive: [
811      {
812        breakpoint: 850,
813        settings: {
814          slidesToShow: 1,
815        },
816      },
817    ],
818  });
819
820  $(".slick-gallery").slick({
821    slidesToShow: 3,
822    slidesToScroll: 1,
823    autoplay: true,
824    dots: false,
825    autoplaySpeed: 5000,
826    responsive: [
827      {
828        breakpoint: 850,
829        settings: {
830          slidesToShow: 2,
831        },
832      },
833      {
834        breakpoint: 550,
835        settings: {
836          slidesToShow: 1,
837        },
838      },
839    ],
840  });
841  // /Mobi|Android/i.test(navigator.userAgent) &&
842  if (jQuery(window).width() < 850) {
843    $(".i-by-pso-mba__row .row.post-two-column").slick({
844      dots: false,
845      infinite: true,
846      speed: 500,
847      responsive: [
848        {
849          breakpoint: 850,
850          settings: {
851            slidesToShow: 1,
852          },
853        },
854      ],
855    });
856    jQuery(".box-custom, .why-should-study-mba .row.post-image").slick({
857      slidesToShow: 1,
858      slidesToScroll: 1,
859      dots: false,
860      responsive: [
861        {
862          breakpoint: 850,
863          settings: {
864            slidesToShow: 2,
865          },
866        },
867        {
868          breakpoint: 550,
869          settings: {
870            slidesToShow: 1,
871          },
872        },
873      ],
874    });
875  }
876  $(".alumni-benefits__content").slick({
877    centerMode: true,
878    centerPadding: "0px",
879    slidesToShow: 3,
880    slidesToScroll: 1,
881    arrows: true,
882    dots: true,
883    focusOnSelect: true,
884    responsive: [
885      {
886        breakpoint: 849,
887        settings: {
888          arrows: false,
889          centerMode: true,
890          // centerPadding: '40px',
891          slidesToShow: 3,
892        },
893      },
894      {
895        breakpoint: 549,
896        settings: {
897          arrows: false,
898          centerMode: true,
899          // centerPadding: '40px',
900          slidesToShow: 1,
901        },
902      },
903    ],
904  });
905});
906$(function ($) {
907  $(".mba-reasons").slick({
908    slidesToShow: 3,
909    slidesToScroll: 1,
910    variableWidth: true,
911    dots: false,
912    focusOnSelect: true,
913  });
914  $(".mba-reasons").on(
915    "beforeChange",
916    function (event, { slideCount: count }, currentSlide, nextSlide) {
917      let selectors = [nextSlide, nextSlide - count, nextSlide + count]
918        .map((n) => `[data-slick-index="${n}"]`)
919        .join(", ");
920      $(".slick-now").removeClass("slick-now");
921      $(selectors).addClass("slick-now");
922    },
923  );
924  $(".mba-reasons").find('[data-slick-index="0"]').addClass("slick-now");
925});
926
927$(function ($) {
928  var isDragging = false;
929  var startY;
930  var scrollTimeout; // Biến để lưu trữ timeout
931  $(document).on("scroll", function () {
932    if (!isDragging) {
933      var winScroll = $(this).scrollTop();
934      var height = $(document).height() - $(window).height();
935      var scrolled = (winScroll / height) * 100;
936      $("#rep-scrollIndicator").css("opacity", "1");
937      $("#scrollIndicator").css("top", scrolled + "%");
938
939      clearTimeout(scrollTimeout);
940      scrollTimeout = setTimeout(function () {
941        $("#rep-scrollIndicator").css("opacity", "0");
942      }, 1500);
943    }
944  });
945});
946
947$(function ($) {
948  if ($(".bldr_blog_posts").length > 0) {
949    // Xử lý sự kiện khi tab được click
950    $(function () {
951      $(".tablinks").click(function (e) {
952        e.preventDefault();
953        let $this = $(this);
954        let tabName = $this.data("tab");
955
956        // Ẩn tất cả tabcontent
957        $(".tabcontent").hide();
958
959        // Loại bỏ class "active" từ tất cả tablinks
960        $(".tablinks").removeClass("active");
961        $(".tablinks").addClass("is-outline");
962
963        // Hiển thị tabcontent của tab được click
964        $("#" + tabName).show();
965
966        // Thêm class "active" cho tab được click
967        $this.removeClass("is-outline").addClass("active");
968      });
969
970      // Tự động click vào tab mặc định
971      $("#defaultOpen").click();
972    });
973
974    // Loại bỏ toàn bộ href .pagination>.page-numbers và redirection page dựa trên các data-cat - data-screen
975    $(function () {
976      setTimeout(() => {
977        // Lấy URL hiện tại
978        var $currentURL = window.location.href;
979
980        // Tạo một đối tượng URL từ URL hiện tại
981        var $url = new URL($currentURL);
982
983        // Kiểm tra xem có tham số truy vấn "screen" và "cat" không
984        var $categoryParam = $url.searchParams.get("cat");
985
986        if ($categoryParam) {
987          $("body,html").animate({
988            scrollTop:
989              $(".bldr_tabgroup_blog_posts[data-cat='" + $categoryParam + "']")
990                .closest(".section")
991                .offset().top - 150,
992          });
993        }
994      }, 200);
995
996      $(".bldr_blog_posts .pagination>.page-numbers").each(function () {
997        let $this = $(this);
998        $this.removeAttr("href");
999        if ($this.hasClass("current")) {
1000          let $current = $(this).text();
1001          if ($current != "1")
1002            $this
1003              .parent()
1004              .children(".prev")
1005              .attr("data-screen", parseInt($current) - 1);
1006          if ($this.next().hasClass("next") == false)
1007            $this
1008              .parent()
1009              .children(".next")
1010              .attr("data-screen", parseInt($current) + 1);
1011        } else {
1012          if (
1013            $this.hasClass("next") == false &&
1014            $this.hasClass("prev") == false &&
1015            $this.hasClass("dots") == false
1016          )
1017            $this.attr("data-screen", parseInt($this.text()));
1018        }
1019      });
1020
1021      $(".bldr_blog_posts .page-numbers[data-screen]").click(function (e) {
1022        e.preventDefault();
1023        let $this = $(this);
1024        let $category = $this.parent().data("cat");
1025        let $screen = $this.data("screen");
1026
1027        // Lấy URL hiện tại
1028        let $currentURL = window.location.href;
1029
1030        // Tạo một đối tượng URL từ URL hiện tại
1031        let $url = new URL($currentURL);
1032
1033        // Thêm tham số 'page' và 'post' vào URL
1034        if ($category) $url.searchParams.set("cat", $category);
1035        if ($screen) $url.searchParams.set("screen", $screen);
1036
1037        // Lấy URL mới với các tham số đã thêm
1038        let $newURL = $url.toString();
1039        // Chuyển hướng trình duyệt đến URL mới
1040        $("#waitprocess").show();
1041        window.location.href = $newURL;
1042        $("#waitprocess").hide();
1043      });
1044
1045      $(".bldr_blog_posts .post_tag").click(function (e) {
1046        e.preventDefault();
1047        let $this = $(this);
1048        let $tag = $this.data("tag");
1049        let $category = $this.closest(".list_tag").data("cat");
1050
1051        // Lấy URL hiện tại
1052        let $currentURL = window.location.href;
1053
1054        // Tạo một đối tượng URL từ URL hiện tại
1055        let $url = new URL($currentURL);
1056
1057        var $tagParam = $url.searchParams.get("tag");
1058
1059        $url.search = "";
1060
1061        $newTagParam = AddNum_RemoveDupliNum($tagParam, $tag);
1062        if ($newTagParam) {
1063          $("#waitprocess").show();
1064          window.location.href =
1065            $url + "?cat=" + $category + "&tag=" + $newTagParam;
1066          $("#waitprocess").hide();
1067        }
1068      });
1069
1070      $(".bldr_blog_posts .close-tag").click(function (e) {
1071        e.preventDefault();
1072        let $this = $(this);
1073        let $parent = $this.parent(".post_tag");
1074        let $tag = $parent.data("tag");
1075        let $category = $this.closest(".list_tag").data("cat");
1076
1077        // Lấy URL hiện tại
1078        let $currentURL = window.location.href;
1079
1080        // Tạo một đối tượng URL từ URL hiện tại
1081        let $url = new URL($currentURL);
1082
1083        var $tagParam = $url.searchParams.get("tag");
1084
1085        $url.search = "";
1086
1087        $newTagParam = RemoveNum($tagParam, $tag);
1088        if ($newTagParam || $newTagParam.trim() == "") {
1089          $("#waitprocess").show();
1090          window.location.href =
1091            $url + "?cat=" + $category + "&tag=" + $newTagParam;
1092          $("#waitprocess").hide();
1093        }
1094      });
1095
1096      $(".bldr_blog_posts .list_tag .see-more").click(function (e) {
1097        e.preventDefault();
1098        let $this = $(this);
1099        let $text_open = $this.data("t1");
1100        let $text_close = $this.data("t2");
1101        let $parent = $this.closest(".row-filter-tag");
1102
1103        $parent.toggleClass("active");
1104        if ($parent.hasClass("active")) {
1105          $parent.find(".see-more .span-text").text($text_close);
1106        } else {
1107          $parent.find(".see-more .span-text").text($text_open);
1108        }
1109        $parent.find(".list_tag_2").slideToggle("fast");
1110      });
1111    });
1112  }
1113});
1114
1115function getChangeTab() {
1116  setTimeout(function () {
1117    jQuery(".tabbed-content.list-category-child .nav li.tab a").off("click");
1118  }, 200);
1119
1120  var hash = jQuery(location).attr("hash");
1121  var navli = ".tabbed-content .nav li.tab";
1122  var tabPanels = ".tabbed-content .tab-panels .panel";
1123
1124  if ($(hash).length > 0 && $(tabPanels).length > 0) {
1125    jQuery("a[href$='" + hash + "']")
1126      .closest("li.tab")
1127      .click();
1128    scrollTop(".tabbed-content");
1129  }
1130
1131  jQuery("body").on("click", navli, function (e) {
1132    e.preventDefault();
1133
1134    var activeTab = jQuery(this).find("a").attr("href");
1135    var disableTab = activeTab.replace("#", "disable-");
1136
1137    if (jQuery(".tabbed-content").hasClass(disableTab)) {
1138      jQuery(this).addClass("noClick");
1139      return false;
1140    }
1141    jQuery(navli).removeClass("active");
1142    jQuery(this).addClass("active");
1143    jQuery(".tabbed-content .panel").hide();
1144
1145    jQuery(tabPanels).removeClass("active");
1146    jQuery(activeTab).addClass("active");
1147    jQuery(activeTab).show();
1148    scrollTop(".tabbed-content", 200);
1149  });
1150}
1151
1152function scrollTop($class, $time = 500) {
1153  jQuery("html,body").animate(
1154    {
1155      scrollTop: jQuery($class).offset().top - (jQuery("header").height() + 80),
1156    },
1157    $time,
1158  );
1159}
1160
1161function fix_icon_box() {
1162  $(".pso-executive-section-2 .icon-box").each(function () {
1163    var $this = $(this);
1164    $this.children(".icon-box-img").prependTo($this.find(".icon-box-text>h3"));
1165  });
1166}
1167
1168function generatePagination(currentPage, totalPages, midSize) {
1169  if (totalPages < 2) return false;
1170  var paginationArray = [];
1171
1172  // Determine range
1173  var rangeStart = Math.max(1, currentPage - midSize);
1174  var rangeEnd = Math.min(totalPages, currentPage + midSize);
1175
1176  // Add pages within the range
1177  for (var i = rangeStart; i <= rangeEnd; i++) {
1178    paginationArray.push(i);
1179  }
1180
1181  // Add ellipsis if necessary
1182  if (paginationArray[0] > 2) {
1183    paginationArray.unshift("..."); // Add left ellipsis
1184    paginationArray.unshift(1); // Add first page
1185  } else if (paginationArray[0] === 2) {
1186    paginationArray.unshift(1); // Add first page if it's not already there
1187  }
1188
1189  if (totalPages - paginationArray[paginationArray.length - 1] > 1) {
1190    paginationArray.push("..."); // Add right ellipsis
1191    paginationArray.push(totalPages); // Add last page
1192  } else if (totalPages - paginationArray[paginationArray.length - 1] === 1) {
1193    paginationArray.push(totalPages); // Add last page if it's not already there
1194  }
1195
1196  var $strPage = '<ul class="page-numbers nav-pagination links text-center">';
1197  $strPage +=
1198    `<li><a class="prev page-number" ` +
1199    (currentPage - 1 > 0 ? 'data-pi="' + (currentPage - 1) + '"' : "") +
1200    `><i class="fa-sharp fa-regular fa-chevron-left"></i></a></li>`;
1201  paginationArray.forEach(function (value) {
1202    var $val = parseInt(value);
1203    if (Number.isInteger($val))
1204      $strPage +=
1205        `<li><a class="page-number ` +
1206        ($val == currentPage ? "current" : "") +
1207        `" data-pi="` +
1208        $val +
1209        `">` +
1210        $val +
1211        `</a></li>`;
1212    else $strPage += `<li><span class="page-number dots">…</span></li>`;
1213  });
1214  $strPage +=
1215    `<li><a class="next page-number" ` +
1216    (currentPage + 1 <= totalPages
1217      ? 'data-pi="' + (currentPage + 1) + '"'
1218      : "") +
1219    `><i class="fa-sharp fa-regular fa-chevron-right"></i></a></li>`;
1220  $strPage += "</ul>";
1221
1222  return $strPage;
1223}
1224
1225// Xử lý thêm các icon share,copy... khi selected text trong bài viết
1226function callbackTooltip(e, ob, _this, key) {
1227  ob.preventDefault();
1228  var $this = null;
1229  if ($(ob.target).hasClass("texttip__btn") == false)
1230    $this = $(ob.target).parent(".texttip__btn");
1231  else $this = $(ob.target);
1232
1233  if (!$this) return;
1234  else {
1235    var selstr = $("#selstr").attr("data-selstr");
1236    var h1 = encodeURIComponent($("h1").text());
1237    var index = parseInt($this.attr("data-texttip-btn-index"));
1238    var currentURL = new URL(window.location.href);
1239    currentURL.search = "";
1240    var newURL = encodeURIComponent(currentURL.toString());
1241    var $text1 = "";
1242    var $text2 = "";
1243    if (key == "twitter") {
1244      //twitter
1245      $url =
1246        "https://twitter.com/intent/tweet?text=“" + selstr + "”&url=" + newURL;
1247      $text1 = "Chia sẻ trên Twitter";
1248      $text2 = "Vui lòng cho phép pop-up để chia sẻ trên Twitter.";
1249      popupCustom($url, $text1, $text2);
1250    } else if (key == "facebook") {
1251      //facebook
1252      $url = "https://www.facebook.com/sharer/sharer.php?u=" + newURL;
1253      $text1 = "Chia sẻ trên Facebook";
1254      $text2 = "Vui lòng cho phép pop-up để chia sẻ trên Facebook.";
1255      popupCustom($url, $text1, $text2);
1256    } else if (key == "linkedin") {
1257      //linkedin
1258      $url = "https://www.linkedin.com/sharing/share-offsite/?url=" + newURL;
1259      $text1 = "Chia sẻ trên Linkedin";
1260      $text2 = "Vui lòng cho phép pop-up để chia sẻ trên Linkedin.";
1261      popupCustom($url, $text1, $text2);
1262    }
1263    // else if (key == 'messenger') {//messenger
1264    //     $url = 'https://www.facebook.com/dialog/send?app_id=977857076615304&link=' + newURL + '&redirect_uri=' + newURL + '&quote=' + selstr;
1265    //     $text1 = 'Chia sẻ trên Messenger';
1266    //     $text2 = 'Vui lòng cho phép pop-up để chia sẻ trên Messenger.';
1267    //     popupCustom($url, $text1, $text2);
1268    // }
1269    else if (key == "whatsapp") {
1270      //whatsapp
1271      $url = "https://api.whatsapp.com/send?text=" + selstr + "%0a%0a" + newURL;
1272      $text1 = "Chia sẻ trên Whatsapp";
1273      $text2 = "Vui lòng cho phép pop-up để chia sẻ trên Whatsapp.";
1274      popupCustom($url, $text1, $text2);
1275    } else if (key == "envelope") {
1276      //mail
1277      $url = "mailto:?body=" + selstr + "%0a%0a" + newURL + "&subject=" + h1;
1278      $text1 = "Chia sẻ trên Email";
1279      $text2 = "Vui lòng cho phép pop-up để chia sẻ trên Email.";
1280      popupCustom($url, $text1, $text2);
1281    } else if (key == "copy") {
1282      //copy
1283      copyToClipboard_ForTooltip(
1284        '.texttip__btn[data-texttip-btn-index="' + index + '"]',
1285        decodeURIComponent(selstr),
1286      );
1287
1288      $this.children("i").attr("class", "fa-solid fa-spinner fa-spin-pulse");
1289      setTimeout(() => {
1290        $this.children("i").attr("class", "fa-solid fa-check");
1291      }, 200);
1292      setTimeout(() => {
1293        $this.children("i").attr("class", "fa-solid fa-copy");
1294      }, 700);
1295    } else if (key == "xmark") {
1296      _this._hide();
1297    }
1298  }
1299}
1300
1301function popupCustom($url, $text1 = "", $text2 = "Vui lòng cho phép pop-up") {
1302  var popup = window.open($url, $text1, "width=600,height=400");
1303  if (popup) popup.focus();
1304  else alert($text2);
1305}
1306
1307function support_khoa_hoc() {
1308  if ($(".page-template-khoa-hoc").length > 0) {
1309    $("body").on(
1310      "click",
1311      "#mega-menu-wrap-khoa-hoc .mega-menu-link, #menu-khoa-hoc .menu-item>a",
1312      function (e) {
1313        e.preventDefault();
1314        var href = $(this).attr("href");
1315        if ($("." + href.replace("#", "")).length) {
1316          $("html,body").animate(
1317            {
1318              scrollTop:
1319                $("." + href.replace("#", "")).offset().top -
1320                $("header").height(),
1321            },
1322            500,
1323          );
1324        }
1325      },
1326    );
1327    $(".slick").slick({
1328      slidesToShow: 4,
1329      slidesToScroll: 4,
1330      autoplay: true,
1331      autoplaySpeed: 2000,
1332      responsive: [
1333        {
1334          breakpoint: 849,
1335          settings: {
1336            slidesToShow: 3,
1337            slidesToScroll: 3,
1338          },
1339        },
1340
1341        {
1342          breakpoint: 449,
1343          settings: {
1344            slidesToShow: 1,
1345            slidesToScroll: 1,
1346          },
1347        },
1348      ],
1349    });
1350    $(".list-quote").slick({
1351      centerMode: true,
1352      centerPadding: "160px",
1353      slidesToShow: 3,
1354      dots: true,
1355      arrows: false,
1356      responsive: [
1357        {
1358          breakpoint: 1366,
1359          settings: {
1360            slidesToShow: 1,
1361            centerPadding: "260px",
1362          },
1363        },
1364        {
1365          breakpoint: 850,
1366          settings: {
1367            slidesToShow: 1,
1368            centerPadding: "160px",
1369          },
1370        },
1371        {
1372          breakpoint: 550,
1373          settings: {
1374            centerMode: false,
1375            centerPadding: "40px",
1376            slidesToShow: 1,
1377          },
1378        },
1379      ],
1380    });
1381    if (isTablets()) {
1382      jQuery(".course-results .c-1 .col-inner").slick({
1383        slidesToShow: 1,
1384        slidesToScroll: 1,
1385        autoplay: false,
1386        dots: true,
1387        arrows: false,
1388      });
1389      jQuery(".program__grid .row").slick({
1390        slidesToShow: 1,
1391        slidesToScroll: 1,
1392        autoplay: false,
1393        dots: true,
1394        arrows: false,
1395      });
1396    }
1397    if (isMobile()) {
1398      jQuery(".slick-2-rows").slick({
1399        rows: 2,
1400        dots: true,
1401        arrows: true,
1402        prevArrow:
1403          '<button type="button" class="slick-prev pull-left"><svg width="36" height="36" viewBox="0 0 36 36" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M7.80669 19.0116L25.9192 33.1584C25.9665 33.1957 26.0234 33.2189 26.0833 33.2252C26.1432 33.2316 26.2037 33.221 26.2578 33.1946C26.3119 33.1681 26.3575 33.127 26.3893 33.0758C26.4211 33.0246 26.4378 32.9655 26.4375 32.9053L26.4375 29.7995C26.4375 29.6026 26.3451 29.4138 26.1924 29.2933L11.7281 17.9991L26.1924 6.70486C26.3491 6.58433 26.4375 6.39549 26.4375 6.19861L26.4375 3.09281C26.4375 2.82361 26.1281 2.67495 25.9192 2.83968L7.80669 16.9866C7.65275 17.1066 7.52821 17.2602 7.44256 17.4357C7.3569 17.6111 7.31238 17.8038 7.31238 17.9991C7.31238 18.1943 7.3569 18.387 7.44256 18.5624C7.52821 18.7379 7.65275 18.8915 7.80669 19.0116Z" fill="white"/></svg></button>',
1404        nextArrow:
1405          '<button type="button" class="slick-next pull-right"><svg width="36" height="36" viewBox="0 0 36 36" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M28.1933 16.9884L10.0808 2.84157C10.0335 2.80431 9.9766 2.78115 9.9167 2.77476C9.85681 2.76837 9.79632 2.779 9.7422 2.80543C9.68807 2.83186 9.6425 2.87303 9.61071 2.92419C9.57893 2.97536 9.56222 3.03446 9.5625 3.09469V6.2005C9.5625 6.39737 9.65491 6.58621 9.80759 6.70674L24.2719 18.0009L9.80759 29.2951C9.6509 29.4157 9.5625 29.6045 9.5625 29.8014V32.9072C9.5625 33.1764 9.87188 33.325 10.0808 33.1603L28.1933 19.0134C28.3473 18.8934 28.4718 18.7398 28.5574 18.5643C28.6431 18.3889 28.6876 18.1962 28.6876 18.0009C28.6876 17.8057 28.6431 17.613 28.5574 17.4376C28.4718 17.2621 28.3473 17.1085 28.1933 16.9884Z" fill="white"/></svg></button>',
1406        infinite: true,
1407        speed: 300,
1408        slidesToShow: 1,
1409        slidesToScroll: 1,
1410      });
1411    }
1412  }
1413}
1414
1415jQuery(window).on("load resize scroll", function () {
1416  if (typeof themeData !== "undefined" && isMobile()) {
1417    var themeUrl = themeData.themeUrl;
1418
1419    jQuery(".mb-scroll").each(function () {
1420      var $this = jQuery(this);
1421      var slickSliderElement = $this.find(".slick-initialized");
1422
1423      if (slickSliderElement.length && typeof themeUrl !== "undefined") {
1424        if (!$this.find(" > div:nth-of-type(1)").hasClass("scroll")) {
1425          var swipe = `<img src="${themeUrl}/assets/images/large_preview.svg" />`;
1426          $this.prepend('<div class="scroll">' + swipe + "</div>");
1427        }
1428
1429        if (!$this.hasClass("scrolled")) {
1430          $this.one("touchstart", function () {
1431            $this.addClass("scrolled");
1432          });
1433        }
1434      }
1435    });
1436  }
1437});
1438$(function () {
1439  function htmlEntitiesDecode(str) {
1440    return $("<textarea />").html(str).text();
1441  }
1442  document.addEventListener(
1443    "wpcf7submit",
1444    function (event) {
1445      var button = $(".wpcf7-submit[disabled]");
1446      button.prop("disabled", false);
1447      $("#waitprocess").hide();
1448      setTimeout(function () {
1449        const successMessage = document.querySelector(".wpcf7-response-output");
1450        const htmlMessage = htmlEntitiesDecode(successMessage.innerText);
1451        successMessage.innerHTML = htmlMessage;
1452      }, 200);
1453    },
1454    false,
1455  );
1456
1457  $("form.wpcf7-form").on("submit", function () {
1458    var form = $(this);
1459    var button = form.find("input[type=submit]");
1460
1461    // disable the button
1462    button.prop("disabled", true);
1463    $("#waitprocess").show();
1464  });
1465});
1466
1467$(function () {
1468  const $stickyCta = $(".sticky-cta");
1469  const $courseSection = $(".course-registration");
1470
1471  if ($stickyCta.length && $courseSection.length) {
1472    const observer = new IntersectionObserver(
1473      function (entries) {
1474        entries.forEach((entry) => {
1475          if (entry.isIntersecting) {
1476            $stickyCta.fadeOut(300);
1477          } else {
1478            $stickyCta.fadeIn(300);
1479          }
1480        });
1481      },
1482      {
1483        threshold: 0.1,
1484      },
1485    );
1486
1487    observer.observe($courseSection[0]);
1488  }
1489});
1490
1491$(function () {
1492  $(".icon-menu-top-bar").on("click", function (e) {
1493    e.preventDefault();
1494
1495    const $menu = $(".nav-menu-top-bar");
1496
1497    // Toggle class active
1498    $(this).toggleClass("active");
1499    $menu.toggleClass("active");
1500
1501    if ($menu.hasClass("hide-for-medium")) {
1502      $menu.removeClass("hide-for-medium").addClass("show-for-medium");
1503    } else {
1504      $menu.removeClass("show-for-medium").addClass("hide-for-medium");
1505    }
1506  });
1507});
1508
1509
1510/**
1511 * Redirect sau khi đăng ký Webinar/Event thành công.
1512 *
1513 * Cách MỚI (form dùng chung, không cần sửa code khi thêm event): trong nội dung
1514 * form CF7 khai báo hidden field:
1515 *   [hidden ty-redirect "/dang-ky-thanh-cong-su-kien/"]
1516 * JS sẽ redirect về URL đó kèm ?ev=<ID bài viết chứa form> (containerPostId) —
1517 * trang cảm ơn dùng chung (template "Đăng ký thành công - Event") đọc ?ev= để
1518 * lấy nội dung cảm ơn nhập ngay trên màn hình tạo event.
1519 * Chỉ chấp nhận đường dẫn nội bộ bắt đầu bằng "/" (chặn redirect ra domain khác).
1520 *
1521 * Cách CŨ (2 form webinar có trang cảm ơn riêng, giữ để tương thích):
1522 * map form ID → URL trong TY_WEBINAR_FORMS.
1523 *
1524 * Lưu ý: event.detail.contactFormId là ID SỐ (post_id của form), KHÔNG phải hash "552858f".
1525 * Tùy lựa chọn "Bạn là" (requester) mà trang cảm ơn hiện nội dung tương ứng.
1526 * CF7 reset form sau submit nên phải đọc giá trị từ event.detail.inputs (bản chụp đã gửi).
1527 */
1528
1529var TY_WEBINAR_FORMS = {
1530  75662: "/dang-ky-thanh-cong-webinar/", // Webinar CEO
1531  76825: "/dang-ky-thanh-cong-webinar-ve-duong/", // Webinar Vẽ đường
1532};
1533
1534document.addEventListener(
1535  "wpcf7mailsent",
1536  function (event) {
1537    // Đọc ty-redirect + lựa chọn "Bạn là" từ dữ liệu đã gửi
1538    var tyRedirect = "";
1539    var requester = "";
1540    if (event.detail.inputs) {
1541      event.detail.inputs.forEach(function (f) {
1542        if (f.name === "ty-redirect") tyRedirect = (f.value || "").trim();
1543        if (f.name === "requester") requester = (f.value || "").trim();
1544      });
1545    }
1546
1547    // Chỉ nhận đường dẫn nội bộ "/..." (không nhận "//host" hay URL tuyệt đối)
1548    if (tyRedirect && (tyRedirect.charAt(0) !== "/" || tyRedirect.charAt(1) === "/")) {
1549      tyRedirect = "";
1550    }
1551
1552    var tyUrl = "";
1553    if (tyRedirect) {
1554      tyUrl = tyRedirect;
1555      var evId = parseInt(event.detail.containerPostId, 10);
1556      // Fallback: form render ngoài loop (container = 0) thì lấy ID bài viết
1557      // từ body class "postid-XXXX" của trang single.
1558      if (!(evId > 0)) {
1559        var evm = document.body.className.match(/\bpostid-(\d+)\b/);
1560        if (evm) evId = parseInt(evm[1], 10);
1561      }
1562      if (evId > 0) {
1563        tyUrl += (tyUrl.indexOf("?") === -1 ? "?" : "&") + "ev=" + evId;
1564      }
1565    } else {
1566      // Fallback cho các form cũ chưa có hidden field ty-redirect
1567      tyUrl = TY_WEBINAR_FORMS[String(event.detail.contactFormId)] || "";
1568    }
1569    if (!tyUrl) return;
1570
1571    var wrap =
1572      (event.target.closest && event.target.closest(".wpcf7")) ||
1573      event.target ||
1574      null;
1575    if (wrap && wrap.querySelectorAll) {
1576      wrap.querySelectorAll(".wpcf7-response-output").forEach(function (el) {
1577        el.style.setProperty("display", "none", "important");
1578      });
1579    }
1580
1581    // Dùng chung 1 trang cảm ơn, URL sạch không tham số.
1582    // Field "Bạn là" trong CF7 khai báo dạng "Nhãn hiển thị|ma-co-dinh"
1583    // ("Khách đăng ký|khach-dang-ky" "Khách mời|khach-moi") nên requester
1584    // nhận về MÃ, không phải nhãn — đổi nhãn trong admin không cần sửa code.
1585    // Loại khách lưu vào sessionStorage để trang cảm ơn đọc ra:
1586    // khach-moi -> "hv" (nội dung ưu đãi); còn lại -> "kdk" (mặc định)
1587    var loai =
1588      requester === "khach-moi" || requester.indexOf("Khách mời") !== -1
1589        ? "hv"
1590        : "kdk";
1591    try {
1592      sessionStorage.setItem("ty_webinar_loai", loai);
1593    } catch (e) {}
1594    window.location.href = tyUrl;
1595  },
1596  false
1597);
1598
1599// Trang cảm ơn webinar dùng chung: hiện section nội dung theo loại khách.
1600// Ưu tiên ?loai= trên URL (để test thủ công), sau đó tới sessionStorage
1601// (do handler submit form ghi vào), cuối cùng mặc định "kdk".
1602// Các section trong trang mang class "ty-variant ty-kdk" / "ty-variant ty-hv";
1603// CSS trong nội dung trang ẩn tất cả, JS này mở đúng section.
1604$(function () {
1605  var variants = document.querySelectorAll(".ty-variant");
1606  if (!variants.length) return;
1607  var loai = new URLSearchParams(window.location.search).get("loai");
1608  if (!loai) {
1609    try {
1610      loai = sessionStorage.getItem("ty_webinar_loai");
1611    } catch (e) {}
1612  }
1613  var target = loai === "hv" ? "ty-hv" : "ty-kdk";
1614  // Nếu trang không có section của loại khách này (event không nhập nội dung
1615  // riêng cho Khách mời) thì rơi về bản Khách đăng ký, tránh trang trắng.
1616  var hasTarget = false;
1617  variants.forEach(function (el) {
1618    if (el.classList.contains(target)) hasTarget = true;
1619  });
1620  if (!hasTarget) target = "ty-kdk";
1621  variants.forEach(function (el) {
1622    el.classList.toggle("ty-show", el.classList.contains(target));
1623  });
1624});
1625
1626// PSO course slider — init Slick cho element [pso_course_slider].
1627// Cấu hình qua data-* attrs: data-columns, data-autoplay, data-arrows (đều có mặc định).
1628$(function () {
1629  if (typeof $.fn.slick === "undefined") return;
1630
1631  $(".pso-course-slider").each(function () {
1632    var $s = $(this);
1633    if ($s.hasClass("slick-initialized")) return;
1634
1635    var cols = parseInt($s.data("columns"), 10) || 3;
1636    var autoplay = $s.data("autoplay") !== false && $s.data("autoplay") !== "false";
1637    var arrows = $s.data("arrows") !== false && $s.data("arrows") !== "false";
1638
1639    $s.slick({
1640      slidesToShow: cols,
1641      slidesToScroll: 1,
1642      arrows: arrows,
1643      dots: false,
1644      autoplay: autoplay,
1645      autoplaySpeed: 4000,
1646      pauseOnHover: true,
1647      infinite: true,
1648      swipeToSlide: true,
1649      responsive: [
1650        { breakpoint: 850, settings: { slidesToShow: Math.min(2, cols) } },
1651        { breakpoint: 550, settings: { slidesToShow: 1 } },
1652      ],
1653    });
1654  });
1655});

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.