PageSourceSearch

https://www.prnewswire.com/etc.clientlibs/prncom/clientlibs/clientlibs-common/resources/js/prncom/mobilenav.js

js prnewswire.com collected 2026-10-01 08:01:41 UTC 11,560 bytes, 328 lines download raw bytes

1define(['jquery', 'mmenu'], function($, mmenu) {
2
3
4    var site;
5    if ($('body').hasClass('prnuk')) {
6        site = 'prnuk';
7    } else if ($('body').hasClass('cnw')) {
8        site = 'cnw';
9    } else if (
10        $('body').hasClass('prncom_international') ||
11        $('body').hasClass('international-news-detail') ||
12        $('body').hasClass('arabic_hebrew') ||
13        $('body').hasClass('prweb-site')
14    ) {
15        site = 'prncom-intl';
16    }else if ($('body').hasClass('prnj') || $('header').hasClass('prnmedia')){
17        site='prnj';
18    } else {
19        site = 'prncom';
20    }
21
22    var prnMobileNav;
23
24    (prnMobileNav = function prnMobileNav(site) {
25        require([], function() {
26
27            var navMobile = $('nav#nav-mobile');
28            var navTabHelpers = $('.mobile-nav-tabs');
29            var navTabs = [];
30
31            $.each(navTabHelpers, function(i, v) {
32
33                var tabValue = $(v).val();
34                var tabName = tabValue.charAt(0) + tabValue.substr(1);
35
36                var tabNameFormatted = tabValue
37                    .replace(/\s+/g, '-')
38                    .toLowerCase();
39
40                var tabLink = $(v).data('link');
41                var isFirst = (i === 0);
42
43                if (site == 'prncom-intl') {
44
45                    var tab =
46                        '<li class="tab">' +
47                        '<a class="tier-one panel-link" href="' + tabLink + '">' +
48                        tabName +
49                        '</a></li>';
50
51                }else {
52
53                    var tab =
54                        '<li class="tab">' +
55                        '<a class="tier-one panel-link ' + tabNameFormatted + '"' +
56                        ' href="#mm-panel-' + tabNameFormatted + '"' +
57                        ' role="tab"' +
58                        ' id="tab-' + tabNameFormatted + '"' +
59                        ' aria-controls="mm-panel-' + tabNameFormatted + '"' +
60                        ' aria-selected="' + (isFirst ? 'false' : 'false') + '"' +
61                        ' tabindex="' + (isFirst ? '0' : '-1') + '">' +
62                        tabName +
63                        '</a></li>';
64
65                    if (tabValue == 'profnet'){
66                        tab =
67                            '<li class="tab">' +
68                            '<a class="tier-one panel-link ' + tabNameFormatted + '"' +
69                            ' href="' + tabLink + '">' +
70                        tabName +
71                        '</a></li>';
72                    }
73                }
74
75                navTabs.push(tab);
76            });
77
78            navMobile.mmenu({
79                extensions: ['border-full'],
80                offCanvas: { zposition: 'front' },
81                iconPanels	: true,
82				counters	: true,
83				keyboardNavigation : {
84						enable	: true,
85						enhance	: true
86					},
87                navbar: { add: true, title: null },
88                navbars: [
89                    {
90                        position: 'top',
91                        content: [ 'close'
92                            // '<p class="mmenu-header"><i class="btl bt-times mm-close"></i></p>'
93                        ],
94                        height: 1
95                    },
96                    {
97                        position: 'top',
98                        content: navTabs,
99                        height: 1
100                    }
101                ]
102            });
103
104            var api = navMobile.data('mmenu');
105
106            var headerIcons = $(
107                '.header-mobile a.dropdown-toggle, .header-mobile .lang-switcher'
108            );
109
110            // =========================
111            // OPEN EVENT
112            // =========================
113            api.bind('open:start', function() {
114
115                if ($(window).width() < 481) {
116                    $(headerIcons).fadeOut();
117                }
118
119                // ===== ARIA INIT =====
120                $('.mm-navbar.mm-navbar-content-3').attr({
121                    role: 'tablist',
122                    'aria-label': 'Main sections'
123                });
124
125                $('.mm-panel.parent-panel').attr({
126                    role: 'tabpanel',
127                    'aria-hidden': 'true'
128                });
129
130                $('.panel-link[role="tab"]').each(function() {
131                    var panelId = $(this).attr('href').replace('#', '');
132                    $('#' + panelId).attr('aria-labelledby', $(this).attr('id'));
133                });
134
135                $('.mm-panel.mm-opened.parent-panel').attr('aria-hidden', 'false');
136
137                // ===== CONTACT LOGIC =====
138                $('#mm-panel-contact a[role="tab"]').on('show.bs.tab', function(e) {
139                    var target = e.currentTarget.hash.replace('#','');
140                    $('.contact-nav').selectpicker('val', target);
141                    api.close();
142                });
143
144                // ===== URL MATCH LOGIC (RESTORED) =====
145                this.path = window.location.pathname.replace(/\/$/, '');
146                var self = this;
147                var match = false;
148
149                // look for exact match
150                if (self.path != '/prncom' && !match) {
151                    if (self.path.indexOf('-list') > -1) {
152                        var p = self.path.substr(0, self.path.lastIndexOf('/'));
153                    } else {
154                        var p = self.path;
155                        if (window.location.hash) {
156                            p = p + window.location.hash;
157                        }
158                    }
159
160                    $.each(
161                        $('#nav-mobile li:not(.mm-footer) a:not(.panel-link,.mm-title,.mm-btn,.mm-next)'),
162                        function() {
163
164                            var href = $(this).attr('href');
165                            if (!href) {
166                                return true; // continue to next element
167                            }
168
169                            var l = $(this).attr('href').replace(/\/$/, '').replace(/\/#/, '#');
170                            self.hash = window.location.hash || null;
171
172                            if (
173                                p.indexOf('contact-us') > -1 &&
174                                p.indexOf('#') < 0 &&
175                                self.hash === null
176                            ) {
177                                p = p + '#general';
178                            }
179
180                            if (p === l) {
181                                match = true;
182                                api.setSelected($(this).parent('li'));
183                                api.openPanel($(this).closest('.mm-panel'));
184                                return false;
185                            }
186                        }
187                    );
188
189                    // look for partial match
190                    if (!match) {
191                        var p = self.path;
192                        // check if there are too many slashes
193                        if ((p.match(new RegExp('/', 'g')) || []).length > 2) {
194                            p = self.path.substr(0, self.path.lastIndexOf('/'));
195                        }
196
197                        if (p.indexOf('news-releases') > -1) {
198                            p = '/news-releases';
199                        }
200
201                        switch (p) {
202                            case '/news-releases':
203                                api.openPanel($('#mm-panel-news'));
204                                break;
205                            case '/solutions':
206                                api.openPanel($('#mm-panel-products'));
207                                break;
208                            case '/knowledge-center':
209                                api.openPanel($('#mm-panel-resources'));
210                                break;
211                            case '/blog':
212                                api.openPanel($('#mm-panel-resources'));
213                                break;
214                            case '/contact-us':
215                                api.openPanel($('#mm-panel-contact'));
216                                break;
217                        }
218                    }
219                }
220            });
221
222            // =========================
223            // TAB + PANEL SYNC
224            // =========================
225            api.bind('openPanel:start', function(panel) {
226
227                $('.panel-link[role="tab"]').attr({
228                    'aria-selected': 'false',
229                    'tabindex': '-1'
230                });
231
232                $('.mm-panel.parent-panel').attr('aria-hidden', 'true');
233
234                var $panel = $(panel);
235                var panelId = $panel.attr('id');
236
237                var $activeTab = $('.panel-link[href="#' + panelId + '"]');
238
239                if ($activeTab.length) {
240                    $activeTab.attr({
241                        'aria-selected': 'true',
242                        'tabindex': '0'
243                    });
244                }
245
246                $panel.attr({'aria-hidden': 'false',tabindex: '-1'});
247
248                // =====================================
249                // Focus management for submenu
250                // =====================================
251                setTimeout(function () {
252
253                    var $openedPanel = $('.mm-panel.mm-opened');
254
255                    // Focus the "Close submenu" button
256                    var $backButton = $openedPanel.find('.mm-btn.mm-prev');
257
258                    if ($backButton.length) {
259                        $backButton.focus();
260                        return;
261                    }
262
263                    // Fallback
264                    $openedPanel.focus();
265
266                }, 100);
267
268            });
269
270            // =========================
271            // BACK BUTTON FOCUS FIX (#237)
272            // =========================
273            $(document).on('click', '.mm-btn.mm-prev', function() {
274
275                var target = $(this).attr('href');
276                var $targetPanel = $(target);
277
278                if ($targetPanel.length) {
279
280                    if (!$targetPanel.attr('tabindex')) {
281                        $targetPanel.attr('tabindex', '-1');
282                    }
283
284                    setTimeout(function () {
285                        $targetPanel.focus();
286                    }, 50);
287                }
288            });
289
290            // =========================
291            // KEYBOARD NAV
292            // =========================
293            $(document).on('keydown', '.panel-link[role="tab"]', function(e) {
294
295                var $tabs = $('.panel-link[role="tab"]');
296                var index = $tabs.index(this);
297
298                if (e.key === 'ArrowRight') {
299                    e.preventDefault();
300                    $tabs.eq((index + 1) % $tabs.length).focus().click();
301                }
302
303                if (e.key === 'ArrowLeft') {
304                    e.preventDefault();
305                    $tabs.eq((index - 1 + $tabs.length) % $tabs.length).focus().click();
306                }
307            });
308
309            // =========================
310            // CLOSE HANDLING
311            // =========================
312            api.bind('closing', function() {
313                if ($(window).width() < 481) {
314                    $('.nav-mobile-button').focus();
315                    $(headerIcons).fadeIn();
316                }
317            });
318
319            $('.mm-close').click(function() {
320                $('.nav-mobile-button').focus();
321                api.close();
322        });
323
324        });
325    })(site);
326
327    return prnMobileNav;
328});

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.