understanding design pattern of a jquery gallery plugin

understanding design pattern of a jquery gallery plugin

hey guys i was just going through the code of a gallery plugin and i have been on this for a few hours now , basiclly the plugin has the following code structure , have a look :

  1. (function( $, undefined ) {

  2.     /*
  3.      * Gallery object.
  4.      */
  5.     $.Gallery               = function( options, element ) {    

  6.         this.$el    = $( element );
  7.         this._init( options );

  8.     };

  9.     $.Gallery.defaults      = {
  10.         current     : 0,    
  11.         autoplay    : false,
  12.         interval    : 2000      };

  13.     $.Gallery.prototype     = {
  14.         _init               : function( options ) {

  15.         },
  16.         _validate           : function() {

  17.         },
  18.         _layout             : function() {


  19.         },
  20.         _setItems           : function() {

  21.         },
  22.         _loadEvents         : function() {


  23.         },
  24.         _getCoordinates     : function( position ) {


  25.         },
  26.         _navigate           : function( dir ) {


  27.         },
  28.         _startSlideshow     : function() {


  29.         },
  30.         destroy             : function() {


  31.     };

  32.     var logError            = function( message ) {

  33.     };

  34.     $.fn.gallery            = function( options ) {


  35.         if ( typeof options === 'string' ) {            

  36.             this.each(function() {

  37.                 // do something 

  38.             });

  39.         } 
  40.         else {


  41.             this.each(function() {

  42.                 // do something

  43.             });

  44.         }

  45.         return this;

  46.     };

  47. })( jQuery );

now i have worked on a few jquery plugin earlier , but never come across such a plugin structure before , espically the below poniters are a bit weird , have a look :

1.  There is just one prototype used in the plugin ,

  1. $.Gallery.prototype = {

  2.   // all the functions are written here . 

  3. };

2.  using this pattern this always actually points to gallery(which is the main object ) and thus makes it easy to make calls to other functions in the prototype chain :

  1. $.Gallery.prototype    = {
  2.             _init               : function( options ) {
  3. // since this is actually pointing to gallery here , you can call _validate directly here , by just saying this.validate() }, _validate : function() {

  4.                 },

So i have a question here, what design patterns is this ? and what are its obvious advantages ?