2013-06-11 18:28:39 +10:00
|
|
|
(function(t,n,i){"use strict";var e,o,r,s,a,l,h,c,p,u,d,A,f,m,w,g,y,b,v,x,C,E,S,M=[].indexOf||function(t){for(var n=0,i=this.length;i>n;n++)if(n in this&&this[n]===t)return n;return-1};y="notify",g=y+"js",v={t:"top",m:"middle",b:"bottom",l:"left",c:"center",r:"right"},p=["l","c","r"],S=["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,e){var o;return o=e.toLowerCase().charAt(0),v[o]?n.push(o):i}),n},E={},r={name:"core",html:'<div class="'+g+'-wrapper">\n <div class="'+g+'-arrow"></div>\n <div class="'+g+'-container"></div>\n</div>',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-"]},h=function(t){return E[t]},o=function(n,e){var o,r;if(!n)throw"Missing Style name";if(!e)throw"Missing Style definition";return(null!=(r=E[n])?r.cssElem:void 0)&&(t.console&&console.warn(""+y+": overwriting style '"+n+"'"),E[n].cssElem.remove()),e.name=n,E[n]=e,o="",e.classes&&$.each(e.classes,function(t,n){return o+="."+g+"-"+e.name+"-"+t+" {\n",$.each(n,function(t,n){return C[t]&&$.each(C[t],function(i,e){return o+=" "+e+t+": "+n+";\n"}),o+=" "+t+": "+n+";\n"}),o+="}\n"}),e.css&&(o+="/* styles for "+e.name+" */\n"+e.css),o?(e.cssElem=A(o),e.cssElem.attr("id","notify-"+e.name)):i},A=function(t){var n;n=s("style"),$("head").append(n);try{n.html(t)}catch(i){n[0].styleSheet.cssText=t}return n},b={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,n){var i;return i=function(){},i.prototype=t,$.extend(!0,new i,n)},a=function(t){return $.extend(b,t)},s=function(t){return $("<"+t+"></"+t+">")},c={},l=function(t){var n;return t.is("[type=radio]")&&(n=t.parents("form:first").find("[type=radio]").filter(function(n,i){return $(i).attr("name")===t.attr("name")}),t=n.first()),t},u=function(t,n,e){var o,r;if("string"==typeof e)e=parseInt(e,10);else if("number"!=typeof e)return;if(!isNaN(e))return o=v[m[n.charAt(0)]],r=n,t[o]!==i&&(n=v[o.charAt(0)],e=-e),t[n]===i?t[n]=e:t[n]+=e,null},x=function(t,n,i){if("l"===t||"t"===t)return 0;if("c"===t||"m"===t)return i/2-n/2;if("r"===t||"b"===t)return i-n;throw"Invalid alignment"},e=function(){function t(t,n,i){"string"==typeof i&&(i={className:i}),this.options=d(b,$.isPlainObject(i)?i:{}),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=l(t),this.elem.data(g,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(""+g+"-text")},t.prototype.show=function(t,n){var e,o,r,s,a,l=this;if(o=function(){return t||l.elem||l.destroy(),n?n():i},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
|