
jQueryPlugin Test
By: a guest on
May 1st, 2012 | syntax:
JavaScript | size: 1.79 KB | hits: 19 | expires: Never
/*
*This is my first jQuery PlugIn and it is based on the following tutorial:
*http://www.queness.com/post/112/a-really-simple-jquery-plugin-tutorial
*
*/
//You need an anonymous function to wrap around your function to avoid conflict
(function($){
//Attach this new method to jQuery
$.fn.extend({
//This is where you write your plugin's name:
//Simple jQuery Notification
sjn: function(options) {
//construktor
var defaults ={
'fadeInTime':1000,
'fadeOutTime':1000,
'maxOpacity':0.85
}
var options = $.extend(defaults, options);
//Public Functions
this.show = function(){
console.log(options.fadeInTime);
//var obj = $(this);
/* $(this).animate(
{
opacity: options.maxOpacity
},
options.fadeInTime,
function(){
console.log("FadinIn Complete...");
}
);*/
}
this.hide = function(){
$(this).animate(
{
opacity: 0
},
options.fadeOutTime,
function(){
console.log("FadinOut Complete...");
}
);
}
return this;
}
}
);
//pass jQuery to the function,
//So that we will able to use any valid Javascript variable name
//to replace "$" SIGN. But, we'll stick to $ (I like dollar sign: ) )
})(jQuery);