1/* 2 * jQuery prmenmu plugin v 0.1.0 3 * Copyright 2014 by Steve George 4 * http://www.pagerange.com/projects/prmenu 5 * Released under the MIT license. 6 * https://github.com/pagerange/prmenu/blob/master/LICENSE 7 */ 8 9/* 10 * Usage: 11 * 12 * $(document).ready(function(){ 13 * $('ul#mymenu').prmenu(); 14 * }); 15 * 16 * Note: 17 * 18 * Options passed into the plugin are not yet used. 19 * Menu styling, link color, etc., can be adjusted in the CSS for now. 20 * 21 */ 22 23; // close previous unclosed statements if any 24 25(function($) { 26 27 var plugin = {}; 28 29 $.prmenu = function(element, options) { 30 31 // Set default options for plugin 32 // Not yet implemented... can't be changed 33 var defaults = { 34 maintain_ratio: true, 35 link: '#000000', 36 visited: '#000000', 37 hover: '#666666', 38 active: '#666666', 39 current: '#444444' 40 }; 41 42 43 // create empty object to hold options 44 plugin.o = {} 45 46 // Function called when we initialize the plugin 47 plugin.init = function() { 48 49 // Merge user options with our defaults 50 plugin.o = $.extend({}, defaults, options); 51 52 // Add the target element to the options object 53 plugin.o.el = $(element); 54 55 // resize elements to user specs 56 plugin.activateMenu(); 57 58 } // end init 59 60 plugin.activateMenu = function() { 61 62 var links; 63 links = plugin.o.el.children('li'); 64 65 // wrap element in prmenu_container div 66 plugin.o.el.wrap('<div class="prmenu_container"></div>'); 67 68 // prepend the mobile menu toggle 69 plugin.o.el.parent().prepend(`<ul class="menu-toggle"><li class="menu-toggle"><a href="#"><svg xmlns="http://www.w3.org/2000/svg" width="37" height="40" viewBox="0 0 24 24" fill="none" stroke="#ffffff" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="3" y1="12" x2="21" y2="12"></line><line x1="3" y1="6" x2="21" y2="6"></line><line x1="3" y1="18" x2="21" y2="18"></line></svg></a></li></ul>`); 70 71 $('li.menu-toggle a').click(function() { 72 plugin.o.el.toggle(); 73 }); 74 75 $(window).resize(function() { 76 plugin.resizeLinks() 77 }); 78 79 plugin.resizeLinks(); 80 81 } // end activateMenu 82 83 84 plugin.resizeLinks = function() { 85 if ($(window).width() > 720) { 86 plugin.setupMenuForDesktopDevices(); 87 } else { 88 plugin.setupMenuForHandheldDevices(); 89 } 90 } 91 92 plugin.setupMenuForDesktopDevices = function() { 93 94 var links, count, width, first, last, aheight; 95 96 links = plugin.o.el.children('li'); 97 aheight = links.children('a').css('height'); 98 99 // Calculate space taken by all li, except for the last 100 // Assign the remaining space to the last li 101 if (links.length > 1) { 102 count = links.length; 103 width = 100 / count; 104 first = width * (count - 1); 105 last = 100 - first; 106 width = width + '%'; 107 last = last + '%'; 108 } else { 109 // If there's only a single element, make it 100% width' 110 width = '100%'; 111 last = '100%'; 112 } 113 114 // Set desktop navigation styling 115 //$('div.prmenu_container').css('height', aheight); 116 $('div.prmenu_container').css('height', 40); 117 links.css('width', width); 118 links.last().css('width', last); 119 plugin.o.el.css('display', 'block'); 120 121 } 122 123 plugin.setupMenuForHandheldDevices = function() { 124 125 var links, aheight; 126 127 links = plugin.o.el.children('li'); 128 aheight = links.find('a').css('height'); 129 130 // Set mobile navigation styling 131 plugin.o.el.css('width', '100%'); 132 plugin.o.el.css('display', 'none'); 133 plugin.o.el.parent().css('height', aheight); 134 links.css('width', '100%'); 135 links.last().css('width', '100%'); 136 links.css('position', 'relative'); 137 links.css('left', '0'); 138 links.show(); 139 links.children('ul').show(); 140 141 } 142 143 plugin.init(); 144 145 } 146 147 $.fn.prmenu = function(options) { 148 149 return this.each(function() { 150 if (undefined == $(this).data('prmenu')) { 151 var plugin = new $.prmenu(this, options); 152 $(this).data('prmenu', plugin); 153 } 154 }); 155 156 } 157 158})(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.