Files
jquery-notify/dist/notify.min.js
T

5 lines
7.4 KiB
JavaScript
Raw Normal View History

2013-06-06 14:03:15 +10:00
/** Notify.js - v0.0.1 - 2013/06/06
2013-04-04 13:13:08 +11:00
* http://notifyjs.com/
* Copyright (c) 2013 Jaime Pillora - MIT
2013-06-05 13:17:20 +10:00
*/
2013-06-06 14:03:15 +10:00
(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:'<div class="'+y+'-wrapper">\n <div class="'+y+'-arrow"></div>\n <div class="'+y+'-container"></div>\n</div>',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+"></"+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].appl