That how I usually implement my plugins:
(function($){
$.fn.plugingName = function(inSettings){
//code that extands settings with default
return this.each(function(){
new PluginClass($(this), settings);
});
}
PluginClass = function(jElem, settings){
//here I usually put variable and function in such a way to compose better
var events = {
onMouseUp : function(){
//some actions
},
onMouseMove : function(event){
//some actions
},
//etc.
},
draw = {
drawGrid : function(){//some actions},
//etc.
},
//etc.
/*****************************
* This is a place of question
****************************/
}
})(jQuery);
I just want to know if there is a pattern to separate the algorithm from declaration part that I described above. Some thing like to put all your algorithm part inside
function main(){
}();
If there is a better approach to distinguish the main part of your algorithm. I hope I described everything clear.
All others improvment that might be done with represented code are also appreciate.