Blame jquery/jquery.smartmenus-1.0.0.js

Packit 1c1d7e
/*!
Packit 1c1d7e
 * SmartMenus jQuery Plugin - v1.0.0 - January 27, 2016
Packit 1c1d7e
 * http://www.smartmenus.org/
Packit 1c1d7e
 *
Packit 1c1d7e
 * Copyright Vasil Dinkov, Vadikom Web Ltd.
Packit 1c1d7e
 * http://vadikom.com
Packit 1c1d7e
 *
Packit 1c1d7e
 * Licensed MIT
Packit 1c1d7e
 */
Packit 1c1d7e
Packit 1c1d7e
(function(factory) {
Packit 1c1d7e
	if (typeof define === 'function' && define.amd) {
Packit 1c1d7e
		// AMD
Packit 1c1d7e
		define(['jquery'], factory);
Packit 1c1d7e
	} else if (typeof module === 'object' && typeof module.exports === 'object') {
Packit 1c1d7e
		// CommonJS
Packit 1c1d7e
		module.exports = factory(require('jquery'));
Packit 1c1d7e
	} else {
Packit 1c1d7e
		// Global jQuery
Packit 1c1d7e
		factory(jQuery);
Packit 1c1d7e
	}
Packit 1c1d7e
} (function($) {
Packit 1c1d7e
Packit 1c1d7e
	var menuTrees = [],
Packit 1c1d7e
		IE = !!window.createPopup, // detect it for the iframe shim
Packit 1c1d7e
		mouse = false, // optimize for touch by default - we will detect for mouse input
Packit 1c1d7e
		touchEvents = 'ontouchstart' in window, // we use this just to choose between toucn and pointer events, not for touch screen detection
Packit 1c1d7e
		mouseDetectionEnabled = false,
Packit 1c1d7e
		requestAnimationFrame = window.requestAnimationFrame || function(callback) { return setTimeout(callback, 1000 / 60); },
Packit 1c1d7e
		cancelAnimationFrame = window.cancelAnimationFrame || function(id) { clearTimeout(id); };
Packit 1c1d7e
Packit 1c1d7e
	// Handle detection for mouse input (i.e. desktop browsers, tablets with a mouse, etc.)
Packit 1c1d7e
	function initMouseDetection(disable) {
Packit 1c1d7e
		var eNS = '.smartmenus_mouse';
Packit 1c1d7e
		if (!mouseDetectionEnabled && !disable) {
Packit 1c1d7e
			// if we get two consecutive mousemoves within 2 pixels from each other and within 300ms, we assume a real mouse/cursor is present
Packit 1c1d7e
			// in practice, this seems like impossible to trick unintentianally with a real mouse and a pretty safe detection on touch devices (even with older browsers that do not support touch events)
Packit 1c1d7e
			var firstTime = true,
Packit 1c1d7e
				lastMove = null;
Packit 1c1d7e
			$(document).bind(getEventsNS([
Packit 1c1d7e
				['mousemove', function(e) {
Packit 1c1d7e
					var thisMove = { x: e.pageX, y: e.pageY, timeStamp: new Date().getTime() };
Packit 1c1d7e
					if (lastMove) {
Packit 1c1d7e
						var deltaX = Math.abs(lastMove.x - thisMove.x),
Packit 1c1d7e
							deltaY = Math.abs(lastMove.y - thisMove.y);
Packit 1c1d7e
	 					if ((deltaX > 0 || deltaY > 0) && deltaX <= 2 && deltaY <= 2 && thisMove.timeStamp - lastMove.timeStamp <= 300) {
Packit 1c1d7e
							mouse = true;
Packit 1c1d7e
							// if this is the first check after page load, check if we are not over some item by chance and call the mouseenter handler if yes
Packit 1c1d7e
							if (firstTime) {
Packit 1c1d7e
								var $a = $(e.target).closest('a');
Packit 1c1d7e
								if ($a.is('a')) {
Packit 1c1d7e
									$.each(menuTrees, function() {
Packit 1c1d7e
										if ($.contains(this.$root[0], $a[0])) {
Packit 1c1d7e
											this.itemEnter({ currentTarget: $a[0] });
Packit 1c1d7e
											return false;
Packit 1c1d7e
										}
Packit 1c1d7e
									});
Packit 1c1d7e
								}
Packit 1c1d7e
								firstTime = false;
Packit 1c1d7e
							}
Packit 1c1d7e
						}
Packit 1c1d7e
					}
Packit 1c1d7e
					lastMove = thisMove;
Packit 1c1d7e
				}],
Packit 1c1d7e
				[touchEvents ? 'touchstart' : 'pointerover pointermove pointerout MSPointerOver MSPointerMove MSPointerOut', function(e) {
Packit 1c1d7e
					if (isTouchEvent(e.originalEvent)) {
Packit 1c1d7e
						mouse = false;
Packit 1c1d7e
					}
Packit 1c1d7e
				}]
Packit 1c1d7e
			], eNS));
Packit 1c1d7e
			mouseDetectionEnabled = true;
Packit 1c1d7e
		} else if (mouseDetectionEnabled && disable) {
Packit 1c1d7e
			$(document).unbind(eNS);
Packit 1c1d7e
			mouseDetectionEnabled = false;
Packit 1c1d7e
		}
Packit 1c1d7e
	}
Packit 1c1d7e
Packit 1c1d7e
	function isTouchEvent(e) {
Packit 1c1d7e
		return !/^(4|mouse)$/.test(e.pointerType);
Packit 1c1d7e
	}
Packit 1c1d7e
Packit 1c1d7e
	// returns a jQuery bind() ready object
Packit 1c1d7e
	function getEventsNS(defArr, eNS) {
Packit 1c1d7e
		if (!eNS) {
Packit 1c1d7e
			eNS = '';
Packit 1c1d7e
		}
Packit 1c1d7e
		var obj = {};
Packit 1c1d7e
		$.each(defArr, function(index, value) {
Packit 1c1d7e
			obj[value[0].split(' ').join(eNS + ' ') + eNS] = value[1];
Packit 1c1d7e
		});
Packit 1c1d7e
		return obj;
Packit 1c1d7e
	}
Packit 1c1d7e
Packit 1c1d7e
	$.SmartMenus = function(elm, options) {
Packit 1c1d7e
		this.$root = $(elm);
Packit 1c1d7e
		this.opts = options;
Packit 1c1d7e
		this.rootId = ''; // internal
Packit 1c1d7e
		this.accessIdPrefix = '';
Packit 1c1d7e
		this.$subArrow = null;
Packit 1c1d7e
		this.activatedItems = []; // stores last activated A's for each level
Packit 1c1d7e
		this.visibleSubMenus = []; // stores visible sub menus UL's (might be in no particular order)
Packit 1c1d7e
		this.showTimeout = 0;
Packit 1c1d7e
		this.hideTimeout = 0;
Packit 1c1d7e
		this.scrollTimeout = 0;
Packit 1c1d7e
		this.clickActivated = false;
Packit 1c1d7e
		this.focusActivated = false;
Packit 1c1d7e
		this.zIndexInc = 0;
Packit 1c1d7e
		this.idInc = 0;
Packit 1c1d7e
		this.$firstLink = null; // we'll use these for some tests
Packit 1c1d7e
		this.$firstSub = null; // at runtime so we'll cache them
Packit 1c1d7e
		this.disabled = false;
Packit 1c1d7e
		this.$disableOverlay = null;
Packit 1c1d7e
		this.$touchScrollingSub = null;
Packit 1c1d7e
		this.cssTransforms3d = 'perspective' in elm.style || 'webkitPerspective' in elm.style;
Packit 1c1d7e
		this.wasCollapsible = false;
Packit 1c1d7e
		this.init();
Packit 1c1d7e
	};
Packit 1c1d7e
Packit 1c1d7e
	$.extend($.SmartMenus, {
Packit 1c1d7e
		hideAll: function() {
Packit 1c1d7e
			$.each(menuTrees, function() {
Packit 1c1d7e
				this.menuHideAll();
Packit 1c1d7e
			});
Packit 1c1d7e
		},
Packit 1c1d7e
		destroy: function() {
Packit 1c1d7e
			while (menuTrees.length) {
Packit 1c1d7e
				menuTrees[0].destroy();
Packit 1c1d7e
			}
Packit 1c1d7e
			initMouseDetection(true);
Packit 1c1d7e
		},
Packit 1c1d7e
		prototype: {
Packit 1c1d7e
			init: function(refresh) {
Packit 1c1d7e
				var self = this;
Packit 1c1d7e
Packit 1c1d7e
				if (!refresh) {
Packit 1c1d7e
					menuTrees.push(this);
Packit 1c1d7e
Packit 1c1d7e
					this.rootId = (new Date().getTime() + Math.random() + '').replace(/\D/g, '');
Packit 1c1d7e
					this.accessIdPrefix = 'sm-' + this.rootId + '-';
Packit 1c1d7e
Packit 1c1d7e
					if (this.$root.hasClass('sm-rtl')) {
Packit 1c1d7e
						this.opts.rightToLeftSubMenus = true;
Packit 1c1d7e
					}
Packit 1c1d7e
Packit 1c1d7e
					// init root (main menu)
Packit 1c1d7e
					var eNS = '.smartmenus';
Packit 1c1d7e
					this.$root
Packit 1c1d7e
						.data('smartmenus', this)
Packit 1c1d7e
						.attr('data-smartmenus-id', this.rootId)
Packit 1c1d7e
						.dataSM('level', 1)
Packit 1c1d7e
						.bind(getEventsNS([
Packit 1c1d7e
							['mouseover focusin', $.proxy(this.rootOver, this)],
Packit 1c1d7e
							['mouseout focusout', $.proxy(this.rootOut, this)],
Packit 1c1d7e
							['keydown', $.proxy(this.rootKeyDown, this)]
Packit 1c1d7e
						], eNS))
Packit 1c1d7e
						.delegate('a', getEventsNS([
Packit 1c1d7e
							['mouseenter', $.proxy(this.itemEnter, this)],
Packit 1c1d7e
							['mouseleave', $.proxy(this.itemLeave, this)],
Packit 1c1d7e
							['mousedown', $.proxy(this.itemDown, this)],
Packit 1c1d7e
							['focus', $.proxy(this.itemFocus, this)],
Packit 1c1d7e
							['blur', $.proxy(this.itemBlur, this)],
Packit 1c1d7e
							['click', $.proxy(this.itemClick, this)]
Packit 1c1d7e
						], eNS));
Packit 1c1d7e
Packit 1c1d7e
					// hide menus on tap or click outside the root UL
Packit 1c1d7e
					eNS += this.rootId;
Packit 1c1d7e
					if (this.opts.hideOnClick) {
Packit 1c1d7e
						$(document).bind(getEventsNS([
Packit 1c1d7e
							['touchstart', $.proxy(this.docTouchStart, this)],
Packit 1c1d7e
							['touchmove', $.proxy(this.docTouchMove, this)],
Packit 1c1d7e
							['touchend', $.proxy(this.docTouchEnd, this)],
Packit 1c1d7e
							// for Opera Mobile < 11.5, webOS browser, etc. we'll check click too
Packit 1c1d7e
							['click', $.proxy(this.docClick, this)]
Packit 1c1d7e
						], eNS));
Packit 1c1d7e
					}
Packit 1c1d7e
					// hide sub menus on resize
Packit 1c1d7e
					$(window).bind(getEventsNS([['resize orientationchange', $.proxy(this.winResize, this)]], eNS));
Packit 1c1d7e
Packit 1c1d7e
					if (this.opts.subIndicators) {
Packit 1c1d7e
						this.$subArrow = $('').addClass('sub-arrow');
Packit 1c1d7e
						if (this.opts.subIndicatorsText) {
Packit 1c1d7e
							this.$subArrow.html(this.opts.subIndicatorsText);
Packit 1c1d7e
						}
Packit 1c1d7e
					}
Packit 1c1d7e
Packit 1c1d7e
					// make sure mouse detection is enabled
Packit 1c1d7e
					initMouseDetection();
Packit 1c1d7e
				}
Packit 1c1d7e
Packit 1c1d7e
				// init sub menus
Packit 1c1d7e
				this.$firstSub = this.$root.find('ul').each(function() { self.menuInit($(this)); }).eq(0);
Packit 1c1d7e
Packit 1c1d7e
				this.$firstLink = this.$root.find('a').eq(0);
Packit 1c1d7e
Packit 1c1d7e
				// find current item
Packit 1c1d7e
				if (this.opts.markCurrentItem) {
Packit 1c1d7e
					var reDefaultDoc = /(index|default)\.[^#\?\/]*/i,
Packit 1c1d7e
						reHash = /#.*/,
Packit 1c1d7e
						locHref = window.location.href.replace(reDefaultDoc, ''),
Packit 1c1d7e
						locHrefNoHash = locHref.replace(reHash, '');
Packit 1c1d7e
					this.$root.find('a').each(function() {
Packit 1c1d7e
						var href = this.href.replace(reDefaultDoc, ''),
Packit 1c1d7e
							$this = $(this);
Packit 1c1d7e
						if (href == locHref || href == locHrefNoHash) {
Packit 1c1d7e
							$this.addClass('current');
Packit 1c1d7e
							if (self.opts.markCurrentTree) {
Packit 1c1d7e
								$this.parentsUntil('[data-smartmenus-id]', 'ul').each(function() {
Packit 1c1d7e
									$(this).dataSM('parent-a').addClass('current');
Packit 1c1d7e
								});
Packit 1c1d7e
							}
Packit 1c1d7e
						}
Packit 1c1d7e
					});
Packit 1c1d7e
				}
Packit 1c1d7e
Packit 1c1d7e
				// save initial state
Packit 1c1d7e
				this.wasCollapsible = this.isCollapsible();
Packit 1c1d7e
			},
Packit 1c1d7e
			destroy: function(refresh) {
Packit 1c1d7e
				if (!refresh) {
Packit 1c1d7e
					var eNS = '.smartmenus';
Packit 1c1d7e
					this.$root
Packit 1c1d7e
						.removeData('smartmenus')
Packit 1c1d7e
						.removeAttr('data-smartmenus-id')
Packit 1c1d7e
						.removeDataSM('level')
Packit 1c1d7e
						.unbind(eNS)
Packit 1c1d7e
						.undelegate(eNS);
Packit 1c1d7e
					eNS += this.rootId;
Packit 1c1d7e
					$(document).unbind(eNS);
Packit 1c1d7e
					$(window).unbind(eNS);
Packit 1c1d7e
					if (this.opts.subIndicators) {
Packit 1c1d7e
						this.$subArrow = null;
Packit 1c1d7e
					}
Packit 1c1d7e
				}
Packit 1c1d7e
				this.menuHideAll();
Packit 1c1d7e
				var self = this;
Packit 1c1d7e
				this.$root.find('ul').each(function() {
Packit 1c1d7e
						var $this = $(this);
Packit 1c1d7e
						if ($this.dataSM('scroll-arrows')) {
Packit 1c1d7e
							$this.dataSM('scroll-arrows').remove();
Packit 1c1d7e
						}
Packit 1c1d7e
						if ($this.dataSM('shown-before')) {
Packit 1c1d7e
							if (self.opts.subMenusMinWidth || self.opts.subMenusMaxWidth) {
Packit 1c1d7e
								$this.css({ width: '', minWidth: '', maxWidth: '' }).removeClass('sm-nowrap');
Packit 1c1d7e
							}
Packit 1c1d7e
							if ($this.dataSM('scroll-arrows')) {
Packit 1c1d7e
								$this.dataSM('scroll-arrows').remove();
Packit 1c1d7e
							}
Packit 1c1d7e
							$this.css({ zIndex: '', top: '', left: '', marginLeft: '', marginTop: '', display: '' });
Packit 1c1d7e
						}
Packit 1c1d7e
						if (($this.attr('id') || '').indexOf(self.accessIdPrefix) == 0) {
Packit 1c1d7e
							$this.removeAttr('id');
Packit 1c1d7e
						}
Packit 1c1d7e
					})
Packit 1c1d7e
					.removeDataSM('in-mega')
Packit 1c1d7e
					.removeDataSM('shown-before')
Packit 1c1d7e
					.removeDataSM('ie-shim')
Packit 1c1d7e
					.removeDataSM('scroll-arrows')
Packit 1c1d7e
					.removeDataSM('parent-a')
Packit 1c1d7e
					.removeDataSM('level')
Packit 1c1d7e
					.removeDataSM('beforefirstshowfired')
Packit 1c1d7e
					.removeAttr('role')
Packit 1c1d7e
					.removeAttr('aria-hidden')
Packit 1c1d7e
					.removeAttr('aria-labelledby')
Packit 1c1d7e
					.removeAttr('aria-expanded');
Packit 1c1d7e
				this.$root.find('a.has-submenu').each(function() {
Packit 1c1d7e
						var $this = $(this);
Packit 1c1d7e
						if ($this.attr('id').indexOf(self.accessIdPrefix) == 0) {
Packit 1c1d7e
							$this.removeAttr('id');
Packit 1c1d7e
						}
Packit 1c1d7e
					})
Packit 1c1d7e
					.removeClass('has-submenu')
Packit 1c1d7e
					.removeDataSM('sub')
Packit 1c1d7e
					.removeAttr('aria-haspopup')
Packit 1c1d7e
					.removeAttr('aria-controls')
Packit 1c1d7e
					.removeAttr('aria-expanded')
Packit 1c1d7e
					.closest('li').removeDataSM('sub');
Packit 1c1d7e
				if (this.opts.subIndicators) {
Packit 1c1d7e
					this.$root.find('span.sub-arrow').remove();
Packit 1c1d7e
				}
Packit 1c1d7e
				if (this.opts.markCurrentItem) {
Packit 1c1d7e
					this.$root.find('a.current').removeClass('current');
Packit 1c1d7e
				}
Packit 1c1d7e
				if (!refresh) {
Packit 1c1d7e
					this.$root = null;
Packit 1c1d7e
					this.$firstLink = null;
Packit 1c1d7e
					this.$firstSub = null;
Packit 1c1d7e
					if (this.$disableOverlay) {
Packit 1c1d7e
						this.$disableOverlay.remove();
Packit 1c1d7e
						this.$disableOverlay = null;
Packit 1c1d7e
					}
Packit 1c1d7e
					menuTrees.splice($.inArray(this, menuTrees), 1);
Packit 1c1d7e
				}
Packit 1c1d7e
			},
Packit 1c1d7e
			disable: function(noOverlay) {
Packit 1c1d7e
				if (!this.disabled) {
Packit 1c1d7e
					this.menuHideAll();
Packit 1c1d7e
					// display overlay over the menu to prevent interaction
Packit 1c1d7e
					if (!noOverlay && !this.opts.isPopup && this.$root.is(':visible')) {
Packit 1c1d7e
						var pos = this.$root.offset();
Packit 1c1d7e
						this.$disableOverlay = $('
').css({
Packit 1c1d7e
							position: 'absolute',
Packit 1c1d7e
							top: pos.top,
Packit 1c1d7e
							left: pos.left,
Packit 1c1d7e
							width: this.$root.outerWidth(),
Packit 1c1d7e
							height: this.$root.outerHeight(),
Packit 1c1d7e
							zIndex: this.getStartZIndex(true),
Packit 1c1d7e
							opacity: 0
Packit 1c1d7e
						}).appendTo(document.body);
Packit 1c1d7e
					}
Packit 1c1d7e
					this.disabled = true;
Packit 1c1d7e
				}
Packit 1c1d7e
			},
Packit 1c1d7e
			docClick: function(e) {
Packit 1c1d7e
				if (this.$touchScrollingSub) {
Packit 1c1d7e
					this.$touchScrollingSub = null;
Packit 1c1d7e
					return;
Packit 1c1d7e
				}
Packit 1c1d7e
				// hide on any click outside the menu or on a menu link
Packit 1c1d7e
				if (this.visibleSubMenus.length && !$.contains(this.$root[0], e.target) || $(e.target).is('a')) {
Packit 1c1d7e
					this.menuHideAll();
Packit 1c1d7e
				}
Packit 1c1d7e
			},
Packit 1c1d7e
			docTouchEnd: function(e) {
Packit 1c1d7e
				if (!this.lastTouch) {
Packit 1c1d7e
					return;
Packit 1c1d7e
				}
Packit 1c1d7e
				if (this.visibleSubMenus.length && (this.lastTouch.x2 === undefined || this.lastTouch.x1 == this.lastTouch.x2) && (this.lastTouch.y2 === undefined || this.lastTouch.y1 == this.lastTouch.y2) && (!this.lastTouch.target || !$.contains(this.$root[0], this.lastTouch.target))) {
Packit 1c1d7e
					if (this.hideTimeout) {
Packit 1c1d7e
						clearTimeout(this.hideTimeout);
Packit 1c1d7e
						this.hideTimeout = 0;
Packit 1c1d7e
					}
Packit 1c1d7e
					// hide with a delay to prevent triggering accidental unwanted click on some page element
Packit 1c1d7e
					var self = this;
Packit 1c1d7e
					this.hideTimeout = setTimeout(function() { self.menuHideAll(); }, 350);
Packit 1c1d7e
				}
Packit 1c1d7e
				this.lastTouch = null;
Packit 1c1d7e
			},
Packit 1c1d7e
			docTouchMove: function(e) {
Packit 1c1d7e
				if (!this.lastTouch) {
Packit 1c1d7e
					return;
Packit 1c1d7e
				}
Packit 1c1d7e
				var touchPoint = e.originalEvent.touches[0];
Packit 1c1d7e
				this.lastTouch.x2 = touchPoint.pageX;
Packit 1c1d7e
				this.lastTouch.y2 = touchPoint.pageY;
Packit 1c1d7e
			},
Packit 1c1d7e
			docTouchStart: function(e) {
Packit 1c1d7e
				var touchPoint = e.originalEvent.touches[0];
Packit 1c1d7e
				this.lastTouch = { x1: touchPoint.pageX, y1: touchPoint.pageY, target: touchPoint.target };
Packit 1c1d7e
			},
Packit 1c1d7e
			enable: function() {
Packit 1c1d7e
				if (this.disabled) {
Packit 1c1d7e
					if (this.$disableOverlay) {
Packit 1c1d7e
						this.$disableOverlay.remove();
Packit 1c1d7e
						this.$disableOverlay = null;
Packit 1c1d7e
					}
Packit 1c1d7e
					this.disabled = false;
Packit 1c1d7e
				}
Packit 1c1d7e
			},
Packit 1c1d7e
			getClosestMenu: function(elm) {
Packit 1c1d7e
				var $closestMenu = $(elm).closest('ul');
Packit 1c1d7e
				while ($closestMenu.dataSM('in-mega')) {
Packit 1c1d7e
					$closestMenu = $closestMenu.parent().closest('ul');
Packit 1c1d7e
				}
Packit 1c1d7e
				return $closestMenu[0] || null;
Packit 1c1d7e
			},
Packit 1c1d7e
			getHeight: function($elm) {
Packit 1c1d7e
				return this.getOffset($elm, true);
Packit 1c1d7e
			},
Packit 1c1d7e
			// returns precise width/height float values
Packit 1c1d7e
			getOffset: function($elm, height) {
Packit 1c1d7e
				var old;
Packit 1c1d7e
				if ($elm.css('display') == 'none') {
Packit 1c1d7e
					old = { position: $elm[0].style.position, visibility: $elm[0].style.visibility };
Packit 1c1d7e
					$elm.css({ position: 'absolute', visibility: 'hidden' }).show();
Packit 1c1d7e
				}
Packit 1c1d7e
				var box = $elm[0].getBoundingClientRect && $elm[0].getBoundingClientRect(),
Packit 1c1d7e
					val = box && (height ? box.height || box.bottom - box.top : box.width || box.right - box.left);
Packit 1c1d7e
				if (!val && val !== 0) {
Packit 1c1d7e
					val = height ? $elm[0].offsetHeight : $elm[0].offsetWidth;
Packit 1c1d7e
				}
Packit 1c1d7e
				if (old) {
Packit 1c1d7e
					$elm.hide().css(old);
Packit 1c1d7e
				}
Packit 1c1d7e
				return val;
Packit 1c1d7e
			},
Packit 1c1d7e
			getStartZIndex: function(root) {
Packit 1c1d7e
				var zIndex = parseInt(this[root ? '$root' : '$firstSub'].css('z-index'));
Packit 1c1d7e
				if (!root && isNaN(zIndex)) {
Packit 1c1d7e
					zIndex = parseInt(this.$root.css('z-index'));
Packit 1c1d7e
				}
Packit 1c1d7e
				return !isNaN(zIndex) ? zIndex : 1;
Packit 1c1d7e
			},
Packit 1c1d7e
			getTouchPoint: function(e) {
Packit 1c1d7e
				return e.touches && e.touches[0] || e.changedTouches && e.changedTouches[0] || e;
Packit 1c1d7e
			},
Packit 1c1d7e
			getViewport: function(height) {
Packit 1c1d7e
				var name = height ? 'Height' : 'Width',
Packit 1c1d7e
					val = document.documentElement['client' + name],
Packit 1c1d7e
					val2 = window['inner' + name];
Packit 1c1d7e
				if (val2) {
Packit 1c1d7e
					val = Math.min(val, val2);
Packit 1c1d7e
				}
Packit 1c1d7e
				return val;
Packit 1c1d7e
			},
Packit 1c1d7e
			getViewportHeight: function() {
Packit 1c1d7e
				return this.getViewport(true);
Packit 1c1d7e
			},
Packit 1c1d7e
			getViewportWidth: function() {
Packit 1c1d7e
				return this.getViewport();
Packit 1c1d7e
			},
Packit 1c1d7e
			getWidth: function($elm) {
Packit 1c1d7e
				return this.getOffset($elm);
Packit 1c1d7e
			},
Packit 1c1d7e
			handleEvents: function() {
Packit 1c1d7e
				return !this.disabled && this.isCSSOn();
Packit 1c1d7e
			},
Packit 1c1d7e
			handleItemEvents: function($a) {
Packit 1c1d7e
				return this.handleEvents() && !this.isLinkInMegaMenu($a);
Packit 1c1d7e
			},
Packit 1c1d7e
			isCollapsible: function() {
Packit 1c1d7e
				return this.$firstSub.css('position') == 'static';
Packit 1c1d7e
			},
Packit 1c1d7e
			isCSSOn: function() {
Packit 1c1d7e
				return this.$firstLink.css('display') == 'block';
Packit 1c1d7e
			},
Packit 1c1d7e
			isFixed: function() {
Packit 1c1d7e
				var isFixed = this.$root.css('position') == 'fixed';
Packit 1c1d7e
				if (!isFixed) {
Packit 1c1d7e
					this.$root.parentsUntil('body').each(function() {
Packit 1c1d7e
						if ($(this).css('position') == 'fixed') {
Packit 1c1d7e
							isFixed = true;
Packit 1c1d7e
							return false;
Packit 1c1d7e
						}
Packit 1c1d7e
					});
Packit 1c1d7e
				}
Packit 1c1d7e
				return isFixed;
Packit 1c1d7e
			},
Packit 1c1d7e
			isLinkInMegaMenu: function($a) {
Packit 1c1d7e
				return $(this.getClosestMenu($a[0])).hasClass('mega-menu');
Packit 1c1d7e
			},
Packit 1c1d7e
			isTouchMode: function() {
Packit 1c1d7e
				return !mouse || this.opts.noMouseOver || this.isCollapsible();
Packit 1c1d7e
			},
Packit 1c1d7e
			itemActivate: function($a, focus) {
Packit 1c1d7e
				var $ul = $a.closest('ul'),
Packit 1c1d7e
					level = $ul.dataSM('level');
Packit 1c1d7e
				// if for some reason the parent item is not activated (e.g. this is an API call to activate the item), activate all parent items first
Packit 1c1d7e
				if (level > 1 && (!this.activatedItems[level - 2] || this.activatedItems[level - 2][0] != $ul.dataSM('parent-a')[0])) {
Packit 1c1d7e
					var self = this;
Packit 1c1d7e
					$($ul.parentsUntil('[data-smartmenus-id]', 'ul').get().reverse()).add($ul).each(function() {
Packit 1c1d7e
						self.itemActivate($(this).dataSM('parent-a'));
Packit 1c1d7e
					});
Packit 1c1d7e
				}
Packit 1c1d7e
				// hide any visible deeper level sub menus
Packit 1c1d7e
				if (!this.isCollapsible() || focus) {
Packit 1c1d7e
					this.menuHideSubMenus(!this.activatedItems[level - 1] || this.activatedItems[level - 1][0] != $a[0] ? level - 1 : level);
Packit 1c1d7e
				}
Packit 1c1d7e
				// save new active item for this level
Packit 1c1d7e
				this.activatedItems[level - 1] = $a;
Packit 1c1d7e
				if (this.$root.triggerHandler('activate.smapi', $a[0]) === false) {
Packit 1c1d7e
					return;
Packit 1c1d7e
				}
Packit 1c1d7e
				// show the sub menu if this item has one
Packit 1c1d7e
				var $sub = $a.dataSM('sub');
Packit 1c1d7e
				if ($sub && (this.isTouchMode() || (!this.opts.showOnClick || this.clickActivated))) {
Packit 1c1d7e
					this.menuShow($sub);
Packit 1c1d7e
				}
Packit 1c1d7e
			},
Packit 1c1d7e
			itemBlur: function(e) {
Packit 1c1d7e
				var $a = $(e.currentTarget);
Packit 1c1d7e
				if (!this.handleItemEvents($a)) {
Packit 1c1d7e
					return;
Packit 1c1d7e
				}
Packit 1c1d7e
				this.$root.triggerHandler('blur.smapi', $a[0]);
Packit 1c1d7e
			},
Packit 1c1d7e
			itemClick: function(e) {
Packit 1c1d7e
				var $a = $(e.currentTarget);
Packit 1c1d7e
				if (!this.handleItemEvents($a)) {
Packit 1c1d7e
					return;
Packit 1c1d7e
				}
Packit 1c1d7e
				if (this.$touchScrollingSub && this.$touchScrollingSub[0] == $a.closest('ul')[0]) {
Packit 1c1d7e
					this.$touchScrollingSub = null;
Packit 1c1d7e
					e.stopPropagation();
Packit 1c1d7e
					return false;
Packit 1c1d7e
				}
Packit 1c1d7e
				if (this.$root.triggerHandler('click.smapi', $a[0]) === false) {
Packit 1c1d7e
					return false;
Packit 1c1d7e
				}
Packit 1c1d7e
				var subArrowClicked = $(e.target).is('span.sub-arrow'),
Packit 1c1d7e
					$sub = $a.dataSM('sub'),
Packit 1c1d7e
					firstLevelSub = $sub ? $sub.dataSM('level') == 2 : false;
Packit 1c1d7e
				// if the sub is not visible
Packit 1c1d7e
				if ($sub && !$sub.is(':visible')) {
Packit 1c1d7e
					if (this.opts.showOnClick && firstLevelSub) {
Packit 1c1d7e
						this.clickActivated = true;
Packit 1c1d7e
					}
Packit 1c1d7e
					// try to activate the item and show the sub
Packit 1c1d7e
					this.itemActivate($a);
Packit 1c1d7e
					// if "itemActivate" showed the sub, prevent the click so that the link is not loaded
Packit 1c1d7e
					// if it couldn't show it, then the sub menus are disabled with an !important declaration (e.g. via mobile styles) so let the link get loaded
Packit 1c1d7e
					if ($sub.is(':visible')) {
Packit 1c1d7e
						this.focusActivated = true;
Packit 1c1d7e
						return false;
Packit 1c1d7e
					}
Packit 1c1d7e
				} else if (this.isCollapsible() && subArrowClicked) {
Packit 1c1d7e
					this.itemActivate($a);
Packit 1c1d7e
					this.menuHide($sub);
Packit 1c1d7e
					return false;
Packit 1c1d7e
				}
Packit 1c1d7e
				if (this.opts.showOnClick && firstLevelSub || $a.hasClass('disabled') || this.$root.triggerHandler('select.smapi', $a[0]) === false) {
Packit 1c1d7e
					return false;
Packit 1c1d7e
				}
Packit 1c1d7e
			},
Packit 1c1d7e
			itemDown: function(e) {
Packit 1c1d7e
				var $a = $(e.currentTarget);
Packit 1c1d7e
				if (!this.handleItemEvents($a)) {
Packit 1c1d7e
					return;
Packit 1c1d7e
				}
Packit 1c1d7e
				$a.dataSM('mousedown', true);
Packit 1c1d7e
			},
Packit 1c1d7e
			itemEnter: function(e) {
Packit 1c1d7e
				var $a = $(e.currentTarget);
Packit 1c1d7e
				if (!this.handleItemEvents($a)) {
Packit 1c1d7e
					return;
Packit 1c1d7e
				}
Packit 1c1d7e
				if (!this.isTouchMode()) {
Packit 1c1d7e
					if (this.showTimeout) {
Packit 1c1d7e
						clearTimeout(this.showTimeout);
Packit 1c1d7e
						this.showTimeout = 0;
Packit 1c1d7e
					}
Packit 1c1d7e
					var self = this;
Packit 1c1d7e
					this.showTimeout = setTimeout(function() { self.itemActivate($a); }, this.opts.showOnClick && $a.closest('ul').dataSM('level') == 1 ? 1 : this.opts.showTimeout);
Packit 1c1d7e
				}
Packit 1c1d7e
				this.$root.triggerHandler('mouseenter.smapi', $a[0]);
Packit 1c1d7e
			},
Packit 1c1d7e
			itemFocus: function(e) {
Packit 1c1d7e
				var $a = $(e.currentTarget);
Packit 1c1d7e
				if (!this.handleItemEvents($a)) {
Packit 1c1d7e
					return;
Packit 1c1d7e
				}
Packit 1c1d7e
				// fix (the mousedown check): in some browsers a tap/click produces consecutive focus + click events so we don't need to activate the item on focus
Packit 1c1d7e
				if (this.focusActivated && (!this.isTouchMode() || !$a.dataSM('mousedown')) && (!this.activatedItems.length || this.activatedItems[this.activatedItems.length - 1][0] != $a[0])) {
Packit 1c1d7e
					this.itemActivate($a, true);
Packit 1c1d7e
				}
Packit 1c1d7e
				this.$root.triggerHandler('focus.smapi', $a[0]);
Packit 1c1d7e
			},
Packit 1c1d7e
			itemLeave: function(e) {
Packit 1c1d7e
				var $a = $(e.currentTarget);
Packit 1c1d7e
				if (!this.handleItemEvents($a)) {
Packit 1c1d7e
					return;
Packit 1c1d7e
				}
Packit 1c1d7e
				if (!this.isTouchMode()) {
Packit 1c1d7e
					$a[0].blur();
Packit 1c1d7e
					if (this.showTimeout) {
Packit 1c1d7e
						clearTimeout(this.showTimeout);
Packit 1c1d7e
						this.showTimeout = 0;
Packit 1c1d7e
					}
Packit 1c1d7e
				}
Packit 1c1d7e
				$a.removeDataSM('mousedown');
Packit 1c1d7e
				this.$root.triggerHandler('mouseleave.smapi', $a[0]);
Packit 1c1d7e
			},
Packit 1c1d7e
			menuHide: function($sub) {
Packit 1c1d7e
				if (this.$root.triggerHandler('beforehide.smapi', $sub[0]) === false) {
Packit 1c1d7e
					return;
Packit 1c1d7e
				}
Packit 1c1d7e
				$sub.stop(true, true);
Packit 1c1d7e
				if ($sub.css('display') != 'none') {
Packit 1c1d7e
					var complete = function() {
Packit 1c1d7e
						// unset z-index
Packit 1c1d7e
						$sub.css('z-index', '');
Packit 1c1d7e
					};
Packit 1c1d7e
					// if sub is collapsible (mobile view)
Packit 1c1d7e
					if (this.isCollapsible()) {
Packit 1c1d7e
						if (this.opts.collapsibleHideFunction) {
Packit 1c1d7e
							this.opts.collapsibleHideFunction.call(this, $sub, complete);
Packit 1c1d7e
						} else {
Packit 1c1d7e
							$sub.hide(this.opts.collapsibleHideDuration, complete);
Packit 1c1d7e
						}
Packit 1c1d7e
					} else {
Packit 1c1d7e
						if (this.opts.hideFunction) {
Packit 1c1d7e
							this.opts.hideFunction.call(this, $sub, complete);
Packit 1c1d7e
						} else {
Packit 1c1d7e
							$sub.hide(this.opts.hideDuration, complete);
Packit 1c1d7e
						}
Packit 1c1d7e
					}
Packit 1c1d7e
					// remove IE iframe shim
Packit 1c1d7e
					if ($sub.dataSM('ie-shim')) {
Packit 1c1d7e
						$sub.dataSM('ie-shim').remove().css({ '-webkit-transform': '', transform: '' });
Packit 1c1d7e
					}
Packit 1c1d7e
					// deactivate scrolling if it is activated for this sub
Packit 1c1d7e
					if ($sub.dataSM('scroll')) {
Packit 1c1d7e
						this.menuScrollStop($sub);
Packit 1c1d7e
						$sub.css({ 'touch-action': '', '-ms-touch-action': '', '-webkit-transform': '', transform: '' })
Packit 1c1d7e
							.unbind('.smartmenus_scroll').removeDataSM('scroll').dataSM('scroll-arrows').hide();
Packit 1c1d7e
					}
Packit 1c1d7e
					// unhighlight parent item + accessibility
Packit 1c1d7e
					$sub.dataSM('parent-a').removeClass('highlighted').attr('aria-expanded', 'false');
Packit 1c1d7e
					$sub.attr({
Packit 1c1d7e
						'aria-expanded': 'false',
Packit 1c1d7e
						'aria-hidden': 'true'
Packit 1c1d7e
					});
Packit 1c1d7e
					var level = $sub.dataSM('level');
Packit 1c1d7e
					this.activatedItems.splice(level - 1, 1);
Packit 1c1d7e
					this.visibleSubMenus.splice($.inArray($sub, this.visibleSubMenus), 1);
Packit 1c1d7e
					this.$root.triggerHandler('hide.smapi', $sub[0]);
Packit 1c1d7e
				}
Packit 1c1d7e
			},
Packit 1c1d7e
			menuHideAll: function() {
Packit 1c1d7e
				if (this.showTimeout) {
Packit 1c1d7e
					clearTimeout(this.showTimeout);
Packit 1c1d7e
					this.showTimeout = 0;
Packit 1c1d7e
				}
Packit 1c1d7e
				// hide all subs
Packit 1c1d7e
				// if it's a popup, this.visibleSubMenus[0] is the root UL
Packit 1c1d7e
				var level = this.opts.isPopup ? 1 : 0;
Packit 1c1d7e
				for (var i = this.visibleSubMenus.length - 1; i >= level; i--) {
Packit 1c1d7e
					this.menuHide(this.visibleSubMenus[i]);
Packit 1c1d7e
				}
Packit 1c1d7e
				// hide root if it's popup
Packit 1c1d7e
				if (this.opts.isPopup) {
Packit 1c1d7e
					this.$root.stop(true, true);
Packit 1c1d7e
					if (this.$root.is(':visible')) {
Packit 1c1d7e
						if (this.opts.hideFunction) {
Packit 1c1d7e
							this.opts.hideFunction.call(this, this.$root);
Packit 1c1d7e
						} else {
Packit 1c1d7e
							this.$root.hide(this.opts.hideDuration);
Packit 1c1d7e
						}
Packit 1c1d7e
						// remove IE iframe shim
Packit 1c1d7e
						if (this.$root.dataSM('ie-shim')) {
Packit 1c1d7e
							this.$root.dataSM('ie-shim').remove();
Packit 1c1d7e
						}
Packit 1c1d7e
					}
Packit 1c1d7e
				}
Packit 1c1d7e
				this.activatedItems = [];
Packit 1c1d7e
				this.visibleSubMenus = [];
Packit 1c1d7e
				this.clickActivated = false;
Packit 1c1d7e
				this.focusActivated = false;
Packit 1c1d7e
				// reset z-index increment
Packit 1c1d7e
				this.zIndexInc = 0;
Packit 1c1d7e
				this.$root.triggerHandler('hideAll.smapi');
Packit 1c1d7e
			},
Packit 1c1d7e
			menuHideSubMenus: function(level) {
Packit 1c1d7e
				for (var i = this.activatedItems.length - 1; i >= level; i--) {
Packit 1c1d7e
					var $sub = this.activatedItems[i].dataSM('sub');
Packit 1c1d7e
					if ($sub) {
Packit 1c1d7e
						this.menuHide($sub);
Packit 1c1d7e
					}
Packit 1c1d7e
				}
Packit 1c1d7e
			},
Packit 1c1d7e
			menuIframeShim: function($ul) {
Packit 1c1d7e
				// create iframe shim for the menu
Packit 1c1d7e
				if (IE && this.opts.overlapControlsInIE && !$ul.dataSM('ie-shim')) {
Packit 1c1d7e
					$ul.dataSM('ie-shim', $('<iframe/>').attr({ src: 'javascript:0', tabindex: -9 })
Packit 1c1d7e
						.css({ position: 'absolute', top: 'auto', left: '0', opacity: 0, border: '0' })
Packit 1c1d7e
					);
Packit 1c1d7e
				}
Packit 1c1d7e
			},
Packit 1c1d7e
			menuInit: function($ul) {
Packit 1c1d7e
				if (!$ul.dataSM('in-mega')) {
Packit 1c1d7e
					// mark UL's in mega drop downs (if any) so we can neglect them
Packit 1c1d7e
					if ($ul.hasClass('mega-menu')) {
Packit 1c1d7e
						$ul.find('ul').dataSM('in-mega', true);
Packit 1c1d7e
					}
Packit 1c1d7e
					// get level (much faster than, for example, using parentsUntil)
Packit 1c1d7e
					var level = 2,
Packit 1c1d7e
						par = $ul[0];
Packit 1c1d7e
					while ((par = par.parentNode.parentNode) != this.$root[0]) {
Packit 1c1d7e
						level++;
Packit 1c1d7e
					}
Packit 1c1d7e
					// cache stuff for quick access
Packit 1c1d7e
					var $a = $ul.prevAll('a').eq(-1);
Packit 1c1d7e
					// if the link is nested (e.g. in a heading)
Packit 1c1d7e
					if (!$a.length) {
Packit 1c1d7e
						$a = $ul.prevAll().find('a').eq(-1);
Packit 1c1d7e
					}
Packit 1c1d7e
					$a.addClass('has-submenu').dataSM('sub', $ul);
Packit 1c1d7e
					$ul.dataSM('parent-a', $a)
Packit 1c1d7e
						.dataSM('level', level)
Packit 1c1d7e
						.parent().dataSM('sub', $ul);
Packit 1c1d7e
					// accessibility
Packit 1c1d7e
					var aId = $a.attr('id') || this.accessIdPrefix + (++this.idInc),
Packit 1c1d7e
						ulId = $ul.attr('id') || this.accessIdPrefix + (++this.idInc);
Packit 1c1d7e
					$a.attr({
Packit 1c1d7e
						id: aId,
Packit 1c1d7e
						'aria-haspopup': 'true',
Packit 1c1d7e
						'aria-controls': ulId,
Packit 1c1d7e
						'aria-expanded': 'false'
Packit 1c1d7e
					});
Packit 1c1d7e
					$ul.attr({
Packit 1c1d7e
						id: ulId,
Packit 1c1d7e
						'role': 'group',
Packit 1c1d7e
						'aria-hidden': 'true',
Packit 1c1d7e
						'aria-labelledby': aId,
Packit 1c1d7e
						'aria-expanded': 'false'
Packit 1c1d7e
					});
Packit 1c1d7e
					// add sub indicator to parent item
Packit 1c1d7e
					if (this.opts.subIndicators) {
Packit 1c1d7e
						$a[this.opts.subIndicatorsPos](this.$subArrow.clone());
Packit 1c1d7e
					}
Packit 1c1d7e
				}
Packit 1c1d7e
			},
Packit 1c1d7e
			menuPosition: function($sub) {
Packit 1c1d7e
				var $a = $sub.dataSM('parent-a'),
Packit 1c1d7e
					$li = $a.closest('li'),
Packit 1c1d7e
					$ul = $li.parent(),
Packit 1c1d7e
					level = $sub.dataSM('level'),
Packit 1c1d7e
					subW = this.getWidth($sub),
Packit 1c1d7e
					subH = this.getHeight($sub),
Packit 1c1d7e
					itemOffset = $a.offset(),
Packit 1c1d7e
					itemX = itemOffset.left,
Packit 1c1d7e
					itemY = itemOffset.top,
Packit 1c1d7e
					itemW = this.getWidth($a),
Packit 1c1d7e
					itemH = this.getHeight($a),
Packit 1c1d7e
					$win = $(window),
Packit 1c1d7e
					winX = $win.scrollLeft(),
Packit 1c1d7e
					winY = $win.scrollTop(),
Packit 1c1d7e
					winW = this.getViewportWidth(),
Packit 1c1d7e
					winH = this.getViewportHeight(),
Packit 1c1d7e
					horizontalParent = $ul.parent().is('[data-sm-horizontal-sub]') || level == 2 && !$ul.hasClass('sm-vertical'),
Packit 1c1d7e
					rightToLeft = this.opts.rightToLeftSubMenus && !$li.is('[data-sm-reverse]') || !this.opts.rightToLeftSubMenus && $li.is('[data-sm-reverse]'),
Packit 1c1d7e
					subOffsetX = level == 2 ? this.opts.mainMenuSubOffsetX : this.opts.subMenusSubOffsetX,
Packit 1c1d7e
					subOffsetY = level == 2 ? this.opts.mainMenuSubOffsetY : this.opts.subMenusSubOffsetY,
Packit 1c1d7e
					x, y;
Packit 1c1d7e
				if (horizontalParent) {
Packit 1c1d7e
					x = rightToLeft ? itemW - subW - subOffsetX : subOffsetX;
Packit 1c1d7e
					y = this.opts.bottomToTopSubMenus ? -subH - subOffsetY : itemH + subOffsetY;
Packit 1c1d7e
				} else {
Packit 1c1d7e
					x = rightToLeft ? subOffsetX - subW : itemW - subOffsetX;
Packit 1c1d7e
					y = this.opts.bottomToTopSubMenus ? itemH - subOffsetY - subH : subOffsetY;
Packit 1c1d7e
				}
Packit 1c1d7e
				if (this.opts.keepInViewport) {
Packit 1c1d7e
					var absX = itemX + x,
Packit 1c1d7e
						absY = itemY + y;
Packit 1c1d7e
					if (rightToLeft && absX < winX) {
Packit 1c1d7e
						x = horizontalParent ? winX - absX + x : itemW - subOffsetX;
Packit 1c1d7e
					} else if (!rightToLeft && absX + subW > winX + winW) {
Packit 1c1d7e
						x = horizontalParent ? winX + winW - subW - absX + x : subOffsetX - subW;
Packit 1c1d7e
					}
Packit 1c1d7e
					if (!horizontalParent) {
Packit 1c1d7e
						if (subH < winH && absY + subH > winY + winH) {
Packit 1c1d7e
							y += winY + winH - subH - absY;
Packit 1c1d7e
						} else if (subH >= winH || absY < winY) {
Packit 1c1d7e
							y += winY - absY;
Packit 1c1d7e
						}
Packit 1c1d7e
					}
Packit 1c1d7e
					// do we need scrolling?
Packit 1c1d7e
					// 0.49 used for better precision when dealing with float values
Packit 1c1d7e
					if (horizontalParent && (absY + subH > winY + winH + 0.49 || absY < winY) || !horizontalParent && subH > winH + 0.49) {
Packit 1c1d7e
						var self = this;
Packit 1c1d7e
						if (!$sub.dataSM('scroll-arrows')) {
Packit 1c1d7e
							$sub.dataSM('scroll-arrows', $([$('')[0], $('')[0]])
Packit 1c1d7e
								.bind({
Packit 1c1d7e
									mouseenter: function() {
Packit 1c1d7e
										$sub.dataSM('scroll').up = $(this).hasClass('scroll-up');
Packit 1c1d7e
										self.menuScroll($sub);
Packit 1c1d7e
									},
Packit 1c1d7e
									mouseleave: function(e) {
Packit 1c1d7e
										self.menuScrollStop($sub);
Packit 1c1d7e
										self.menuScrollOut($sub, e);
Packit 1c1d7e
									},
Packit 1c1d7e
									'mousewheel DOMMouseScroll': function(e) { e.preventDefault(); }
Packit 1c1d7e
								})
Packit 1c1d7e
								.insertAfter($sub)
Packit 1c1d7e
							);
Packit 1c1d7e
						}
Packit 1c1d7e
						// bind scroll events and save scroll data for this sub
Packit 1c1d7e
						var eNS = '.smartmenus_scroll';
Packit 1c1d7e
						$sub.dataSM('scroll', {
Packit 1c1d7e
								y: this.cssTransforms3d ? 0 : y - itemH,
Packit 1c1d7e
								step: 1,
Packit 1c1d7e
								// cache stuff for faster recalcs later
Packit 1c1d7e
								itemH: itemH,
Packit 1c1d7e
								subH: subH,
Packit 1c1d7e
								arrowDownH: this.getHeight($sub.dataSM('scroll-arrows').eq(1))
Packit 1c1d7e
							})
Packit 1c1d7e
							.bind(getEventsNS([
Packit 1c1d7e
								['mouseover', function(e) { self.menuScrollOver($sub, e); }],
Packit 1c1d7e
								['mouseout', function(e) { self.menuScrollOut($sub, e); }],
Packit 1c1d7e
								['mousewheel DOMMouseScroll', function(e) { self.menuScrollMousewheel($sub, e); }]
Packit 1c1d7e
							], eNS))
Packit 1c1d7e
							.dataSM('scroll-arrows').css({ top: 'auto', left: '0', marginLeft: x + (parseInt($sub.css('border-left-width')) || 0), width: subW - (parseInt($sub.css('border-left-width')) || 0) - (parseInt($sub.css('border-right-width')) || 0), zIndex: $sub.css('z-index') })
Packit 1c1d7e
								.eq(horizontalParent && this.opts.bottomToTopSubMenus ? 0 : 1).show();
Packit 1c1d7e
						// when a menu tree is fixed positioned we allow scrolling via touch too
Packit 1c1d7e
						// since there is no other way to access such long sub menus if no mouse is present
Packit 1c1d7e
						if (this.isFixed()) {
Packit 1c1d7e
							$sub.css({ 'touch-action': 'none', '-ms-touch-action': 'none' })
Packit 1c1d7e
								.bind(getEventsNS([
Packit 1c1d7e
									[touchEvents ? 'touchstart touchmove touchend' : 'pointerdown pointermove pointerup MSPointerDown MSPointerMove MSPointerUp', function(e) {
Packit 1c1d7e
										self.menuScrollTouch($sub, e);
Packit 1c1d7e
									}]
Packit 1c1d7e
								], eNS));
Packit 1c1d7e
						}
Packit 1c1d7e
					}
Packit 1c1d7e
				}
Packit 1c1d7e
				$sub.css({ top: 'auto', left: '0', marginLeft: x, marginTop: y - itemH });
Packit 1c1d7e
				// IE iframe shim
Packit 1c1d7e
				this.menuIframeShim($sub);
Packit 1c1d7e
				if ($sub.dataSM('ie-shim')) {
Packit 1c1d7e
					$sub.dataSM('ie-shim').css({ zIndex: $sub.css('z-index'), width: subW, height: subH, marginLeft: x, marginTop: y - itemH });
Packit 1c1d7e
				}
Packit 1c1d7e
			},
Packit 1c1d7e
			menuScroll: function($sub, once, step) {
Packit 1c1d7e
				var data = $sub.dataSM('scroll'),
Packit 1c1d7e
					$arrows = $sub.dataSM('scroll-arrows'),
Packit 1c1d7e
					end = data.up ? data.upEnd : data.downEnd,
Packit 1c1d7e
					diff;
Packit 1c1d7e
				if (!once && data.momentum) {
Packit 1c1d7e
					data.momentum *= 0.92;
Packit 1c1d7e
					diff = data.momentum;
Packit 1c1d7e
					if (diff < 0.5) {
Packit 1c1d7e
						this.menuScrollStop($sub);
Packit 1c1d7e
						return;
Packit 1c1d7e
					}
Packit 1c1d7e
				} else {
Packit 1c1d7e
					diff = step || (once || !this.opts.scrollAccelerate ? this.opts.scrollStep : Math.floor(data.step));
Packit 1c1d7e
				}
Packit 1c1d7e
				// hide any visible deeper level sub menus
Packit 1c1d7e
				var level = $sub.dataSM('level');
Packit 1c1d7e
				if (this.activatedItems[level - 1] && this.activatedItems[level - 1].dataSM('sub') && this.activatedItems[level - 1].dataSM('sub').is(':visible')) {
Packit 1c1d7e
					this.menuHideSubMenus(level - 1);
Packit 1c1d7e
				}
Packit 1c1d7e
				data.y = data.up && end <= data.y || !data.up && end >= data.y ? data.y : (Math.abs(end - data.y) > diff ? data.y + (data.up ? diff : -diff) : end);
Packit 1c1d7e
				$sub.add($sub.dataSM('ie-shim')).css(this.cssTransforms3d ? { '-webkit-transform': 'translate3d(0, ' + data.y + 'px, 0)', transform: 'translate3d(0, ' + data.y + 'px, 0)' } : { marginTop: data.y });
Packit 1c1d7e
				// show opposite arrow if appropriate
Packit 1c1d7e
				if (mouse && (data.up && data.y > data.downEnd || !data.up && data.y < data.upEnd)) {
Packit 1c1d7e
					$arrows.eq(data.up ? 1 : 0).show();
Packit 1c1d7e
				}
Packit 1c1d7e
				// if we've reached the end
Packit 1c1d7e
				if (data.y == end) {
Packit 1c1d7e
					if (mouse) {
Packit 1c1d7e
						$arrows.eq(data.up ? 0 : 1).hide();
Packit 1c1d7e
					}
Packit 1c1d7e
					this.menuScrollStop($sub);
Packit 1c1d7e
				} else if (!once) {
Packit 1c1d7e
					if (this.opts.scrollAccelerate && data.step < this.opts.scrollStep) {
Packit 1c1d7e
						data.step += 0.2;
Packit 1c1d7e
					}
Packit 1c1d7e
					var self = this;
Packit 1c1d7e
					this.scrollTimeout = requestAnimationFrame(function() { self.menuScroll($sub); });
Packit 1c1d7e
				}
Packit 1c1d7e
			},
Packit 1c1d7e
			menuScrollMousewheel: function($sub, e) {
Packit 1c1d7e
				if (this.getClosestMenu(e.target) == $sub[0]) {
Packit 1c1d7e
					e = e.originalEvent;
Packit 1c1d7e
					var up = (e.wheelDelta || -e.detail) > 0;
Packit 1c1d7e
					if ($sub.dataSM('scroll-arrows').eq(up ? 0 : 1).is(':visible')) {
Packit 1c1d7e
						$sub.dataSM('scroll').up = up;
Packit 1c1d7e
						this.menuScroll($sub, true);
Packit 1c1d7e
					}
Packit 1c1d7e
				}
Packit 1c1d7e
				e.preventDefault();
Packit 1c1d7e
			},
Packit 1c1d7e
			menuScrollOut: function($sub, e) {
Packit 1c1d7e
				if (mouse) {
Packit 1c1d7e
					if (!/^scroll-(up|down)/.test((e.relatedTarget || '').className) && ($sub[0] != e.relatedTarget && !$.contains($sub[0], e.relatedTarget) || this.getClosestMenu(e.relatedTarget) != $sub[0])) {
Packit 1c1d7e
						$sub.dataSM('scroll-arrows').css('visibility', 'hidden');
Packit 1c1d7e
					}
Packit 1c1d7e
				}
Packit 1c1d7e
			},
Packit 1c1d7e
			menuScrollOver: function($sub, e) {
Packit 1c1d7e
				if (mouse) {
Packit 1c1d7e
					if (!/^scroll-(up|down)/.test(e.target.className) && this.getClosestMenu(e.target) == $sub[0]) {
Packit 1c1d7e
						this.menuScrollRefreshData($sub);
Packit 1c1d7e
						var data = $sub.dataSM('scroll'),
Packit 1c1d7e
							upEnd = $(window).scrollTop() - $sub.dataSM('parent-a').offset().top - data.itemH;
Packit 1c1d7e
						$sub.dataSM('scroll-arrows').eq(0).css('margin-top', upEnd).end()
Packit 1c1d7e
							.eq(1).css('margin-top', upEnd + this.getViewportHeight() - data.arrowDownH).end()
Packit 1c1d7e
							.css('visibility', 'visible');
Packit 1c1d7e
					}
Packit 1c1d7e
				}
Packit 1c1d7e
			},
Packit 1c1d7e
			menuScrollRefreshData: function($sub) {
Packit 1c1d7e
				var data = $sub.dataSM('scroll'),
Packit 1c1d7e
					upEnd = $(window).scrollTop() - $sub.dataSM('parent-a').offset().top - data.itemH;
Packit 1c1d7e
				if (this.cssTransforms3d) {
Packit 1c1d7e
					upEnd = -(parseFloat($sub.css('margin-top')) - upEnd);
Packit 1c1d7e
				}
Packit 1c1d7e
				$.extend(data, {
Packit 1c1d7e
					upEnd: upEnd,
Packit 1c1d7e
					downEnd: upEnd + this.getViewportHeight() - data.subH
Packit 1c1d7e
				});
Packit 1c1d7e
			},
Packit 1c1d7e
			menuScrollStop: function($sub) {
Packit 1c1d7e
				if (this.scrollTimeout) {
Packit 1c1d7e
					cancelAnimationFrame(this.scrollTimeout);
Packit 1c1d7e
					this.scrollTimeout = 0;
Packit 1c1d7e
					$sub.dataSM('scroll').step = 1;
Packit 1c1d7e
					return true;
Packit 1c1d7e
				}
Packit 1c1d7e
			},
Packit 1c1d7e
			menuScrollTouch: function($sub, e) {
Packit 1c1d7e
				e = e.originalEvent;
Packit 1c1d7e
				if (isTouchEvent(e)) {
Packit 1c1d7e
					var touchPoint = this.getTouchPoint(e);
Packit 1c1d7e
					// neglect event if we touched a visible deeper level sub menu
Packit 1c1d7e
					if (this.getClosestMenu(touchPoint.target) == $sub[0]) {
Packit 1c1d7e
						var data = $sub.dataSM('scroll');
Packit 1c1d7e
						if (/(start|down)$/i.test(e.type)) {
Packit 1c1d7e
							if (this.menuScrollStop($sub)) {
Packit 1c1d7e
								// if we were scrolling, just stop and don't activate any link on the first touch
Packit 1c1d7e
								e.preventDefault();
Packit 1c1d7e
								this.$touchScrollingSub = $sub;
Packit 1c1d7e
							} else {
Packit 1c1d7e
								this.$touchScrollingSub = null;
Packit 1c1d7e
							}
Packit 1c1d7e
							// update scroll data since the user might have zoomed, etc.
Packit 1c1d7e
							this.menuScrollRefreshData($sub);
Packit 1c1d7e
							// extend it with the touch properties
Packit 1c1d7e
							$.extend(data, {
Packit 1c1d7e
								touchStartY: touchPoint.pageY,
Packit 1c1d7e
								touchStartTime: e.timeStamp
Packit 1c1d7e
							});
Packit 1c1d7e
						} else if (/move$/i.test(e.type)) {
Packit 1c1d7e
							var prevY = data.touchY !== undefined ? data.touchY : data.touchStartY;
Packit 1c1d7e
							if (prevY !== undefined && prevY != touchPoint.pageY) {
Packit 1c1d7e
								this.$touchScrollingSub = $sub;
Packit 1c1d7e
								var up = prevY < touchPoint.pageY;
Packit 1c1d7e
								// changed direction? reset...
Packit 1c1d7e
								if (data.up !== undefined && data.up != up) {
Packit 1c1d7e
									$.extend(data, {
Packit 1c1d7e
										touchStartY: touchPoint.pageY,
Packit 1c1d7e
										touchStartTime: e.timeStamp
Packit 1c1d7e
									});
Packit 1c1d7e
								}
Packit 1c1d7e
								$.extend(data, {
Packit 1c1d7e
									up: up,
Packit 1c1d7e
									touchY: touchPoint.pageY
Packit 1c1d7e
								});
Packit 1c1d7e
								this.menuScroll($sub, true, Math.abs(touchPoint.pageY - prevY));
Packit 1c1d7e
							}
Packit 1c1d7e
							e.preventDefault();
Packit 1c1d7e
						} else { // touchend/pointerup
Packit 1c1d7e
							if (data.touchY !== undefined) {
Packit 1c1d7e
								if (data.momentum = Math.pow(Math.abs(touchPoint.pageY - data.touchStartY) / (e.timeStamp - data.touchStartTime), 2) * 15) {
Packit 1c1d7e
									this.menuScrollStop($sub);
Packit 1c1d7e
									this.menuScroll($sub);
Packit 1c1d7e
									e.preventDefault();
Packit 1c1d7e
								}
Packit 1c1d7e
								delete data.touchY;
Packit 1c1d7e
							}
Packit 1c1d7e
						}
Packit 1c1d7e
					}
Packit 1c1d7e
				}
Packit 1c1d7e
			},
Packit 1c1d7e
			menuShow: function($sub) {
Packit 1c1d7e
				if (!$sub.dataSM('beforefirstshowfired')) {
Packit 1c1d7e
					$sub.dataSM('beforefirstshowfired', true);
Packit 1c1d7e
					if (this.$root.triggerHandler('beforefirstshow.smapi', $sub[0]) === false) {
Packit 1c1d7e
						return;
Packit 1c1d7e
					}
Packit 1c1d7e
				}
Packit 1c1d7e
				if (this.$root.triggerHandler('beforeshow.smapi', $sub[0]) === false) {
Packit 1c1d7e
					return;
Packit 1c1d7e
				}
Packit 1c1d7e
				$sub.dataSM('shown-before', true)
Packit 1c1d7e
					.stop(true, true);
Packit 1c1d7e
				if (!$sub.is(':visible')) {
Packit 1c1d7e
					// highlight parent item
Packit 1c1d7e
					var $a = $sub.dataSM('parent-a');
Packit 1c1d7e
					if (this.opts.keepHighlighted || this.isCollapsible()) {
Packit 1c1d7e
						$a.addClass('highlighted');
Packit 1c1d7e
					}
Packit 1c1d7e
					if (this.isCollapsible()) {
Packit 1c1d7e
						$sub.removeClass('sm-nowrap').css({ zIndex: '', width: 'auto', minWidth: '', maxWidth: '', top: '', left: '', marginLeft: '', marginTop: '' });
Packit 1c1d7e
					} else {
Packit 1c1d7e
						// set z-index
Packit 1c1d7e
						$sub.css('z-index', this.zIndexInc = (this.zIndexInc || this.getStartZIndex()) + 1);
Packit 1c1d7e
						// min/max-width fix - no way to rely purely on CSS as all UL's are nested
Packit 1c1d7e
						if (this.opts.subMenusMinWidth || this.opts.subMenusMaxWidth) {
Packit 1c1d7e
							$sub.css({ width: 'auto', minWidth: '', maxWidth: '' }).addClass('sm-nowrap');
Packit 1c1d7e
							if (this.opts.subMenusMinWidth) {
Packit 1c1d7e
							 	$sub.css('min-width', this.opts.subMenusMinWidth);
Packit 1c1d7e
							}
Packit 1c1d7e
							if (this.opts.subMenusMaxWidth) {
Packit 1c1d7e
							 	var noMaxWidth = this.getWidth($sub);
Packit 1c1d7e
							 	$sub.css('max-width', this.opts.subMenusMaxWidth);
Packit 1c1d7e
								if (noMaxWidth > this.getWidth($sub)) {
Packit 1c1d7e
									$sub.removeClass('sm-nowrap').css('width', this.opts.subMenusMaxWidth);
Packit 1c1d7e
								}
Packit 1c1d7e
							}
Packit 1c1d7e
						}
Packit 1c1d7e
						this.menuPosition($sub);
Packit 1c1d7e
						// insert IE iframe shim
Packit 1c1d7e
						if ($sub.dataSM('ie-shim')) {
Packit 1c1d7e
							$sub.dataSM('ie-shim').insertBefore($sub);
Packit 1c1d7e
						}
Packit 1c1d7e
					}
Packit 1c1d7e
					var complete = function() {
Packit 1c1d7e
						// fix: "overflow: hidden;" is not reset on animation complete in jQuery < 1.9.0 in Chrome when global "box-sizing: border-box;" is used
Packit 1c1d7e
						$sub.css('overflow', '');
Packit 1c1d7e
					};
Packit 1c1d7e
					// if sub is collapsible (mobile view)
Packit 1c1d7e
					if (this.isCollapsible()) {
Packit 1c1d7e
						if (this.opts.collapsibleShowFunction) {
Packit 1c1d7e
							this.opts.collapsibleShowFunction.call(this, $sub, complete);
Packit 1c1d7e
						} else {
Packit 1c1d7e
							$sub.show(this.opts.collapsibleShowDuration, complete);
Packit 1c1d7e
						}
Packit 1c1d7e
					} else {
Packit 1c1d7e
						if (this.opts.showFunction) {
Packit 1c1d7e
							this.opts.showFunction.call(this, $sub, complete);
Packit 1c1d7e
						} else {
Packit 1c1d7e
							$sub.show(this.opts.showDuration, complete);
Packit 1c1d7e
						}
Packit 1c1d7e
					}
Packit 1c1d7e
					// accessibility
Packit 1c1d7e
					$a.attr('aria-expanded', 'true');
Packit 1c1d7e
					$sub.attr({
Packit 1c1d7e
						'aria-expanded': 'true',
Packit 1c1d7e
						'aria-hidden': 'false'
Packit 1c1d7e
					});
Packit 1c1d7e
					// store sub menu in visible array
Packit 1c1d7e
					this.visibleSubMenus.push($sub);
Packit 1c1d7e
					this.$root.triggerHandler('show.smapi', $sub[0]);
Packit 1c1d7e
				}
Packit 1c1d7e
			},
Packit 1c1d7e
			popupHide: function(noHideTimeout) {
Packit 1c1d7e
				if (this.hideTimeout) {
Packit 1c1d7e
					clearTimeout(this.hideTimeout);
Packit 1c1d7e
					this.hideTimeout = 0;
Packit 1c1d7e
				}
Packit 1c1d7e
				var self = this;
Packit 1c1d7e
				this.hideTimeout = setTimeout(function() {
Packit 1c1d7e
					self.menuHideAll();
Packit 1c1d7e
				}, noHideTimeout ? 1 : this.opts.hideTimeout);
Packit 1c1d7e
			},
Packit 1c1d7e
			popupShow: function(left, top) {
Packit 1c1d7e
				if (!this.opts.isPopup) {
Packit 1c1d7e
					alert('SmartMenus jQuery Error:\n\nIf you want to show this menu via the "popupShow" method, set the isPopup:true option.');
Packit 1c1d7e
					return;
Packit 1c1d7e
				}
Packit 1c1d7e
				if (this.hideTimeout) {
Packit 1c1d7e
					clearTimeout(this.hideTimeout);
Packit 1c1d7e
					this.hideTimeout = 0;
Packit 1c1d7e
				}
Packit 1c1d7e
				this.$root.dataSM('shown-before', true)
Packit 1c1d7e
					.stop(true, true);
Packit 1c1d7e
				if (!this.$root.is(':visible')) {
Packit 1c1d7e
					this.$root.css({ left: left, top: top });
Packit 1c1d7e
					// IE iframe shim
Packit 1c1d7e
					this.menuIframeShim(this.$root);
Packit 1c1d7e
					if (this.$root.dataSM('ie-shim')) {
Packit 1c1d7e
						this.$root.dataSM('ie-shim').css({ zIndex: this.$root.css('z-index'), width: this.getWidth(this.$root), height: this.getHeight(this.$root), left: left, top: top }).insertBefore(this.$root);
Packit 1c1d7e
					}
Packit 1c1d7e
					// show menu
Packit 1c1d7e
					var self = this,
Packit 1c1d7e
						complete = function() {
Packit 1c1d7e
							self.$root.css('overflow', '');
Packit 1c1d7e
						};
Packit 1c1d7e
					if (this.opts.showFunction) {
Packit 1c1d7e
						this.opts.showFunction.call(this, this.$root, complete);
Packit 1c1d7e
					} else {
Packit 1c1d7e
						this.$root.show(this.opts.showDuration, complete);
Packit 1c1d7e
					}
Packit 1c1d7e
					this.visibleSubMenus[0] = this.$root;
Packit 1c1d7e
				}
Packit 1c1d7e
			},
Packit 1c1d7e
			refresh: function() {
Packit 1c1d7e
				this.destroy(true);
Packit 1c1d7e
				this.init(true);
Packit 1c1d7e
			},
Packit 1c1d7e
			rootKeyDown: function(e) {
Packit 1c1d7e
				if (!this.handleEvents()) {
Packit 1c1d7e
					return;
Packit 1c1d7e
				}
Packit 1c1d7e
				switch (e.keyCode) {
Packit 1c1d7e
					case 27: // reset on Esc
Packit 1c1d7e
						var $activeTopItem = this.activatedItems[0];
Packit 1c1d7e
						if ($activeTopItem) {
Packit 1c1d7e
							this.menuHideAll();
Packit 1c1d7e
							$activeTopItem[0].focus();
Packit 1c1d7e
							var $sub = $activeTopItem.dataSM('sub');
Packit 1c1d7e
							if ($sub) {
Packit 1c1d7e
								this.menuHide($sub);
Packit 1c1d7e
							}
Packit 1c1d7e
						}
Packit 1c1d7e
						break;
Packit 1c1d7e
					case 32: // activate item's sub on Space
Packit 1c1d7e
						var $target = $(e.target);
Packit 1c1d7e
						if ($target.is('a') && this.handleItemEvents($target)) {
Packit 1c1d7e
							var $sub = $target.dataSM('sub');
Packit 1c1d7e
							if ($sub && !$sub.is(':visible')) {
Packit 1c1d7e
								this.itemClick({ currentTarget: e.target });
Packit 1c1d7e
								e.preventDefault();
Packit 1c1d7e
							}
Packit 1c1d7e
						}
Packit 1c1d7e
						break;
Packit 1c1d7e
				}
Packit 1c1d7e
			},
Packit 1c1d7e
			rootOut: function(e) {
Packit 1c1d7e
				if (!this.handleEvents() || this.isTouchMode() || e.target == this.$root[0]) {
Packit 1c1d7e
					return;
Packit 1c1d7e
				}
Packit 1c1d7e
				if (this.hideTimeout) {
Packit 1c1d7e
					clearTimeout(this.hideTimeout);
Packit 1c1d7e
					this.hideTimeout = 0;
Packit 1c1d7e
				}
Packit 1c1d7e
				if (!this.opts.showOnClick || !this.opts.hideOnClick) {
Packit 1c1d7e
					var self = this;
Packit 1c1d7e
					this.hideTimeout = setTimeout(function() { self.menuHideAll(); }, this.opts.hideTimeout);
Packit 1c1d7e
				}
Packit 1c1d7e
			},
Packit 1c1d7e
			rootOver: function(e) {
Packit 1c1d7e
				if (!this.handleEvents() || this.isTouchMode() || e.target == this.$root[0]) {
Packit 1c1d7e
					return;
Packit 1c1d7e
				}
Packit 1c1d7e
				if (this.hideTimeout) {
Packit 1c1d7e
					clearTimeout(this.hideTimeout);
Packit 1c1d7e
					this.hideTimeout = 0;
Packit 1c1d7e
				}
Packit 1c1d7e
			},
Packit 1c1d7e
			winResize: function(e) {
Packit 1c1d7e
				if (!this.handleEvents()) {
Packit 1c1d7e
					// we still need to resize the disable overlay if it's visible
Packit 1c1d7e
					if (this.$disableOverlay) {
Packit 1c1d7e
						var pos = this.$root.offset();
Packit 1c1d7e
	 					this.$disableOverlay.css({
Packit 1c1d7e
							top: pos.top,
Packit 1c1d7e
							left: pos.left,
Packit 1c1d7e
							width: this.$root.outerWidth(),
Packit 1c1d7e
							height: this.$root.outerHeight()
Packit 1c1d7e
						});
Packit 1c1d7e
					}
Packit 1c1d7e
					return;
Packit 1c1d7e
				}
Packit 1c1d7e
				// hide sub menus on resize - on mobile do it only on orientation change
Packit 1c1d7e
				if (!('onorientationchange' in window) || e.type == 'orientationchange') {
Packit 1c1d7e
					var isCollapsible = this.isCollapsible();
Packit 1c1d7e
					// if it was collapsible before resize and still is, don't do it
Packit 1c1d7e
					if (!(this.wasCollapsible && isCollapsible)) { 
Packit 1c1d7e
						if (this.activatedItems.length) {
Packit 1c1d7e
							this.activatedItems[this.activatedItems.length - 1][0].blur();
Packit 1c1d7e
						}
Packit 1c1d7e
						this.menuHideAll();
Packit 1c1d7e
					}
Packit 1c1d7e
					this.wasCollapsible = isCollapsible;
Packit 1c1d7e
				}
Packit 1c1d7e
			}
Packit 1c1d7e
		}
Packit 1c1d7e
	});
Packit 1c1d7e
Packit 1c1d7e
	$.fn.dataSM = function(key, val) {
Packit 1c1d7e
		if (val) {
Packit 1c1d7e
			return this.data(key + '_smartmenus', val);
Packit 1c1d7e
		}
Packit 1c1d7e
		return this.data(key + '_smartmenus');
Packit 1c1d7e
	}
Packit 1c1d7e
Packit 1c1d7e
	$.fn.removeDataSM = function(key) {
Packit 1c1d7e
		return this.removeData(key + '_smartmenus');
Packit 1c1d7e
	}
Packit 1c1d7e
Packit 1c1d7e
	$.fn.smartmenus = function(options) {
Packit 1c1d7e
		if (typeof options == 'string') {
Packit 1c1d7e
			var args = arguments,
Packit 1c1d7e
				method = options;
Packit 1c1d7e
			Array.prototype.shift.call(args);
Packit 1c1d7e
			return this.each(function() {
Packit 1c1d7e
				var smartmenus = $(this).data('smartmenus');
Packit 1c1d7e
				if (smartmenus && smartmenus[method]) {
Packit 1c1d7e
					smartmenus[method].apply(smartmenus, args);
Packit 1c1d7e
				}
Packit 1c1d7e
			});
Packit 1c1d7e
		}
Packit 1c1d7e
		var opts = $.extend({}, $.fn.smartmenus.defaults, options);
Packit 1c1d7e
		return this.each(function() {
Packit 1c1d7e
			new $.SmartMenus(this, opts);
Packit 1c1d7e
		});
Packit 1c1d7e
	}
Packit 1c1d7e
Packit 1c1d7e
	// default settings
Packit 1c1d7e
	$.fn.smartmenus.defaults = {
Packit 1c1d7e
		isPopup:		false,		// is this a popup menu (can be shown via the popupShow/popupHide methods) or a permanent menu bar
Packit 1c1d7e
		mainMenuSubOffsetX:	0,		// pixels offset from default position
Packit 1c1d7e
		mainMenuSubOffsetY:	0,		// pixels offset from default position
Packit 1c1d7e
		subMenusSubOffsetX:	0,		// pixels offset from default position
Packit 1c1d7e
		subMenusSubOffsetY:	0,		// pixels offset from default position
Packit 1c1d7e
		subMenusMinWidth:	'10em',		// min-width for the sub menus (any CSS unit) - if set, the fixed width set in CSS will be ignored
Packit 1c1d7e
		subMenusMaxWidth:	'20em',		// max-width for the sub menus (any CSS unit) - if set, the fixed width set in CSS will be ignored
Packit 1c1d7e
		subIndicators: 		true,		// create sub menu indicators - creates a SPAN and inserts it in the A
Packit 1c1d7e
		subIndicatorsPos: 	'prepend',	// position of the SPAN relative to the menu item content ('prepend', 'append')
Packit 1c1d7e
		subIndicatorsText:	'+',		// [optionally] add text in the SPAN (e.g. '+') (you may want to check the CSS for the sub indicators too)
Packit 1c1d7e
		scrollStep: 		30,		// pixels step when scrolling long sub menus that do not fit in the viewport height
Packit 1c1d7e
		scrollAccelerate:	true,		// accelerate scrolling or use a fixed step
Packit 1c1d7e
		showTimeout:		250,		// timeout before showing the sub menus
Packit 1c1d7e
		hideTimeout:		500,		// timeout before hiding the sub menus
Packit 1c1d7e
		showDuration:		0,		// duration for show animation - set to 0 for no animation - matters only if showFunction:null
Packit 1c1d7e
		showFunction:		null,		// custom function to use when showing a sub menu (the default is the jQuery 'show')
Packit 1c1d7e
							// don't forget to call complete() at the end of whatever you do
Packit 1c1d7e
							// e.g.: function($ul, complete) { $ul.fadeIn(250, complete); }
Packit 1c1d7e
		hideDuration:		0,		// duration for hide animation - set to 0 for no animation - matters only if hideFunction:null
Packit 1c1d7e
		hideFunction:		function($ul, complete) { $ul.fadeOut(200, complete); },	// custom function to use when hiding a sub menu (the default is the jQuery 'hide')
Packit 1c1d7e
							// don't forget to call complete() at the end of whatever you do
Packit 1c1d7e
							// e.g.: function($ul, complete) { $ul.fadeOut(250, complete); }
Packit 1c1d7e
		collapsibleShowDuration:0,		// duration for show animation for collapsible sub menus - matters only if collapsibleShowFunction:null
Packit 1c1d7e
		collapsibleShowFunction:function($ul, complete) { $ul.slideDown(200, complete); },	// custom function to use when showing a collapsible sub menu
Packit 1c1d7e
							// (i.e. when mobile styles are used to make the sub menus collapsible)
Packit 1c1d7e
		collapsibleHideDuration:0,		// duration for hide animation for collapsible sub menus - matters only if collapsibleHideFunction:null
Packit 1c1d7e
		collapsibleHideFunction:function($ul, complete) { $ul.slideUp(200, complete); },	// custom function to use when hiding a collapsible sub menu
Packit 1c1d7e
							// (i.e. when mobile styles are used to make the sub menus collapsible)
Packit 1c1d7e
		showOnClick:		false,		// show the first-level sub menus onclick instead of onmouseover (i.e. mimic desktop app menus) (matters only for mouse input)
Packit 1c1d7e
		hideOnClick:		true,		// hide the sub menus on click/tap anywhere on the page
Packit 1c1d7e
		noMouseOver:		false,		// disable sub menus activation onmouseover (i.e. behave like in touch mode - use just mouse clicks) (matters only for mouse input)
Packit 1c1d7e
		keepInViewport:		true,		// reposition the sub menus if needed to make sure they always appear inside the viewport
Packit 1c1d7e
		keepHighlighted:	true,		// keep all ancestor items of the current sub menu highlighted (adds the 'highlighted' class to the A's)
Packit 1c1d7e
		markCurrentItem:	false,		// automatically add the 'current' class to the A element of the item linking to the current URL
Packit 1c1d7e
		markCurrentTree:	true,		// add the 'current' class also to the A elements of all ancestor items of the current item
Packit 1c1d7e
		rightToLeftSubMenus:	false,		// right to left display of the sub menus (check the CSS for the sub indicators' position)
Packit 1c1d7e
		bottomToTopSubMenus:	false,		// bottom to top display of the sub menus
Packit 1c1d7e
		overlapControlsInIE:	true		// make sure sub menus appear on top of special OS controls in IE (i.e. SELECT, OBJECT, EMBED, etc.)
Packit 1c1d7e
	};
Packit 1c1d7e
Packit 1c1d7e
	return $;
Packit 1c1d7e
}));