PageSourceSearch

https://mbbsadvisor.in/dropdown.js

js mbbsadvisor.in collected 2026-09-29 14:08:14 UTC 21,762 bytes, 524 lines download raw bytes

1
2/* ===== GLOBAL MOBILE DRAWER FUNCTIONS ===== */
3function mobCloseDrawer() {
4    var d = document.getElementById('mobDrawer');
5    var b = document.getElementById('mobBackdrop');
6    var h = document.getElementById('mobHamburger');
7    if (d) d.classList.remove('show');
8    if (b) b.classList.remove('show');
9    if (h) h.classList.remove('is-open');
10    document.body.style.overflow = '';
11}
12
13function mobToggleDrawer() {
14    var d = document.getElementById('mobDrawer');
15    if (!d) return;
16    if (d.classList.contains('show')) {
17        mobCloseDrawer();
18    } else {
19        d.classList.add('show');
20        var b = document.getElementById('mobBackdrop');
21        var h = document.getElementById('mobHamburger');
22        if (b) b.classList.add('show');
23        if (h) h.classList.add('is-open');
24        document.body.style.overflow = 'hidden';
25    }
26}
27
28function mobToggleMenu(targetId) {
29    var sub = document.getElementById(targetId);
30    if (!sub) return;
31    var isOpen = sub.classList.contains('open');
32    document.querySelectorAll('.mob-submenu.open').forEach(function (s) {
33        s.classList.remove('open');
34    });
35    document.querySelectorAll('.mob-menu-row.active-row').forEach(function (r) {
36        r.classList.remove('active-row');
37    });
38    if (!isOpen) {
39        sub.classList.add('open');
40        var row = document.querySelector('.mob-menu-row[data-target="' + targetId + '"]');
41        if (row) row.classList.add('active-row');
42    }
43}
44
45
46
47
48document.addEventListener("DOMContentLoaded", function () {
49    const liveBtn = document.getElementById("liveCounsellingBtn");
50    if (liveBtn) liveBtn.addEventListener("click", function () {
51        const applyBtn = document.querySelector(".openLeadModal");
52        if (applyBtn) applyBtn.click();
53    });
54});
55
56
57
58document.addEventListener("DOMContentLoaded", function () {
59    const path = window.location.pathname.toLowerCase().replace(/\/+$/, '');
60    const mobileNavBar = document.getElementById('mobileNavBar');
61
62    function openLeadModal() {
63        let modalId = 'mbbsModal';
64        if (path.includes('/franchise/become-overseas-education-franchise')) modalId = 'franchiseModal';
65        const modalEl = document.getElementById(modalId);
66        if (modalEl) {
67            // Hide mobile navbar completely when modal opens
68            if (mobileNavBar) mobileNavBar.style.display = 'none';
69            const modalInstance = new bootstrap.Modal(modalEl);
70            modalInstance.show();
71        }
72    }
73
74    document.querySelectorAll('.openLeadModal').forEach(function (btn) {
75        btn.addEventListener('click', openLeadModal);
76    });
77
78    // Show mobile navbar again when ANY modal is hidden
79    document.addEventListener('hidden.bs.modal', function () {
80        if (mobileNavBar) mobileNavBar.style.display = '';
81    });
82
83    // Also handle if modal is dismissed via backdrop click
84    document.addEventListener('hide.bs.modal', function () {
85        setTimeout(function () {
86            if (mobileNavBar) mobileNavBar.style.display = '';
87        }, 350);
88    });
89});
90
91
92
93
94document.addEventListener('DOMContentLoaded', function () {
95
96    function navBottom() {
97        var fixed = document.querySelector('.header__wrap.stricky-fixed');
98        if (fixed) {
99            var r = fixed.getBoundingClientRect();
100            if (r.height > 0) return r.bottom;
101        }
102        var nav = document.querySelector(
103            '.header__wrap.d-lg-block nav.navbar, .header__wrap:not(.d-lg-none) nav.navbar');
104        if (nav) {
105            var r2 = nav.getBoundingClientRect();
106            if (r2.height > 0) return r2.bottom;
107        }
108        var anyNav = document.querySelector('nav.navbar');
109        if (anyNav) {
110            var r3 = anyNav.getBoundingClientRect();
111            if (r3.height > 0) return r3.bottom;
112        }
113        var hdr = document.querySelector('.header__wrap.d-lg-block') || document.querySelector(
114            '.site-header') || document.querySelector('header');
115        if (hdr) return hdr.getBoundingClientRect().bottom;
116        return 90;
117    }
118
119    function makeHoverDropdown(parent, panel, positionFn, hideDelay) {
120        if (!parent || !panel) return;
121        var delay = hideDelay || 150,
122            timer = null;
123
124        function show() {
125            clearTimeout(timer);
126            requestAnimationFrame(function () {
127                positionFn(panel);
128                panel.style.display = 'block';
129            });
130        }
131
132        function hide() {
133            timer = setTimeout(function () {
134                panel.style.display = 'none';
135            }, delay);
136        }
137        parent.addEventListener('mouseenter', show);
138        parent.addEventListener('mouseleave', hide);
139        panel.addEventListener('mouseenter', function () {
140            clearTimeout(timer);
141        });
142        panel.addEventListener('mouseleave', hide);
143        window.addEventListener('scroll', function () {
144            if (panel.style.display === 'block') requestAnimationFrame(function () {
145                positionFn(panel);
146            });
147        }, {
148            passive: true
149        });
150    }
151
152    var exploreSection = document.getElementById('exploreSection');
153    var mainContent = document.getElementById('mainContent');
154    var mbbsHeader = document.getElementById('mbbsHeader');
155    var studyHeader = document.getElementById('studyHeader');
156    var mbbsCountries = document.getElementById('mbbsCountries');
157    var studyCountries = document.getElementById('studyCountries');
158
159    function positionExplore() {
160        if (!exploreSection) return;
161        requestAnimationFrame(function () {
162            requestAnimationFrame(function () {
163                var bot = navBottom();
164                exploreSection.style.top = bot + 'px';
165                exploreSection.style.left = '0';
166                exploreSection.style.right = '0';
167                exploreSection.style.width = '100vw';
168                var inner = exploreSection.querySelector('.explore-inner');
169                if (inner) {
170                    inner.style.maxHeight = (window.innerHeight - bot - 10) + 'px';
171                    inner.style.overflowY = 'auto';
172                }
173            });
174        });
175    }
176
177    var exploreOpen = false,
178        explorePinned = false,
179        exploreTimer = null;
180
181    function setAllExploreBtns(attr, val) {
182        document.querySelectorAll('#exploreBtn').forEach(function (b) {
183            if (val) b.setAttribute(attr, val);
184            else b.removeAttribute(attr);
185        });
186    }
187
188    function openExplore() {
189        clearTimeout(exploreTimer);
190        exploreSection.style.visibility = 'hidden';
191        exploreSection.style.display = 'block';
192        setAllExploreBtns('data-open', '1');
193        exploreOpen = true;
194        if (mainContent && !mainContent.innerHTML.trim()) loadCategory('georgia');
195        requestAnimationFrame(function () {
196            requestAnimationFrame(function () {
197                var bot = navBottom();
198                exploreSection.style.top = bot + 'px';
199                exploreSection.style.left = '0';
200                exploreSection.style.right = '0';
201                exploreSection.style.width = '100vw';
202                var inner = exploreSection.querySelector('.explore-inner');
203                if (inner) {
204                    inner.style.maxHeight = (window.innerHeight - bot - 10) + 'px';
205                    inner.style.overflowY = 'auto';
206                }
207                exploreSection.style.visibility = '';
208            });
209        });
210    }
211
212    function closeExplore() {
213        exploreSection.style.display = 'none';
214        setAllExploreBtns('data-open', '');
215        exploreOpen = false;
216        explorePinned = false;
217    }
218
219    function scheduleCloseExplore() {
220        if (!explorePinned) exploreTimer = setTimeout(closeExplore, 180);
221    }
222
223    if (exploreSection) {
224        document.addEventListener('mouseenter', function (e) {
225            if (e.target && e.target.id === 'exploreBtn') openExplore();
226        }, true);
227        document.addEventListener('mouseleave', function (e) {
228            if (e.target && e.target.id === 'exploreBtn') scheduleCloseExplore();
229        }, true);
230        exploreSection.addEventListener('mouseenter', function () {
231            clearTimeout(exploreTimer);
232        });
233        exploreSection.addEventListener('mouseleave', scheduleCloseExplore);
234        document.addEventListener('click', function (e) {
235            var btn = e.target.closest('#exploreBtn');
236            if (btn) {
237                e.stopPropagation();
238                if (explorePinned) {
239                    explorePinned = false;
240                    closeExplore();
241                } else {
242                    explorePinned = true;
243                    openExplore();
244                }
245                return;
246            }
247            if (explorePinned && !exploreSection.contains(e.target)) {
248                explorePinned = false;
249                closeExplore();
250            }
251        });
252        window.addEventListener('scroll', function () {
253            if (exploreOpen) positionExplore();
254        }, {
255            passive: true
256        });
257        window.addEventListener('resize', function () {
258            if (exploreOpen) positionExplore();
259        });
260        if (window.MutationObserver) {
261            var stickyObs = new MutationObserver(function (mutations) {
262                mutations.forEach(function (m) {
263                    if (m.type === 'attributes' && exploreOpen) positionExplore();
264                    if (m.type === 'childList') m.addedNodes.forEac
264h(function (n) {
265                        if (n.nodeType === 1 && exploreOpen) positionExplore();
266                    });
267                });
268            });
269            document.querySelectorAll('.header__wrap').forEach(function (hw) {
270                stickyObs.observe(hw, {
271                    attributes: true,
272                    attributeFilter: ['class']
273                });
274            });
275            stickyObs.observe(document.body, {
276                childList: true
277            });
278        }
279    }
280
281    var commonExams =
282        '<div class="col-lg-4"><span class="section-title2323">Exams UG 2026</span><a href="/neet-exam" class="item-link">NEET Exam 2026</a><a href="/neet-admit-card" class="item-link">NEET Admit Card 2026</a><a href="/neet-syllabus" class="item-link">NEET Syllabus 2026</a><a href="/neet-exam-pattern" class="item-link">NEET Exam Pattern 2026</a><a href="/neet-ug-counselling" class="item-link">NEET Counselling 2026</a><a href="/neet-answer-key" class="item-link">NEET Answer Key 2026</a><a href="/neet-exam-dates" class="item-link">NEET Exam Dates 2026</a><a href="/neet-result" class="item-link">NEET Result 2026</a><a href="/neet-cut-off" class="item-link">NEET Cutoff 2026</a><span class="section-title2323 mt-3">NEET UG State Counselling 2026</span><a href="/bihar-neet-ug-counselling" class="item-link">Bihar NEET Counselling 2026</a><a href="/maharashtra-neet-ug-counselling" class="item-link">Maharashtra NEET Counselling 2026</a><a href="/mp-neet-ug-counselling" class="item-link">MP NEET Counselling 2026</a><a href="/uttarakhand-neet-ug-counselling" class="item-link">Uttarakhand NEET Counselling 2026</a></div>';
283    var contents = {
284
285
286
287
288
289
290    };
291
292    function loadCategory(cat) {
293        if (!mainContent) return;
294        document.querySelectorAll('.country-link').forEach(function (el) {
295            el.classList.toggle('active', el.dataset.category === cat);
296        });
297        mainContent.innerHTML = contents[cat] || '<p class="p-4 text-muted">Coming Soon...</p>';
298        var inMbbs = mbbsCountries ? mbbsCountries.querySelector('[data-category="' + cat + '"]') : null;
299        var inStudy = studyCountries ? studyCountries.querySelector('[data-category="' + cat + '"]') : null;
300        if (inMbbs && mbbsHeader && studyHeader) {
301            mbbsHeader.classList.add('active');
302            studyHeader.classList.remove('active');
303        }
304        if (inStudy && studyHeader && mbbsHeader) {
305            studyHeader.classList.add('active');
306            mbbsHeader.classList.remove('active');
307        }
308    }
309    document.querySelectorAll('.country-link').forEach(function (link) {
310        link.addEventListener('mouseenter', function () {
311            loadCategory(link.dataset.category);
312        });
313        link.addEventListener('click', function (e) {
314            e.preventDefault();
315            loadCategory(link.dataset.category);
316        });
317    });
318    if (mbbsHeader && mbbsCountries && studyCountries && studyHeader) {
319        function setArrow(el, isOpen) {
320            var icon = el.querySelector('.toggle-arrow');
321            if (!icon) return;
322            icon.style.transform = isOpen ? 'rotate(90deg)' : 'rotate(0deg)';
323        }
324        mbbsHeader.addEventListener('click', function () {
325            var open = mbbsCountries.style.display !== 'none';
326            mbbsCountries.style.display = open ? 'none' : 'block';
327            studyCountries.style.display = 'none';
328            setArrow(mbbsHeader, !open);
329            setArrow(studyHeader, false);
330            mbbsHeader.classList.toggle('active', !open);
331            studyHeader.classList.remove('active');
332        });
333        studyHeader.addEventListener('click', function () {
334            var open = studyCountries.style.display !== 'none';
335            studyCountries.style.display = open ? 'none' : 'block';
336            mbbsCountries.style.display = 'none';
337            setArrow(studyHeader, !open);
338            setArrow(mbbsHeader, false);
339            studyHeader.classList.toggle('active', !open);
340            mbbsHeader.classList.remove('active');
341        });
342    }
343    loadCategory('georgia');
344
345    document.querySelectorAll('.destination-hover').forEach(function (li) {
346        var dd = li.querySelector('.dropdown-menu');
347        if (!dd) return;
348        var t = null;
349        li.addEventListener('mouseenter', function () {
350            clearTimeout(t);
351            dd.style.display = 'block';
352            li.classList.add('dd-open');
353        });
354        li.addEventListener('mouseleave', function () {
355            t = setTimeout(function () {
356                dd.style.display = 'none';
357                li.classList.remove('dd-open');
358            }, 120);
359        });
360        dd.addEventListener('mouseenter', function () {
361            clearTimeout(t);
362        });
363        dd.addEventListener('mouseleave', function () {
364            t = setTimeout(function () {
365                dd.style.display = 'none';
366                li.classList.remove('dd-open');
367            }, 120);
368        });
369    });
370
371    function initDropdownsOn(navRoot) {
372        if (!navRoot || navRoot._dropdownsInited) return;
373        navRoot._dropdownsInited = true;
374        var neetParent = navRoot.querySelector('#neetUgParent'),
375            neetMega = navRoot.querySelector('#neetUgMega');
376        if (neetParent && neetMega) {
377            var neetBtn = neetParent.querySelector('#neetUgBtn, .nav-link');
378            if (neetBtn) neetBtn.addEventListener('click', function (e) {
379                e.preventDefault();
380            });
381            makeHoverDropdown(neetParent, neetMega, function (panel) {
382                var bot = navBottom(),
383                    rect = neetParent.getBoundingClientRect(),
384                    left = Math.max(8, rect.left);
385                panel.style.cssText = 'position:fixed !important; top:' + bot + 'px; left:' + left +
386                    'px; z-index:10001; display:block;';
387                requestAnimationFrame(function () {
388                    var w = panel.offsetWidth || 600;
389                    if (left + w > window.innerWidth - 8) panel.style.left = Math.max(8,
390                        window.innerWidth - w - 8) + 'px';
391                });
392            });
393        }
394        [{
395            parentId: 'neetPgParent',
396            panelId: 'neetPgMenu'
397        }, {
398            parentId: 'neetindiaParent',
399            panelId: 'neetindiaMega'
400
401        }, {
402            parentId: 'testPrepParent',
403            panelId: 'testPrepMenu'
404        }, {
405            parentId: 'galleryParent',
406            panelId: 'galleryMenu'
407        }].forEach(function (item) {
408            var par = navRoot.querySelector('#' + item.parentId),
409                panel = navRoot.querySelector('#' + item.panelId);
410            if (!par || !panel || par._stdInited) return;
411            par._stdInited = true;
412            var btn = par.querySelector('.nav-link');
413            if (btn) btn.addEventListener('click', function (e) {
414                e.preventDefault();
415            });
416            makeHoverDropdown(par, panel, function (p) {
417                var bot = navBottom(),
418                    rect = par.getBoundingClientRect(),
419                    left = Math.max(8, rect.left);
420                p.style.cssText = 'position:fixed !important; top:' + bot + 'px; left:' +
421                    left + 'px; z-index:10001; display:block;';
422                requestAnimationFrame(function () {
423                    var w = p.offsetWidth || 220;
424                    if (left + w > window.innerWidth - 8) p.style.left = Math.max(8,
425                        window.innerWidth - w - 8) + 'px';
426                });
427            });
428        });
429        var discoverParent = navRoot.querySelector('.dropdown-chat'),
430            discoverBox = discoverParent ? discoverParent.querySelector('.chat-dropdown-box') : null;
431        if (discoverParent && discoverBox) {
432            makeHoverDropdown(discoverParent, discoverBox, function (panel) {
433                var bot = navBottom(),
434                    rect = discoverParent.getBoundingClientRect();
435                var pw = panel.offsetWidth;
436                if (!pw) {
437                    panel.style.visibility = 'hidden';
438                    panel.style.display = 'block';
439                    pw = panel.offsetWidth || 380;
440                    panel.style.display = 'none';
441                    panel.style.visibility = '';
442                }
443                var left = Math.max(8, rect.right - pw);
444                if (left + pw > window.innerWidth - 8) left = Math.max(8, window.innerWidth - pw -
445                    8);
446                panel.style.cssText = 'position:fixed !important; top:' + bot + 'px; left:' + left +
447                    'px; z-index:10001; display:block; min-width:380px;';
448            }, 300);
449        }
450        navRoot.querySelectorAll('.destination-hover').forEach(function (li) {
451            var dd = li.querySelector('.dropdown-menu');
452            if (!dd || li._ddInited) return;
453            li._ddInited = true;
454            var t = null;
455            li.addEventListener('mouseenter', function () {
456                clearTimeout(t);
457                dd.style.display = 'block';
458            });
459            li.addEventListener('mouseleave', function () {
460                t = setTimeout(function () {
461                    dd.style.display = 'none';
462                }, 120);
463            });
464            dd.addEventListener('mouseenter', function () {
465                clearTimeout(t);
466            });
467            dd.addEventListener('mouseleave', function () {
468                t = setTimeout(function () {
469                    dd.style.display = 'none';
470                }, 120);
471            });
472        });
473    }
474    var originalNav = document.querySelector('.header__wrap') || document.querySelector('nav.navbar') ||
475        document.body;
476    initDropdownsOn(originalNav);
477    if (window.MutationObserver) {
478        var bodyObs = new MutationObserver(function (mutations) {
479            mutations.forEach(function (m) {
480                m.addedNodes.forEach(function (node) {
481                    if (node.nodeType !== 1) return;
482                    var isHeader = node.classList && (node.classList.contains(
483                        'stricky-fixed') || node.classList.contains(
484                            'header__wrap') || node.tagName === 'NAV');
485                    if (isHeader) {
486                        initDropdownsOn(node);
487                        return;
488                    }
489                    var inner = node.querySelector && node.querySelector(
490                        '.header__wrap, nav.navbar, .stricky-fixed');
491                    if (inner) initDropdownsOn(inner);
492                });
493                if (m.type === 'attributes' && m.target) {
494                    var el = m.target;
495                    if (el.classList && el.classList.contains('stricky-fixed'))
496                        initDropdownsOn(el);
497                }
498            });
499        });
500        bodyObs.observe(document.body, {
501            childList: true,
502            subtree: true,
503            attributes: true,
504            attributeFilter: ['class']
505        });
506    }
507
508    // Swipe to close drawer
509    var mobSwipeStartX = 0;
510    var mobDrawerEl = document.getElementById('mobDrawer');
511    if (mobDrawerEl) {
512        mobDrawerEl.addEventListener('touchstart', function (e) {
513            mobSwipeStartX = e.touches[0].clientX;
514        }, {
515            passive: true
516        });
517        mobDrawerEl.addEventListener('touchend', function (e) {
518            if (mobSwipeStartX - e.changedTouches[0].clientX > 60) mobCloseDrawer();
519        }, {
520            passive: true
521        });
522    }
523
524}); // DOMContentLoaded

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.