1(function ($) { 2 'use strict'; 3 4 var defaults = {}; 5 6 function Sidenav (element, options) { 7 this.$el = $(element); 8 this.opt = $.extend(true, {}, defaults, options); 9 10 this.init(this); 11 } 12 13 Sidenav.prototype = { 14 init: function (self) { 15 self.initToggle(self); 16 self.initDropdown(self); 17 }, 18 19 initToggle: function (self) { 20 $(document).on('click', function (e) { 21 var $target = $(e.target); 22 23 if ($target.closest(self.$el.data('sidenav-toggle'))[0]) { 24 self.$el.toggleClass('show'); 25 $('body').toggleClass('sidenav-no-scroll'); 26 27 self.toggleOverlay(); 28 29 } else if (!$target.closest(self.$el)[0]){ 30 self.$el.removeClass('show'); 31 $('body').removeClass('sidenav-no-scroll'); 32 33 self.hideOverlay(); 34 } 35 }); 36 }, 37 38 initDropdown: function (self) { 39 self.$el.on('click', '[data-sidenav-dropdown-toggle]', function (e) { 40 var $this = $(this); 41 42 $this 43 .next('[data-sidenav-dropdown]') 44 .slideToggle('fast'); 45 46 $this 47 .find('[data-sidenav-dropdown-icon]') 48 .toggleClass('show'); 49 50 e.preventDefault(); 51 }); 52 }, 53 54 toggleOverlay: function () {
55 var $overlay = $('[data-sidenav-overlay]'); 56 57 if (!$overlay[0]) { 58 $overlay = $('<div data-sidenav-overlay class="sidenav-overlay"/>'); 59 $('body').append($overlay); 60 } 61 62 $overlay.fadeToggle('fast'); 63 }, 64 65 hideOverlay: function () { 66 $('[data-sidenav-overlay]').fadeOut('fast'); 67 } 68 }; 69 70 $.fn.sidenav = function (options) { 71 return this.each(function() { 72 if (!$.data(this, 'sidenav')) { 73 $.data(this, 'sidenav', new Sidenav(this, options)); 74 } 75 }); 76 }; 77})(window.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.