1;(function ($, window, document, undefined) { 2 var pluginName = 'nav'; 3 var defaults = { 4 itemElements: '> [data-nav-items] > [data-nav-item]', 5 panelElements: '> [data-nav-panels] > [data-nav-panel]' 6 }; 7 8 function Nav(element, options) { 9 this.element = element; 10 this.options = $.extend({}, defaults, options); 11 this._defaults = defaults; 12 this._name = pluginName; 13 14 this.init(); 15 } 16 17 Nav.prototype.init = function () { 18 var self = this; 19 var opts = self.options; 20 21 var $nav = $(self.element); 22 var $items = $nav.find(opts.itemElements); 23 var $panels = $nav.find(opts.panelElements); 24 25 function addEventListeners() { 26 $items.each(function (index) { 27 $items.eq(index).on('mouseenter', function () { 28 $panels.each(function(index2) { 29 $panels.eq(index2).hide(); 30 }); 31 $panels.eq(index).show(); 32 }); 33 $items.eq(index).on('mouseleave', function () { 34 $panels.eq(index).hide(); 35 }); 36 }); 37 38 $panels.each(function (index) { 39 $panels.eq(index).on('mouseenter', function () { 40 $panels.eq(index).show(); 41 $items.eq(index).addClass('active'); 42 }); 43 $panels.eq(index).on('mouseleave', function () { 44 $panels.eq(index).hide(); 45 $items.eq(index).removeClass('active'); 46 }); 47 }); 48 } 49 50 function setup() { 51 $panels.each(function (index) { 52 $panels.eq(index).hide(); 53 }); 54 } 55 56 setup(); 57 addEventListeners(); 58 }; 59 60 $.fn[pluginName] = function (options) { 61 return this.each(function () { 62 if (!$.data(this, 'plugin_' + pluginName)) { 63 $.data(this, 'plugin_' + pluginName, new Nav(this, options)); 64 } 65 }); 66 }; 67})(jQuery, window, document);
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.