1/** 2 * @file 3 * Integrate Sidr library with Responsive Menus. 4 */ 5(function ($) { 6 /** 7 * Preparation for each element Sidr will affect. 8 */ 9 function sidr_it(menuElement, ind, iteration, $windowWidth) { 10 // Only apply if window size is correct. 11 var $media_size = iteration.media_size || 768; 12 // Call Sidr with our settings. 13 $(menuElement).once('responsive-menus-sidr', function() { 14 var $id = 'sidr-' + ind; 15 var $wrapper_id = 'sidr-wrapper-' + ind; 16 $(this).before('<div id="' + $wrapper_id + '"><a id="' + $id + '-button" href="#' + $id + '">' + iteration.trigger_txt + '</a></div>'); 17 $('#' + $wrapper_id).hide(); 18 if ($windowWidth <= $media_size) { 19 $('#' + $wrapper_id).show(); 20 $(this).hide(); 21 } 22 // Set 1/0 to true/false respectively. 23 $.each(iteration, function(key, value) { 24 if (value == 0) { 25 iteration[key] = false; 26 } 27 if (value == 1) { 28 iteration[key] = true; 29 } 30 }); 31 // Sidr power go. 32 $('#' + $id + '-button').sidr({ 33 name: $id || "sidr", 34 speed: parseInt(iteration.speed) || 200, 35 side: iteration.side || "left", 36 source: iteration.selectors[ind] || "#main-menu", 37 displace: iteration.displace, 38 renaming: iteration.renaming, 39 onOpen: function() { eval(iteration.onOpen); } || function() {}, 40 onClose: function() { eval(iteration.onClose); } || function() {} 41 }); 42 }); 43 } 44 45 46 /** 47 * Main loop. 48 */ 49 Drupal.behaviors.responsive_menus_sidr = { 50 attach: function (context, settings) { 51 settings.responsive_menus = settings.responsive_menus || {}; 52 var $windowWidth = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth; 53 $.each(settings.responsive_menus, function(ind, iteration) { 54 if (iteration.responsive_menus_style != 'sidr') { 55 return true; 56 } 57 if (!iteration.selectors.length) { 58 return; 59 } 60 // Iterate each selector. 61 $.each(iteration.selectors, function(index, value) { 62 // Stop if there is no menu element. 63 if ($(value).length < 1) { 64 return true; 65 } 66 // Multi-level (selector hits multiple ul's). 67 if ($(value).length > 1) { 68 $(value).each(function(val_index) { 69 if (!$(this).parents('ul').length) { 70 sidr_it(this, index, iteration, $windowWidth); 71 } 72 }); 73 } 74 else { 75 // Single level. 76 sidr_it(value, index, iteration, $windowWidth); 77 } 78 }); 79 }); 80 81 // Handle window resizing. 82 $(window).resize(function() { 83 // Window width with legacy browsers. 84 $windowWidth = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth; 85 $.each(settings.responsive_menus, function(ind, iteration) { 86 if (iteration.responsive_menus_style != 'sidr') { 87 return true; 88 } 89 if (!iteration.selectors.length) { 90 return; 91 } 92 // Iterate each selector. 93 $.each(iteration.selectors, function(index, value) { 94 // Stop if there is no menu element. 95 if ($(value).length < 1) { 96 return true; 97 } 98 var $wrapper_id = 'sidr-wrapper-' + index; 99 $media_size = iteration.media_size || 768; 100 if ($windowWidth <= $media_size) { 101 if (!$(value).hasClass('sidr-hidden')) { 102 $('#' + $wrapper_id).show(); 103 $(value).hide().addClass('sidr-hidden'); 104 } 105 } 106 else { 107 if ($(value).hasClass('sidr-hidden')) { 108 $('#' + $wrapper_id).hide(); 109 $(value).show().removeClass('sidr-hidden'); 110 } 111 } 112 }); 113 }); 114 }); 115 } 116 }; 117}(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.