Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 25th, 2012  |  syntax: None  |  size: 0.87 KB  |  hits: 11  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. ## [Javascript]
  2. (function($) {
  3.  
  4.   /**
  5.   * Delegate to listen for events
  6.   */
  7.   $.fn.pluginName = function(selector) {
  8.     // Listen for user interactions matching the component
  9.     return this.delegate(selector, {
  10.       click : init,
  11.       keydown : init
  12.     });
  13.   }
  14.  
  15.   /**
  16.   * Initiaizes the search component if it hasn't already been initialized.
  17.   */
  18.   function init(event) {
  19.     // If the component has not been intialized, initialize it.
  20.     if (!$(this).data("pluginName.initialized")) {
  21.       $(this).data("pluginName.initialized", true);
  22.       component.apply(this, event);
  23.     }
  24.   }
  25.  
  26.  
  27.   function component(event) {
  28.    
  29.     // TODO: Setup component code here
  30.     $(this).bind({
  31.       click : function() { },
  32.       keydown : function() { }
  33.     });
  34.    
  35.     // Refire event for component
  36.     $(event.target).trigger(event.type);
  37.   }
  38. })(jQuery);