-
Notifications
You must be signed in to change notification settings - Fork 26
/
jquery.fs.shifter.min.js
9 lines (8 loc) · 1.58 KB
/
jquery.fs.shifter.min.js
1
2
3
4
5
6
7
8
9
/*
* Shifter v3.1.2 - 2015-04-04
* A jQuery plugin for simple slide-out mobile navigation. Part of the Formstone Library.
* http://classic.formstone.it/shifter/
*
* Copyright 2015 Ben Plum; MIT Licensed
*/
!function(a,b){"use strict";function c(c){i||(k=a.extend({},s,c||{}),k.$html=a("html"),k.$body=a("body"),k.$shifts=a([g(m),g(n)].join(", ")),k.$nav=a(g(o)),k.$shifts.length>0&&k.$nav.length>0&&(i=!0,k.$body.on(r,g(l),e),void 0!==b.matchMedia&&(k.mediaQuery=b.matchMedia("(max-width:"+(k.maxWidth===1/0?"100000px":k.maxWidth)+")"),k.mediaQuery.addListener(d),d())))}function d(){k.mediaQuery.matches?t.enable():t.disable()}function e(a){a.preventDefault(),a.stopPropagation(),j||(k.$body.hasClass(q)?t.close():t.open()),"touchstart"===a.type&&(j=!0,setTimeout(f,500))}function f(){j=!1}function g(a){return"."+a}var h="shifter",i=!1,j=!1,k={},l=h+"-handle",m=h+"-page",n=h+"-header",o=h+"-navigation",p=h+"-enabled",q=h+"-open",r="touchstart."+h+" click."+h,s={maxWidth:"980px"},t={close:function(){i&&(k.$html.removeClass(q),k.$body.removeClass(q),k.$shifts.off(g(h)),k.$nav.find("input").trigger("blur"))},enable:function(){i&&k.$body.addClass(p)},destroy:function(){i&&(k.$html.removeClass(q),k.$body.removeClass([p,q].join(" ")).off(r),void 0!==b.matchMedia&&k.mediaQuery.removeListener(d),k={},i=!1)},disable:function(){i&&(t.close(),k.$body.removeClass(p))},open:function(){i&&(k.$html.addClass(q),k.$body.addClass(q),k.$shifts.one(r,e))}};a[h]=function(a){return t[a]?t[a].apply(this,Array.prototype.slice.call(arguments,1)):"object"!=typeof a&&a?this:c.apply(this,arguments)}}(jQuery,window);