1 ;(function($, window, document, undefined) {
3 function pushMenu (elem, options) {
4 this.$body = $("body");
6 this.options = $.extend({}, this.config, options);
7 this.$toggler = this.$body.find(this.options.button || '.open');
11 pushMenu.prototype.classes = {
14 overlay : "pm_overlay",
18 pushMenu.prototype.initialize = function(){
21 _this.initializeEvents();
23 if(this.$body.find("."+this.classes.overlay).length < 1){
24 var overlay = $("<div>").addClass(this.classes.overlay+" "+this.classes.hide);
25 this.$body.append(overlay);
29 pushMenu.prototype.initializeEvents = function(){
33 this.$toggler.on('click', function(){
34 _this.toggleMenu("show");
37 this.$body.on('click','.'+_this.classes.overlay, function(){
38 _this.toggleMenu("hide");
42 pushMenu.prototype.toggleMenu = function(status){
43 var method = status == "show" ? "addClass" : "removeClass";
44 // hack to remove initial hidden status - dragorn
45 if (status === "show")
46 this.$elem.removeClass("pm_initial");
47 this.$elem[method](this.classes.open);
48 this.toggleOverlay(status);
51 pushMenu.prototype.toggleOverlay = function(status){
53 var overlay = _this.$body.find("."+_this.classes.overlay);
55 overlay.addClass(_this.classes.show).removeClass(_this.classes.hide);
58 overlay.removeClass(this.classes.show);
59 setTimeout(function(){
60 overlay.addClass(_this.classes.hide);
65 $.fn.pushmenu = function(options){
67 return this.each(function(){
69 new pushMenu(this, options);
75 })(jQuery, window, document);