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