2013-06-06 15:35:06 +10:00
|
|
|
(function(t,n,e){"use strict";var i,o,r,s,a,l,h,c,p,u,d,A,f,m,w,g,y,b,v,x,C,E,H=[].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",w=g+"js",b={t:"top",m:"middle",b:"bottom",l:"left",c:"center",r:"right"},c=["l","c","r"],E=["t","m","b"],A=["t","b","l","r"],f={t:"b",m:null,b:"t",l:"r",c:null,r:"l"},m=function(t){var n;return n=[],$.each(t.split(/\W+/),function(t,i){var o;return o=i.toLowerCase().charAt(0),b[o]?n.push(o):e}),n},C={},r={name:"core",html:'<div class="'+w+'-wrapper">\n <div class="'+w+'-arrow"></div>\n <div class="'+w+'-container"></div>\n</div>',css:"."+w+"-corner {\n position: fixed;\n margin: 5px;\n z-index: 1050;\n}\n\n."+w+"-corner ."+w+"-wrapper,\n."+w+"-corner ."+w+"-container {\n position: relative;\n display: block;\n height: inherit;\n width: inherit;\n margin: 3px;\n}\n\n."+w+"-wrapper {\n z-index: 1;\n position: absolute;\n display: inline-block;\n height: 0;\n width: 0;\n}\n\n."+w+"-container {\n display: none;\n z-index: 1;\n position: absolute;\n cursor: pointer;\n}\n\n."+w+"-text {\n position: relative;\n}\n\n."+w+"-arrow {\n position: absolute;\n z-index: 2;\n width: 0;\n height: 0;\n}"},x={"border-radius":["-webkit-","-moz-"]},o=function(n,i){var o,r;return(null!=(r=C[n])?r.cssElem:void 0)&&(t.console&&console.warn(""+g+": overwriting style '"+n+"'"),C[n].cssElem.remove()),i.name=n,C[n]=i,o="",i.classes&&$.each(i.classes,function(t,n){return o+="."+w+"-"+i.name+"-"+t+" {\n",$.each(n,function(t,n){return x[t]&&$.each(x[t],function(e,i){return o+=" "+i+t+": "+n+";\n"}),o+=" "+t+": "+n+";\n"}),o+="}\n"}),i.css&&(o+="/* styles for "+i.name+" */\n"+i.css),o?(i.cssElem=d(o),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},y={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(y,t)},s=function(t){return $("<"+t+"></"+t+">")},h={},l=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 o,r;if("string"==typeof i)i=parseInt(i,10);else if("number"!=typeof i)return;if(!isNaN(i))return o=b[f[n.charAt(0)]],r=n,t[o]!==e&&(n=b[o.charAt(0)],i=-i),t[n]===e?t[n]=i:t[n]+=i,null},v=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(y,$.isPlainObject(e)?e:{}),this.loadHTML(),this.wrapper=$(r.html),this.wrapper.data(w,this),this.arrow=this.wrapper.find("."+w+"-arrow"),this.container=this.wrapper.find("."+w+"-container"),this.container.append(this.userContainer),t&&t.length&&(this.elementType=t.attr("type"),this.originalElement=t,this.elem=l(t),this.elem.data(w,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(""+w+"-text")},t.prototype.show=function(t,n){var i,o,r,s,a,l=this;if(o=function(){return t||l.elem||l.destroy(),n?n():e},a=this.container.parent().parents(":hidden").length>0,r=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 o();s=this.options.hideAnimation,i.push(this.options.hideDuration)}return i.p
|