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

5 lines
7.8 KiB
JavaScript
Raw Normal View History

/** Notify.js - v0.0.1 - 2013/06/14
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
*/
(function(t,i,n){"use strict";var e,o,r,s,a,h,l,c,p,u,d,f,m,w,y,g,b,v,x,S,C,H,P,T,N=[].indexOf||function(t){for(var i=0,n=this.length;n>i;i++)if(i in this&&this[i]===t)return i;return-1};v="notify",b=v+"js",S={t:"top",m:"middle",b:"bottom",l:"left",c:"center",r:"right"},u=["l","c","r"],T=["t","m","b"],w=["t","b","l","r"],y={t:"b",m:null,b:"t",l:"r",c:null,r:"l"},g=function(t){var i;return i=[],$.each(t.split(/\W+/),function(t,e){var o;return o=e.toLowerCase().charAt(0),S[o]?i.push(o):n}),i},P={},r={name:"core",html:'<div class="'+b+'-wrapper">\n <div class="'+b+'-arrow"></div>\n <div class="'+b+'-container"></div>\n</div>',css:"."+b+"-corner {\n position: fixed;\n margin: 5px;\n z-index: 1050;\n}\n\n."+b+"-corner ."+b+"-wrapper,\n."+b+"-corner ."+b+"-container {\n position: relative;\n display: block;\n height: inherit;\n width: inherit;\n margin: 3px;\n}\n\n."+b+"-wrapper {\n z-index: 1;\n position: absolute;\n display: inline-block;\n height: 0;\n width: 0;\n}\n\n."+b+"-container {\n display: none;\n z-index: 1;\n position: absolute;\n cursor: pointer;\n}\n\n."+b+"-text {\n position: relative;\n}\n\n."+b+"-arrow {\n position: absolute;\n z-index: 2;\n width: 0;\n height: 0;\n}"},H={"border-radius":["-webkit-","-moz-"]},c=function(t){return P[t]},o=function(i,e){var o,r;if(!i)throw"Missing Style name";if(!e)throw"Missing Style definition";return(null!=(r=P[i])?r.cssElem:void 0)&&(t.console&&console.warn(""+v+": overwriting style '"+i+"'"),P[i].cssElem.remove()),e.name=i,P[i]=e,o="",e.classes&&$.each(e.classes,function(t,i){return o+="."+b+"-"+e.name+"-"+t+" {\n",$.each(i,function(t,i){return H[t]&&$.each(H[t],function(n,e){return o+=" "+e+t+": "+i+";\n"}),o+=" "+t+": "+i+";\n"}),o+="}\n"}),e.css&&(o+="/* styles for "+e.name+" */\n"+e.css),o?(e.cssElem=m(o),e.cssElem.attr("id","notify-"+e.name)):n},m=function(t){var i;i=s("style"),i.attr("type","text/css"),$("head").append(i);try{i.html(t)}catch(n){i[0].styleSheet.cssText=t}return i},x={clickToHide:!0,autoHide:!0,autoHideDelay:5e3,arrowShow:!0,arrowSize:5,breakNewLines:!0,elementPosition:"bottom",globalPosition:"top right",style:"bootstrap",className:"error",showAnimation:"slideDown",showDuration:400,hideAnimation:"slideUp",hideDuration:200,gap:5},f=function(t,i){var n;return n=function(){},n.prototype=t,$.extend(!0,new n,i)},a=function(t){return $.extend(x,t)},s=function(t){return $("<"+t+"></"+t+">")},p={},l=function(t){var i;return t.is("[type=radio]")&&(i=t.parents("form:first").find("[type=radio]").filter(function(i,n){return $(n).attr("name")===t.attr("name")}),t=i.first()),t},d=function(t,i,e){var o,r;if("string"==typeof e)e=parseInt(e,10);else if("number"!=typeof e)return;if(!isNaN(e))return o=S[y[i.charAt(0)]],r=i,t[o]!==n&&(i=S[o.charAt(0)],e=-e),t[i]===n?t[i]=e:t[i]+=e,null},C=function(t,i,n){if("l"===t||"t"===t)return 0;if("c"===t||"m"===t)return n/2-i/2;if("r"===t||"b"===t)return n-i;throw"Invalid alignment"},h=function(t){return h.e=h.e||s("div"),h.e.text(t).html()},e=function(){function t(t,i,n){"string"==typeof n&&(n={className:n}),this.options=f(x,$.isPlainObject(n)?n:{}),this.loadHTML(),this.wrapper=$(r.html),this.wrapper.data(b,this),this.arrow=this.wrapper.find("."+b+"-arrow"),this.container=this.wrapper.find("."+b+"-container"),this.container.append(this.userContainer),t&&t.length&&(this.elementType=t.attr("type"),this.originalElement=t,this.elem=l(t),this.elem.data(b,this),this.elem.before(this.wrapper)),this.container.hide(),this.run(i)}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(""+b+"-text")},t.prototype.show=function(t,i){var e,o,r,s,a,h=this;if(o=function(){return t||h.elem||h.destroy(),i?i():n},a=this.container.parent().parents(":hidden").length>0,r=this.container.add(this.arrow