/
jquery.notific8.min.js
9 lines (9 loc) · 4.53 KB
/
jquery.notific8.min.js
1
2
3
4
5
6
7
8
9
/**
* @author Will Steinmetz
* jQuery notification plug-in inspired by the notification style of Windows 8
* Copyright (c)2013-2015, Will Steinmetz
* Licensed under the BSD license.
* http://opensource.org/licenses/BSD-3-Clause
*/
!function(a){"use strict";var b,c,d,e;d=void 0,b=void 0,c=void 0,e=void 0,d={life:1e4,family:"legacy",theme:"teal",sticky:!1,verticalEdge:"right",horizontalEdge:"top",zindex:1100,icon:!1,closeText:"close",onInit:null,onCreate:null,onClose:null},b=function(){var b,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t;return n=function(){a(window).unbind(".notific8"),a(".jquery-notific8-container").remove()},i=function(c){var d,e,i,j,l,m,n,o,p,q;j=c.data("notific8"),o=Number(a("body").data("notific8s")),i="margin-"+j.settings.verticalEdge,p={},q=j.settings.verticalEdge,l=j.settings.horizontalEdge,d=a(".jquery-notific8-container."+q+"."+l),o+=1,a("body").data("notific8s",o),n="jquery-notific8-notification-"+o,m='<div class="'+r(j).join(" ")+'" id="'+n+'">\n'+g(j)+"\n"+f(j)+"\n"+b(j)+"\n"+h(j)+"\n</div>",e=a(m),d.append(e),j.settings.onCreate&&j.settings.onCreate(e,j),setTimeout(function(){e.addClass("open"),j.settings.sticky||!function(a,b){setTimeout(function(){k(a,j)},b)}(e,Number(j.settings.life)+200)},5)},o=function(a){return a.settings.hasOwnProperty("icon")&&"string"==typeof a.settings.icon},b=function(a){var b;return b='<div class="jquery-notific8-close',a.settings.sticky?(b+=' sticky">',b+=""+a.settings.closeText):b+='">×',b+="</div>"},f=function(a){return a.settings.hasOwnProperty("heading")&&"string"==typeof a.settings.heading?'<div class="jquery-notific8-heading">\n '+a.settings.heading+"\n</div>":""},g=function(a){return o(a)?'<i class="jquery-notific8-icon notific8-fontastic-'+a.settings.icon+'"></i>':""},h=function(a){return'<div class="jquery-notific8-message">\n '+a.message+"\n</div>"},r=function(a){var b;return b=["jquery-notific8-notification","family-"+a.settings.family,a.settings.theme],o(a)&&b.push("has-icon"),a.settings.sticky&&b.push("sticky"),b},k=function(a,b){a.removeClass("open"),a.height(0),setTimeout(function(){a.remove(),b.settings.onClose&&b.settings.onClose(a,b)},200)},l=function(b){a.extend(d,b)},s=function(){a(".jquery-notific8-notification").remove()},t=function(a){d.zindex=a},p=function(b,e){return c.each(function(){var c,f;c=a(this),f=c.data("notific8"),c.data("notific8",{target:c,settings:{},message:""}),f=c.data("notific8"),f.message=b,a.extend(f.settings,d,e),i(c),f.settings.onInit&&f.settings.onInit(f)})},q=function(){var b,c;b=a("body"),b.data("notific8s",0),c='<div class="jquery-notific8-container $pos"></div>',b.append(c.replace("$pos","top right")),b.append(c.replace("$pos","top left")),b.append(c.replace("$pos","bottom right")),b.append(c.replace("$pos","bottom left")),a(".jquery-notific8-container").css("z-index",d.zindex),a(".jquery-notific8-container").on("click",".jquery-notific8-close",function(b){var c,d,e,f;e=a(b.currentTarget),d=e.closest(".jquery-notific8-notification"),c=d.closest(".jquery-notific8-container"),f=c.data("notific8"),k(d,f)})},j=function(a){a.verticalEdge=(a.verticalEdge||d.verticalEdge).toLowerCase(),a.horizontalEdge=(a.horizontalEdge||d.horizontalEdge).toLowerCase(),"right"!==a.verticalEdge&&"left"!==a.verticalEdge&&(a.verticalEdge=d.verticalEdge),"top"!==a.horizontalEdge&&"bottom"!==a.horizontalEdge&&(a.horizontalEdge=d.horizontalEdge)},m=function(a){var b,c,d,f,g,h,i;for(f=a.split("-"),h="",c=void 0,d=void 0,i=document.createElement("p").style,b=void 0,g=void 0,b=function(a){return a.charAt(0).toUpperCase()+a.slice(1)},c=0,d=f.length;d>c;)h+=f[c].toLowerCase().replace(/\b\w{3,}/g,b),c+=1;g=h.charAt(0).toLowerCase()+h.slice(1),e[a]=i.hasOwnProperty(g)||i.hasOwnProperty("Webkit"+h)||i.hasOwnProperty("Moz"+h)||i.hasOwnProperty("ms"+h)||i.hasOwnProperty("O"+h)},{init:p,destroy:n,configure:l,zindex:t,initContainers:q,checkEdges:j,css3Support:m,remove:s}}(),a.notific8=function(c,d){var e,f;switch(c){case"configure":case"config":return b.configure.apply(this,[d]);case"zindex":return b.zindex.apply(this,[d]);case"destroy":return b.destroy.apply(this,[d]);case"remove":return b.remove.apply(this,[d]);default:return"undefined"==typeof d&&(d={}),0===a(".jquery-notific8-container").size()&&b.initContainers(),b.checkEdges(d),f=d.verticalEdge,e=d.horizontalEdge,a(".jquery-notific8-container."+f+"."+e).notific8(c,d)}},a.fn.notific8=function(d){c=this,"undefined"==typeof e&&(e={},b.css3Support("transition")),"string"==typeof d?b.init.apply(this,arguments):a.error("jQuery.notific8 takes a string message as the first parameter")}}(jQuery);
//# sourceMappingURL=jquery.notific8.min.js.map