PageSourceSearch

https://csp.jtc.gov.sg/js/jtc_newcsp_navigation.js

js jtc.gov.sg collected 2026-09-24 18:17:48 UTC 10,761 bytes, 287 lines download raw bytes

1$(document).ready(function () {
2    $(".navbar-toggler").click(function () {
3        let target = $(this).attr("data-target");
4        $(target).toggleClass("show");
5        let navTopLine = document.querySelector(".navbar-top-line a");
6        navTopLine.style.display = "none";
7        $(".navbar-top-line span").css("display", "none");
8        $(".navbar .navbar-top-line .icon-close").siblings().css("display", "none");
9    });
10
11    $(".masthead-button").click(function () {
12        $("#sgds-masthead-content").toggleClass("hide")
13        $(".sgds-masthead-identify-icon").toggleClass("open")
14    });
15    //   ----header-dropdown----
16    $(".navbar-light .nav-item.dropdown .nav-link.js-nav-link-item").on("click", function (e) {
17        document.location.href = e.target.href;
18    });
19    function heightDropdownItem(e) {
20        let divHeight = 0;
21
22        e.find('.dropdown-item').each(function () {
23            divHeight += $(this).outerHeight();
24        });
25
26        return divHeight;
27    }
28
29    $(".navbar-main .navbar-nav .nav-item.dropdown .nav-link").on(
30        "click",
31        function (e) {
32            e.stopPropagation();
33            e.preventDefault(); // Prevent page reload
34            $(".navbar-main .navbar-nav .nav-item.dropdown .nav-link")
35                .not(this)
36                .siblings()
37                .css("display", "none");
38            $(".csp-nav-wrapper .navbar-light .nav-item.dropdown a").next().css("display", "none");
39            $('.user-dropdown .login-user').css("display", "none");
40            $('.user-dropdown .login-user').removeClass("show");
41            $(this).next(".dropdown-menu").toggle();
42            $(this).next(".dropdown-menu").children().css("display", "block");
43            let divHeight = heightDropdownItem($(this).next("ul"));
44            $(this).next("ul").children('.bg-submenu').css('height', divHeight);
45            $(".dropdown-item.has-submenu .nav-link").click(function (e) {
46                e.preventDefault(); // Prevent page reload
47                e.stopPropagation();
48                $(this).parents().eq(0).siblings().css("display", "none");
49                $(this).parents().eq(1).css("display", "block");
50                $(this).next().css("top", "0");
51                divHeight = heightDropdownItem($(this).next("ul"));
52                $(this).next("ul").children('.bg-submenu').css('height', divHeight);
53            });
54            $(".dropdown-item .dropdown-menu .dropdown-item--back span").click(function (e) {
55                $(this).parents().eq(1).css("display", "none");
56                $(this).parents().eq(3).css("display", "block");
57                $(this).parents().eq(2).siblings().css("display", "block");
58            })
59            $(".dropdown-item .dropdown-menu .dropdown-item.has-submenu .nav-link").click(function (e) {
60                e.preventDefault(); // Prevent page reload
61                e.stopPropagation();
62                $(this).parents().eq(3).css("display", "block");
63                $(this).next().css("top", "0");
64            });
65        }
66
67    );
68    $(".navbar-main .navbar-nav .nav-item.dropdown .js-submenu a").click(
69        function (e) {
70            e.preventDefault(); // Prevent page reload
71            e.stopPropagation();
72            let submenu = $(this).next(".dropdown-menu");
73            submenu.show();
74            $(".dropdown-menu").not(submenu).hide();
75        }
76    );
77
78    $(".js-go-back").click(function (e) {
79        e.preventDefault();
80        e.stopPropagation();
81        let parentMenu = $(this).closest(".js-dropdown-menu");
82        parentMenu.hide();
83        parentMenu.closest(".dropdown-menu").show();
84        $(this).parents().eq(1).css("display", "none");
85    });
86
87    $(document).click(function (e) {
88        $(".js-dropdown-menu").hide();
89        if (!$(e.target).hasClass("show")) {
90            $('.user-dropdown .login-user').css("display", "none");
91        }
92    });
93    $(document).on("click", ".user-dropdown .dropdown-toggle", function (e) {
94        $('#spn_firstName').removeAttr("aria-expanded");
95        if ($(e.target).hasClass("show")) {
96            $('.user-dropdown .login-user').css("display", "block");
97        } else {
98            $('.user-dropdown .login-user').css("display", "none");
99        }
100    });
101
102    // ----mobile-close-----
103    $(".navbar .navbar-top-line .icon-close").click(function () {
104        $("#main-menu.navbar-collapse").removeClass('show');
105        $('#main-menu #profile-icon').closest('span').css('display', 'inline-block');
106        $('#main-menu .profile-icon-container.icon-profile').css('display', 'inline-block');
107        $('#main-menu #spn_firstName').css('display', 'inline-block');
108        $('#main-menu #notificationBell').css('display', 'inline-block');
109        $('#main-menu #notificationBell .notifications').css('display', 'inline-block');
110        $('#main-menu #notificationBell .notification-icon').css('display', 'inline-block');
111        $('#main-menu #notificationBell .notification-count').css('display', 'inline-block');
112
113    })
114    
115    $(".navbar #login-menu .navbar-top-line .icon-close").click(function () {
116        $("#login-menu.navbar-collapse").removeClass('show');
117
118    })
119    // -----sub-header------
120
121    $(".csp-nav-wrapper .navbar-light .nav-item.dropdown a,.csp-nav-wrapper .navbar-light .nav-item.dropdown div").click(function (e) {
122        e.stopPropagation();
123        $(".csp-nav-wrapper .navbar-light .nav-item.dropdown a").not(this).siblings().css("display", "none");
124        $(".navbar-main .navbar-nav .nav-item.dropdown a.nav-link").next().css("display", "none");
125        $(this).next(".dropdown-menu").toggle();
126        $(this).next(".dropdown-menu").children().css("display", "block");
127        $('.user-dropdown .login-user').css("display", "none");
128        $('.user-dropdown .login-user').removeClass("show");
129        let divHeight = heightDropdownItem($(this).next("ul")) - 7;
130        $(this).next("ul").children('.bg-submenu').css('height', divHeight);
131        $(".dropdown-item.has-submenu .nav-link").click(function (e) {
132            e.preventDefault();
133            e.stopPropagation();
134            $(this).parents().eq(0).siblings().css("display", "none");
135            $(this).parents().eq(1).css("display", "block");
136            $(this).next().css("top", "0")
137            let divHeight = heightDropdownItem($(this).next("ul")) - 7;
138            $(this).next("ul").children('.bg-submenu').css('height', divHeight);
139        });
140
141        $(".dropdown-item .dropdown-menu .dropdown-item--back span").click(function (e) {
142            $(this).parents().eq(1).css("display", "none");
143            $(this).parents().eq(2).siblings().css("display", "block");
144            $(this).parents().eq(3).css("display", "block");
145        })
146
147    })
148    // Setting Height of bg-submenu to 0 for mobile screens
149
150    const mediaQuery = window.matchMedia('(max-width: 991px)')
151    // Check if the media query is true
152    $(".nav-link").click(function (e) {
153        if (mediaQuery.matches) {
154            $('.bg-submenu').css("height", "0")
155        }
156    });
157    // ----search-toggle----
158
159    $(".navbar .nav-search .cta__icon.icon-search").click(function () {
160        $(".navbar-main .navbar__form.js-navbar-form").toggleClass('has-opened');
161
162    })
163
164    // -------back-to-top------
165
166    $('.back-to-top').each(function () {
167        $(this).click(function () {
168            $('html,body').animate({ scrollTop: 0 }, 'slow');
169            return false;
170        });
171    });
172
173    $(document).scroll(function () {
174        let y = $(this).scrollTop();
175        if (y > 100) {
176            $('.back-to-top').fadeIn()
177        } else {
178            $('.back-to-top').fadeOut()
179        }
180    });
181
182
183    $(".js-navbar-hambuger").click(function () {
184       
185        if ($('header #main-menu').hasClass("show")) {
186            $('body').addClass("lock-scroll");
187        }
188        else {
189            $('body').removeClass("lock-scroll");
190
191        }
192    });
193
194    $("#main-menu .icon-close").click(function () {
195        $('body').removeClass("lock-scroll");
196    });
197
198    function footerGap() {
199        if ($('#shortcutList').length != 0) {
200            if (window.innerWidth <= 767.98) {
201                $("#footer").css('padding-bottom', '70px');
202                $(".back-to-top").css('bottom', '80px');
203
204            }
205        }
206    }
207
208    footerGap();
209
210    $(window).resize(function () {
211        footerGap();
212    });
213
214
215});
216
217// scroll to top on page refresh
218$(document).ready(function () {
219    $(this).scrollTop(0);
220});
221
222
223$(document).on("click", ".li_shortcuts", function () {
224    $('.loader-body').removeClass("d-none");
225});
226
227// View shortcut button
228$(document).ready(function () {
229    $(window).on("click", function () {
230        if ($('.navbar-collapse').hasClass('show')) {
231            $('.side-shortcut').css('z-index', '0');
232            $('.sideBar-sticky').css('z-index', '0');
233        }
234        else {
235            $('.side-shortcut').css('z-index', '1');
236            $('.sideBar-sticky').css('z-index', '999');
237        }
238    });
239
240    //Removing Z-index from all elements when hamburger menu is shown
241    $('.js-navbar-hambuger').on('click', function () {
242        // Select all elements on the page
243        $('.navbar-collapse.show').css('z-index', '1001');
244    });
245    $('.icon-close').on('click', function () {
246    });
247    $('#logout-mobile').on('click', function () {
248    })
249});
250// End View shortcut button
251// View check on resize
252$(window).on('resize', function () {
253    let width = $(window).width();
254    if ($(".navbar-collapse").hasClass('show')) {
255        $(".navbar .navbar-top-line .icon-close").click();
256    }
257    if (width >= 991) {
258        $('.dropdown-menu.login-user').css('display', 'none');
259    }
260
261}).trigger('resize');
262
263//Toggling of hamburger and login menu
264
265$(document).ready(function () {
266
267    $(".navbar-toggler.profile-icon-container").click(function () {
268        if ($("#main-menu").hasClass("show")) {
269            $("#main-menu").removeClass("show");
270        }
271        $('.dropdown-menu.login-user').css('display', 'block');
272    });
273
274    $(".navbar-toggler.js-navbar-hambuger").click(function () {
275        if ($("#login-menu").hasClass("show")) {
276            $("#login-menu").removeClass("show");
277        }
278    });
279
280    let headheight = $('header ').innerHeight();
281    let applyheight = headheight - 7;
282
283    $(".navbar-toggler").click(function () {
284        $('.navbar-collapse.show').attr('style', 'top: ' + applyheight + 'px !important;');
285    });
286
287})

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.