Posted By

onefastsnail on 05/24/12


Tagged


Versions (?)

jquery plugin template


 / Published in: Other
 

  1. /*
  2. * A jQuery plugin template
  3. * Basically used as personal reference
  4. *
  5. * Author: Andy Goh (hantu)
  6. * Website: http://www.andygoh.net
  7. *
  8. * Revisions:
  9. * 0.1 - Initial commit
  10. *
  11. * References:
  12. * http://www.learningjquery.com/2007/10/a-plugin-development-pattern
  13. * http://docs.jquery.com/Plugins/Authoring
  14. *
  15. * Notes:
  16. * - Good idea to name your file jquery.pluginName.js
  17. */
  18. (function($) {
  19.  
  20. // replace 'pluginName' with the name of your plugin
  21. $.fn.pluginName = function(options) {
  22. // plugin default options
  23. var defaults = {
  24. };
  25.  
  26. // extends defaults with options provided
  27. if (options) {
  28. $.extend(defaults, options);
  29. }
  30.  
  31. // iterate over matched elements
  32. return this.each(function() {
  33. // implementations
  34. });
  35.  
  36. };
  37.  
  38. // public functions definition
  39. $.fn.pluginName.functionName = function(foo) {
  40. return this;
  41. };
  42.  
  43. // private functions definition
  44. function foobar() {}
  45.  
  46. })(jQuery);

Report this snippet  

You need to login to post a comment.