Javascript Jquery Pattern
// http://alistapart.com/article/the-design-of-code-organizing-javascript
(function($) {
$.jPanelMenu = function(options) {
var jpm = {
options: $.extend({
'animated': true,
'duration': 500,
'direction': 'left'
}, options),
openMenu: function( ) {
// Open menu…
this.setMenuStyle( );
},
closeMenu: function( ) {
// close menu…
this.setMenuStyle( );
},
setMenuStyle: function( ) {
// Set style…
}
};
return {
open: jpm.openMenu,
close: jpm.closeMenu,
someComplexMethod: function( ) {
// do complex method…
}
};
};
})(jQuery);
// Calling the API function
var jpm = $.jPanelMenu({
duration: 1000
});
jpm.open( );