diff --git a/app/js/jquery.okayNav.js b/app/js/jquery.okayNav.js
index 50815d0..f348460 100644
--- a/app/js/jquery.okayNav.js
+++ b/app/js/jquery.okayNav.js
@@ -1,5 +1,5 @@
/*!
- * jquery.okayNav.js 2.0.3 (https://github.com/VPenkov/okayNav)
+ * jquery.okayNav.js 2.0.4 (https://github.com/VPenkov/okayNav)
* Author: Vergil Penkov (http://vergilpenkov.com/)
* MIT license: https://opensource.org/licenses/MIT
*/
@@ -25,6 +25,7 @@
}
}(function($) {
// Defaults
+
var okayNav = 'okayNav',
defaults = {
parent: '', // will call nav's parent() by default
@@ -46,32 +47,31 @@
function Plugin(element, options) {
self = this;
this.options = $.extend({}, defaults, options);
- _options = this.options;
+ self.options = this.options;
- $navigation = $(element);
- $document = $(document);
- $window = $(window);
+ self.navigation = $(element);
+ self.document = $(document);
+ self.window = $(window);
- this.options.parent == '' ? this.options.parent = $navigation.parent() : '';
+ this.options.parent == '' ? this.options.parent = self.navigation.parent() : '';
- _nav_visible = false; // Store the state of the hidden nav
- _nav_full_width = 0;
- _parent_full_width = 0;
+ self.nav_open = false; // Store the state of the hidden nav
+ self.parent_full_width = 0;
// Swipe stuff
- radCoef = 180 / Math.PI;
- _sTouch = {
+ self.radCoef = 180 / Math.PI;
+ self.sTouch = {
x: 0,
y: 0
};
- _cTouch = {
+ self.cTouch = {
x: 0,
y: 0
};
- _sTime = 0;
- _nav_position = 0;
- _percent_open = 0;
- _nav_moving = false;
+ self.sTime = 0;
+ self.nav_position = 0;
+ self.percent_open = 0;
+ self.nav_moving = false;
self.init();
@@ -84,52 +84,52 @@
$('body').addClass('okayNav-loaded');
// Add classes
- $navigation
+ self.navigation
.addClass('okayNav loaded')
.children('ul').addClass('okayNav__nav--visible');
// Append elements
if (self.options.align_right) {
- $navigation
+ self.navigation
.append('
')
- .append('' + _options.toggle_icon_content + '')
+ .append('' + self.options.toggle_icon_content + '')
} else {
- $navigation
+ self.navigation
.prepend('')
- .prepend('' + _options.toggle_icon_content + '')
+ .prepend('' + self.options.toggle_icon_content + '')
}
// Cache new elements for further use
- $nav_visible = $navigation.children('.okayNav__nav--visible');
- $nav_invisible = $navigation.children('.okayNav__nav--invisible');
- $nav_toggle_icon = $navigation.children('.' + _options.toggle_icon_class);
+ self.nav_visible = self.navigation.children('.okayNav__nav--visible');
+ self.nav_invisible = self.navigation.children('.okayNav__nav--invisible');
+ self.toggle_icon = self.navigation.children('.' + self.options.toggle_icon_class);
- _toggle_icon_width = $nav_toggle_icon.outerWidth(true);
- _nav_default_width = self.getChildrenWidth($navigation);
- _parent_full_width = $(_options.parent).outerWidth(true);
- _last_visible_child_width = 0; // We'll define this later
+ self.toggle_icon_width = self.toggle_icon.outerWidth(true);
+ self.default_width = self.getChildrenWidth(self.navigation);
+ self.parent_full_width = $(self.options.parent).outerWidth(true);
+ self.last_visible_child_width = 0; // We'll define this later
// Events are up once everything is set
self.initEvents();
// Trim white spaces between visible nav elements
- $nav_visible.contents().filter(function() {
+ self.nav_visible.contents().filter(function() {
return this.nodeType = Node.TEXT_NODE && /\S/.test(this.nodeValue) === false;
}).remove();
- if (_options.swipe_enabled == true) self.initSwipeEvents();
+ if (self.options.swipe_enabled == true) self.initSwipeEvents();
},
initEvents: function() {
// Toggle hidden nav when hamburger icon is clicked and
// Collapse hidden nav on click outside the header
- $document.on('click.okayNav', function(e) {
+ self.document.on('click.okayNav', function(e) {
var _target = $(e.target);
- if (_nav_visible === true && _target.closest('.okayNav').length == 0)
+ if (self.nav_open === true && _target.closest('.okayNav').length == 0)
self.closeInvisibleNav();
- if (_target.hasClass(_options.toggle_icon_class)) {
+ if (_target.hasClass(self.options.toggle_icon_class)) {
e.preventDefault();
self.toggleInvisibleNav();
}
@@ -137,27 +137,27 @@
var optimizeResize = self._debounce(function() {
self.recalcNav()
- }, _options.recalc_delay);
- $window.on('load.okayNav resize.okayNav', optimizeResize);
+ }, self.options.recalc_delay);
+ self.window.on('load.okayNav resize.okayNav', optimizeResize);
},
initSwipeEvents: function() {
- $document
+ self.document
.on('touchstart.okayNav', function(e) {
- $nav_invisible.removeClass('transition-enabled');
+ self.nav_invisible.removeClass('transition-enabled');
//Trigger only on touch with one finger
if (e.originalEvent.touches.length == 1) {
var touch = e.originalEvent.touches[0];
if (
((touch.pageX < 25 && self.options.align_right == false) ||
- (touch.pageX > ($(_options.parent).outerWidth(true) - 25) &&
+ (touch.pageX > ($(self.options.parent).outerWidth(true) - 25) &&
self.options.align_right == true)) ||
- _nav_visible === true) {
+ self.nav_open === true) {
- _sTouch.x = _cTouch.x = touch.pageX;
- _sTouch.y = _cTouch.y = touch.pageY;
- _sTime = Date.now();
+ self.sTouch.x = self.cTouch.x = touch.pageX;
+ self.sTouch.y = self.cTouch.y = touch.pageY;
+ self.sTime = Date.now();
}
}
@@ -165,32 +165,32 @@
.on('touchmove.okayNav', function(e) {
var touch = e.originalEvent.touches[0];
self._triggerMove(touch.pageX, touch.pageY);
- _nav_moving = true;
+ self.nav_moving = true;
})
.on('touchend.okayNav', function(e) {
- _sTouch = {
+ self.sTouch = {
x: 0,
y: 0
};
- _cTouch = {
+ self.cTouch = {
x: 0,
y: 0
};
- _sTime = 0;
+ self.sTime = 0;
//Close menu if not swiped enough
- if (_percent_open > (100 - self.options.threshold)) {
- _nav_position = 0;
+ if (self.percent_open > (100 - self.options.threshold)) {
+ self.nav_position = 0;
self.closeInvisibleNav();
- } else if (_nav_moving == true) {
- _nav_position = $nav_invisible.width();
+ } else if (self.nav_moving == true) {
+ self.nav_position = self.nav_invisible.width();
self.openInvisibleNav();
}
- _nav_moving = false;
+ self.nav_moving = false;
- $nav_invisible.addClass('transition-enabled');
+ self.nav_invisible.addClass('transition-enabled');
});
},
@@ -203,31 +203,31 @@
},
_triggerMove: function(x, y) {
- _cTouch.x = x;
- _cTouch.y = y;
+ self.cTouch.x = x;
+ self.cTouch.y = y;
var currentTime = Date.now();
- var dx = (_cTouch.x - _sTouch.x);
- var dy = (_cTouch.y - _sTouch.y);
+ var dx = (self.cTouch.x - self.sTouch.x);
+ var dy = (self.cTouch.y - self.sTouch.y);
var opposing = dy * dy;
var distance = Math.sqrt(dx * dx + opposing);
//Length of the opposing side of the 90deg triagle
var dOpposing = Math.sqrt(opposing);
- var angle = Math.asin(Math.sin(dOpposing / distance)) * radCoef;
- var speed = distance / (currentTime - _sTime);
+ var angle = Math.asin(Math.sin(dOpposing / distance)) * self.radCoef;
+ var speed = distance / (currentTime - self.sTime);
//Set new start position
- _sTouch.x = x;
- _sTouch.y = y;
+ self.sTouch.x = x;
+ self.sTouch.y = y;
//Remove false swipes
if (angle < 20) {
var dir = self._getDirection(dx);
- var newPos = _nav_position + dir * distance;
- var menuWidth = $nav_invisible.width();
+ var newPos = self.nav_position + dir * distance;
+ var menuWidth = self.nav_invisible.width();
var overflow = 0;
@@ -237,14 +237,14 @@
overflow = menuWidth - newPos;
}
- var size = menuWidth - (_nav_position + dir * distance + overflow);
+ var size = menuWidth - (self.nav_position + dir * distance + overflow);
var threshold = (size / menuWidth) * 100;
//Set new position and threshold
- _nav_position += dir * distance + overflow;
- _percent_open = threshold;
+ self.nav_position += dir * distance + overflow;
+ self.percent_open = threshold;
- $nav_invisible.css('transform', 'translateX(' + (self.options.align_right ? 1 : -1) * threshold + '%)');
+ self.nav_invisible.css('transform', 'translateX(' + (self.options.align_right ? 1 : -1) * threshold + '%)');
}
},
@@ -253,19 +253,19 @@
* A few methods to allow working with elements
*/
getParent: function() {
- return _options.parent;
+ return self.options.parent;
},
getVisibleNav: function() { // Visible navigation
- return $nav_visible;
+ return self.nav_visible;
},
getInvisibleNav: function() { // Hidden behind the kebab icon
- return $nav_invisible;
+ return self.nav_invisible;
},
getNavToggleIcon: function() { // Kebab icon
- return $nav_toggle_icon;
+ return self.toggle_icon;
},
/*
@@ -288,43 +288,43 @@
},
openInvisibleNav: function() {
- !_options.enable_swipe ? _options.beforeOpen.call() : '';
+ !self.options.enable_swipe ? self.options.beforeOpen.call() : '';
- $nav_toggle_icon.addClass('icon--active');
- $nav_invisible.addClass('nav-open');
- _nav_visible = true;
- $nav_invisible.css({
+ self.toggle_icon.addClass('icon--active');
+ self.nav_invisible.addClass('nav-open');
+ self.nav_open = true;
+ self.nav_invisible.css({
'-webkit-transform': 'translateX(0%)',
'transform': 'translateX(0%)'
});
- _options.afterOpen.call();
+ self.options.afterOpen.call();
},
closeInvisibleNav: function() {
- !_options.enable_swipe ? _options.beforeClose.call() : '';
+ !self.options.enable_swipe ? self.options.beforeClose.call() : '';
- $nav_toggle_icon.removeClass('icon--active');
- $nav_invisible.removeClass('nav-open');
+ self.toggle_icon.removeClass('icon--active');
+ self.nav_invisible.removeClass('nav-open');
if (self.options.align_right) {
- $nav_invisible.css({
+ self.nav_invisible.css({
'-webkit-transform': 'translateX(100%)',
'transform': 'translateX(100%)'
});
} else {
- $nav_invisible.css({
+ self.nav_invisible.css({
'-webkit-transform': 'translateX(-100%)',
'transform': 'translateX(-100%)'
});
}
- _nav_visible = false;
+ self.nav_open = false;
- _options.afterClose.call();
+ self.options.afterClose.call();
},
toggleInvisibleNav: function() {
- if (!_nav_visible) {
+ if (!self.nav_open) {
self.openInvisibleNav();
} else {
self.closeInvisibleNav();
@@ -346,24 +346,24 @@
},
getVisibleItemCount: function() {
- return $('li', $nav_visible).length;
+ return $('li', self.nav_visible).length;
},
getHiddenItemCount: function() {
- return $('li', $nav_invisible).length;
+ return $('li', self.nav_invisible).length;
},
recalcNav: function() {
- var wrapper_width = $(_options.parent).outerWidth(true),
- space_taken = self.getChildrenWidth(_options.parent),
- nav_full_width = $navigation.outerWidth(true),
+ var wrapper_width = $(self.options.parent).outerWidth(true),
+ space_taken = self.getChildrenWidth(self.options.parent),
+ nav_full_width = self.navigation.outerWidth(true),
visible_nav_items = self.getVisibleItemCount(),
- collapse_width = $nav_visible.outerWidth(true) + _toggle_icon_width,
- expand_width = space_taken + _last_visible_child_width + _toggle_icon_width,
- expandAll_width = space_taken - nav_full_width + _nav_default_width;
+ collapse_width = self.nav_visible.outerWidth(true) + self.toggle_icon_width,
+ expand_width = space_taken + self.last_visible_child_width + self.toggle_icon_width,
+ expandAll_width = space_taken - nav_full_width + self.default_width;
if (wrapper_width > expandAll_width) {
self._expandAllItems();
- $nav_toggle_icon.addClass('okay-invisible');
+ self.toggle_icon.addClass('okay-invisible');
return;
}
@@ -373,23 +373,23 @@
self._collapseNavItem();
}
- if (wrapper_width > expand_width + _toggle_icon_width + 15) {
+ if (wrapper_width > expand_width + self.toggle_icon_width + 15) {
self._expandNavItem();
}
// Hide the kebab icon if no items are hidden
self.getHiddenItemCount() == 0 ?
- $nav_toggle_icon.addClass('okay-invisible') :
- $nav_toggle_icon.removeClass('okay-invisible');
+ self.toggle_icon.addClass('okay-invisible') :
+ self.toggle_icon.removeClass('okay-invisible');
},
_collapseNavItem: function() {
- var $last_child = $('li:last-child', $nav_visible);
- _last_visible_child_width = $last_child.outerWidth(true);
- $document.trigger('okayNav:collapseItem', $last_child);
- $last_child.detach().prependTo($nav_invisible);
- _options.itemHidden.call();
+ var $last_child = $('li:last-child', self.nav_visible);
+ self.last_visible_child_width = $last_child.outerWidth(true);
+ self.document.trigger('okayNav:collapseItem', $last_child);
+ $last_child.detach().prependTo(self.nav_invisible);
+ self.options.itemHidden.call();
// All nav items are visible by default
// so we only need recursion when collapsing
@@ -397,30 +397,30 @@
},
_expandNavItem: function() {
- var $first = $('li:first-child', $nav_invisible);
- $document.trigger('okayNav:expandItem', $first);
- $first.detach().appendTo($nav_visible);
- _options.itemDisplayed.call();
+ var $first = $('li:first-child', self.nav_invisible);
+ self.document.trigger('okayNav:expandItem', $first);
+ $first.detach().appendTo(self.nav_visible);
+ self.options.itemDisplayed.call();
},
_expandAllItems: function() {
- $('li', $nav_invisible).detach().appendTo($nav_visible);
- _options.itemDisplayed.call();
+ $('li', self.nav_invisible).detach().appendTo(self.nav_visible);
+ self.options.itemDisplayed.call();
},
_collapseAllItems: function() {
- $('li', $nav_visible).detach().appendTo($nav_invisible);
- _options.itemHidden.call();
+ $('li', self.nav_visible).detach().appendTo(self.nav_invisible);
+ self.options.itemHidden.call();
},
destroy: function() {
- $('li', $nav_invisible).appendTo($nav_visible);
- $nav_invisible.remove();
- $nav_visible.removeClass('okayNav__nav--visible');
- $nav_toggle_icon.remove();
+ $('li', self.nav_invisible).appendTo(self.nav_visible);
+ self.nav_invisible.remove();
+ self.nav_visible.removeClass('okayNav__nav--visible');
+ self.toggle_icon.remove();
- $document.unbind('.okayNav');
- $window.unbind('.okayNav');
+ self.document.unbind('.okayNav');
+ self.window.unbind('.okayNav');
}
}
diff --git a/dist/js/jquery.okayNav-min.js b/dist/js/jquery.okayNav-min.js
index 8456cf7..df5ca6a 100644
--- a/dist/js/jquery.okayNav-min.js
+++ b/dist/js/jquery.okayNav-min.js
@@ -1,6 +1,6 @@
/*!
- * jquery.okayNav.js 2.0.3 (https://github.com/VPenkov/okayNav)
+ * jquery.okayNav.js 2.0.4 (https://github.com/VPenkov/okayNav)
* Author: Vergil Penkov (http://vergilpenkov.com/)
* MIT license: https://opensource.org/licenses/MIT
*/
-!function(n){"function"==typeof define&&define.amd?define(["jquery"],n):"object"==typeof module&&module.exports?module.exports=function(i,e){return void 0===e&&(e="undefined"!=typeof window?require("jquery"):require("jquery")(i)),n(e),e}:n(jQuery)}(function(n){function i(i,e){self=this,this.options=n.extend({},t,e),_options=this.options,$navigation=n(i),$document=n(document),$window=n(window),""==this.options.parent?this.options.parent=$navigation.parent():"",_nav_visible=!1,_nav_full_width=0,_parent_full_width=0,radCoef=180/Math.PI,_sTouch={x:0,y:0},_cTouch={x:0,y:0},_sTime=0,_nav_position=0,_percent_open=0,_nav_moving=!1,self.init()}var e="okayNav",t={parent:"",toggle_icon_class:"okayNav__menu-toggle",toggle_icon_content:"",align_right:!0,swipe_enabled:!0,threshold:50,resize_delay:10,beforeOpen:function(){},afterOpen:function(){},beforeClose:function(){},afterClose:function(){},itemHidden:function(){},itemDisplayed:function(){}};i.prototype={init:function(){n("body").addClass("okayNav-loaded"),$navigation.addClass("okayNav loaded").children("ul").addClass("okayNav__nav--visible"),self.options.align_right?$navigation.append('').append(''+_options.toggle_icon_content+""):$navigation.prepend('').prepend(''+_options.toggle_icon_content+""),$nav_visible=$navigation.children(".okayNav__nav--visible"),$nav_invisible=$navigation.children(".okayNav__nav--invisible"),$nav_toggle_icon=$navigation.children("."+_options.toggle_icon_class),_toggle_icon_width=$nav_toggle_icon.outerWidth(!0),_nav_default_width=self.getChildrenWidth($navigation),_parent_full_width=n(_options.parent).outerWidth(!0),_last_visible_child_width=0,self.initEvents(),$nav_visible.contents().filter(function(){return this.nodeType=Node.TEXT_NODE&&/\S/.test(this.nodeValue)===!1}).remove(),1==_options.swipe_enabled&&self.initSwipeEvents()},initEvents:function(){$document.on("click.okayNav",function(i){var e=n(i.target);_nav_visible===!0&&0==e.closest(".okayNav").length&&self.closeInvisibleNav(),e.hasClass(_options.toggle_icon_class)&&(i.preventDefault(),self.toggleInvisibleNav())});var i=self._debounce(function(){self.recalcNav()},_options.recalc_delay);$window.on("load.okayNav resize.okayNav",i)},initSwipeEvents:function(){$document.on("touchstart.okayNav",function(i){if($nav_invisible.removeClass("transition-enabled"),1==i.originalEvent.touches.length){var e=i.originalEvent.touches[0];(e.pageX<25&&0==self.options.align_right||e.pageX>n(_options.parent).outerWidth(!0)-25&&1==self.options.align_right||_nav_visible===!0)&&(_sTouch.x=_cTouch.x=e.pageX,_sTouch.y=_cTouch.y=e.pageY,_sTime=Date.now())}}).on("touchmove.okayNav",function(n){var i=n.originalEvent.touches[0];self._triggerMove(i.pageX,i.pageY),_nav_moving=!0}).on("touchend.okayNav",function(n){_sTouch={x:0,y:0},_cTouch={x:0,y:0},_sTime=0,_percent_open>100-self.options.threshold?(_nav_position=0,self.closeInvisibleNav()):1==_nav_moving&&(_nav_position=$nav_invisible.width(),self.openInvisibleNav()),_nav_moving=!1,$nav_invisible.addClass("transition-enabled")})},_getDirection:function(n){return self.options.align_right?n>0?-1:1:0>n?-1:1},_triggerMove:function(n,i){_cTouch.x=n,_cTouch.y=i;var e=Date.now(),t=_cTouch.x-_sTouch.x,o=_cTouch.y-_sTouch.y,a=o*o,s=Math.sqrt(t*t+a),l=Math.sqrt(a),_=Math.asin(Math.sin(l/s))*radCoef;s/(e-_sTime);if(_sTouch.x=n,_sTouch.y=i,20>_){var v=self._getDirection(t),c=_nav_position+v*s,r=$nav_invisible.width(),d=0;0>c?d=-c:c>r&&(d=r-c);var p=r-(_nav_position+v*s+d),u=p/r*100;_nav_position+=v*s+d,_percent_open=u,$nav_invisible.css("transform","translateX("+(self.options.align_right?1:-1)*u+"%)")}},getParent:function(){return _options.parent},getVisibleNav:function(){return $nav_visible},getInvisibleNav:function(){return $nav_invisible},getNavToggleIcon:function(){return $nav_toggle_icon},_debounce:function(n,i,e){var t;return function(){var o=this,a=arguments,s=function(){t=null,e||n.apply(o,a)},l=e&&!t;clearTimeout(t),t=setTimeout(s,i),l&&n.apply(o,a)}},openInvisibleNav:function(){_options.enable_swipe?"":_options.beforeOpen.call(),$nav_toggle_icon.addClass("icon--active"),$nav_invisible.addClass("nav-open"),_nav_visible=!0,$nav_invisible.css({"-webkit-transform":"translateX(0%)",transform:"translateX(0%)"}),_options.afterOpen.call()},closeInvisibleNav:function(){_options.enable_swipe?"":_options.beforeClose.call(),$nav_toggle_icon.removeClass("icon--active"),$nav_invisible.removeClass("nav-open"),self.options.align_right?$nav_invisible.css({"-webkit-transform":"translateX(100%)",transform:"translateX(100%)"}):$nav_invisible.css({"-webkit-transform":"translateX(-100%)",transform:"translateX(-100%)"}),_nav_visible=!1,_options.afterClose.call()},toggleInvisibleNav:function(){_nav_visible?self.closeInvisibleNav():self.openInvisibleNav()},getChildrenWidth:function(i){for(var e=0,t=n(i).children(),o=0;ol?(self._expandAllItems(),void $nav_toggle_icon.addClass("okay-invisible")):(o>0&&a>=t&&s>=i&&self._collapseNavItem(),i>s+_toggle_icon_width+15&&self._expandNavItem(),void(0==self.getHiddenItemCount()?$nav_toggle_icon.addClass("okay-invisible"):$nav_toggle_icon.removeClass("okay-invisible")))},_collapseNavItem:function(){var i=n("li:last-child",$nav_visible);_last_visible_child_width=i.outerWidth(!0),$document.trigger("okayNav:collapseItem",i),i.detach().prependTo($nav_invisible),_options.itemHidden.call(),self.recalcNav()},_expandNavItem:function(){var i=n("li:first-child",$nav_invisible);$document.trigger("okayNav:expandItem",i),i.detach().appendTo($nav_visible),_options.itemDisplayed.call()},_expandAllItems:function(){n("li",$nav_invisible).detach().appendTo($nav_visible),_options.itemDisplayed.call()},_collapseAllItems:function(){n("li",$nav_visible).detach().appendTo($nav_invisible),_options.itemHidden.call()},destroy:function(){n("li",$nav_invisible).appendTo($nav_visible),$nav_invisible.remove(),$nav_visible.removeClass("okayNav__nav--visible"),$nav_toggle_icon.remove(),$document.unbind(".okayNav"),$window.unbind(".okayNav")}},n.fn[e]=function(t){var o=arguments;if(void 0===t||"object"==typeof t)return this.each(function(){n.data(this,"plugin_"+e)||n.data(this,"plugin_"+e,new i(this,t))});if("string"==typeof t&&"_"!==t[0]&&"init"!==t){var a;return this.each(function(){var s=n.data(this,"plugin_"+e);s instanceof i&&"function"==typeof s[t]&&(a=s[t].apply(s,Array.prototype.slice.call(o,1))),"destroy"===t&&n.data(this,"plugin_"+e,null)}),void 0!==a?a:this}}});
\ No newline at end of file
+!function(e){"function"==typeof define&&define.amd?define(["jquery"],e):"object"==typeof module&&module.exports?module.exports=function(n,i){return void 0===i&&(i="undefined"!=typeof window?require("jquery"):require("jquery")(n)),e(i),i}:e(jQuery)}(function(e){function n(n,i){self=this,this.options=e.extend({},s,i),self.options=this.options,self.navigation=e(n),self.document=e(document),self.window=e(window),""==this.options.parent?this.options.parent=self.navigation.parent():"",self.nav_open=!1,self.parent_full_width=0,self.radCoef=180/Math.PI,self.sTouch={x:0,y:0},self.cTouch={x:0,y:0},self.sTime=0,self.nav_position=0,self.percent_open=0,self.nav_moving=!1,self.init()}var i="okayNav",s={parent:"",toggle_icon_class:"okayNav__menu-toggle",toggle_icon_content:"",align_right:!0,swipe_enabled:!0,threshold:50,resize_delay:10,beforeOpen:function(){},afterOpen:function(){},beforeClose:function(){},afterClose:function(){},itemHidden:function(){},itemDisplayed:function(){}};n.prototype={init:function(){e("body").addClass("okayNav-loaded"),self.navigation.addClass("okayNav loaded").children("ul").addClass("okayNav__nav--visible"),self.options.align_right?self.navigation.append('').append(''+self.options.toggle_icon_content+""):self.navigation.prepend('').prepend(''+self.options.toggle_icon_content+""),self.nav_visible=self.navigation.children(".okayNav__nav--visible"),self.nav_invisible=self.navigation.children(".okayNav__nav--invisible"),self.toggle_icon=self.navigation.children("."+self.options.toggle_icon_class),self.toggle_icon_width=self.toggle_icon.outerWidth(!0),self.default_width=self.getChildrenWidth(self.navigation),self.parent_full_width=e(self.options.parent).outerWidth(!0),self.last_visible_child_width=0,self.initEvents(),self.nav_visible.contents().filter(function(){return this.nodeType=Node.TEXT_NODE&&/\S/.test(this.nodeValue)===!1}).remove(),1==self.options.swipe_enabled&&self.initSwipeEvents()},initEvents:function(){self.document.on("click.okayNav",function(n){var i=e(n.target);self.nav_open===!0&&0==i.closest(".okayNav").length&&self.closeInvisibleNav(),i.hasClass(self.options.toggle_icon_class)&&(n.preventDefault(),self.toggleInvisibleNav())});var n=self._debounce(function(){self.recalcNav()},self.options.recalc_delay);self.window.on("load.okayNav resize.okayNav",n)},initSwipeEvents:function(){self.document.on("touchstart.okayNav",function(n){if(self.nav_invisible.removeClass("transition-enabled"),1==n.originalEvent.touches.length){var i=n.originalEvent.touches[0];(i.pageX<25&&0==self.options.align_right||i.pageX>e(self.options.parent).outerWidth(!0)-25&&1==self.options.align_right||self.nav_open===!0)&&(self.sTouch.x=self.cTouch.x=i.pageX,self.sTouch.y=self.cTouch.y=i.pageY,self.sTime=Date.now())}}).on("touchmove.okayNav",function(e){var n=e.originalEvent.touches[0];self._triggerMove(n.pageX,n.pageY),self.nav_moving=!0}).on("touchend.okayNav",function(e){self.sTouch={x:0,y:0},self.cTouch={x:0,y:0},self.sTime=0,self.percent_open>100-self.options.threshold?(self.nav_position=0,self.closeInvisibleNav()):1==self.nav_moving&&(self.nav_position=self.nav_invisible.width(),self.openInvisibleNav()),self.nav_moving=!1,self.nav_invisible.addClass("transition-enabled")})},_getDirection:function(e){return self.options.align_right?e>0?-1:1:0>e?-1:1},_triggerMove:function(e,n){self.cTouch.x=e,self.cTouch.y=n;var i=Date.now(),s=self.cTouch.x-self.sTouch.x,l=self.cTouch.y-self.sTouch.y,t=l*l,o=Math.sqrt(s*s+t),a=Math.sqrt(t),f=Math.asin(Math.sin(a/o))*self.radCoef;o/(i-self.sTime);if(self.sTouch.x=e,self.sTouch.y=n,20>f){var v=self._getDirection(s),c=self.nav_position+v*o,r=self.nav_invisible.width(),d=0;0>c?d=-c:c>r&&(d=r-c);var _=r-(self.nav_position+v*o+d),p=_/r*100;self.nav_position+=v*o+d,self.percent_open=p,self.nav_invisible.css("transform","translateX("+(self.options.align_right?1:-1)*p+"%)")}},getParent:function(){return self.options.parent},getVisibleNav:function(){return self.nav_visible},getInvisibleNav:function(){return self.nav_invisible},getNavToggleIcon:function(){return self.toggle_icon},_debounce:function(e,n,i){var s;return function(){var l=this,t=arguments,o=function(){s=null,i||e.apply(l,t)},a=i&&!s;clearTimeout(s),s=setTimeout(o,n),a&&e.apply(l,t)}},openInvisibleNav:function(){self.options.enable_swipe?"":self.options.beforeOpen.call(),self.toggle_icon.addClass("icon--active"),self.nav_invisible.addClass("nav-open"),self.nav_open=!0,self.nav_invisible.css({"-webkit-transform":"translateX(0%)",transform:"translateX(0%)"}),self.options.afterOpen.call()},closeInvisibleNav:function(){self.options.enable_swipe?"":self.options.beforeClose.call(),self.toggle_icon.removeClass("icon--active"),self.nav_invisible.removeClass("nav-open"),self.options.align_right?self.nav_invisible.css({"-webkit-transform":"translateX(100%)",transform:"translateX(100%)"}):self.nav_invisible.css({"-webkit-transform":"translateX(-100%)",transform:"translateX(-100%)"}),self.nav_open=!1,self.options.afterClose.call()},toggleInvisibleNav:function(){self.nav_open?self.closeInvisibleNav():self.openInvisibleNav()},getChildrenWidth:function(n){for(var i=0,s=e(n).children(),l=0;la?(self._expandAllItems(),void self.toggle_icon.addClass("okay-invisible")):(l>0&&t>=s&&o>=n&&self._collapseNavItem(),n>o+self.toggle_icon_width+15&&self._expandNavItem(),void(0==self.getHiddenItemCount()?self.toggle_icon.addClass("okay-invisible"):self.toggle_icon.removeClass("okay-invisible")))},_collapseNavItem:function(){var n=e("li:last-child",self.nav_visible);self.last_visible_child_width=n.outerWidth(!0),self.document.trigger("okayNav:collapseItem",n),n.detach().prependTo(self.nav_invisible),self.options.itemHidden.call(),self.recalcNav()},_expandNavItem:function(){var n=e("li:first-child",self.nav_invisible);self.document.trigger("okayNav:expandItem",n),n.detach().appendTo(self.nav_visible),self.options.itemDisplayed.call()},_expandAllItems:function(){e("li",self.nav_invisible).detach().appendTo(self.nav_visible),self.options.itemDisplayed.call()},_collapseAllItems:function(){e("li",self.nav_visible).detach().appendTo(self.nav_invisible),self.options.itemHidden.call()},destroy:function(){e("li",self.nav_invisible).appendTo(self.nav_visible),self.nav_invisible.remove(),self.nav_visible.removeClass("okayNav__nav--visible"),self.toggle_icon.remove(),self.document.unbind(".okayNav"),self.window.unbind(".okayNav")}},e.fn[i]=function(s){var l=arguments;if(void 0===s||"object"==typeof s)return this.each(function(){e.data(this,"plugin_"+i)||e.data(this,"plugin_"+i,new n(this,s))});if("string"==typeof s&&"_"!==s[0]&&"init"!==s){var t;return this.each(function(){var o=e.data(this,"plugin_"+i);o instanceof n&&"function"==typeof o[s]&&(t=o[s].apply(o,Array.prototype.slice.call(l,1))),"destroy"===s&&e.data(this,"plugin_"+i,null)}),void 0!==t?t:this}}});
\ No newline at end of file