Advertisement
Guest User

jQueryPlugin Test

a guest
May 1st, 2012
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2.  *This is my first jQuery PlugIn and it is based on the following tutorial:
  3.  *http://www.queness.com/post/112/a-really-simple-jquery-plugin-tutorial
  4.  *
  5.  */
  6.  
  7. //You need an anonymous function to wrap around your function to avoid conflict
  8. (function($){
  9.  
  10.     //Attach this new method to jQuery
  11.     $.fn.extend({
  12.          
  13.         //This is where you write your plugin's name:
  14.         //Simple jQuery Notification
  15.         sjn: function(options) {
  16.  
  17.             //construktor
  18.             var defaults ={
  19.                 'fadeInTime':1000,
  20.                 'fadeOutTime':1000,
  21.                 'maxOpacity':0.85
  22.             }
  23.             var options = $.extend(defaults, options);
  24.            
  25.            
  26.             //Public Functions
  27.             this.show = function(){
  28.                 console.log(options.fadeInTime);
  29.                 //var obj = $(this);
  30.                /* $(this).animate(
  31.                 {
  32.                     opacity: options.maxOpacity
  33.                 },
  34.                     options.fadeInTime,
  35.                     function(){
  36.                         console.log("FadinIn Complete...");
  37.                     }
  38.                 );*/
  39.             }
  40.  
  41.             this.hide = function(){
  42.                 $(this).animate(
  43.                     {
  44.                         opacity: 0
  45.                     },
  46.                     options.fadeOutTime,
  47.                     function(){
  48.                         console.log("FadinOut Complete...");
  49.                     }
  50.                 );
  51.             }
  52.             return this;
  53.  
  54.                
  55.  
  56.         }
  57.        
  58.     }
  59. );
  60.      
  61. //pass jQuery to the function,
  62. //So that we will able to use any valid Javascript variable name
  63. //to replace "$" SIGN. But, we'll stick to $ (I like dollar sign: ) )      
  64. })(jQuery);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement