-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d3f5fa7
commit b89b9be
Showing
1 changed file
with
67 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
/* | ||
* jQuery sidebar plugin | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong. |
||
* --------------------- | ||
* 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); |
a version number here would be great (same in url.js) in order to recognise the library in an application.