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 // Allow the settings and options to be extended or overridden. 52 if (typeof settings.custom !== 'undefined') { 53 if (typeof settings.custom.options !== 'undefined') { 54 extend(options, drupalSettings.responsive_menu.custom.options); 55 } 56 if (typeof drupalSettings.responsive_menu.custom.config !== 'undefined') { 57 extend(config, drupalSettings.responsive_menu.custom.config); 58 } 59 } 60 61 // Set up the off canvas menu. 62 const mmenu = new Mmenu(mmenuId, options, config); 63 64 // Due to a rendering issue with Chrome the page needs the viewport 65 // metatag to have a value including initial-scale=1.0 otherwise it 66 // won't render properly. 67 // @see issue #3153145 68 const mmenuApi = mmenu.API; 69 const viewports = document.getElementsByName('viewport'); 70 71 if (viewports.length !== 0 && settings.modifyViewport) { 72 const viewportMeta = viewports[0] 73 const defaultViewport = viewports[0].content 74 const staticViewport = "width=device-width, initial-scale=1.0, minimum-scale=1.0"; 75 76 mmenuApi.bind('open:start', function() { 77 viewportMeta.setAttribute('content', staticViewport); 78 }); 79 mmenuApi.bind('close:start', function() { 80 viewportMeta.setAttribute('content', defaultViewport); 81 }); 82 } 83 } 84 } 85 }; 86})(); 87 88/** 89 * Similar to the jQuery extend but shallow. 90 * 91 * @param out 92 * @returns {*|{}} 93 */ 94const extend = function (out) { 95 out = out || {}; 96 97 for (let i = 1; i < arguments.length; i++) { 98 if (!arguments[i]) 99 continue; 100 101 for (let key in arguments[i]) { 102 if (arguments[i].hasOwnProperty(key)) 103 out[key] = arguments[i][key]; 104 } 105 } 106 107 return out; 108};
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.