1(function () { 2 3 'use strict'; 4 5 /** 6 * Provides the off-canvas menu. 7 * 8 * @type {Drupal~behavior} 9 * 10 * @prop {Drupal~behaviorAttach} attach 11 * Attaches the behavior for the off-canvas menu. 12 */ 13 Drupal.behaviors.responsive_menu_mmenu = { 14 attach: function (context) { 15 16 const mmenuId = '#off-canvas'; 17 const offCanvas = document.querySelector(mmenuId) 18 19 // The instatiation of the mmenu must only happen once. 20 if (offCanvas && !offCanvas.hasOwnProperty('mmApi') && typeof (Mmenu) !== 'undefined') { 21 const settings = drupalSettings.responsive_menu; 22 const position = settings.position, 23 theme = settings.theme, 24 pagedim = settings.pagedim; 25 26 const options = { 27 extensions: [ 28 theme, 29 'fx-menu-slide', 30 position === 'left' ? 'position-left' : 'position-right' 31 ], 32 keyboardNavigation: { 33 enable: true, 34 enhance: true, 35 }, 36 drag: { 37 open: settings.drag 38 } 39 }; 40 41 if (pagedim !== 'none') { 42 options.extensions.push(pagedim); 43 }; 44 45 const config = { 46 classNames: { 47 selected: 'menu-item--active-trail' 48 } 49 }; 50 51 if (settings.pageWrapper) { 52 config['offCanvas'] = { 53 selector: '.responsive-menu-page-wrapper', 54 } 55 }; 56 57 // Allow the settings and options to be extended or overridden. 58 if (typeof settings.custom !== 'undefined') { 59 if (typeof settings.custom.options !== 'undefined') { 60 extend(options, drupalSettings.responsive_menu.custom.options); 61 } 62 if (typeof drupalSettings.responsive_menu.custom.config !== 'undefined') { 63 extend(config, drupalSettings.responsive_menu.custom.config); 64 } 65 } 66 67 // Set up the off canvas menu. 68 const mmenu = new Mmenu(mmenuId, options, config); 69 70 // Due to a rendering issue with Chrome the page needs the viewport 71 // metatag to have a value including initial-scale=1.0 otherwise it 72 // won't render properly. 73 // @see issue #3153145 74 const mmenuApi = mmenu.API; 75 const viewports = document.getElementsByName('viewport'); 76 77 if (viewports.length !== 0 && settings.modifyViewport) { 78 const viewportMeta = viewports[0] 79 const defaultViewport = viewports[0].content 80 const staticViewport = "width=device-width, initial-scale=1.0, minimum-scale=1.0"; 81 82 mmenuApi.bind('open:start', function() { 83 viewportMeta.setAttribute('content', staticViewport); 84 }); 85 mmenuApi.bind('close:start', function() { 86 viewportMeta.setAttribute('content', defaultViewport); 87 }); 88 } 89 } 90 } 91 }; 92})(); 93 94/** 95 * Similar to the jQuery extend but shallow. 96 * 97 * @param out 98 * @returns {*|{}} 99 */ 100const extend = function (out) { 101 out = out || {}; 102 103 for (let i = 1; i < arguments.length; i++) { 104 if (!arguments[i]) 105 continue; 106 107 for (let key in arguments[i]) { 108 if (arguments[i].hasOwnProperty(key)) 109 out[key] = arguments[i][key]; 110 } 111 } 112 113 return out; 114};
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.