PageSourceSearch

https://skyfroglandscape.com/wp-content/themes/intrigue-me/blocks/main-navigation/view.js?ver=7.1.2

js skyfroglandscape.com collected 2026-10-02 19:34:04 UTC 14,765 bytes, 316 lines download raw bytes

1(function($){
2    $(function(){
3        //initialize smooth scroll listener
4        document.addEventListener('scrollStart', imtCurrentMenuItem);
5        imtCurrentMenuItem();
6    });
7    $(function () {
8        const menuToggle = $('#imt-menu-toggle');
9        const header = $('header.imt-header');
10
11        // If dropdown mobile menu is selected
12        if(menuToggle.attr('aria-controls') == 'imt-dropdown'){
13            //initialize animations
14            let dropdownContainer = $("#imt-dropdown");
15            // dropdownContainer.animate({
16            //     height: "toggle"
17            // },0);   
18            let parents = dropdownContainer.find('.has-children')
19            parents.each(function(){
20                let child = $(this);
21                let children = child.children('.submenu');
22                let grandchildren = children.find('.submenu');
23                let link = child.children('a');
24                let icon = link.children('i');
25                let iconUp = $('#main-navigation-ul').attr('data-iconup');
26                let iconDown = $('#main-navigation-ul').attr('data-icondown');
27                let addSharp = $('#main-navigation-ul').attr('data-sharp');
28                icon.length ? icon : link.append('<i class="fa ' + iconDown + ' ' + addSharp + '" aria-hidden="true"></i>');
29                icon = link.children('i');
30
31                //initialize animations
32                children.animate({
33                    height: "toggle"
34                }, 0);
35                children.animate({
36                    height: "toggle"
37                }, 0);
38                grandchildren.animate({
39                    height: "toggle"
40                }, 0);
41                grandchildren.animate({
42                    height: "toggle"
43                }, 0);
44                
45                link.click(function(e){
46                    e.preventDefault();
47                    let toggleValues = iconDown + ' ' + iconUp;
48                    icon.toggleClass(toggleValues);
49                    let children = icon.parent('a').next();
50                    let parent = icon.parent('a').parent('li');
51                    let ul = icon.parent('a').parent('li').parent('ul');
52                    
53                    // TODO: add data element to enable this option
54                    if (hideParents === true || hideParents === 'true') {
55                        ul.children('li').each(function(){
56                            let li = $(this);
57                            if(li[0] !== parent[0]){
58                                li.animate({
59                                    height: "toggle"
60                                }, 500);
61                            }
62                        });
63                    }
64
65                    children.animate({
66                        height: "toggle"
67                    }, 500);
68                });
69            });
70        }
71
72        // If offcanvas mobile menu is selected
73        if(menuToggle.attr('aria-controls') == "imt-offcanvas"){
74            let offcanvas = $('#imt-offcanvas');
75
76            //set the offset for the offcanvas menu to be equal to the height of the header
77            offcanvas.css("top",header.height() + "px");
78
79            //if the user scrolls reset the alignment
80            $(window).on("scroll touchmove", function () {
81                setTimeout(function(){
82                    offcanvas.css("top",header.height() + "px");
83                },100);
84            });
85            
86
87            // offcanvas.animate({
88            //     height: "toggle"
89            // },0);
90            let parents = offcanvas.find('.has-children')
91            parents.each(function(){
92                let child = $(this);
93                let children = child.children('.submenu');
94                let grandchildren = children.find('.submenu');
95                let link = child.children('a');
96                let icon = link.children('i');
97                let iconUp = $('#main-navigation-ul').attr('data-iconup');
98                let iconDown = $('#main-navigation-ul').attr('data-icondown');
99                let addSharp = $('#main-navigation-ul').attr('data-sharp');
100                let hideParents = $('#main-navigation-ul').attr('data-hideparents');
101                icon.length ? icon : link.append('<i class="fa ' + iconDown + ' ' + addSharp + '" aria-hidden="true"></i>');
102                icon = link.children('i');
103
104                //initialize animations
105                children.animate({
106                    height: "toggle"
107                }, 0);
108                children.animate({
109                    height: "toggle"
110                }, 0);
111                
112                // link click -- anywhere on link, including span or icon
113                // Only available when mobile menu is expanded
114                link.click(function(e){
115                    e.preventDefault();
116                    if ($('#imt-offcanvas').attr('aria-hidden') === undefined || $('#imt-offcanvas').attr('aria-hidden') !== 'false') {
117                        return false;
118                    }
119                    let toggleValues = iconDown + ' ' + iconUp;
120                    icon.toggleClass(toggleValues);
121                    let children = icon.parent('a').next();
122                    let parent = icon.parent('a').parent('li');
123                    let ul = icon.parent('a').parent('li').parent('ul');
124
125                    let parentIsParent = false;
126                    if (parent.hasClass('has-children')) {
127                        parentIsParent = true;
128                    }
129
130                    // TODO: close all items not related to clicked link
131
132                    // TODO: add data element to enable this option
133                    if (hideParents === true || hideParents === 'true') {
134                        ul.children('li').each(function(){
135                            let li = $(this);
136                            if(li[0] !== parent[0]){
137                                li.animate({
138                                    height: "toggle"
139                                }, 500);
140                            }
141                        });
142                    }
143                    
144                    children.animate({
145                        height: "toggle"
146                    }, 500);
147                });
148            });
149
150            //anchor links close menu
151            let links = offcanvas.find('.menu-item:not(.has-children)')
152            links.each(function(){
153                link = $(this);
154                link.click(function(e){
155                    if(menuToggle.hasClass('open')){ // check if the menu is open
156                        menuToggle.toggleClass("open closed");
157                        menuToggle.attr('aria-expanded') == 'false' ? menuToggle.attr('aria-expanded', 'true') : menuToggle.attr('aria-expanded', 'false');
158                        if(menuToggle.attr('aria-controls') == "imt-offcanvas"){
159                            let offcanvas = $('#imt-offcanvas');
160                            offcanvas.attr('aria-hidden') == 'false' ? offcanvas.attr('aria-hidden', 'true') : offcanvas.attr('aria-hidden', 'false');
161                            offcanvas.animate({
162                                height: "toggle"
163                            },500);
164                        }
165                    }
166                });
167            });
168        }
169
170
171        $('#imt-menu-toggle').click(function(){
172            menuToggle.toggleClass("open closed");
173            menuToggle.attr('aria-expanded') == 'false' ? menuToggle.attr('aria-expanded', 'true') : menuToggle.attr('aria-expanded', 'false');
174            if(menuToggle.attr('aria-controls') == 'imt-dropdown'){
175                let dropdownContainer = $("#imt-dropdown");
176                dropdownContainer.attr('aria-hidden') == 'false' ? dropdownContainer.attr('aria-hidden', 'true') : dropdownContainer.attr('aria-hidden', 'false');
177                dropdownContainer.animate({
178                    height: "toggle"
179                },500);
180            }
181            else if(menuToggle.attr('aria-controls') == "imt-offcanvas"){
182                let offcanvas = $('#imt-offcanvas');
183                offcanvas.attr('aria-hidden') == 'false' ? offcanvas.attr('aria-hidden', 'true') : offcanvas.attr('aria-hidden', 'false');
184                offcanvas.animate({
185                    height: "toggle"
186                },500);
187            }
188        });
189    });
190
191    // Set current menu item
192    // https://stackoverflow.com/questions/4866284/jquery-add-class-active-on-menu
193    function imtCurrentMenuItem(){
194        var hash = window.location.hash,
195        hashRegExp = new RegExp(hash); //create a regular expression to match the hash or match nothing
196
197        var url = window.location.pathname + hash,
198            // Create regexp to match current url pathname and remove trailing slash if present as it could collide with the link in navigation in case trailing slash wasn't present there
199            urlRegExp = new RegExp(url == '/' && hash === '' ? window.location.origin + '\/?$' : url.replace(/\/$/,'') + '\/?$');
200
201            //Remove all references of the current menu item
202            $('.imt-main-nav a').each(function(){
203                if ($(this).hasClass('imt-current-menu-item')){
204                    $(this).removeClass('imt-current-menu-item');
205                }
206            })
207
208            // Navigate through each menu link and set the current menu items
209            $('.imt-main-nav a').each(function(){
210                // Test its normalized href against the url pathname regexp
211                let thisUrl = this.href.replace(/\/$/,'');
212                let isFirstLevel = false;
213                let isSecondLevel = false;
214                let isThirdLevel = false;
215                let doNotFlagActive = false;
216                //ignore pages that have an href of #
217                let checkLast = new RegExp('#$');
218
219                let checkHash = new RegExp('#([a-zA-Z0-9-_]*)$');
220
221                // Handle parent and grandparent active states
222                // Check for links that have been set with the 'imt-do-not-flag-active' class; 
223                // prevents duplicate active states where the same page
224                // is linked from multiple places in the menu
225                if (this.parentElement.classList.contains('imt-link-level-1')) {
226                    isFirstLevel = true;
227                    if (this.parentElement.classList.contains('imt-do-not-flag-active')) {
228                        doNotFlagActive = true;
229                        isFirstLevel = false;
230                    }
231                } else if (this.parentElement.classList.contains('imt-link-level-2')) {
232                    isSecondLevel = true;
233                    if (this.parentElement.classList.contains('imt-do-not-flag-active')) {
234                        doNotFlagActive = true;
235                        isFirstLevel = false;
236                        isSecondLevel = false;
237                    }
238                } else if (this.parentElement.classList.contains('imt-link-level-3')) {
239                    isThirdLevel = true;
240                    if (this.parentElement.classList.contains('imt-do-not-flag-active')) {
241                        doNotFlagActive = true;
242                        isFirstLevel = false;
243                        isSecondLevel = false;
244                        isThirdLevel = false;
245                    }
246                }
247                
248                var match = false;
249                // Check if this url matches the current page's path & if it's been labeled to not flag & if it is just a # url
250                if ( urlRegExp.test( thisUrl ) && checkLast.test(thisUrl) !== true && doNotFlagActive === false ){
251                    // Check if the current page has a hash
252                    if(hash !== '' && checkHash.test(thisUrl)){
253                        //Check if this URL has a hash matching the current page
254                        hashRegExp.test(thisUrl) ? match = true : match = false;
255                    // If the current page doesn't have a hash
256                    }else if(hash !== '' || checkHash.test(thisUrl)){
257                        match = false;
258                    }else{
259                        match = true;
260                    }
261
262                    if(match){
263                        // Add class for match
264                        $(this).addClass('imt-current-menu-item');
265                        // Add class to parent, grandparent
266                        if (isSecondLevel) {
267                            $(this).closest('li.imt-link-level-1').children(":first").addClass('imt-current-menu-item');
268                        } else if (isThirdLevel) {
269                            $(this).closest('li.imt-link-level-1').children(":first").addClass('imt-current-menu-item');
270                            $(this).closest('li.imt-link-level-2').children(":first").addClass('imt-current-menu-item');
271                        }
272                    }
273                }
274            });
275
276            //Remove all references of the current menu item
277            $('#imt-top-bar a.imt-btn').each(function(){
278                if ($(this).hasClass('imt-current-menu-item')){
279                    $(this).removeClass('imt-current-menu-item');
280                }
281            })
282
283            // Check top bar links
284            $('#imt-top-bar a.imt-btn').each(function(){
285                // Test its normalized href against the url pathname regexp
286                let thisUrl = this.href.replace(/\/$/,'');
287                // ignore # links used for top level dropdowns
288                let checkLast = new RegExp('#$');
289
290                let checkHash = new RegExp('#([a-zA-Z0-9-_]*)$');
291                var match = false;
292                if ( urlRegExp.test( thisUrl ) && checkLast.test(thisUrl) !== true ){
293                    // Check if the current page has a hash
294                    if(hash !== '' && checkHash.test(thisUrl)){
295                        //Check if this URL has a hash matching the current page
296                        hashRegExp.test(thisUrl) ? match = true : match = false;
297                    // If the current page doesn't have a hash
298                    }else if(hash !== '' || checkHash.test(thisUrl)){
299                        match = false;
300                    }else{
301                        match = true;
302                    }
303
304                    if(match){
305                        // Add class for match
306                        if ($(this).parent().hasClass('imt-do-not-flag-active')) {
307                            // do nothing
308                        } else {
309                            $(this).addClass('imt-current-menu-item');
310                        }
311                    }
312                }
313            });
314    }
315
316})(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.