Any suggestions on how I could improve it?
(function($){
$.extend({
notify: function(options, duration) {
var
// Default options object
defaults = {
inline: false,
href: '',
html: '',
onStart: function(){},
onShow: function(){},
onComplete: function(){},
onCleanup: function(){},
onClosed: function(){}
},
options = $.extend(defaults, options),
// Elements & Clones
notifications_active = ($('ul#notification_area').length ? true : false),
container = (notifications_active ? $('ul#notification_area') : $('<ul> </ul>').attr('id', 'notification_area')),
wrapper = $('<li></li>').addClass('notification'),
// Useful variables
clone,
get_clone,
close,
start_countdown,
element,
north,
south,
east,
west,
content,
add_notification;
options.onStart.call(this);
if(!notifications_active){
$('body').append(container);
}
get_clone = function(){
if(options.href){
if(options.inline){
return $(options.href).clone();
}
else {
return $('<iframe></iframe>').attr('src', options.href).css({width: '100%', height: '100%'});
}
}
else if(options.html){
return $(options.html);
}
}
close = function(){
options.onCleanup.call(this);
wrapper.fadeOut('fast', function(){
$(this).remove();
options.onClosed();
})
}
start_countdown = function(){
setTimeout(function(){
close();
}, duration);
}
element = function(tag, cl, id){
var el = document.createElement(tag);
if(cl){
el.className = cl;
}
if(id){
el.id = id;
}
return $(el);
}
add_notification = function(){
wrapper.append(
element('div', 'notify_top').append(
element('div', "notify_nw"),
north = element('div', "notify_n"),
element('div', "notify_ne")
),
element('div', 'notify_center').append(
east = element('div', "notify_w"),
content = element('div', 'notify_content').append(clone),
west = element('div', "notify_e")
),
element('div', 'notify_bottom').append(
element('div', "notify_se"),
south = element('div', "notify_s"),
element('div', "notify_sw")
)
);
wrapper.css("visibility", "hidden").appendTo(container);
if(options.close){
var close_elem = $('<span></span>').addClass('cl').html(options.close);
content.append(close_elem);
}
var anim_length = 0 - parseInt(wrapper.outerHeight());
wrapper.css('marginBottom', anim_length);
wrapper_height = wrapper.height();
north.width(parseInt(wrapper.width())-40);
south.width(parseInt(wrapper.width())-40);
east.height(parseInt(content.height()));
west.height(parseInt(content.height()));
options.onShow.call(this);
wrapper.animate({marginBottom: 0}, 'fast', function(){
wrapper.hide().css('visibility', 'visible').fadeIn('fast');
if(duration){
start_countdown();
}
if(!options.close){
wrapper.bind('click', function(){
close();
})
}
else {
close_elem.bind('click', function(){
close();
})
}
options.onComplete.call(this);
});
}
clone = get_clone();
add_notification();
}
});
})(jQuery);