Advertisement
Guest User

Untitled

a guest
May 1st, 2012
97
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.     var self = this;
  11.    
  12.     //Attach this new method to jQuery
  13.     $.fn.extend({
  14.          
  15.         //This is where you write your plugin's name:
  16.         //Simple jQuery Notification
  17.         sjn: function() {
  18.              
  19.              
  20.             //public properties with defaults
  21.             this.fadeInTime = 1000;
  22.             this.fadeOutTime = 1000;
  23.             this.maxOpacity = 0.85;
  24.            
  25.            
  26.             //construktor
  27.             /*var defaults ={
  28.                 'fadeInTime':1000,
  29.                 'fadeOutTime':1000,
  30.                 'maxOpacity':0.85
  31.             }*/
  32.             /*var options = $.extend(defaults, options);*/
  33.            
  34.            
  35.             //Public Functions
  36.             this.show = function(message){
  37.                 //console.log(self.fadeInTime);
  38.                 //var obj = $(this);
  39.                 console.log(message);
  40.                 $(this).stop();
  41.                 $(this).animate(
  42.                     {
  43.                         opacity: this.maxOpacity
  44.                     },
  45.                     this.fadeInTime, 'easeOutQuart',
  46.                     function(){
  47.                            hide();
  48.                     }
  49.                 );
  50.             }
  51.  
  52.             //private Functions
  53.             function hide(){
  54.                 $(this).stop();
  55.                 $(this).animate(
  56.                     {
  57.                         opacity: 0
  58.                     },
  59.                     this.fadeOutTime, 'easeOutQuart',
  60.                     function(){
  61.                         console.log("FadinOut Complete...");
  62.                     }
  63.                 );
  64.             }
  65.                    
  66.             return this;
  67.         }
  68.        
  69.     }
  70.    
  71.    
  72. );
  73.  
  74.    
  75. //pass jQuery to the function,
  76. //So that we will able to use any valid Javascript variable name
  77. //to replace "$" SIGN. But, we'll stick to $ (I like dollar sign: ) )      
  78. })(jQuery);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement