1 2!function ($) { 3 4 "use strict"; // jshint ;_; 5 6 7 /* DROPDOWN CLASS DEFINITION 8 * ========================= */ 9 10 var toggle = '[data-jsapi] .parent > a' 11 , SAMegamenu = function (element) { 12 var $el = $(element).on('click.sapi.data-api', this.toggle) 13 $('html').on('click.sapi.data-api', function () { 14 $el.parent().removeClass('open') 15 }) 16 } 17 18 SAMegamenu.prototype = { 19 20 constructor: SAMegamenu 21 22 , toggle: function (e) { 23 24 var $this = $(this) 25 , $parent 26 , isActive 27 28 if ($this.is('.disabled, :disabled')) return 29 30 $parent = getParent($this) 31 32 33 isActive = $parent.hasClass('open') 34 if (isActive) { 35 var href = $this.attr('href'); 36 if( href.indexOf('#') === 0 ){ 37 return 38 }else{ 39 e.stopPropagation() 40 windown.location.href = href; 41 return false 42 } 43 } 44 var toggle_parents = $this.parents().filter($(toggle).parent()).not($parent); 45 clearMenus(); 46 toggle_parents.addClass('open'); 47 48 if (!isActive) { 49 $parent.toggleClass('open') 50 } 51 52 $this.focus() 53 54 if (!isActive){ 55 var $check_class = $('.sj-megamenu'); 56 if( $check_class.hasClass('sj-megamenu-hover') ){ 57 return true; 58 }else { 59 return false; 60 } 61 } 62 } 63 64 , keydown: function (e) { 65 var $this 66 , $items 67 , $active 68 , $parent 69 , isActive 70 , index 71 72 if (!/(38|40|27)/.test(e.keyCode)) return 73 74 $this = $(this) 75 76 e.preventDefault() 77 e.stopPropagation() 78 79 if ($this.is('.disabled, :disabled')) return 80 81 $parent = getParent($this) 82 83 isActive = $parent.hasClass('open') 84 85 if (!isActive || (isActive && e.keyCode == 27)) return $this.click() 86 87 $items = $('[role=menu] li:not(.divider):visible a', $parent) 88 89 if (!$items.length) return 90 91 index = $items.index($items.filter(':focus')) 92 93 if (e.keyCode == 38 && index > 0) index-- // up 94 if (e.keyCode == 40 && index < $items.length - 1) index++ // down 95 if (!~index) index = 0 96 97 $items 98 .eq(index) 99 .focus() 100 } 101 102 } 103 104 function clearMenus() { 105 $(toggle).each(function () { 106 getParent($(this)).removeClass('open') 107 }) 108 } 109 110 function getParent($this) { 111 var selector = $this.attr('data-target') 112 , $parent 113 114 if (!selector) { 115 selector = $this.attr('href') 116 selector = selector && /#/.test(selector) && selector.replace(/.*(?=#[^\s]*$)/, '') //strip for ie7 117 } 118 119 $parent = $(selector) 120 $parent.length || ($parent = $this.parent()) 121 122 return $parent 123 } 124 125 126 /* DROPDOWN PLUGIN DEFINITION 127 * ========================== */ 128 129 var old = $.fn.dropdown 130 131 $.fn.dropdown = function (option) { 132 return this.each(function () { 133 var $this = $(this) 134 , data = $this.data('dropdown') 135 if (!data) $this.data('dropdown', (data = new SAMegamenu(this))) 136 if (typeof option == 'string') data[option].call($this) 137 }) 138 } 139 140 $.fn.dropdown.Constructor = SAMegamenu 141 142 143 /* DROPDOWN NO CONFLICT 144 * ==================== */ 145 146 $.fn.dropdown.noConflict = function () { 147 $.fn.dropdown = old 148 return this 149 } 150 151 152 /* APPLY TO STANDARD DROPDOWN ELEMENTS 153 * =================================== */ 154 155 $(document) 156 .on('click.sapi.data-api touchstart.sapi.data-api', clearMenus) 157 .on('click.sapi touchstart.sapi.data-api', '.parent form,.parent .jmod-output', function (e) { e.stopPropagation() }) 158 .on('touchstart.sapi.data-api', '.sj-megamenu-child', function (e) { e.stopPropagation() }) 159 .on('click.sapi.data-api touchstart.sapi.data-api' , toggle, SAMegamenu.prototype.toggle) 160 .on('keydown.sapi.data-api touchstart.sapi.data-api', toggle + ', [role=menu]' , SAMegamenu.prototype.keydown) 161 .on('click.sapi.menu-open', '[data-sapi="collapse"]', function(e){ 162 $(this).toggleClass('open'); 163 //e.prevenDefault(); 164 }) 165}(window.jQuery); 166
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.