Skip to content

Commit

Permalink
Added the plugin script.
Browse files Browse the repository at this point in the history
  • Loading branch information
IonicaBizau committed Dec 2, 2013
1 parent d3f5fa7 commit b89b9be
Showing 1 changed file with 67 additions and 0 deletions.
67 changes: 67 additions & 0 deletions jquery.sidebar.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
/*
* jQuery sidebar plugin

This comment has been minimized.

Copy link
@gabipetrovay

gabipetrovay Dec 17, 2014

Member

a version number here would be great (same in url.js) in order to recognise the library in an application.

This comment has been minimized.

Copy link
@IonicaBizau

IonicaBizau Dec 17, 2014

Author Collaborator

Or even better in $.fn.sidebar.version.

This comment has been minimized.

Copy link
@IonicaBizau

IonicaBizau Dec 26, 2014

Author Collaborator

#8

* ---------------------
* A very simple sidebar jQuery plugin
*
* Copyright (c) 2013 - jillix gmbh
*
* */
;(function ($){

/*
* $("[jQuery selector]").sidebar({...});
* */
$.fn.sidebar = function(options) {

// defaults
var settings = $.extend( {
speed : 200, // animate speed
side : 'left' // side: 'left' or 'right'
}, options);

// get 'this' jQuery element
var self = this;

/*
* Opens the sidebar
* $("[jQuery selector]).trigger("open");
* */
this.on("open", function () {

// animate properties
var properties = {};

// animate to 0px the `right/left`
properties[settings.side] = 0;

// start animation
self.animate(properties, settings.speed, function () {
// finally emit something
self.trigger("opened");
});
});


/*
* Closes the sidebar
*
* $("[jQuery selector]).trigger("close");
* */
this.on("close", function (callback) {

// animate properties
var properties = {};

// TODO padding? borders?
properties[settings.side] = - self.width() - 30;

// start animation
self.animate(properties, settings.speed, function () {
// finally emit something
self.trigger("closed");
});
});

return this;
};
})(jQuery);

0 comments on commit b89b9be

Please sign in to comment.