Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

jAlert

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jAlert - npm Package Compare versions

Comparing version 4.6.5 to 4.7.0

.DS_Store

2

auto-compile-pre-commit-hook.txt

@@ -9,2 +9,2 @@ #!/bin/sh

git add -A #add to the current commit
git add -A #add to the current commit

@@ -7,2 +7,2 @@ /*

*/
!function(d){var n;Date.now||(Date.now=function(){return+new Date}),d.fn.jAlert=function(o){d("body").focus(),d("body").blur();var e={xsmall:"xsm",small:"sm",medium:"md",large:"lg",xlarge:"xlg"},i=[],a=["animated"],r=[];if(1<this.length)return this.each(function(){d.fn.jAlert(o)}),this;if(void 0!==d(this)[0]&&"undefined"!=d(this)[0].jAlert)return d(this)[0].jAlert;if(d.each(d.fn.jAlert.defaults,function(e,t){var n=e.toLowerCase();void 0!==o[n]&&(o[e]=o[n])}),(o=d.extend({},d.fn.jAlert.defaults,o)).id)t=o.id;else var t="ja_"+(Date.now().toString()+Math.floor(1e5*Math.random()));var l={set:function(e,t){return l[e]=t,l},__set:function(e,t){return l.set(e,t)},get:function(e){return l[e]},__get:function(e){return l.get(e)},animateAlert:function(e){return"hide"==e?(l.instance.jAlert().blurBackground&&d("body").removeClass("ja_blur"),l.instance.removeClass(l.showAnimation).addClass(l.hideAnimation)):(l.instance.jAlert().blurBackground&&d("body").addClass("ja_blur"),l.instance.addClass(l.showAnimation).removeClass(l.hideAnimation).show()),l},closeAlert:function(t,n){return 0!=t&&(t=!0),l.instance&&(l.animateAlert("hide"),window.setTimeout(function(){var e=l.instance.parents(".ja_wrap");t?e.remove():e.hide(),"function"==typeof n?n(l.instance):"function"==typeof l.onClose&&l.onClose(l.instance),0===d(".jAlert:visible").length&&d("html,body").css("overflow","")},l.animationTimeout)),l},showAlert:function(e,t,n,o){0!=e&&(e=!0),!1!==t&&(t=!0),e&&d(".jAlert:visible").jAlert().closeAlert(t);var i=l.instance.parents(".ja_wrap");return d("body").append(i),l.animateAlert("show"),"function"==typeof o&&(l.onClose=o),window.setTimeout(function(){"function"==typeof n&&n(l.instance)},l.animationTimeout),l}};if(d.each(o,function(e,t){l.set(e,t)}),l.set("id",t),l.content&&0===l.content.indexOf("#")&&0<d(l.content).length&&(l.content=d(l.content).html()),l.video&&-1<l.video.indexOf("youtube.com/watch?v=")&&-1===l.video.indexOf("embed")&&(l.video=l.video.replace("watch?v=","embed/")),"confirm"==l.type&&(l.content||(l.content=l.confirmQuestion),l.btns=[{text:l.confirmBtnText,theme:"green",class:"confirmBtn",closeAlert:!0,onClick:l.onConfirm},{text:l.denyBtnText,theme:"red",class:"denyBtn",closeAlert:!0,onClick:l.onDeny}],l.autofocus=l.confirmAutofocus),l.color&&(l.theme=l.color),-1==d.inArray(l.theme,["default","green","dark_green","red","dark_red","black","brown","gray","dark_gray","blue","dark_blue","yellow"]))return console.log("jAlert Config Error: Invalid theme selection."),!1;if(a.push("ja_"+l.theme),l.class&&a.push(l.class),l.classes&&a.push(l.classes),l.fullscreen&&a.push("ja_fullscreen"),l.noPadContent&&a.push("ja_no_pad"),l.title||a.push("ja_noTitle"),l.width&&(l.size=l.width),l.size&&"object"==typeof l.size&&(void 0===l.size.width||void 0===l.size.height))return console.log("jAlert Config Error: Invalid size selection (try a preset or make sure you're including height and width in your size object)."),!1;if(l.size?"object"==typeof l.size?(i.push("width: "+l.size.width+";"),i.push("height: "+l.size.height+";"),a.push("ja_setheight")):(void 0!==e[l.size]&&(l.size=e[l.size]),-1<d.inArray(l.size,["xsm","sm","md","lg","xlg","full","auto"])?a.push("ja_"+l.size):i.push("width: "+l.size+";")):a.push("ja_sm"),-1==d.inArray(l.backgroundColor,["white","black"]))return console.log("jAlert Config Error: Invalid background color selection."),!1;r.push("ja_wrap_"+l.backgroundColor),l.onOpen=[l.onOpen];var n="<div class='ja_loader'>Loading...</div>";l.picture&&(l.image=l.picture),l.image?(l.content="<div class='ja_media_wrap'>"+n+"<img src='"+l.image+"' class='ja_img' onload='$.fn.jAlert.mediaLoaded($(this))''",l.imageWidth&&(l.content+=" style='width: "+l.imageWidth+"'"),l.content+="></div>"):l.video?(l.content="<div class='ja_media_wrap'>"+n+"<div class='ja_video'></div></div>",l.onOpen.unshift(function(e){var t=document.createElement("iframe");t.src=e.jAlert().video,t.addEventListener?t.addEventListener("load",function(){d.fn.jAlert.mediaLoaded(d(this))},!0):t.attachEvent?t.attachEvent("onload",function(){d.fn.jAlert.mediaLoaded(d(this))}):t.onload=function(){d.fn.jAlert.mediaLoaded(d(this))},e.find(".ja_video").append(t)})):l.iframe?(l.iframeHeight||(l.iframeHeight=d(window).height()+"px"),l.content="<div class='ja_media_wrap'>"+n+"</div>",l.onOpen.unshift(function(e){var t=document.createElement("iframe");t.src=e.jAlert().iframe,t.className="ja_iframe",t.addEventListener?t.addEventListener("load",function(){d.fn.jAlert.mediaLoaded(d(this))},!0):t.attachEvent?t.attachEvent("onload",function(){d.fn.jAlert.mediaLoaded(d(this))}):t.onload=function(){d.fn.jAlert.mediaLoaded(d(this))},e.find(".ja_media_wrap").append(t)})):l.ajax&&(l.content="<div class='ja_media_wrap'>"+n+"</div>",onAjaxCallbacks=l.onOpen,l.onOpen=[function(o){d.ajax(o.jAlert().ajax,{async:!0,complete:function(e,t){o.find(".ja_media_wrap").replaceWith(e.responseText),d.each(onAjaxCallbacks,function(e,t){t(o)})},error:function(e,t,n){l.onAjaxFail(o,"Error getting content: Code: "+e.status+" : Msg: "+e.statusText)}})}]);var s=function(o){if(void 0===o.href&&(o.href=""),void 0===o.class&&(o.class=""),void 0===o.theme?o.class+=" ja_btn_default":o.class+=" ja_btn_"+o.theme,void 0===o.text&&(o.text=""),void 0===o.id){var e=Date.now().toString()+Math.floor(1e5*Math.random());o.id="ja_btn_"+e}return void 0===o.target&&(o.target="_self"),void 0===o.closeAlert&&(o.closeAlert=!0),d("body").off("click","#"+o.id),d("body").on("click","#"+o.id,function(e){var t=d(this);o.closeAlert&&t.parents(".jAlert").jAlert().closeAlert();var n=!0;return"function"==typeof o.onClick&&(n=o.onClick(e,t)),!n||o.closeAlert?(e.preventDefault(),!1):n}),"<a href='"+o.href+"' id='"+o.id+"' target='"+o.target+"' class='ja_btn "+o.class+"'>"+o.text+"</a> "},c=function(e){var n="";n+='<div class="ja_wrap '+r.join(" ")+'"><div class="jAlert '+a.join(" ")+'" style="'+i.join(" ")+'" id="'+l.id+'"><div>',l.closeBtn&&(n+="<div class='closejAlert ja_close",l.closeBtnAlt?n+=" ja_close_alt":l.closeBtnRoundWhite?n+=" ja_close_round_white":l.closeBtnRound&&(n+=" ja_close_round"),n+="'>&times;</div>"),l.title&&(n+="<div class='ja_title'><div>"+l.title+"</div></div>"),n+='<div class="ja_body">'+e,l.btns&&(n+='<div class="ja_btn_wrap ',l.btnBackground&&(n+="optBack"),n+='">'),"object"==typeof l.btns[0]?d.each(l.btns,function(e,t){"object"==typeof t&&(n+=s(t))}):"object"==typeof l.btns?n+=s(l.btns):l.btns&&console.log("jAlert Config Error: Incorrect value for btns (must be object or array of objects): "+l.btns),l.btns&&(n+="</div>");var t=d(n+="</div></div></div></div>");l.replaceOtherAlerts&&d(".jAlert:visible").each(function(){d(this).jAlert().closeAlert()});return d("body").append(t),l.instance=d("#"+l.id),l.instance[0].jAlert=l,d("html,body").css("overflow","hidden"),l.animateAlert("show"),l.closeBtn&&l.instance.on("click",".closejAlert",function(e){return e.preventDefault(),d(this).parents(".jAlert:first").jAlert().closeAlert(),!1}),l.closeOnClick&&(d(document).off("mouseup touchstart",d.fn.jAlert.onMouseUp),d(document).on("mouseup touchstart",d.fn.jAlert.onMouseUp)),l.closeOnEsc&&(d(document).off("keydown",d.fn.jAlert.onEscKeyDown),d(document).on("keydown",d.fn.jAlert.onEscKeyDown)),l.onOpen&&d.each(l.onOpen,function(e,t){t(l.instance)}),l.autofocus?l.instance.find(l.autofocus).focus():l.instance.focus(),l.autoClose&&d.fn.closeTimer(function(){var e=d.jAlert("current");!1!==e&&e.closeAlert()},l.autoClose),l.instance};return this.initialize=function(){return l.content||l.image||l.video||l.iframe||l.ajax?(l.content||(l.content=""),c(l.content)):(console.log("jAlert potential error: No content defined"),c(""))},this.initialize(),l},d.fn.closeTimer=(jQuery,n=0,function(e,t){clearTimeout(n),n=setTimeout(e,t)}),d.fn.jAlert.defaults={title:!1,content:!1,noPadContent:!1,fullscreen:!1,image:!1,imageWidth:"auto",video:!1,ajax:!1,onAjaxFail:function(e,t){e.jAlert().closeAlert(),errorAlert(t)},iframe:!1,iframeHeight:!1,class:"",classes:"",id:!1,showAnimation:"fadeInUp",hideAnimation:"fadeOutDown",animationTimeout:600,theme:"default",backgroundColor:"black",blurBackground:!1,size:!1,replaceOtherAlerts:!1,closeOnClick:!1,closeOnEsc:!0,closeBtn:!0,closeBtnAlt:!1,closeBtnRound:!0,closeBtnRoundWhite:!1,btns:!1,autoClose:!1,btnBackground:!0,autofocus:!1,onOpen:function(e){return!1},onClose:function(e){return!1},type:"modal",confirmQuestion:"Are you sure?",confirmBtnText:"Yes",denyBtnText:"No",confirmAutofocus:".confirmBtn",onConfirm:function(e,t){return e.preventDefault(),console.log("confirmed"),!1},onDeny:function(e,t){return e.preventDefault(),!1}},d.fn.jAlert.onMouseUp=function(e){var t=e.target?e.target:e.srcElement,n=d(".jAlert:visible:last");0<n.length&&n.jAlert().closeOnClick&&(d(t).is(".jAlert *")||n.jAlert().closeAlert())},d.fn.jAlert.onEscKeyDown=function(e){if(27===e.keyCode){var t=d(".jAlert:visible:last");0<t.length&&t.jAlert().closeOnEsc&&t.jAlert().closeAlert()}},d.fn.attachjAlert=function(e){return e.preventDefault(),d.jAlert(d(this).data()),!1},d.jAlert=function(e){if("current"==e){var t=d(".jAlert:visible:last");return 0<t.length&&t.jAlert()}return"attach"==e?(d("[data-jAlert]").off("click",d.fn.attachjAlert),d("[data-jAlert]").on("click",d.fn.attachjAlert),d("[data-jalert]").off("click",d.fn.attachjAlert),d("[data-jalert]").on("click",d.fn.attachjAlert),!1):d.fn.jAlert(e)},d.fn.alertOnClick=function(t){d(this).on("click",function(e){return e.preventDefault(),d.jAlert(t),!1})},d.alertOnClick=function(e,t){d("body").on("click",e,function(e){return e.preventDefault(),d.jAlert(t),!1})},d.fn.closeAlert=function(e,t){d(this).jAlert().closeAlert(e,t)},d.fn.jAlert.mediaLoaded=function(e){var t=e.parents(".ja_media_wrap"),n=t.find(".ja_video"),o=e.parents(".jAlert:first").jAlert();t.find(".ja_loader").remove(),0<n.length?n.fadeIn("fast"):e.fadeIn("fast"),void 0!==o.iframeHeight&&o.iframeHeight&&(e.css("display","block"),e.height(o.iframeHeight))}}(jQuery);
(function(a){Date.now||(Date.now=function(){return+new Date}),a.fn.jAlert=function(b){a("body").focus(),a("body").blur();var c={xsmall:"xsm",small:"sm",medium:"md",large:"lg",xlarge:"xlg"},d=[],e=["animated"],f=[];if(1<this.length)return this.each(function(){a.fn.jAlert(b)}),this;if("undefined"!=typeof a(this)[0]&&"undefined"!=a(this)[0].jAlert)return a(this)[0].jAlert;if(a.each(a.fn.jAlert.defaults,function(a){var c=a.toLowerCase();"undefined"!=typeof b[c]&&(b[a]=b[c])}),b=a.extend({},a.fn.jAlert.defaults,b),!b.id)var g=Date.now().toString()+Math.floor(1e5*Math.random()),h="ja_"+g;else var h=b.id;var i={set:function(a,b){return i[a]=b,i},__set:function(a,b){return i.set(a,b)},get:function(a){return i[a]},__get:function(a){return i.get(a)},animateAlert:function(b){return"hide"==b?(i.instance.data("jAlert").blurBackground&&a("body").removeClass("ja_blur"),i.instance.removeClass(i.showAnimation).addClass(i.hideAnimation)):(i.instance.data("jAlert").blurBackground&&a("body").addClass("ja_blur"),i.instance.addClass(i.showAnimation).removeClass(i.hideAnimation).show()),i},closeAlert:function(b,c){return!1!=b&&(b=!0),i.instance&&(i.animateAlert("hide"),window.setTimeout(function(){var d=i.instance.parents(".ja_wrap");b?d.remove():d.hide(),"function"==typeof c?c(i.instance):"function"==typeof i.onClose&&i.onClose(i.instance),0===a(".jAlert:visible").length&&a("html,body").css("overflow","")},i.animationTimeout)),i},showAlert:function(b,c,d,e){!1!=b&&(b=!0),!1!==c&&(c=!0),b&&a(".jAlert:visible").data("jAlert").jAlert().closeAlert(c);var f=i.instance.parents(".ja_wrap");return a("body").append(f),i.animateAlert("show"),"function"==typeof e&&(i.onClose=e),window.setTimeout(function(){"function"==typeof d&&d(i.instance)},i.animationTimeout),i}};if(a.each(b,function(a,b){i.set(a,b)}),i.set("id",h),i.content&&0===i.content.indexOf("#")&&0<a(i.content).length&&(i.content=a(i.content).html()),"object"==typeof i.content&&i.jquery&&(i.content=i.content.html()),i.video&&-1<i.video.indexOf("youtube.com/watch?v=")&&-1===i.video.indexOf("embed")&&(i.video=i.video.replace("watch?v=","embed/")),"confirm"==i.type&&(!i.content&&(i.content=i.confirmQuestion),i.btns=[{text:i.confirmBtnText,theme:"green",class:"confirmBtn",closeAlert:!0,onClick:i.onConfirm},{text:i.denyBtnText,theme:"red",class:"denyBtn",closeAlert:!0,onClick:i.onDeny}],i.autofocus=i.confirmAutofocus),i.color&&(i.theme=i.color),-1==a.inArray(i.theme,["default","green","dark_green","red","dark_red","black","brown","gray","dark_gray","blue","dark_blue","yellow"]))return console.log("jAlert Config Error: Invalid theme selection."),!1;if(e.push("ja_"+i.theme),i["class"]&&e.push(i["class"]),i.classes&&e.push(i.classes),i.fullscreen&&e.push("ja_fullscreen"),i.noPadContent&&e.push("ja_no_pad"),i.title||e.push("ja_noTitle"),i.width&&(i.size=i.width),i.size&&"object"==typeof i.size&&("undefined"==typeof i.size.width||"undefined"==typeof i.size.height))return console.log("jAlert Config Error: Invalid size selection (try a preset or make sure you're including height and width in your size object)."),!1;if(i.size?"object"==typeof i.size?(d.push("width: "+i.size.width+";"),d.push("height: "+i.size.height+";"),e.push("ja_setheight")):("undefined"!=typeof c[i.size]&&(i.size=c[i.size]),-1<a.inArray(i.size,["xsm","sm","md","lg","xlg","full","auto"])?e.push("ja_"+i.size):d.push("width: "+i.size+";")):e.push("ja_sm"),-1==a.inArray(i.backgroundColor,["white","black"]))return console.log("jAlert Config Error: Invalid background color selection."),!1;f.push("ja_wrap_"+i.backgroundColor),i.onOpen=[i.onOpen];i.picture&&(i.image=i.picture),i.image?(i.noPadContent=!0,i.content="<div class='ja_media_wrap'><div class='ja_loader'>Loading...</div><img src='"+i.image+"' class='ja_img' onload='$.fn.jAlert.mediaLoaded($(this))''",i.imageWidth&&(i.content+=" style='width: "+i.imageWidth+"'"),i.content+="></div>",i.onOpen.unshift(function(a){var b=a.find(".ja_img");b.on("load",function(){a.css("width",b.width()+"px"),a.css("height",b.height()+"px")})})):i.video?(i.content="<div class='ja_media_wrap'><div class='ja_loader'>Loading...</div><div class='ja_video'></div></div>",i.onOpen.unshift(function(b){var c=document.createElement("iframe");c.src=b.data("jAlert").video,c.addEventListener?c.addEventListener("load",function(){a.fn.jAlert.mediaLoaded(a(this))},!0):c.attachEvent?c.attachEvent("onload",function(){a.fn.jAlert.mediaLoaded(a(this))}):c.onload=function(){a.fn.jAlert.mediaLoaded(a(this))},b.find(".ja_video").append(c)})):i.iframe?(!i.iframeHeight&&(i.iframeHeight=a(window).height()+"px"),i.content="<div class='ja_media_wrap'><div class='ja_loader'>Loading...</div></div>",i.onOpen.unshift(function(b){var c=document.createElement("iframe");c.src=b.jAlert().iframe,c.className="ja_iframe",c.addEventListener?c.addEventListener("load",function(){a.fn.jAlert.mediaLoaded(a(this))},!0):c.attachEvent?c.attachEvent("onload",function(){a.fn.jAlert.mediaLoaded(a(this))}):c.onload=function(){a.fn.jAlert.mediaLoaded(a(this))},b.find(".ja_media_wrap").append(c)})):i.ajax&&(i.content="<div class='ja_media_wrap'><div class='ja_loader'>Loading...</div></div>",onAjaxCallbacks=i.onOpen,i.onOpen=[function(b){a.ajax(b.jAlert().ajax,{async:!0,complete:function(c){b.find(".ja_media_wrap").replaceWith(c.responseText),a.each(onAjaxCallbacks,function(a,c){c(b)})},error:function(a){i.onAjaxFail(b,"Error getting content: Code: "+a.status+" : Msg: "+a.statusText)}})}]);var j=function(b){if("undefined"==typeof b.href&&(b.href=""),"undefined"==typeof b["class"]&&(b["class"]=""),b["class"]+="undefined"==typeof b.theme?" ja_btn_default":" ja_btn_"+b.theme,"undefined"==typeof b.text&&(b.text=""),"undefined"==typeof b.id){var c=Date.now().toString()+Math.floor(1e5*Math.random());b.id="ja_btn_"+c}return"undefined"==typeof b.target&&(b.target="_self"),"undefined"==typeof b.closeAlert&&(b.closeAlert=!0),a("body").off("click","#"+b.id),a("body").on("click","#"+b.id,function(c){var d=a(this);i=d.parents(".jAlert").jAlert(),b.closeAlert&&i.closeAlert();var e=!0;return"function"==typeof b.onClick&&(e=b.onClick(c,d,i)),!e||b.closeAlert?(c.preventDefault(),!1):e}),"<a href='"+b.href+"' id='"+b.id+"' target='"+b.target+"' class='ja_btn "+b["class"]+"'>"+b.text+"</a> "},k=function(b){var c="";c+="<div class=\"ja_wrap "+f.join(" ")+"\"><div class=\"jAlert "+e.join(" ")+"\" style=\""+d.join(" ")+"\" id=\""+i.id+"\"><div>",i.closeBtn&&(c+="<div class='closejAlert ja_close",i.closeBtnAlt?c+=" ja_close_alt":i.closeBtnRoundWhite?c+=" ja_close_round_white":i.closeBtnRound&&(c+=" ja_close_round"),c+="'>&times;</div>"),i.title&&(c+="<div class='ja_title'><div>"+i.title+"</div></div>"),c+="<div class=\"ja_body\">"+b,i.btns&&(c+="<div class=\"ja_btn_wrap ",i.btnBackground&&(c+="optBack"),c+="\">"),"object"==typeof i.btns[0]?a.each(i.btns,function(a,b){"object"==typeof b&&(c+=j(b))}):"object"==typeof i.btns?c+=j(i.btns):i.btns&&console.log("jAlert Config Error: Incorrect value for btns (must be object or array of objects): "+i.btns),i.btns&&(c+="</div>"),c+="</div></div></div></div>";var g=a(c);if(i.replaceOtherAlerts){var h=a(".jAlert:visible");h.each(function(){a(this).jAlert().closeAlert()})}return a("body").append(g),a(".jAlert:last").data("jAlert",i),i.instance=a("#"+i.id),i.instance[0].jAlert=i,a("html,body").css("overflow","hidden"),i.animateAlert("show"),i.closeBtn&&i.instance.on("click",".closejAlert",function(b){return b.preventDefault(),a(this).parents(".jAlert:first").closeAlert(),!1}),i.closeOnClick&&(a(document).off("mouseup touchstart",a.fn.jAlert.onMouseUp),a(document).on("mouseup touchstart",a.fn.jAlert.onMouseUp)),i.closeOnEsc&&(a(document).off("keydown",a.fn.jAlert.onEscKeyDown),a(document).on("keydown",a.fn.jAlert.onEscKeyDown)),i.onOpen&&a.each(i.onOpen,function(a,b){b(i.instance)}),i.autofocus?i.instance.find(i.autofocus).focus():i.instance.focus(),i.autoClose&&a.fn.closeTimer(function(){var b=a.jAlert("current");!1!==b&&b.closeAlert()},i.autoClose),i.instance};return this.initialize=function(){return i.content||i.image||i.video||i.iframe||i.ajax?(i.content||(i.content=""),k(i.content)):(console.log("jAlert potential error: No content defined"),k(""))},this.initialize(),i},a.fn.closeTimer=function(){var a=0;return function(b,c){clearTimeout(a),a=setTimeout(b,c)}}(jQuery),a.fn.jAlert.defaults={title:!1,content:!1,noPadContent:!1,fullscreen:!1,image:!1,imageWidth:"auto",video:!1,ajax:!1,onAjaxFail:function(a,b){a.jAlert().closeAlert(),errorAlert(b)},iframe:!1,iframeHeight:!1,class:"",classes:"",id:!1,showAnimation:"fadeInUp",hideAnimation:"fadeOutDown",animationTimeout:600,theme:"default",backgroundColor:"black",blurBackground:!1,size:!1,replaceOtherAlerts:!1,closeOnClick:!1,closeOnEsc:!0,closeBtn:!0,closeBtnAlt:!1,closeBtnRound:!0,closeBtnRoundWhite:!1,btns:!1,autoClose:!1,btnBackground:!0,autofocus:!1,onOpen:function(){return!1},onClose:function(){return!1},type:"modal",confirmQuestion:"Are you sure?",confirmBtnText:"Yes",denyBtnText:"No",confirmAutofocus:".confirmBtn",onConfirm:function(a){return a.preventDefault(),console.log("confirmed"),!1},onDeny:function(a){return a.preventDefault(),!1}},a.fn.jAlert.onMouseUp=function(b){var c=b.target?b.target:b.srcElement,d=a(".jAlert:visible:last");0<d.length&&d.data("jAlert").closeOnClick&&!a(c).is(".jAlert *")&&d.data("jAlert").closeAlert()},a.fn.jAlert.onEscKeyDown=function(b){if(27===b.keyCode){var c=a(".jAlert:visible:last");0<c.length&&c.data("jAlert").closeOnEsc&&c.data("jAlert").closeAlert()}},a.fn.attachjAlert=function(b){return b.preventDefault(),a.jAlert(a(this).data()),!1},a.jAlert=function(b){if("current"==b){var c=a(".jAlert:visible:last");return!!(0<c.length)&&c.data("jAlert")}return"attach"==b?(a("[data-jAlert]").off("click",a.fn.attachjAlert),a("[data-jAlert]").on("click",a.fn.attachjAlert),a("[data-jalert]").off("click",a.fn.attachjAlert),a("[data-jalert]").on("click",a.fn.attachjAlert),!1):a.fn.jAlert(b)},a.fn.alertOnClick=function(b){a(this).on("click",function(c){return c.preventDefault(),a.jAlert(b),!1})},a.alertOnClick=function(b,c){a("body").on("click",b,function(b){return b.preventDefault(),a.jAlert(c),!1})},a.fn.closeAlert=function(b,c){a(this).data("jAlert")&&a(this).data("jAlert").closeAlert(b,c)},a.fn.jAlert.mediaLoaded=function(a){var b=a.parents(".ja_media_wrap"),c=b.find(".ja_video"),d=a.parents(".jAlert:first"),e=d.data("jAlert");b.find(".ja_loader").remove(),0<c.length?c.fadeIn("fast"):a.fadeIn("fast"),"undefined"!=typeof e.iframeHeight&&e.iframeHeight&&(a.css("display","block"),a.height(e.iframeHeight))}})(jQuery);
{
"name": "jAlert",
"version": "4.6.5",
"version": "4.7.0",
"description": "Simple jQuery (Modal | Popup | Lightbox | Alert) Plugin",

@@ -15,3 +15,3 @@ "repository": {

"dependencies": {
"jquery": "^1.7.1"
"jquery": "^3.4.0"
},

@@ -18,0 +18,0 @@ "license":{

@@ -6,11 +6,11 @@ [![Join the chat at https://gitter.im/jAlert/Lobby](https://badges.gitter.im/jAlert/Lobby.svg)](https://gitter.im/jAlert/Lobby?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)

jAlert v4
jAlert
======
by HTMLGuy, LLC
by HTMLGuy, LLC (https://htmlguy.com)
![logo](http://htmlguyllc.github.io/jAlert/index-assets/img/logo.png)
![example jalert](https://htmlguyllc.github.io/jAlert/index-assets/img/logo.png)
Demo & Detailed Docs
=======
http://htmlguyllc.github.io/jAlert/
https://htmlguyllc.github.io/jAlert/
===

@@ -26,3 +26,3 @@

=======
Using NPM:
Available on NPM (https://www.npmjs.com/package/jAlert):
```html

@@ -29,0 +29,0 @@ npm install jAlert

@@ -9,8 +9,8 @@ /*

if(!Date.now)
Date.now = function(){
return +new Date();
};
if(!Date.now)
Date.now = function(){
return +new Date();
};
$.fn.jAlert = function(options) {
$.fn.jAlert = function(options) {

@@ -21,3 +21,3 @@ //remove focus from current element so you can't just hit enter a bunch to popup the same alert over and over again

var themes = ['default', 'green', 'dark_green', 'red', 'dark_red', 'black', 'brown', 'gray', 'dark_gray', 'blue', 'dark_blue', 'yellow'],
var themes = ['default', 'green', 'dark_green', 'red', 'dark_red', 'black', 'brown', 'gray', 'dark_gray', 'blue', 'dark_blue', 'yellow'],
sizes = ['xsm', 'sm', 'md', 'lg', 'xlg', 'full', 'auto'],

@@ -30,9 +30,9 @@ sizeAliases = {'xsmall': 'xsm', 'small':'sm','medium':'md','large':'lg','xlarge':'xlg'},

/* Block Multiple Instances by running jAlert for each one */
if (this.length > 1){
this.each(function() {
$.fn.jAlert(options);
});
return this;
}
/* Block Multiple Instances by running jAlert for each one */
if (this.length > 1){
this.each(function() {
$.fn.jAlert(options);
});
return this;
}

@@ -52,22 +52,22 @@ /* If this is an existing jAlert, return it so you can access public methods and properties */

$.each($.fn.jAlert.defaults, function(key, val){
var lowerKey = key.toLowerCase();
if( typeof options[lowerKey] !== 'undefined' )
{
options[key] = options[lowerKey];
}
var lowerKey = key.toLowerCase();
if( typeof options[lowerKey] !== 'undefined' )
{
options[key] = options[lowerKey];
}
});
/* Combine user options with default */
options = $.extend({}, $.fn.jAlert.defaults, options);
/* Combine user options with default */
options = $.extend({}, $.fn.jAlert.defaults, options);
/* If they didn't set an id, just create a random one */
if( !options.id )
{
var unique = Date.now().toString() + Math.floor(Math.random() * 100000);
var alert_id = 'ja_' + unique;
}
else
{
var alert_id = options.id;
}
/* If they didn't set an id, just create a random one */
if( !options.id )
{
var unique = Date.now().toString() + Math.floor(Math.random() * 100000);
var alert_id = 'ja_' + unique;
}
else
{
var alert_id = options.id;
}

@@ -98,3 +98,3 @@ /**

{
if( alert.instance.jAlert().blurBackground )
if( alert.instance.data('jAlert').blurBackground )
{

@@ -108,3 +108,3 @@ $('body').removeClass('ja_blur');

{
if( alert.instance.jAlert().blurBackground )
if( alert.instance.data('jAlert').blurBackground )
{

@@ -125,11 +125,11 @@ $('body').addClass('ja_blur');

}
if(alert.instance)
{
alert.animateAlert('hide');
window.setTimeout(function()
{
var alertWrap = alert.instance.parents('.ja_wrap');
if( remove )

@@ -143,3 +143,3 @@ {

}
if(typeof onClose == 'function')

@@ -153,3 +153,3 @@ {

}
if( $('.jAlert:visible').length === 0 )

@@ -159,3 +159,3 @@ {

}
}, alert.animationTimeout);

@@ -181,3 +181,3 @@ }

{
$('.jAlert:visible').jAlert().closeAlert(removeOthers);
$('.jAlert:visible').data('jAlert').jAlert().closeAlert(removeOthers);
}

@@ -214,3 +214,3 @@

$.each(options, function(key, val){
alert.set(key, val);
alert.set(key, val);
});

@@ -235,2 +235,10 @@

/**
* If content is a dom element, grab it's HTML
*/
if( typeof alert.content === 'object' && alert.jquery )
{
alert.content = alert.content.html();
}
/**
* Automatically convert a youtube video's URL to the embed version

@@ -246,16 +254,16 @@ */

*/
if( alert.type == 'confirm' )
{
if( !alert.content )
{
if( alert.type == 'confirm' )
{
if( !alert.content )
{
alert.content = alert.confirmQuestion;
}
}
alert.btns = [
{ 'text': alert.confirmBtnText, 'theme': 'green', 'class': 'confirmBtn', 'closeAlert': true, 'onClick': alert.onConfirm },
{ 'text': alert.denyBtnText, 'theme': 'red', 'class': 'denyBtn', 'closeAlert': true, 'onClick': alert.onDeny }
];
alert.btns = [
{ 'text': alert.confirmBtnText, 'theme': 'green', 'class': 'confirmBtn', 'closeAlert': true, 'onClick': alert.onConfirm },
{ 'text': alert.denyBtnText, 'theme': 'red', 'class': 'denyBtn', 'closeAlert': true, 'onClick': alert.onDeny }
];
alert.autofocus = alert.confirmAutofocus;
}
alert.autofocus = alert.confirmAutofocus;
}

@@ -271,7 +279,7 @@ /* If used the alias color, swap to theme */

*/
if( $.inArray(alert.theme, themes) == -1 )
{
console.log('jAlert Config Error: Invalid theme selection.');
return false;
}
if( $.inArray(alert.theme, themes) == -1 )
{
console.log('jAlert Config Error: Invalid theme selection.');
return false;
}

@@ -281,16 +289,16 @@ /**

*/
classes.push('ja_'+alert.theme);
classes.push('ja_'+alert.theme);
/* If they set custom classes */
if( alert['class'] )
{
classes.push(alert['class']);
}
if( alert.classes )
{
classes.push(alert.classes);
}
/* If they set custom classes */
if( alert['class'] )
{
classes.push(alert['class']);
}
if( alert.classes )
{
classes.push(alert.classes);
}
//if fullscreen, add class
if( alert.fullscreen )
//if fullscreen, add class
if( alert.fullscreen )
{

@@ -301,3 +309,3 @@ classes.push('ja_fullscreen');

//if no padding on the content
if( alert.noPadContent )
if( alert.noPadContent )
{

@@ -307,7 +315,7 @@ classes.push('ja_no_pad');

/* If no title, add class */
if( !alert.title )
{
classes.push( 'ja_noTitle' );
}
/* If no title, add class */
if( !alert.title )
{
classes.push( 'ja_noTitle' );
}

@@ -320,22 +328,22 @@ /* If used the alias width, swap to size */

/* if it's set and it's not in the array of sizes OR it's an object and it's missing width/height */
if( alert.size && ((typeof alert.size == 'object' && (typeof alert.size.width == 'undefined' || typeof alert.size.height == 'undefined'))) ) {
/* if it's set and it's not in the array of sizes OR it's an object and it's missing width/height */
if( alert.size && ((typeof alert.size == 'object' && (typeof alert.size.width == 'undefined' || typeof alert.size.height == 'undefined'))) ) {
console.log('jAlert Config Error: Invalid size selection (try a preset or make sure you\'re including height and width in your size object).');
return false;
}
/* If it's not set, set to md */
else if( !alert.size )
{
classes.push('ja_sm');
}
/* If it's set and it's an object */
else if( typeof alert.size == 'object' )
{
styles.push('width: '+alert.size.width+';');
styles.push('height: '+alert.size.height+';');
/* If it's not set, set to md */
else if( !alert.size )
{
classes.push('ja_sm');
}
/* If it's set and it's an object */
else if( typeof alert.size == 'object' )
{
styles.push('width: '+alert.size.width+';');
styles.push('height: '+alert.size.height+';');
classes.push('ja_setheight');
}
/* If it's set and it's not an object */
else
{
}
/* If it's set and it's not an object */
else
{
//swap alias for actual size class

@@ -357,17 +365,17 @@ if( typeof sizeAliases[alert.size] !== 'undefined' )

}
}
}
/* Add background color class */
if( $.inArray(alert.backgroundColor, backgroundColors) == -1 )
{
console.log('jAlert Config Error: Invalid background color selection.');
return false;
}
/* Add background color class */
if( $.inArray(alert.backgroundColor, backgroundColors) == -1 )
{
console.log('jAlert Config Error: Invalid background color selection.');
return false;
}
backgroundClasses.push('ja_wrap_'+alert.backgroundColor);
backgroundClasses.push('ja_wrap_'+alert.backgroundColor);
alert.onOpen = [ alert.onOpen ];
alert.onOpen = [ alert.onOpen ];
var onload = "onload='$.fn.jAlert.mediaLoaded($(this))'",
loader = "<div class='ja_loader'>Loading...</div>";
var onload = "onload='$.fn.jAlert.mediaLoaded($(this))'",
loader = "<div class='ja_loader'>Loading...</div>";

@@ -383,171 +391,185 @@ /**

/* Creates content */
if( alert.image )
{
alert.content = "<div class='ja_media_wrap'>"+
loader+
"<img src='"+alert.image+"' class='ja_img' "+onload+"'";
if( alert.imageWidth )
{
alert.content += " style='width: "+alert.imageWidth+"'";
}
alert.content += ">"+
"</div>";
}
else if( alert.video )
{
alert.content = "<div class='ja_media_wrap'>"+
loader+
"<div class='ja_video'>"+
"</div>"+
"</div>";
if( alert.image )
{
//images should never have padding
alert.noPadContent = true;
/* Add to the onOpen callbacks array to append the iframe and attach the onload callback in a crossbrowser compatible way (IE is a bizitch). */
alert.onOpen.unshift( function(elem){
var iframe = document.createElement("iframe");
iframe.src = elem.jAlert().video;
alert.content = "<div class='ja_media_wrap'>"+
loader+
"<img src='"+alert.image+"' class='ja_img' "+onload+"'";
if( alert.imageWidth )
{
alert.content += " style='width: "+alert.imageWidth+"'";
}
alert.content += ">"+
"</div>";
if(iframe.addEventListener)
{
iframe.addEventListener('load', function(){
$.fn.jAlert.mediaLoaded($(this));
}, true)
}
else if (iframe.attachEvent){
iframe.attachEvent("onload", function(){
$.fn.jAlert.mediaLoaded($(this));
});
} else {
iframe.onload = function(){
$.fn.jAlert.mediaLoaded($(this));
};
}
/* Add to the onOpen callbacks array to shrink the alert to fit the size of the image if the image is smaller than it */
alert.onOpen.unshift( function(elem){
var img_elem = elem.find('.ja_img');
img_elem.on('load', function () {
elem.css('width', img_elem.width() + 'px');
elem.css('height', img_elem.height() + 'px');
});
});
}
else if( alert.video )
{
alert.content = "<div class='ja_media_wrap'>"+
loader+
"<div class='ja_video'>"+
"</div>"+
"</div>";
/* Add to the onOpen callbacks array to append the iframe and attach the onload callback in a crossbrowser compatible way (IE is a bizitch). */
alert.onOpen.unshift( function(elem){
var iframe = document.createElement("iframe");
iframe.src = elem.data('jAlert').video;
if(iframe.addEventListener)
{
iframe.addEventListener('load', function(){
$.fn.jAlert.mediaLoaded($(this));
}, true)
}
else if (iframe.attachEvent){
iframe.attachEvent("onload", function(){
$.fn.jAlert.mediaLoaded($(this));
});
} else {
iframe.onload = function(){
$.fn.jAlert.mediaLoaded($(this));
};
}
elem.find('.ja_video').append(iframe);
});
});
}
else if( alert.iframe )
{
if( !alert.iframeHeight )
{
alert.iframeHeight = $(window).height() +'px';
}
}
else if( alert.iframe )
{
if( !alert.iframeHeight )
{
alert.iframeHeight = $(window).height() +'px';
}
alert.content = "<div class='ja_media_wrap'>"+
loader+
"</div>";
alert.content = "<div class='ja_media_wrap'>"+
loader+
"</div>";
/* Add to the onOpen callbacks array to append the iframe and attach the onload callback in a crossbrowser compatible way (IE is a bizitch). */
alert.onOpen.unshift( function(elem){
var iframe = document.createElement("iframe");
iframe.src = elem.jAlert().iframe;
iframe.className = 'ja_iframe';
/* Add to the onOpen callbacks array to append the iframe and attach the onload callback in a crossbrowser compatible way (IE is a bizitch). */
alert.onOpen.unshift( function(elem){
var iframe = document.createElement("iframe");
iframe.src = elem.jAlert().iframe;
iframe.className = 'ja_iframe';
if(iframe.addEventListener)
{
iframe.addEventListener('load', function(){
$.fn.jAlert.mediaLoaded($(this));
}, true)
}
else if (iframe.attachEvent){
iframe.attachEvent("onload", function(){
$.fn.jAlert.mediaLoaded($(this));
});
} else {
iframe.onload = function(){
$.fn.jAlert.mediaLoaded($(this));
};
}
if(iframe.addEventListener)
{
iframe.addEventListener('load', function(){
$.fn.jAlert.mediaLoaded($(this));
}, true)
}
else if (iframe.attachEvent){
iframe.attachEvent("onload", function(){
$.fn.jAlert.mediaLoaded($(this));
});
} else {
iframe.onload = function(){
$.fn.jAlert.mediaLoaded($(this));
};
}
elem.find('.ja_media_wrap').append(iframe);
});
}
else if( alert.ajax )
{
alert.content = "<div class='ja_media_wrap'>"+
loader+
"</div>";
});
}
else if( alert.ajax )
{
alert.content = "<div class='ja_media_wrap'>"+
loader+
"</div>";
/* Store as another var */
onAjaxCallbacks = alert.onOpen;
/* Store as another var */
onAjaxCallbacks = alert.onOpen;
/* Overwrite the onOpen to be the ajax call */
alert.onOpen = [function(elem){
$.ajax(elem.jAlert().ajax, {
async: true,
complete: function(jqXHR, textStatus)
{
/* Overwrite the onOpen to be the ajax call */
alert.onOpen = [function(elem){
$.ajax(elem.jAlert().ajax, {
async: true,
complete: function(jqXHR, textStatus)
{
elem.find('.ja_media_wrap').replaceWith(jqXHR.responseText);
/* Run onOpen callbacks here */
$.each(onAjaxCallbacks, function(index, onAjax){
onAjax(elem);
});
},
error: function(jqXHR, textStatus, errorThrown)
{
alert.onAjaxFail(elem, 'Error getting content: Code: '+jqXHR.status+ ' : Msg: '+jqXHR.statusText);
}
});
}];
}
/* Run onOpen callbacks here */
$.each(onAjaxCallbacks, function(index, onAjax){
onAjax(elem);
});
},
error: function(jqXHR, textStatus, errorThrown)
{
alert.onAjaxFail(elem, 'Error getting content: Code: '+jqXHR.status+ ' : Msg: '+jqXHR.statusText);
}
});
}];
}
var getBtnHTML = function(btn){
var getBtnHTML = function(btn){
if(typeof btn.href == 'undefined'){ btn.href = ''; }
if(typeof btn['class'] == 'undefined'){ btn['class'] = ''; }
if(typeof btn.theme == 'undefined'){ btn['class'] += ' ja_btn_default'; }else{ btn['class'] += ' ja_btn_'+btn.theme; }
if(typeof btn.text == 'undefined'){ btn.text = ''; }
if(typeof btn.id == 'undefined'){ var unique = Date.now().toString() + Math.floor(Math.random() * 100000); btn.id = 'ja_btn_' + unique; }
if(typeof btn.target == 'undefined'){ btn.target = '_self'; }
if(typeof btn.closeAlert == 'undefined'){ btn.closeAlert = true; }
if(typeof btn.href == 'undefined'){ btn.href = ''; }
if(typeof btn['class'] == 'undefined'){ btn['class'] = ''; }
if(typeof btn.theme == 'undefined'){ btn['class'] += ' ja_btn_default'; }else{ btn['class'] += ' ja_btn_'+btn.theme; }
if(typeof btn.text == 'undefined'){ btn.text = ''; }
if(typeof btn.id == 'undefined'){ var unique = Date.now().toString() + Math.floor(Math.random() * 100000); btn.id = 'ja_btn_' + unique; }
if(typeof btn.target == 'undefined'){ btn.target = '_self'; }
if(typeof btn.closeAlert == 'undefined'){ btn.closeAlert = true; }
$('body').off('click', '#'+btn.id); //remove handler before adding it to remove dupe handlers
$('body').off('click', '#'+btn.id); //remove handler before adding it to remove dupe handlers
/* Attach on click handler */
$('body').on('click', '#'+btn.id, function(e){
/* Attach on click handler */
$('body').on('click', '#'+btn.id, function(e){
var button = $(this);
var button = $(this);
if( btn.closeAlert )
{
button.parents('.jAlert').jAlert().closeAlert();
}
alert = button.parents('.jAlert').jAlert();
var callbackResponse = true;
if( btn.closeAlert )
{
alert.closeAlert();
}
if( typeof btn.onClick == 'function' )
{
callbackResponse = btn.onClick(e, button);
}
var callbackResponse = true;
if( !callbackResponse || btn.closeAlert )
{
e.preventDefault();
return false;
}
if( typeof btn.onClick == 'function' )
{
callbackResponse = btn.onClick(e, button, alert);
}
return callbackResponse;
if( !callbackResponse || btn.closeAlert )
{
e.preventDefault();
return false;
}
});
return callbackResponse;
return "<a href='"+btn.href+"' id='"+btn.id+"' target='"+btn.target+"' class='ja_btn "+btn['class']+"'>"+btn.text+"</a> ";
};
});
/* Adds a new alert to the dom */
var addAlert = function(content){
return "<a href='"+btn.href+"' id='"+btn.id+"' target='"+btn.target+"' class='ja_btn "+btn['class']+"'>"+btn.text+"</a> ";
};
var html = '';
/* Adds a new alert to the dom */
var addAlert = function(content){
html += '<div class="ja_wrap '+backgroundClasses.join(' ')+'">'+
'<div class="jAlert '+classes.join(' ')+ '" style="' +styles.join(' ')+ '" id="' +alert.id+ '">'+
'<div>';
var html = '';
if( alert.closeBtn )
{
html += "<div class='closejAlert ja_close";
if( alert.closeBtnAlt )
{
html += ' ja_close_alt';
}
html += '<div class="ja_wrap '+backgroundClasses.join(' ')+'">'+
'<div class="jAlert '+classes.join(' ')+ '" style="' +styles.join(' ')+ '" id="' +alert.id+ '">'+
'<div>';
if( alert.closeBtn )
{
html += "<div class='closejAlert ja_close";
if( alert.closeBtnAlt )
{
html += ' ja_close_alt';
}
else if( alert.closeBtnRoundWhite )

@@ -561,57 +583,57 @@ {

}
html += "'>&times;</div>"; //closejAlert has a close handler attached, ja_close is for styling
}
html += "'>&times;</div>"; //closejAlert has a close handler attached, ja_close is for styling
}
if( alert.title )
{
html += "<div class='ja_title'><div>"+alert.title+"</div></div>";
}
if( alert.title )
{
html += "<div class='ja_title'><div>"+alert.title+"</div></div>";
}
html += '<div class="ja_body">'+content;
html += '<div class="ja_body">'+content;
if( alert.btns )
{
html += '<div class="ja_btn_wrap ';
if( alert.btns )
{
html += '<div class="ja_btn_wrap ';
if( alert.btnBackground )
{
html += 'optBack';
}
if( alert.btnBackground )
{
html += 'optBack';
}
html += '">';
}
html += '">';
}
if( typeof alert.btns[0] == 'object' )
{
$.each(alert.btns, function(index, btn){
if( typeof btn == 'object' )
{
html += getBtnHTML(btn);
}
});
}
else if( typeof alert.btns == 'object' )
{
html += getBtnHTML(alert.btns);
}
else if( alert.btns )
{
console.log('jAlert Config Error: Incorrect value for btns (must be object or array of objects): '+alert.btns);
}
if( typeof alert.btns[0] == 'object' )
{
$.each(alert.btns, function(index, btn){
if( typeof btn == 'object' )
{
html += getBtnHTML(btn);
}
});
}
else if( typeof alert.btns == 'object' )
{
html += getBtnHTML(alert.btns);
}
else if( alert.btns )
{
console.log('jAlert Config Error: Incorrect value for btns (must be object or array of objects): '+alert.btns);
}
if( alert.btns )
{
html += '</div>';
}
if( alert.btns )
{
html += '</div>';
}
html += '</div>'+
'</div>'+
'</div>'+
'</div>';
html += '</div>'+
'</div>'+
'</div>'+
'</div>';
var alertHTML = $(html);
var alertHTML = $(html);
if( alert.replaceOtherAlerts )
{
if( alert.replaceOtherAlerts )
{
var alerts = $('.jAlert:visible');

@@ -621,8 +643,10 @@ alerts.each(function(){

});
}
}
$('body').append(alertHTML);
$('body').append(alertHTML);
$('.jAlert:last').data('jAlert', alert);
//cache instance
alert.instance = $('#'+alert.id);
alert.instance = $('#'+alert.id);

@@ -636,54 +660,54 @@ //attach alert object to dom element

//show the new alert
alert.animateAlert('show');
alert.animateAlert('show');
//add close button handler
if( alert.closeBtn ){
if( alert.closeBtn ){
alert.instance.on('click', '.closejAlert', function(e){
e.preventDefault();
$(this).parents('.jAlert:first').jAlert().closeAlert();
return false;
});
alert.instance.on('click', '.closejAlert', function(e){
e.preventDefault();
$(this).parents('.jAlert:first').closeAlert();
return false;
});
}
}
/* Bind mouseup handler to document if this alert has closeOnClick enabled */
if( alert.closeOnClick ){
/* Bind mouseup handler to document if this alert has closeOnClick enabled */
if( alert.closeOnClick ){
/* Unbind if already exists */
$(document).off('mouseup touchstart', $.fn.jAlert.onMouseUp);
/* Unbind if already exists */
$(document).off('mouseup touchstart', $.fn.jAlert.onMouseUp);
/* Bind mouseup */
$(document).on('mouseup touchstart', $.fn.jAlert.onMouseUp);
/* Bind mouseup */
$(document).on('mouseup touchstart', $.fn.jAlert.onMouseUp);
}
}
/* Bind on keydown handler to document and if esc was pressed, find all visible jAlerts with that close option enabled and close them */
if( alert.closeOnEsc ){
/* Bind on keydown handler to document and if esc was pressed, find all visible jAlerts with that close option enabled and close them */
if( alert.closeOnEsc ){
/* Unbind if already exists */
$(document).off('keydown', $.fn.jAlert.onEscKeyDown);
/* Unbind if already exists */
$(document).off('keydown', $.fn.jAlert.onEscKeyDown);
/* Bind keydown */
$(document).on('keydown', $.fn.jAlert.onEscKeyDown);
/* Bind keydown */
$(document).on('keydown', $.fn.jAlert.onEscKeyDown);
}
}
/* If there are onOpen callbacks, run them. */
if( alert.onOpen )
{
$.each(alert.onOpen, function(index, onOpen){
onOpen(alert.instance);
});
}
/* If there are onOpen callbacks, run them. */
if( alert.onOpen )
{
$.each(alert.onOpen, function(index, onOpen){
onOpen(alert.instance);
});
}
/* If the alert has an element that should be focused by default */
if( alert.autofocus )
{
alert.instance.find(alert.autofocus).focus();
}
else
{
alert.instance.focus();
}
/* If the alert has an element that should be focused by default */
if( alert.autofocus )
{
alert.instance.find(alert.autofocus).focus();
}
else
{
alert.instance.focus();
}
/*

@@ -698,3 +722,3 @@ Set Auto

$.fn.closeTimer(function()
{
{
var currentAlert = $.jAlert('current');

@@ -705,39 +729,39 @@ if(currentAlert !== false)

}
}, alert.autoClose);
}, alert.autoClose);
}
return alert.instance;
return alert.instance;
};
};
/* Shows an alert based on content type */
this.initialize = function(){
/* Shows an alert based on content type */
this.initialize = function(){
if( !alert.content && !alert.image && !alert.video && !alert.iframe && !alert.ajax )
{
console.log('jAlert potential error: No content defined');
return addAlert('');
}
else
{
if( !alert.content )
{
alert.content = '';
}
if( !alert.content && !alert.image && !alert.video && !alert.iframe && !alert.ajax )
{
console.log('jAlert potential error: No content defined');
return addAlert('');
}
else
{
if( !alert.content )
{
alert.content = '';
}
return addAlert(alert.content);
}
return addAlert(alert.content);
}
};
};
//initialize
this.initialize();
this.initialize();
//return the object so you can chain public methods/properties
return alert;
return alert;
/* END OF PLUGIN */
};
/* END OF PLUGIN */
};
/* set closeTimer for preventing on duplicate */
/* set closeTimer for preventing on duplicate */
$.fn.closeTimer = (function(){

@@ -751,113 +775,113 @@ var timer = 0;

/* Default alert */
$.fn.jAlert.defaults = {
'title': false, //title for the popup (false = don't show)
'content': false, //html for the popup (replaced if you use image, ajax, or iframe)
/* Default alert */
$.fn.jAlert.defaults = {
'title': false, //title for the popup (false = don't show)
'content': false, //html for the popup (replaced if you use image, ajax, or iframe)
'noPadContent': false, //remove padding from the body
'fullscreen': false, //make the jAlert completely fullscreen
'image': false, //adds a centered img tag
'imageWidth': 'auto', //defaults to max-width: 100%; width: auto;
'video': false, //adds a responsive iframe video - value is the "src" of the iframe
'ajax': false, //uses ajax call to get contents
'onAjaxFail': function(alert, errorThrown){ //callback for when ajax fails
alert.jAlert().closeAlert();
errorAlert(errorThrown);
},
'iframe': false, //uses iframe as content
'iframeHeight': false, //string. height of the iframe within the popup (false = 90% of viewport height)
'class': '', //adds a class to the jAlert (add as many as you want space delimited)
'classes': '', //add classes to the jAlert (space delimited)
'id': false, //adds an ID to the jAlert
'showAnimation': 'fadeInUp',
'hideAnimation': 'fadeOutDown',
'animationTimeout': 600, //approx duration of animation to wait until onClose
'theme': 'default', // red, green, blue, black, default
'backgroundColor': 'black', //white, black
'image': false, //adds a centered img tag
'imageWidth': 'auto', //defaults to max-width: 100%; width: auto;
'video': false, //adds a responsive iframe video - value is the "src" of the iframe
'ajax': false, //uses ajax call to get contents
'onAjaxFail': function(alert, errorThrown){ //callback for when ajax fails
alert.jAlert().closeAlert();
errorAlert(errorThrown);
},
'iframe': false, //uses iframe as content
'iframeHeight': false, //string. height of the iframe within the popup (false = 90% of viewport height)
'class': '', //adds a class to the jAlert (add as many as you want space delimited)
'classes': '', //add classes to the jAlert (space delimited)
'id': false, //adds an ID to the jAlert
'showAnimation': 'fadeInUp',
'hideAnimation': 'fadeOutDown',
'animationTimeout': 600, //approx duration of animation to wait until onClose
'theme': 'default', // red, green, blue, black, default
'backgroundColor': 'black', //white, black
'blurBackground': false, //blurs background elements
'size': false, //false = css default, xsm, sm, md, lg, xlg, full, { height: 200, width: 200 }
'replaceOtherAlerts': false, //if there's already an open jAlert, remove it first
'closeOnClick': false, //close the alert when you click anywhere
'closeOnEsc': true, //close the alert when you click the escape key
'closeBtn': true, //adds a button to the top right of the alert that allows you to close it
'closeBtnAlt': false, //alternative close button
'size': false, //false = css default, xsm, sm, md, lg, xlg, full, { height: 200, width: 200 }
'replaceOtherAlerts': false, //if there's already an open jAlert, remove it first
'closeOnClick': false, //close the alert when you click anywhere
'closeOnEsc': true, //close the alert when you click the escape key
'closeBtn': true, //adds a button to the top right of the alert that allows you to close it
'closeBtnAlt': false, //alternative close button
'closeBtnRound': true, //alternative round close button
'closeBtnRoundWhite': false, //alternative round close button (in white)
'btns': false, //adds buttons to the popup at the bottom. Pass an object for a single button, or an object of objects for many
'btns': false, //adds buttons to the popup at the bottom. Pass an object for a single button, or an object of objects for many
'autoClose' : false, // By default we specify as false. You can add secound
/*
Variety of buttons you could create (also, an example of how to pass the object
/*
Variety of buttons you could create (also, an example of how to pass the object
'btns': [
{'text':'Open in new window', 'closeAlert':false, 'href': 'http://google.com', 'target':'_new'},
{'text':'Cool, close this alert', 'theme': 'blue', 'closeAlert':true},
{'text':'Buy Now', 'closeAlert':true, 'theme': 'green', 'onClick': function(){ console.log('You bought it!'); } },
{'text':'I do not want it', 'closeAlert': true, 'theme': 'red', 'onClick': function(){ console.log('Did not want it'); } },
{'text':'DOA', 'closeAlert': true, 'theme': 'black', 'onClick': function(){ console.log('Dead on arrival'); } }
]
*/
'btnBackground': true, //adds optional background to btns
'autofocus': false, //pass a selector to autofocus on it
'btns': [
{'text':'Open in new window', 'closeAlert':false, 'href': 'http://google.com', 'target':'_new'},
{'text':'Cool, close this alert', 'theme': 'blue', 'closeAlert':true},
{'text':'Buy Now', 'closeAlert':true, 'theme': 'green', 'onClick': function(){ console.log('You bought it!'); } },
{'text':'I do not want it', 'closeAlert': true, 'theme': 'red', 'onClick': function(){ console.log('Did not want it'); } },
{'text':'DOA', 'closeAlert': true, 'theme': 'black', 'onClick': function(){ console.log('Dead on arrival'); } }
]
*/
'btnBackground': true, //adds optional background to btns
'autofocus': false, //pass a selector to autofocus on it
'onOpen': function(alert){ //on open call back. Fires just after the alert has finished rendering
return false;
},
'onClose': function(alert){ //fires when you close the alert
return false;
},
'onOpen': function(alert){ //on open call back. Fires just after the alert has finished rendering
return false;
},
'onClose': function(alert){ //fires when you close the alert
return false;
},
'type': 'modal', //modal, confirm, tooltip
'type': 'modal', //modal, confirm, tooltip
/* The following only applies when type == 'confirm' */
'confirmQuestion': 'Are you sure?',
'confirmBtnText': 'Yes',
'denyBtnText': 'No',
'confirmAutofocus': '.confirmBtn', //confirmBtn or denyBtn
'onConfirm': function(e, btn){
e.preventDefault();
console.log('confirmed');
return false;
},
'onDeny': function(e, btn){
e.preventDefault();
//console.log('denied');
return false;
}
};
/* The following only applies when type == 'confirm' */
'confirmQuestion': 'Are you sure?',
'confirmBtnText': 'Yes',
'denyBtnText': 'No',
'confirmAutofocus': '.confirmBtn', //confirmBtn or denyBtn
'onConfirm': function(e, btn){
e.preventDefault();
console.log('confirmed');
return false;
},
'onDeny': function(e, btn){
e.preventDefault();
//console.log('denied');
return false;
}
};
/** Mouseup on document */
$.fn.jAlert.onMouseUp = function(e){
/** Mouseup on document */
$.fn.jAlert.onMouseUp = function(e){
//cross browser
var target = e.target ? e.target : e.srcElement;
/* Find top visible jAlert and see if it has closeOnClick enabled */
var lastVisibleAlert = $('.jAlert:visible:last');
/* Find top visible jAlert and see if it has closeOnClick enabled */
var lastVisibleAlert = $('.jAlert:visible:last');
if( lastVisibleAlert.length > 0 && lastVisibleAlert.jAlert().closeOnClick )
{
//close only if clicked outside
if( lastVisibleAlert.length > 0 && lastVisibleAlert.data('jAlert').closeOnClick )
{
//close only if clicked outside
if( !$(target).is('.jAlert *') )
{
lastVisibleAlert.jAlert().closeAlert();
lastVisibleAlert.data('jAlert').closeAlert();
}
}
}
};
};
/* Keydown on document (escape key) */
$.fn.jAlert.onEscKeyDown = function(e){
/* Keydown on document (escape key) */
$.fn.jAlert.onEscKeyDown = function(e){
/* Escape = 27 */
if(e.keyCode === 27){
/* Escape = 27 */
if(e.keyCode === 27){
/* Find top visible jAlert and see if it has closeOnClick enabled */
var lastVisibleAlert = $('.jAlert:visible:last');
/* Find top visible jAlert and see if it has closeOnClick enabled */
var lastVisibleAlert = $('.jAlert:visible:last');
if( lastVisibleAlert.length > 0 && lastVisibleAlert.jAlert().closeOnEsc )
{
lastVisibleAlert.jAlert().closeAlert();
}
if( lastVisibleAlert.length > 0 && lastVisibleAlert.data('jAlert').closeOnEsc )
{
lastVisibleAlert.data('jAlert').closeAlert();
}
}
}
};
};

@@ -870,4 +894,4 @@ $.fn.attachjAlert = function(e){

/* If you're not using the DOM (aka, you're not hiding or showing a specific alert, you can just use $.jAlert */
$.jAlert = function(options){
/* If you're not using the DOM (aka, you're not hiding or showing a specific alert, you can just use $.jAlert */
$.jAlert = function(options){

@@ -882,3 +906,3 @@ /**

{
return latest.jAlert();
return latest.data('jAlert');
}

@@ -903,49 +927,52 @@

return $.fn.jAlert(options);
};
return $.fn.jAlert(options);
};
/* Alert on click function - attach to existing dom */
$.fn.alertOnClick = function(options)
{
$(this).on('click', function(e){
e.preventDefault();
$.jAlert(options);
return false;
});
};
/* Alert on click function - attach to existing dom */
$.fn.alertOnClick = function(options)
{
$(this).on('click', function(e){
e.preventDefault();
$.jAlert(options);
return false;
});
};
/* Alert on click function - global, works for changing dom */
$.alertOnClick = function(selector, options)
{
$('body').on('click', selector, function(e){
e.preventDefault();
$.jAlert(options);
return false;
});
};
/* Alert on click function - global, works for changing dom */
$.alertOnClick = function(selector, options)
{
$('body').on('click', selector, function(e){
e.preventDefault();
$.jAlert(options);
return false;
});
};
$.fn.closeAlert = function(remove, onClose){
$(this).jAlert().closeAlert(remove, onClose);
if( $(this).data('jAlert') )
{
$(this).data('jAlert').closeAlert(remove, onClose);
}
};
/* Onload callback for iframe, img, etc */
$.fn.jAlert.mediaLoaded = function(elem){
var wrap = elem.parents('.ja_media_wrap'),
vid_wrap = wrap.find('.ja_video'),
/* Onload callback for iframe, img, etc */
$.fn.jAlert.mediaLoaded = function(elem){
var wrap = elem.parents('.ja_media_wrap'),
vid_wrap = wrap.find('.ja_video'),
alert = elem.parents('.jAlert:first'),
jalert = alert.jAlert();
jalert = alert.data('jAlert');
wrap.find('.ja_loader').remove();
wrap.find('.ja_loader').remove();
if( vid_wrap.length > 0 )
{
vid_wrap.fadeIn('fast');
}
else
{
elem.fadeIn('fast');
}
if( vid_wrap.length > 0 )
{
vid_wrap.fadeIn('fast');
}
else
{
elem.fadeIn('fast');
}
//if iframe, add height after load and set display: block
if( typeof jalert.iframeHeight !== 'undefined' && jalert.iframeHeight )
//if iframe, add height after load and set display: block
if( typeof jalert.iframeHeight !== 'undefined' && jalert.iframeHeight )
{

@@ -956,5 +983,5 @@ elem.css('display', 'block');

};
};
/* END OF ON JQUERY LOAD */
/* END OF ON JQUERY LOAD */
})(jQuery);

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc