/*
 * jQuery UI Notification
 * Copyright (c) 2011 Marcus Ekwall
 *
 * http://writeless.se/projects/jquery-ui-notification/
 *
 * Depends:
 *   - jQuery 1.4
 *   - jQuery UI 1.8 widget factory
 *
 * Dual licensed under the MIT and GPL licenses:
 *   http://www.opensource.org/licenses/mit-license.php
 *   http://www.gnu.org/licenses/gpl.html
 *
*/
(function(a){a(document.body).is("[role]")||a(document.body).attr("role","application");var e=0;a.widget("me.notification",{options:{notificationClass:"ui-widget-content",offset:10,duration:2E3,show:{effect:"fade",options:{},speed:250,callback:function(){}},hide:{effect:"fade",options:{},speed:250,callback:function(){}},fancyHide:true,sticky:false,stack:"below"},content:{title:"Notification",content:function(){return a(this).attr("title")},template:"<h4>${Title}</h4><p>${Content}</p>"},_init:function(){this.notifications=
[];this.notification=a("<div></div>").attr("role","notification").attr("aria-hidden","true").addClass("ui-notification ui-widget ui-corner-all").hide();this.options.stack=="below"?this.notification.css("marginBottom",this.options.offset):this.notification.css("marginTop",this.options.offset);this.notificationClose=a("<a/>").attr("href","#").attr("role","button").addClass("ui-notification-close ui-corner-all").hover(function(){a(this).addClass("ui-state-hover")},function(){a(this).removeClass("ui-state-hover")}).append(a("<span></span>").addClass("ui-icon ui-icon-closethick").text("close"));
this.notificationContent=a("<div></div>").addClass("ui-notification-content")},enable:function(){this.options.disabled=false},disable:function(){this.options.disabled=true},widget:function(b){return b?this.notifications[b]:this.notifications},index:function(){return e},create:function(b,c){b=a.extend({},this.content,b);c=a.extend({},this.options,c);c.disabled||this.notifications.push((new a.me.notification.instance(this))._create(b,a.extend({},this.options,c)))}});a.extend(a.me.notification,{instance:function(b){this.parent=
b}});a.extend(a.me.notification.instance.prototype,{_create:function(b,c){this.options=c;b=b.template.replace("${Title}",b.title).replace("${Content}",b.content);this.element=this.parent.notification.clone(true).attr("id","ui-notification-"+e++).append(this.parent.notificationContent.clone().html(b)).addClass(c.notificationClass);c.stack=="below"?this.element.appendTo(this.parent.element):this.element.prependTo(this.parent.element);var d=this;c.sticky?this.parent.notificationClose.clone(true).click(function(){d.hide();
return false}).prependTo(this.element):setTimeout(function(){d.hide()},d.options.duration);this.show();return this},show:function(){var b=this.options.show;this.element.attr("aria-hidden","false").show(b.effect,b.options,b.speed,b.callback)},hide:function(){var b=this,c=this.options.hide,d=a("<div></div>").height(this.element.outerHeight(true));this.options.fancyHide&&this.element.wrap(d);this.element.hide(c.effect,c.options,c.speed,function(){b.options.fancyHide?a(this).parent().animate({height:0},
250,function(){a(this).remove()}):a(this).remove();c.callback&&c.callback()})}})})(jQuery);
