PageSourceSearch

https://annunciation.org/scripts/responsive-mega-drop-down-menu/js/mega_menu.js?cb=1781732248

js annunciation.org collected 2026-10-02 05:35:57 UTC 18,631 bytes, 344 lines download raw bytes

1(function ($) {
2    // default settings
3    var defaultSettings = {
4        // DESKTOP MODE SETTINGS
5        logo_align          : 'left',    // align the logo left or right. options (left) or (right)
6        links_align         : 'left',    // align the links left or right. options (left) or (right)
7        socialBar_align     : 'left',    // align the socialBar left or right. options (left) or (right)
8        searchBar_align     : 'right',   // align the search bar left or right. options (left) or (right)
9        trigger             : 'hover',   // show drop down using click or hover. options (hover) or (click)
10        effect              : 'fade',    // drop down effects. options (fade), (scale), (expand-top), (expand-bottom), (expand-left), (expand-right)
11        effect_speed        : 400,       // drop down show speed in milliseconds
12        sibling             : true,      // hide the others showing drop downs if this option true. this option works on if the trigger option is "click". options (true) or (false)
13        outside_click_close : true,      // hide the showing drop downs when user click outside the menu. this option works if the trigger option is "click". options (true) or (false)
14        top_fixed           : false,     // fixed the menu top of the screen. options (true) or (false)
15        sticky_header       : false,     // menu fixed on top when scroll down down. options (true) or (false)
16        sticky_header_height: 200,       // sticky header height top of the screen. activate sticky header when meet the height. option change the height in px value.
17        menu_position       : 'horizontal',    // change the menu position. options (horizontal), (vertical-left) or (vertical-right)
18        full_width          : true,            // make menu full width. options (true) or (false)
19        // MOBILE MODE SETTINGS
20        mobile_settings     : {
21            collapse            : false, // collapse the menu on click. options (true) or (false)
22            sibling             : true,  // hide the others showing drop downs when click on current drop down. options (true) or (false)
23            scrollBar           : true,  // enable the scroll bar. options (true) or (false)
24            scrollBar_height    : 400,   // scroll bar height in px value. this option works if the scrollBar option true.
25            top_fixed           : false, // fixed menu top of the screen. options (true) or (false)
26            sticky_header       : false, // menu fixed on top when scroll down down. options (true) or (false)
27            sticky_header_height: 200    // sticky header height top of the screen. activate sticky header when meet the height. option change the height in px value.
28        }
29    };
30    // extend function
31    $.fn.megaMenu = function (settings) {
32        settings = $.extend({}, defaultSettings, settings || {});
33        return this.each(function () {
34
35            // variables
36            var $this = $(this),
37                $ul = 'ul',
38                $li = 'li',
39                $a = 'a',
40                menu_logo = $this.find('.menu-logo'),
41                menu_logo_li = menu_logo.children($li),
42                menu_links = $this.find('.menu-links'),
43                menu_links_li = menu_links.children($li),
44                menu_socialBar = $this.find('.menu-social-bar'),
45                menu_searchBar = $this.find('.menu-search-bar'),
46                mobile_trigger_button = '.menu-mobile-collapse-trigger',
47                mobile_dropDown_trigger = '.mobileTriggerButton',
48                desktop_dropDown_trigger = '.desktopTriggerButton',
49                activeClass = 'active',
50                activeTrigger = 'activeTrigger',
51                activeTriggerMobile = 'activeTriggerMobile',
52                dropDown = '.drop-down-multilevel, .drop-down, .drop-down-tab-bar',
53                desktopTopFixed = 'desktopTopFixed',
54                mobileTopFixed = 'mobileTopFixed',
55                fullWidth = 'menuFullWidth',
56                contact_form = $this.find('.menu-contact-form'),
57                contact_form_notification = contact_form.find('.nav_form_notification'),
58                Canvas;
59
60            // Main Object
61            Canvas = {
62                // menu contact form ajax submit
63                contact_form_ajax      : function () {
64                    // add submit function on contact form
65                    $(contact_form).submit(function (event) {
66
67                    });
68
69                },
70                // menu full width function
71                menu_full_width        : function () {
72                    // check if the full_width options true
73                    if (settings.full_width === true) {
74                        // add class menu full width
75                        $this.addClass(fullWidth);
76                    }
77                },
78                // logo align function
79                logo_Align             : function () {
80                    // check is the logo align right
81                    if (settings.logo_align === 'right') {
82                        // add class menu align right
83                        menu_logo.addClass('menu-logo-align-right');
84                    }
85                },
86                // menu links align right
87                links_Align            : function () {
88                    // check if the links align right
89                    if (settings.links_align === 'right') {
90                        // add class menu menu links align
91                        menu_links.addClass('menu-links-align-right');
92                    }
93                },
94                // menu social bar align right
95                social_bar_Align       : function () {
96                    // check if the social bar align right
97                    if (settings.socialBar_align === 'right') {
98                        // add class menu social bar align
99                        menu_socialBar.addClass('menu-social-bar-right');
100                    }
101                },
102                // menu search bar align right
103                search_bar_Align       : function () {
104                    // check if the search bar align right
105                    if (settings.searchBar_align === 'left') {
106                        // add class menu search bar align
107                        menu_searchBar.addClass('menu-search-bar-left');
108                    }
109                },
110                // mobile collapse trigger button
111                collapse_trigger_button: function () {
112                    // check if the collapse true
113                    if (settings.mobile_settings.collapse === true) {
114                        // append the mobile collapse trigger button
115                        menu_logo_li.append('<div class="menu-mobile-collapse-trigger">' +
116                            '<span></span>' +
117                            '</div>');
118                        // hide the menu links, menu social bar
119                        var drop_down = menu_links.add(menu_socialBar);
120                        drop_down.hide(0);
121                        // apply css
122                        menu_searchBar.addClass(activeClass);
123                        // add the click trigger
124                        $this.find(mobile_trigger_button).on('click', function () {
125                            // check if the menu links and menu social bar hide
126                            if (drop_down.is(':hidden')) {
127                                // show the drop down
128                                $(this).addClass(activeClass);
129                                drop_down.show(0);
130                            } else {
131                                // hide the drop down
132                                $(this).removeClass(activeClass);
133                                drop_down.hide(0);
134                            }
135                            return false;
136                        });
137                    }
138                },
139                // switch effects
140                switch_effects         : function () {
141                    switch (settings.effect) {
142                        case 'fade':
143                            $this.find(dropDown).addClass('effect-fade');
144                            break;
145                        case 'scale':
146                            $this.find(dropDown).addClass('effect-scale');
147                            break;
148                        case 'expand-top':
149                            $this.find(dropDown).addClass('effect-expand-top');
150                            break;
151                        case 'expand-bottom':
152                            $this.find(dropDown).addClass('effect-expand-bottom');
153                            break;
154                        case 'expand-left':
155                            $this.find(dropDown).addClass('effect-expand-left');
156                            break;
157                        case 'expand-right':
158                            $this.find(dropDown).addClass('effect-expand-right');
159                            break;
160                    }
161                },
162                // transition delay
163                transition_delay       : function () {
164                    // add the effects class on drop down
165                    $this.find(dropDown).css({
166                        'webkitTransition': 'all ' + settings.effect_speed + 'ms ease ',
167                        'transition'      : 'all ' + settings.effect_speed + 'ms ease '
168                    });
169                },
170                // hover trigger for desktop mode
171                hover_trigger          : function () {
172                    // check if the trigger hover
173                    if (settings.trigger === 'hover') {
174                        // add the effects class on drop down
175                        Canvas.transition_delay();
176                        // add hover trigger
177                        $this.find(dropDown).parents($li).addClass('hoverTrigger');
178                        // switch effects
179                        Canvas.switch_effects();
180                    }
181                },
182                // click trigger for mobile mode
183                mobile_trigger         : function () {
184                    // append the mobile trigger div
185                    $this.find(dropDown).prev($a).append('<div class="mobileTriggerButton"></div>');
186                    // add the click trigger on mobile trigger div
187                    $this.find(mobile_dropDown_trigger).on('click', function () {
188                        // variables
189                        var elem = $(this),
190                            parents = elem.parents($a),
191                            drop_down = parents.next(dropDown);
192                        // check if the drop down is hidden
193                        if (drop_down.is(':hidden')) {
194                            // check if the sibling true
195                            if (settings.mobile_settings.sibling === true) {
196                                // hide the others opens drop downs
197                                elem.parents($this).siblings($ul + ',' + $li).find(dropDown).hide(0);
198                                // remove active class
199                                elem.parents($this).siblings($li).removeClass(activeTriggerMobile);
200                                elem.parents($this).siblings($ul).find($li).removeClass(activeTriggerMobile);
201                            }
202                            // add active class
203                            parents.parent($li).addClass(activeTriggerMobile);
204                            // show drop down
205                            drop_down.show(0);
206                        } else {
207                            // remove active class
208                            parents.parent($li).removeClass(activeTriggerMobile);
209                            // hide drop down
210                            drop_down.hide(0);
211                        }
212                        // stop a tag going to anywhere
213                        return false;
214                    });
215                    // stop icons click behaviour
216                    $this.find('i.fa.fa-indicator').on('click', function () {
217                        return false;
218                    });
219                },
220                // click trigger for desktop mode
221                click_trigger          : function () {
222                    // check if the trigger click
223                    if (settings.trigger === 'click') {
224                        // append the desktop trigger div
225                        $this.find(dropDown).prev($a).append('<div class="desktopTriggerButton"></div>');
226                        // add click trigger div
227                        $this.find(dropDown).parents($li).addClass('ClickTrigger');
228                        // add the transition on drop down
229                        Canvas.switch_effects();
230                        Canvas.transition_delay();
231                        // add the click trigger on desktop trigger div
232                        $this.find(desktop_dropDown_trigger).on('click', function (event) {
233                            event.stopPropagation();
234                            event.stopImmediatePropagation();
235                            // variables
236                            var elem = $(this),
237                                parents = elem.parents($a),
238                                drop_down = parents.next(dropDown);
239                            // check if the drop down is hidden
240                            if (!(drop_down.hasClass(activeClass))) {
241                                // check if the sibling true
242                                if (settings.sibling === true) {
243                                    // hide the others opens drop downs
244                                    elem.parents($this).siblings($ul + ',' + $li).find(dropDown).removeClass(activeClass);
245                                    // remove active class
246                                    elem.parents($this).siblings($li).removeClass(activeTrigger);
247                                    elem.parents($this).siblings($ul).find($li).removeClass(activeTrigger);
248                                }
249                                // add active class
250                                parents.parent($li).addClass(activeTrigger);
251                                // show drop down
252                                drop_down.addClass(activeClass);
253                            } else {
254                                // remove active class
255                                parents.parent($li).removeClass(activeTrigger);
256                                // hide drop down
257                                drop_down.removeClass(activeClass);
258                            }
259                            // stop a tag going to anywhere
260                            //return false;
261                        });
262                    }
263                },
264                // outside click to close drop downs
265                outside_close          : function () {
266                    // check if the outside close setting true for desktop
267                    if (settings.outside_click_close === true
268                        && settings.trigger === 'click'
269                        && $this.find(dropDown).is(':visible')) {
270                        // add the click trigger on document
271                        $(document).off('click').on('click', function (event) {
272                            if (!$this.is(event.target) && $this.has(event.target).length === 0) {
273                                $this.find(dropDown).removeClass(activeClass);
274                                menu_links_li.removeClass('activeTrigger');
275                            }
276                        });
277                    } else {
278                        // on mobile mode off the click trigger
279                        $(document).off('click');
280                    }
281                },
282                // scroll bar for mobile mode
283                scroll_bar             : function () {
284                    // check if the scroll bar true
285                    if (settings.mobile_settings.scrollBar === true) {
286                        // add the css on menu links
287                        menu_links.css({
288                            'maxHeight': '100vh',
289                            'overflow' : 'auto'
290                        });
291                    }
292                },
293                // menu fixed on top
294                top_Fixed              : function () {
295                    // check if the top fixed true for desktop mode
296                    if (settings.top_fixed === true) {
297                        $this.addClass(desktopTopFixed);
298                    }
299                    // mobile mode top fixed
300                    if (settings.mobile_settings.top_fixed) {
301                        $this.addClass(mobileTopFixed);
302                    }
303                },
304                // sticky header
305                sticky_Header          : function () {
306                },
307                // position change
308                position               : function () {
309                    // check if the position left
310                    if (settings.menu_position === 'vertical-left') {
311                        $this.addClass('vertical-left');
312                    } else if (settings.menu_position === 'vertical-right') {
313                        $this.addClass('vertical-right');
314                    }
315                }
316            };
317
318            // call functions
319            Canvas.menu_full_width();
320            Canvas.logo_Align();
321            Canvas.links_Align();
322            Canvas.social_bar_Align();
323            Canvas.search_bar_Align();
324            Canvas.collapse_trigger_button();
325            Canvas.hover_trigger();
326            Canvas.mobile_trigger();
327            Canvas.click_trigger();
328 //           Canvas.outside_close();
329            Canvas.scroll_bar();
330            Canvas.top_Fixed();
331            Canvas.sticky_Header();
332            Canvas.position();
333            Canvas.contact_form_ajax();
334            // window resize function used for update the function on windows resize
335            $(window).resize(function () {
336  //              Canvas.outside_close();
337                Canvas.sticky_Header();
338            });
339
340        });
341    };
342
343    /*global $, jQuery, document*/
344}(jQuery));

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.