/*
  Pushy - Off Canvas Menu
  Created by Christopher Yee
  https://chrisyee.ca
  
  Modified for this software by Maian Media
  https://www.maianmedia.com
*/

! function(s) {
  function e() {
    i.hasClass(c) ? (r.toggleClass(f), r.hasClass(f) ? l("open") : setTimeout(function() {
      jQuery('.menu-btn').attr('class','fa fa-bars fa-fw menu-btn pushy-rotate-reset');
      l("close")
    }, 500)) : (r.toggleClass(d), r.hasClass(d) ? l("open") : setTimeout(function() {
      jQuery('.menu-btn').attr('class','fa fa-bars fa-fw menu-btn pushy-rotate-reset');
      l("close")
    }, 500)), y && i.one("transitionend", function() {
      y.focus()
    })
  }

  function n() {
    i.hasClass(c) ? r.removeClass(f) : r.removeClass(d)
  }

  function a() {
    i.hasClass(c) ? (r.addClass(f), i.animate({
      left: "0px"
    }, v), u.animate({
      left: b
    }, v), m.animate({
      left: b
    }, v)) : (r.addClass(d), i.animate({
      right: "0px"
    }, v), u.animate({
      right: b
    }, v), m.animate({
      right: b
    }, v)), y && y.focus()
  }

  function t() {
    i.hasClass(c) ? (r.removeClass(f), i.animate({
      left: "-" + b
    }, v), u.animate({
      left: "0px"
    }, v), m.animate({
      left: "0px"
    }, v)) : (r.removeClass(d), i.animate({
      right: "-" + b
    }, v), u.animate({
      right: "0px"
    }, v), m.animate({
      right: "0px"
    }, v))
  }

  function o() {
    s(g).addClass(x), s(g).on("click", function() {
      var e = s(this);
      e.hasClass(x) ? (s(g).addClass(x).removeClass(k), e.removeClass(x).addClass(k)) : e.addClass(x).removeClass(k)
    })
  }

  function l(e) {
    switch (e) {
      case "open":
        s("body,html").addClass("pushy_html_body");
        jQuery('.menu-btn').attr('class','fa fa-chevron-left fa-fw menu-btn pushy-rotate-start');
        break;
      case "close":
        s("body,html").removeClass("pushy_html_body");
    }
  }
  var i = s(".pushy"),
    r = s("body"),
    u = s("#container"),
    m = s(".push"),
    c = "pushy-left",
    f = "pushy-open-left",
    d = "pushy-open-right",
    h = s(".site-overlay"),
    p = s(".menu-btn, .pushy-link"),
    C = s(".menu-btn"),
    y = s(i.data("focus")),
    v = 200,
    b = i.width() + "px",
    g = ".pushy-submenu",
    k = "pushy-submenu-open",
    x = "pushy-submenu-closed";
  s(g);
  s(document).keyup(function(s) {
    27 == s.keyCode && (r.hasClass(f) || r.hasClass(d)) && (w ? n() : (t(), T = !1), C && C.focus())
  });
  var w = function() {
    var s = document.createElement("p"),
      e = !1,
      n = {
        webkitTransform: "-webkit-transform",
        OTransform: "-o-transform",
        msTransform: "-ms-transform",
        MozTransform: "-moz-transform",
        transform: "transform"
      };
    if (null !== document.body) {
      document.body.insertBefore(s, null);
      for (var a in n) void 0 !== s.style[a] && (s.style[a] = "translate3d(1px,1px,1px)", e = window.getComputedStyle(s).getPropertyValue(n[a]));
      return document.body.removeChild(s), void 0 !== e && e.length > 0 && "none" !== e
    }
    return !1
  }();
  if (w) o(), p.on("click", function() {
    e()
  }), h.on("click", function() {
    e()
  });
  else {
    r.addClass("no-csstransforms3d"), i.hasClass(c) ? i.css({
      left: "-" + b
    }) : i.css({
      right: "-" + b
    }), u.css({
      "overflow-x": "hidden"
    });
    var T = !1;
    o(), p.on("click", function() {
      T ? (t(), T = !1) : (a(), T = !0)
    }), h.on("click", function() {
      T ? (t(), T = !1) : (a(), T = !0)
    })
  }
}(jQuery);