jquery.meanmenu.min.js 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229
  1. (function($) {
  2. 'use strict';
  3. $.fn.meanmenu = function(e) {
  4. setTimeout(()=>{
  5. var n = {
  6. meanMenuTarget: jQuery(this),
  7. meanMenuContainer: 'body',
  8. meanMenuClose: '<span /><span /><span />',
  9. meanMenuCloseSize: '18px',
  10. meanMenuOpen: '<span /><span /><span />',
  11. meanRevealPosition: 'right',
  12. meanRevealPositionDistance: '0',
  13. meanRevealColour: '',
  14. meanScreenWidth: '480',
  15. meanNavPush: '',
  16. meanShowChildren: !0,
  17. meanExpandableChildren: !0,
  18. meanExpand: '+',
  19. meanContract: '-',
  20. meanRemoveAttrs: !1,
  21. onePage: !1,
  22. meanDisplay: 'block',
  23. removeElements: '',
  24. };
  25. e = $.extend(n, e);
  26. var a = window.innerWidth || document.documentElement.clientWidth;
  27. return this.each(function() {
  28. var n = e.meanMenuTarget,
  29. t = e.meanMenuContainer,
  30. r = e.meanMenuClose,
  31. i = e.meanMenuCloseSize,
  32. s = e.meanMenuOpen,
  33. u = e.meanRevealPosition,
  34. m = e.meanRevealPositionDistance,
  35. l = e.meanRevealColour,
  36. o = e.meanScreenWidth,
  37. c = e.meanNavPush,
  38. v = '.meanmenu-reveal',
  39. h = e.meanShowChildren,
  40. d = e.meanExpandableChildren,
  41. y = e.meanExpand,
  42. j = e.meanContract,
  43. Q = e.meanRemoveAttrs,
  44. f = e.onePage,
  45. g = e.meanDisplay,
  46. p = e.removeElements,
  47. C = !1;
  48. (navigator.userAgent.match(/iPhone/i) ||
  49. navigator.userAgent.match(/iPod/i) ||
  50. navigator.userAgent.match(/iPad/i) ||
  51. navigator.userAgent.match(/Android/i) ||
  52. navigator.userAgent.match(/Blackberry/i) ||
  53. navigator.userAgent.match(/Windows Phone/i)) &&
  54. (C = !0),
  55. (navigator.userAgent.match(/MSIE 8/i) ||
  56. navigator.userAgent.match(/MSIE 7/i)) &&
  57. jQuery('html').css('overflow-y', 'scroll');
  58. var w = '',
  59. x = function() {
  60. if ('center' === u) {
  61. var e =
  62. window.innerWidth ||
  63. document.documentElement.clientWidth,
  64. n = e / 2 - 22 + 'px';
  65. (w = 'left:' + n + ';right:auto;'),
  66. C
  67. ?
  68. jQuery('.meanmenu-reveal').animate({
  69. left: n,
  70. }) :
  71. jQuery('.meanmenu-reveal').css('left', n);
  72. }
  73. },
  74. A = !1,
  75. E = !1;
  76. 'right' === u && (w = 'right:' + m + ';left:auto;'),
  77. 'left' === u && (w = 'left:' + m + ';right:auto;'),
  78. x();
  79. var M = '',
  80. W = function() {
  81. jQuery('.mean-bar,.mean-push').remove(),
  82. jQuery(t).removeClass('mean-container'),
  83. jQuery(n).css('display', g),
  84. (A = !1),
  85. (E = !1),
  86. jQuery(p).removeClass('mean-remove');
  87. },
  88. b = function() {
  89. var e = 'background:' + l + ';color:' + l + ';' + w;
  90. if (o >= a) {
  91. jQuery(p).addClass('mean-remove'),
  92. (E = !0),
  93. jQuery(t).addClass('mean-container'),
  94. jQuery('.mean-container').prepend(
  95. '<div class="mean-bar"><a href="#nav" class="meanmenu-reveal" style="' +
  96. e +
  97. '">Show Navigation</a><nav class="mean-nav"></nav></div>'
  98. );
  99. var r = jQuery(n).html();
  100. jQuery('.mean-nav').html(r),
  101. Q &&
  102. jQuery(
  103. 'nav.mean-nav ul, nav.mean-nav ul *'
  104. ).each(function() {
  105. jQuery(this).is('.mean-remove') ?
  106. jQuery(this).attr(
  107. 'class',
  108. 'mean-remove'
  109. ) :
  110. jQuery(this).removeAttr('class'),
  111. jQuery(this).removeAttr('id');
  112. }),
  113. jQuery(n).before('<div class="mean-push" />'),
  114. jQuery('.mean-push').css('margin-top', c),
  115. jQuery(n).hide(),
  116. jQuery('.meanmenu-reveal').show(),
  117. jQuery(v).html(s),
  118. (M = jQuery(v)),
  119. jQuery('.mean-nav ul').hide(),
  120. h ?
  121. d ?
  122. (jQuery('.mean-nav ul ul').each(
  123. function() {
  124. jQuery(this).children()
  125. .length &&
  126. jQuery(this, 'li:first')
  127. .parent()
  128. .append(
  129. '<a class="mean-expand" href="#" style="font-size: ' +
  130. i +
  131. '">' +
  132. y +
  133. '</a>'
  134. );
  135. }
  136. ),
  137. jQuery('.mean-expand').on(
  138. 'click',
  139. function(e) {
  140. e.preventDefault(),
  141. jQuery(this).hasClass(
  142. 'mean-clicked'
  143. ) ?
  144. (jQuery(this).text(y),
  145. jQuery(this)
  146. .prev('ul')
  147. .slideUp(
  148. 300,
  149. function() {}
  150. )) :
  151. (jQuery(this).text(j),
  152. jQuery(this)
  153. .prev('ul')
  154. .slideDown(
  155. 300,
  156. function() {}
  157. )),
  158. jQuery(this).toggleClass(
  159. 'mean-clicked'
  160. );
  161. }
  162. )) :
  163. jQuery('.mean-nav ul ul').show() :
  164. jQuery('.mean-nav ul ul').hide(),
  165. jQuery('.mean-nav ul li')
  166. .last()
  167. .addClass('mean-last'),
  168. M.removeClass('meanclose'),
  169. jQuery(M).on('click',function(e) {
  170. e.preventDefault(),
  171. A === !1 ?
  172. (M.css('text-align', 'center'),
  173. M.css('text-indent', '0'),
  174. M.css('font-size', i),
  175. jQuery(
  176. '.mean-nav ul:first'
  177. ).slideDown(),
  178. (A = !0)) :
  179. (jQuery(
  180. '.mean-nav ul:first'
  181. ).slideUp(),
  182. (A = !1)),
  183. M.toggleClass('meanclose'),
  184. jQuery(p).addClass('mean-remove');
  185. }),
  186. f &&
  187. jQuery('.mean-nav ul > li > a:first-child').on(
  188. 'click',
  189. function() {
  190. jQuery('.mean-nav ul:first').slideUp(),
  191. (A = !1),
  192. jQuery(M)
  193. .toggleClass('meanclose')
  194. .html(s);
  195. }
  196. );
  197. } else W();
  198. };
  199. C ||
  200. jQuery(window).resize(function() {
  201. (a =
  202. window.innerWidth ||
  203. document.documentElement.clientWidth),
  204. a > o,
  205. W(),
  206. o >= a ? (b(), x()) : W();
  207. }),
  208. jQuery(window).resize(function() {
  209. (a =
  210. window.innerWidth ||
  211. document.documentElement.clientWidth),
  212. C
  213. ?
  214. (x(), o >= a ? E === !1 && b() : W()) :
  215. (W(), o >= a && (b(), x()));
  216. }),
  217. b();
  218. });
  219. },100)
  220. };
  221. })(jQuery);