(function ($) { $.msgAlert = function (config) { var defaults, options, msgAlert, popup, header, close, content, footer, overlay; defaults = { type: '', title: '', text: '', callback: function () {}, closeTrigger: true, escClose: true, overlay: true, overlayClose: false, buttons: [{ text: 'Ok', callback: function () { $.msgAlert.close(); options.callback() } }] }; options = $.extend(defaults, config); msgAlert = $('
', { 'class': 'msgAlert ' + options.type }).appendTo('body'); popup = $('
', { 'class': 'msgAlert_popup' }).appendTo(msgAlert); if (options.title != '') { header = $('
', { 'class': 'msgAlert_header', 'html': '

' + options.title + '

' }).appendTo(popup) } if (options.closeTrigger) { close = $('', { 'href': 'javascript:;', 'class': 'msgAlert_close', 'click': close }).appendTo(header) } content = $('
', { 'class': 'msgAlert_content', 'text': options.text }).appendTo(popup); footer = $('
', { 'class': 'msgAlert_footer' }).appendTo(msgAlert); if (options.overlay) { overlay = $('
', { 'class': 'msgAlert_overlay' }).appendTo('body'); if (options.overlay && options.overlayClose) { overlay.bind('click', close) } } if (options.type == 'warning') { options.buttons = [{ text: 'Yes', callback: function () { options.callback(); $.msgAlert.close() } }, { text: 'No', callback: function () { $.msgAlert.close() } }, { text: 'Cancel', callback: function () { $.msgAlert.close() } }] } if (options.buttons.length > 0) { for (key in options.buttons) { $('