/** Notify.js - v0.0.1 - 2013/06/03
* http://notifyjs.com/
* Copyright (c) 2013 Jaime Pillora - MIT
*/(function(t,n,e){"use strict";var i,r,o,s,a,l,h,p,c,u,d,f,w,m,y,A,b,g,x,v,C,S,k,R=[].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",o=g+"js",v={t:"top",m:"middle",b:"bottom",l:"left",c:"center",r:"right"},u=["l","c","r"],k=["t","m","b"],m=["t","b","l","r"],y={t:"b",m:null,b:"t",l:"r",c:null,r:"l"},b=function(t){var n;return n=[],$.each(t.split(/\W+/),function(t,i){var r;return r=i.toLowerCase().charAt(0),v[r]?n.push(r):e}),n},S={},s={name:"core",html:'
',css:"."+o+"-corner {\n position: fixed;\n top: 0;\n right: 0;\n margin: 5px;\n z-index: 1050;\n}\n\n."+o+"-corner ."+o+"-wrapper,\n."+o+"-corner ."+o+"-container {\n position: relative;\n display: block;\n height: inherit;\n width: inherit;\n}\n\n."+o+"-wrapper {\n z-index: 1;\n position: absolute;\n display: inline-block;\n height: 0;\n width: 0;\n}\n\n."+o+"-container {\n display: none;\n z-index: 1;\n position: absolute;\n cursor: pointer;\n}\n\n."+o+"-text {\n position: relative;\n}\n\n."+o+"-arrow {\n position: absolute;\n z-index: 2;\n width: 0;\n height: 0;\n}"},p="bootstrap",h={html:"\n \n
",classes:{base:"padding: 8px 35px 8px 14px;\ntext-shadow: 0 1px 0 rgba(255, 255, 255, 0.5);\nbackground-color: #fcf8e3;\nborder: 1px solid #fbeed5;\n-webkit-border-radius: 4px;\n-moz-border-radius: 4px;\nborder-radius: 4px;\nwhite-space: nowrap;",error:"color: #B94A48;\nbackground-color: #F2DEDE;\nborder-color: #EED3D7;\npadding-left: 25px;\nbackground-repeat: no-repeat;\nbackground-position: 3px 7px;\nbackground-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAYAAACNiR0NAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAtRJREFUeNqkVc1u00AQHq+dOD+0poIQfkIjalW0SEGqRMuRnHos3DjwAH0ArlyQeANOOSMeAA5VjyBxKBQhgSpVUKKQNGloFdw4cWw2jtfMOna6JOUArDTazXi/b3dm55socPqQhFka++aHBsI8GsopRJERNFlY88FCEk9Yiwf8RhgRyaHFQpPHCDmZG5oX2ui2yilkcTT1AcDsbYC1NMAyOi7zTX2Agx7A9luAl88BauiiQ/cJaZQfIpAlngDcvZZMrl8vFPK5+XktrWlx3/ehZ5r9+t6e+WVnp1pxnNIjgBe4/6dAysQc8dsmHwPcW9C0h3fW1hans1ltwJhy0GxK7XZbUlMp5Ww2eyan6+ft/f2FAqXGK4CvQk5HueFz7D6GOZtIrK+srupdx1GRBBqNBtzc2AiMr7nPplRdKhb1q6q6zjFhrklEFOUutoQ50xcX86ZlqaZpQrfbBdu2R6/G19zX6XSgh6RX5ubyHCM8nqSID6ICrGiZjGYYxojEsiw4PDwMSL5VKsC8Yf4VRYFzMzMaxwjlJSlCyAQ9l0CW44PBADzXhe7xMdi9HtTrdYjFYkDQL0cn4Xdq2/EAE+InCnvADTf2eah4Sx9vExQjkqXT6aAERICMewd/UAp/IeYANM2joxt+q5VI+ieq2i0Wg3l6DNzHwTERPgo1ko7XBXj3vdlsT2F+UuhIhYkp7u7CarkcrFOCtR3H5JiwbAIeImjT/YQKKBtGjRFCU5IUgFRe7fF4cCNVIPMYo3VKqxwjyNAXNepuopyqnld602qVsfRpEkkz+GFL1wPj6ySXBpJtWVa5xlhpcyhBNwpZHmtX8AGgfIExo0ZpzkWVTBGiXCSEaHh62/PoR0p/vHaczxXGnj4bSo+G78lELU80h1uogBwWLf5YlsPmgDEd4M236xjm+8nm4IuE/9u+/PH2JXZfbwz4zw1WbO+SQPpXfwG/BBgAhCNZiSb/pOQAAAAASUVORK5CYII=);",info:"",warn:""}},r=function(t,n){var i;return S[t]?(alert(""+g+": style '"+t+"' already defined"),e):(n.name=t,S[t]=n,!n.cssElem&&(i="",n.classes&&$.each(n.classes,function(t,e){return i+="."+o+"-"+n.name+"-"+t+" {\n "+e+"\n}\n"}),n.css&&(i+="/* styles for "+n.name+" */\n"+n.css),i)?(n.cssElem=w(i),n.cssElem.attr("data-notify-style",n.name)):e)},w=function(t){var n;n=l("style"),$("head").append(n);try{n.html(t)}catch(e){n[0].styleSheet.cssText=t}return n},x={autoHide:!1,autoHideDelay:2e3,arrowShow:!0,arrowSize:5,arrowColor:"border",position:"bottom",style:"bootstrap",cls:"error",showAnimation:"slideDown",showDuration:400,hideAnimation:"slideUp",hideDuration:200,offsetY:0,offsetX:0},f=function(t,n){var e;return e=function(){},e.prototype=t,$.extend(!0,new e,n)},A=function(t){return $.extend(x,t)},l=function(t){return $("<"+t+">"+t+">")},a=l("div").addClass(""+o+"-corner"),c=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},d=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=v[y[n.charAt(0)]],o=n,t[r]!==e&&(n=v[r.charAt(0)],i*=-1),t[n]===e?t[n]=i:t[n]+=i,null},C=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={color:e}),this.options=f(x,$.isPlainObject(e)?e:{}),this.loadHTML(),this.wrapper=$(s.html),this.wrapper.data(o,this),this.arrow=this.wrapper.find("."+o+"-arrow"),this.container=this.wrapper.find("."+o+"-container"),this.container.append(this.userContainer),t&&t.length?(this.elementType=t.attr("type"),this.originalElement=t,this.elem=c(t),this.elem.data(o,this),this.elem.before(this.wrapper)):(this.options.arrowShow=!1,a.prepend(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)throw"style: "+name+" HTML is missing the: 'data-notify-text' attribute";return this.text.addClass(""+o+"-text")},t.prototype.show=function(t,n){var e,i,r,o;if(null==n&&(n=$.noop),o=this.container.parent().parents(":hidden").length>0,i=this.container.add(this.arrow),e=[],o&&t)r="show";else if(o&&!t)r="hide";else if(!o&&t)r=this.options.showAnimation,e.push(this.options.showDuration);else{if(o||t)return n();r=this.options.hideAnimation,e.push(this.options.hideDuration)}return e.push(n),i[r].apply(i,e)},t.prototype.updatePosition=function(){var t,n,i,r,o,s,a,l,h,p,c,f,w,A,b,g,x,S,E,H,D,I,X,j,B,F;if(this.elem){if(p=this.elem.position(),a=this.elem.outerHeight(),c=this.elem.outerWidth(),l=this.elem.innerHeight(),h=this.elem.innerWidth(),j=this.wrapper.position(),r=this.container.height(),o=this.container.width(),I=this.getPosition(),console.log(I),S=I[0],g=I[1],x=I[2]||g,f=v[S],A=y[S],b=v[A],s={},s[b]="b"===S?a:"r"===S?c:0,d(s,"left",p.left-j.left),w=parseInt(this.elem.css("margin-left"),10),w&&d(s,"left",w),/^inline/.test(this.elem.css("display"))&&(E=parseInt(this.elem.css("padding-top"),10),E&&d(s,"top",-E)),d(s,"top",this.options.offsetY),d(s,"left",this.options.offsetX),X=this.getStyle(),this.options.arrowShow){for(n=this.options.arrowSize,t=$.extend({},s),B=0,F=m.length;F>B;B++)H=m[B],D=v[H],H!==A&&(i=D===f?"black":"transparent",t["border-"+D]=""+n+"px solid "+i);d(s,v[A],n),R.call(m,g)>=0&&d(t,v[g],2*n)}else this.arrow.hide();return R.call(k,S)>=0?(d(s,"left",C(g,o,c)),t&&d(t,"left",C(g,n,h))):R.call(u,S)>=0&&(d(s,"top",C(g,r,a)),t&&d(t,"top",C(g,n,l))),this.container.is(":visible")&&(s.display="block"),this.container.removeAttr("style").css(s),t?this.arrow.removeAttr("style").css(t):e}},t.prototype.getPosition=function(){var t,n,e,i,r,o,s,a;if(n=this.options.position,t=b(n),0===t.length&&(t[0]="b"),e=t[0],0>R.call(m,e))throw"Must be one of ["+m+"]";if((1===t.length||(i=t[0],R.call(k,i)>=0&&(r=t[1],0>R.call(u,r)))||(o=t[0],R.call(u,o)>=0&&(s=t[1],0>R.call(k,s))))&&(t[1]=(a=t[0],R.call(u,a)>=0?"m":"l")),!this.options.autoReposition)return t;throw"Not implemented"},t.prototype.getStyle=function(t){var n;if(t||(t=this.options.style),t||(t="default"),n=S[t],!n)throw"Missing style: "+t;return n},t.prototype.updateStyleClasses=function(){var t,n;return t=["base"],$.isArray(this.options.cls)?t=t.concat(this.options.cls):this.options.cls&&t.push(this.options.cls),n=this.getStyle(),t=$.map(t,function(t){return""+o+"-"+n.name+"-"+t}).join(" "),this.userContainer.attr("class",t)},t.prototype.run=function(t,n){var i=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?("string"===$.type(t)?this.text.html(t.replace("\n","
")):this.text.empty().append(t),this.updateStyleClasses(),this.updatePosition(),this.show(!0),this.options.autoHide?(clearTimeout(this.autohideTimer),this.autohideTimer=setTimeout(function(){return i.show(!1)},this.options.autoHideDelay)):e):e},t.prototype.destroy=function(){var t=this;return this.show(!1,function(){return t.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=c($(this)).data(o),e?e.run(t,n):new i($(this),t,n)}),this},$.extend($[g],{options:A,addStyle:r}),$(function(){return $("body").append(a),$("link").each(function(){var t,n;return n=$(this).attr("href"),n.match(/bootstrap/)?(t=!0,!1):e}),w(s.css).attr("data-notify-style","core"),$[g].addStyle(p,h),$(n).on("click","."+o+"-wrapper",function(){var t;return(t=$(this).data(o))?t.elem?t.show(!1):t.destroy():e})})})(window,document);