forked from peachananr/square_menu
-
Notifications
You must be signed in to change notification settings - Fork 0
/
jquery.square_menu.min.js
1 lines (1 loc) · 2.23 KB
/
jquery.square_menu.min.js
1
!function(e){var t={flyDirection:"bottom",button:"Menu",animationStyle:"vertical",closeButton:"X"};e.fn.square_menu=function(n){var r=e.extend({},t,n),i=e(this);e("body").addClass("fsm-body");i.addClass("sm-menu sm-"+r.flyDirection+" sm-"+r.animationStyle);i.wrapInner("<div class='sm-wrapper'></div>");i.find("nav").addClass("sm-nav").wrapInner("<div class='nav-inner'></div>");e.fn.closeMenu=function(){e(".sm-menu").addClass("animated").removeClass("re-rotate");e(".sm-menu .sm-close").remove();e(".sm-menu .sm-nav:first-child .nav-inner").removeClass("animated flyInLeft");e(".sm-menu .sm-nav:nth-child(2) .nav-inner").removeClass("animated flyInRight");if(e("body").hasClass("sm-activate")){e(".sm-menu").find(".sm-nav").removeClass("animated");e(".sm-menu").one("transitionend webkitTransitionEnd oTransitionEnd MSTransitionEnd",function(){e("body").removeClass("sm-activate").find(".sm-menu").removeClass("ff-hack")})}};e.fn.openMenu=function(){e(".sm-menu").addClass("animated").addClass("ff-hack");if(!e("body").hasClass("sm-activate")){if(e(".sm-overlay").length<1)e("<div class='sm-overlay'></div>").hide().prependTo("body");e(".sm-overlay").fadeIn("fast",function(){e("body").addClass("sm-activate");var t=false;e("body").one("transitionend webkitTransitionEnd oTransitionEnd MSTransitionEnd",function(n){if(!t){t=true;e(".sm-menu .sm-nav").addClass("animated");e(".sm-menu .sm-nav").one("transitionend webkitTransitionEnd oTransitionEnd MSTransitionEnd",function(t){if(t.originalEvent.propertyName=="-webkit-transform"||t.originalEvent.propertyName=="transform"||t.originalEvent.propertyName=="-o-transform"||t.originalEvent.propertyName=="-moz-transform"){e(".sm-menu").addClass("re-rotate");if(r.closeButton!=false){i.prepend("<a href='#' class='sm-close'>"+r.closeButton+"</a>");e(".sm-close").click(function(){i.closeMenu();return false})}e(".sm-menu .sm-nav:first-child .nav-inner").addClass("animated flyInLeft");e(".sm-menu .sm-nav:nth-child(2) .nav-inner").addClass("animated flyInRight");e(".sm-overlay:not(.clicked)").addClass("clicked").click(function(){i.closeMenu()})}})}})})}else{i.closeMenu()}};if(r.button!=false){e("<a href='#' class='sm-button'>"+r.button+"</a>").insertAfter(i)}e(".sm-button").click(function(){i.openMenu();return false})}}(window.jQuery)