Return to Snippet

Revision: 46694
at May 23, 2011 17:02 by madr


Initial Code
(function($) {
  var settings = {
    setting1:         'http://lunchguiden.labbplats.se/sok',
    setting2:         'baa'
  };
    
  var $cache1, $cache2, $cache3,
  variable1, variable2;
  
  var methods = {
    mock: function(replace, func) {
      methods[replace] = func;
    },
    
    setup: function(options) {},
    
    init: function( options ) {
      methods.setup(options);
      
      this.each(function() {
        
      });
      
      return this;
    },
    
    /* 
    Delegate clicks 
    */
    
    delegateClick: function( $target ) {
      var id              = $target.attr('id'),
          cls             = $target.attr('class'),
          magicHappened   = false;
      
      (function(id){
        if (!id) { return; }
        
        /*
        test id with regexp or $.hasClass
        */
        
      })($target.attr('id'));
      
      (function(cls){
        if (!cls) { return; }
        
        /*
        test class with regexp or $.hasClass
        */
        
      })($target.attr('class'));
      
      return magicHappened;
    }
  };
  
  var protoSlice = Array.prototype.slice;

  $.fn.mktslideshow = function(method) {
    if ( methods[method] ) {
      return methods[method].apply( this, protoSlice.call( arguments, 1 ) );
    } else if ( typeof method === 'object' || ! method ) {
      return methods.init.apply( this, arguments );
    } else {
      $.error( 'Method ' +  method + ' does not exist on jQuery.fn.mktslideshow' );
    }
  };
  
  $.extend($.fn.mktslideshow, {
    defaults: settings
  });
})(jQuery);

Initial URL


Initial Description


Initial Title
jquery plugin skeleton, qunit friendly

Initial Tags
javascript, textmate, jquery

Initial Language
Other