More of a 'why', 'than it's broken'...
Can someone explain why you'd add the plugin name to the scope and set an alias here:
(function($, plugin) {
$[plugin] = {
timers: {}
};
$.fn[plugin] = function(type, msg, timeout) {
return this.each(function() {
var $this = $('<p class="' + type + '">' + msg + '</p>').prependTo($(this)),
$sameMsgs = $this.siblings().filter(function() {
return !($(this).html() == msg);
});
$this.hide()[$sameMsgs.length ? 'show' : 'slideDown']();
if ($[plugin].timers[msg]) {
clearTimeout($[plugin].timers[msg]);
$sameMsgs.remove();
}
$[plugin].timers[msg] = setTimeout(function() {
$this.slideUp(function() {
$(this).remove()
});
}, timeout || 2500);
});
};
})(jQuery, "quickResponse");
What I'd like to do is write the plugin like so:
(function($) {
$.fn.quickResponse = function(type, msg, timeout)
{
....
};
})(jQuery);