/** Notify.js - v0.0.1 - 2013/06/12
* http://notifyjs.com/
* Copyright (c) 2013 Jaime Pillora - MIT
*/
(function(t,i,n){"use strict";var e,o,r,s,a,h,l,c,p,u,d,f,m,w,y,g,v,b,x,S,C,H,P,T=[].indexOf||function(t){for(var i=0,n=this.length;n>i;i++)if(i in this&&this[i]===t)return i;return-1};v="notify",g=v+"js",x={t:"top",m:"middle",b:"bottom",l:"left",c:"center",r:"right"},p=["l","c","r"],P=["t","m","b"],m=["t","b","l","r"],w={t:"b",m:null,b:"t",l:"r",c:null,r:"l"},y=function(t){var i;return i=[],$.each(t.split(/\W+/),function(t,e){var o;return o=e.toLowerCase().charAt(0),x[o]?i.push(o):n}),i},H={},r={name:"core",html:'
',css:"."+g+"-corner {\n position: fixed;\n margin: 5px;\n z-index: 1050;\n}\n\n."+g+"-corner ."+g+"-wrapper,\n."+g+"-corner ."+g+"-container {\n position: relative;\n display: block;\n height: inherit;\n width: inherit;\n margin: 3px;\n}\n\n."+g+"-wrapper {\n z-index: 1;\n position: absolute;\n display: inline-block;\n height: 0;\n width: 0;\n}\n\n."+g+"-container {\n display: none;\n z-index: 1;\n position: absolute;\n cursor: pointer;\n}\n\n."+g+"-text {\n position: relative;\n}\n\n."+g+"-arrow {\n position: absolute;\n z-index: 2;\n width: 0;\n height: 0;\n}"},C={"border-radius":["-webkit-","-moz-"]},l=function(t){return H[t]},o=function(i,e){var o,r;if(!i)throw"Missing Style name";if(!e)throw"Missing Style definition";return(null!=(r=H[i])?r.cssElem:void 0)&&(t.console&&console.warn(""+v+": overwriting style '"+i+"'"),H[i].cssElem.remove()),e.name=i,H[i]=e,o="",e.classes&&$.each(e.classes,function(t,i){return o+="."+g+"-"+e.name+"-"+t+" {\n",$.each(i,function(t,i){return C[t]&&$.each(C[t],function(n,e){return o+=" "+e+t+": "+i+";\n"}),o+=" "+t+": "+i+";\n"}),o+="}\n"}),e.css&&(o+="/* styles for "+e.name+" */\n"+e.css),o?(e.cssElem=f(o),e.cssElem.attr("id","notify-"+e.name)):n},f=function(t){var i;i=s("style"),i.attr("type","text/css"),$("head").append(i);try{i.html(t)}catch(n){i[0].styleSheet.cssText=t}return i},b={clickToHide:!0,autoHide:!0,autoHideDelay:5e3,arrowShow:!0,arrowSize:5,elementPosition:"bottom",globalPosition:"top right",style:"bootstrap",className:"error",showAnimation:"slideDown",showDuration:400,hideAnimation:"slideUp",hideDuration:200,gap:5},d=function(t,i){var n;return n=function(){},n.prototype=t,$.extend(!0,new n,i)},a=function(t){return $.extend(b,t)},s=function(t){return $("<"+t+">"+t+">")},c={},h=function(t){var i;return t.is("[type=radio]")&&(i=t.parents("form:first").find("[type=radio]").filter(function(i,n){return $(n).attr("name")===t.attr("name")}),t=i.first()),t},u=function(t,i,e){var o,r;if("string"==typeof e)e=parseInt(e,10);else if("number"!=typeof e)return;if(!isNaN(e))return o=x[w[i.charAt(0)]],r=i,t[o]!==n&&(i=x[o.charAt(0)],e=-e),t[i]===n?t[i]=e:t[i]+=e,null},S=function(t,i,n){if("l"===t||"t"===t)return 0;if("c"===t||"m"===t)return n/2-i/2;if("r"===t||"b"===t)return n-i;throw"Invalid alignment"},e=function(){function t(t,i,n){"string"==typeof n&&(n={className:n}),this.options=d(b,$.isPlainObject(n)?n:{}),this.loadHTML(),this.wrapper=$(r.html),this.wrapper.data(g,this),this.arrow=this.wrapper.find("."+g+"-arrow"),this.container=this.wrapper.find("."+g+"-container"),this.container.append(this.userContainer),t&&t.length&&(this.elementType=t.attr("type"),this.originalElement=t,this.elem=h(t),this.elem.data(g,this),this.elem.before(this.wrapper)),this.container.hide(),this.run(i)}return t.prototype.loadHTML=function(){var t;if(t=this.getStyle(),this.userContainer=$(t.html),this.text=this.userContainer.find("[data-notify-text]"),0===this.text.length&&(this.text=this.userContainer.find("[data-notify-html]"),this.rawHTML=!0),0===this.text.length)throw"style: '"+name+"' HTML is missing a: 'data-notify-text' or 'data-notify-html' attribute";return this.text.addClass(""+g+"-text")},t.prototype.show=function(t,i){var e,o,r,s,a,h=this;if(o=function(){return t||h.elem||h.destroy(),i?i():n},a=this.container.parent().parents(":hidden").length>0,r=this.container.add(this.arrow),e=[],a&&t)s="show";else if(a&&!t)s="hide";else if(!a&&t)s=this.options.showAnimation,e.push(this.options.showDuration);else{if(a||t)return o();s=this.options.hideAnimation,e.push(this.options.hideDuration)}return e.push(o),r[s].apply(r,e)},t.prototype.setGlobalPosition=function(){var t,i,n,e,o,r,a,h;return h=this.getPosition(),a=h[0],r=h[1],o=x[a],t=x[r],e=a+"|"+r,i=c[e],i||(i=c[e]=s("div"),n={},n[o]=0,"middle"===t?n.top="45%":"center"===t?n.left="45%":n[t]=0,i.css(n).addClass(""+g+"-corner"),$("body").append(i)),i.prepend(this.wrapper)},t.prototype.setElementPosition=function(){var t,i,e,o,r,s,a,h,l,c,d,f,y,g,v,b,C,H,A,M,N,k,z,D,E,L,j,O,I;for(z=this.getPosition(),M=z[0],H=z[1],A=z[2],d=this.elem.position(),h=this.elem.outerHeight(),f=this.elem.outerWidth(),l=this.elem.innerHeight(),c=this.elem.innerWidth(),D=this.wrapper.position(),r=this.container.height(),s=this.container.width(),g=x[M],b=w[M],C=x[b],a={},a[C]="b"===M?h:"r"===M?f:0,u(a,"top",d.top-D.top),u(a,"left",d.left-D.left),I=["top","left"],E=0,j=I.length;j>E;E++)N=I[E],v=parseInt(this.elem.css("margin-"+N),10),v&&u(a,N,v);if(y=Math.max(0,this.options.gap-(this.options.arrowShow?e:0)),u(a,C,y),this.options.arrowShow){for(e=this.options.arrowSize,i=$.extend({},a),t=this.userContainer.css("border-color")||this.userContainer.css("background-color")||"white",L=0,O=m.length;O>L;L++)N=m[L],k=x[N],N!==b&&(o=k===g?t:"transparent",i["border-"+k]=""+e+"px solid "+o);u(a,x[b],e),T.call(m,H)>=0&&u(i,x[H],2*e)}else this.arrow.hide();return T.call(P,M)>=0?(u(a,"left",S(H,s,f)),i&&u(i,"left",S(H,e,c))):T.call(p,M)>=0&&(u(a,"top",S(H,r,h)),i&&u(i,"top",S(H,e,l))),this.container.is(":visible")&&(a.display="block"),this.container.removeAttr("style").css(a),i?this.arrow.removeAttr("style").css(i):n},t.prototype.getPosition=function(){var t,i,n,e,o,r,s,a;if(i=this.options.position||(this.elem?this.options.elementPosition:this.options.globalPosition),t=y(i),0===t.length&&(t[0]="b"),n=t[0],0>T.call(m,n))throw"Must be one of ["+m+"]";return(1===t.length||(e=t[0],T.call(P,e)>=0&&(o=t[1],0>T.call(p,o)))||(r=t[0],T.call(p,r)>=0&&(s=t[1],0>T.call(P,s))))&&(t[1]=(a=t[0],T.call(p,a)>=0?"m":"l")),2===t.length&&(t[2]=t[1]),t},t.prototype.getStyle=function(t){var i;if(t||(t=this.options.style),t||(t="default"),i=H[t],!i)throw"Missing style: "+t;return i},t.prototype.updateClasses=function(){var t,i;return t=["base"],$.isArray(this.options.className)?t=t.concat(this.options.className):this.options.className&&t.push(this.options.className),i=this.getStyle(),t=$.map(t,function(t){return""+g+"-"+i.name+"-"+t}).join(" "),this.userContainer.attr("class",t)},t.prototype.run=function(t,i){var e=this;return $.isPlainObject(i)?$.extend(this.options,i):"string"===$.type(i)&&(this.options.color=i),this.container&&!t?(this.show(!1),n):this.container||t?(this.text[this.rawHTML?"html":"text"](t),this.updateClasses(),this.elem?this.setElementPosition():this.setGlobalPosition(),this.show(!0),this.options.autoHide?(clearTimeout(this.autohideTimer),this.autohideTimer=setTimeout(function(){return e.show(!1)},this.options.autoHideDelay)):n):n},t.prototype.destroy=function(){return this.wrapper.remove()},t}(),$[v]=function(t,i,n){return t&&t.nodeName||t.jquery?$(t)[v](i,n):(n=i,i=t,new e(null,i,n)),t},$.fn[v]=function(t,i){return $(this).each(function(){var n;return n=h($(this)).data(g),n?n.run(t,i):new e($(this),t,i)}),this},$.extend($[v],{defaults:a,addStyle:o,pluginOptions:b,getStyle:l,insertCSS:f}),$(function(){return f(r.css).attr("id","core-notify"),$(i).on("click notify-hide","."+g+"-wrapper",function(t){var i;return i=$(this).data(g),i&&(i.options.clickToHide||"notify-hide"===t.type)?i.show(!1):n})})})(window,document);