From de994884141d4521937eda39b0d5d1a05c15bc4b Mon Sep 17 00:00:00 2001 From: Cristian Gabriel Danasel Date: Tue, 24 Oct 2017 15:29:06 +0100 Subject: [PATCH 01/17] Add auto close after a period of time --- src/jAlert.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/jAlert.js b/src/jAlert.js index 489e82f..4d630ce 100644 --- a/src/jAlert.js +++ b/src/jAlert.js @@ -707,7 +707,25 @@ { alert.instance.focus(); } + /* + Set Auto + usage $.jAlert({ + autoClose : true, + closeTime : 4500 + }); + */ + if(alert.autoClose) + { + setTimeout(function() + { + var currentAlert = $.jAlert('current'); + if(currentAlert !== false) + { + currentAlert.closeAlert(); + } + }, alert.closeTime); + } alert.instance.bind("DOMSubtreeModified", function(){ alert.centerAlert(); }); From a7c55de3603fcbceb1feab0a6e8d27f3f5068c11 Mon Sep 17 00:00:00 2001 From: Cristian Gabriel Danasel Date: Tue, 24 Oct 2017 15:31:49 +0100 Subject: [PATCH 02/17] Update minify --- dist/jAlert.min.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dist/jAlert.min.js b/dist/jAlert.min.js index 027c914..8552ce3 100644 --- a/dist/jAlert.min.js +++ b/dist/jAlert.min.js @@ -1 +1 @@ -!function($){Date.now||(Date.now=function(){return+new Date}),$.fn.jAlert=function(options){$("body").focus(),$("body").blur();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"],sizeAliases={xsmall:"xsm",small:"sm",medium:"md",large:"lg",xlarge:"xlg"},backgroundColors=["white","black"],styles=[],classes=["animated"],backgroundClasses=[];if(this.length>1)return this.each(function(){$.fn.jAlert(options)}),this;if("undefined"!=typeof $(this)[0]&&"undefined"!=$(this)[0].jAlert)return $(this)[0].jAlert;if($.each($.fn.jAlert.defaults,function(key,val){var lowerKey=key.toLowerCase();"undefined"!=typeof options[lowerKey]&&(options[key]=options[lowerKey])}),options=$.extend({},$.fn.jAlert.defaults,options),options.id)var alert_id=options.id;else var unique=Date.now().toString()+Math.floor(1e5*Math.random()),alert_id="ja_"+unique;var alert={set:function(key,val){return alert[key]=val,alert},__set:function(key,val){return alert.set(key,val)},get:function(key){return alert[key]},__get:function(key){return alert.get(key)},centerAlert:function(){var viewportHeight=$(window).height(),alertHeight=alert.instance.height(),diff=viewportHeight-alertHeight,margin=diff/2;return margin=margin>200?margin-100:margin,margin=margin<=0?0:margin,margin-=1,alert.instance.css("margin-top",margin+"px"),alert.instance.css("margin-bottom","0px"),$("body").css("overflow","hidden"),diff>5?alert.instance.parents(".ja_wrap").css("position","fixed"):(alert.instance.parents(".ja_wrap").css("position","absolute"),$("html, body").animate({scrollTop:top-50},200)),alert},animateAlert:function(which){return"hide"==which?(alert.instance.jAlert().blurBackground&&$("body").removeClass("ja_blur"),alert.instance.removeClass(alert.showAnimation).addClass(alert.hideAnimation)):(alert.instance.jAlert().blurBackground&&$("body").addClass("ja_blur"),alert.centerAlert(),alert.instance.addClass(alert.showAnimation).removeClass(alert.hideAnimation).show()),alert},closeAlert:function(remove,onClose){return 0!=remove&&(remove=!0),alert.instance&&(alert.instance.unbind("DOMSubtreeModified"),alert.animateAlert("hide"),window.setTimeout(function(){var alertWrap=alert.instance.parents(".ja_wrap");remove?alertWrap.remove():alertWrap.hide(),"function"==typeof onClose?onClose(alert.instance):"function"==typeof alert.onClose&&alert.onClose(alert.instance),$(".jAlert:visible").length>0?$(".jAlert:visible:last").jAlert().centerAlert():$("body").css("overflow","auto")},alert.animationTimeout)),alert},showAlert:function(replaceOthers,removeOthers,onOpen,onClose){0!=replaceOthers&&(replaceOthers=!0),removeOthers!==!1&&(removeOthers=!0),replaceOthers&&$(".jAlert:visible").jAlert().closeAlert(removeOthers);var wrap=alert.instance.parents(".ja_wrap");return $("body").append(wrap),alert.animateAlert("show"),"function"==typeof onClose&&(alert.onClose=onClose),window.setTimeout(function(){"function"==typeof onOpen&&onOpen(alert.instance)},alert.animationTimeout),alert}};if($.each(options,function(key,val){alert.set(key,val)}),alert.set("id",alert_id),alert.content&&0===alert.content.indexOf("#")&&$(alert.content).length>0&&(alert.content=$(alert.content).html()),alert.video&&alert.video.indexOf("youtube.com/watch?v=")>-1&&alert.video.indexOf("embed")===-1&&(alert.video=alert.video.replace("watch?v=","embed/")),"confirm"==alert.type&&(alert.content||(alert.content=alert.confirmQuestion),alert.btns=[{text:alert.confirmBtnText,theme:"green",class:"confirmBtn",closeAlert:!0,onClick:alert.onConfirm},{text:alert.denyBtnText,theme:"red",class:"denyBtn",closeAlert:!0,onClick:alert.onDeny}],alert.autofocus=alert.confirmAutofocus),alert.color&&(alert.theme=alert.color),$.inArray(alert.theme,themes)==-1)return console.log("jAlert Config Error: Invalid theme selection."),!1;if(classes.push("ja_"+alert.theme),alert.class&&classes.push(alert.class),alert.classes&&classes.push(alert.classes),alert.fullscreen&&classes.push("ja_fullscreen"),alert.noPadContent&&classes.push("ja_no_pad"),alert.title||classes.push("ja_noTitle"),alert.width&&(alert.size=alert.width),alert.size&&"object"==typeof alert.size&&("undefined"==typeof alert.size.width||"undefined"==typeof alert.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(alert.size?"object"==typeof alert.size?(styles.push("width: "+alert.size.width+";"),styles.push("height: "+alert.size.height+";"),classes.push("ja_setheight")):("undefined"!=typeof sizeAliases[alert.size]&&(alert.size=sizeAliases[alert.size]),$.inArray(alert.size,sizes)>-1?classes.push("ja_"+alert.size):styles.push("width: "+alert.size+";")):classes.push("ja_sm"),$.inArray(alert.backgroundColor,backgroundColors)==-1)return console.log("jAlert Config Error: Invalid background color selection."),!1;backgroundClasses.push("ja_wrap_"+alert.backgroundColor),alert.onOpen=[alert.onOpen];var onload="onload='$.fn.jAlert.mediaLoaded($(this))'",loader="
Loading...
";alert.picture&&(alert.image=alert.picture),alert.image?(alert.content="
"+loader+"
",alert.onOpen.unshift(function(elem){var iframe=document.createElement("iframe");iframe.src=elem.jAlert().video,iframe.addEventListener?iframe.addEventListener("load",function(){$.fn.jAlert.mediaLoaded($(this))},!0):iframe.attachEvent?iframe.attachEvent("onload",function(){$.fn.jAlert.mediaLoaded($(this))}):iframe.onload=function(){$.fn.jAlert.mediaLoaded($(this))},elem.find(".ja_video").append(iframe)})):alert.iframe?(alert.iframeHeight||(alert.iframeHeight=$(window).height()+"px"),alert.content="
"+loader+"
",alert.onOpen.unshift(function(elem){var iframe=document.createElement("iframe");iframe.src=elem.jAlert().iframe,iframe.className="ja_iframe",iframe.addEventListener?iframe.addEventListener("load",function(){$.fn.jAlert.mediaLoaded($(this))},!0):iframe.attachEvent?iframe.attachEvent("onload",function(){$.fn.jAlert.mediaLoaded($(this))}):iframe.onload=function(){$.fn.jAlert.mediaLoaded($(this))},elem.find(".ja_media_wrap").append(iframe)})):alert.ajax&&(alert.content="
"+loader+"
",onAjaxCallbacks=alert.onOpen,alert.onOpen=[function(elem){$.ajax(elem.jAlert().ajax,{async:!0,complete:function(jqXHR,textStatus){elem.find(".ja_media_wrap").replaceWith(jqXHR.responseText),$.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){if("undefined"==typeof btn.href&&(btn.href=""),"undefined"==typeof btn.class&&(btn.class=""),"undefined"==typeof btn.theme?btn.class+=" ja_btn_default":btn.class+=" ja_btn_"+btn.theme,"undefined"==typeof btn.text&&(btn.text=""),"undefined"==typeof btn.id){var unique=Date.now().toString()+Math.floor(1e5*Math.random());btn.id="ja_btn_"+unique}return"undefined"==typeof btn.target&&(btn.target="_self"),"undefined"==typeof btn.closeAlert&&(btn.closeAlert=!0),$("body").off("click","#"+btn.id),$("body").on("click","#"+btn.id,function(e){var button=$(this);btn.closeAlert&&button.parents(".jAlert").jAlert().closeAlert();var callbackResponse=!0;return"function"==typeof btn.onClick&&(callbackResponse=btn.onClick(e,button)),!callbackResponse||btn.closeAlert?(e.preventDefault(),!1):callbackResponse}),""+btn.text+" "},addAlert=function(content){var html="";html+='
',alert.closeBtn&&(html+="
×
"),alert.title&&(html+="
"+alert.title+"
"),html+='
'+content,alert.btns&&(html+='
0&&lastVisibleAlert.jAlert().closeOnClick&&($(target).is(".jAlert *")||lastVisibleAlert.jAlert().closeAlert())},$.fn.jAlert.onEscKeyDown=function(e){if(27===e.keyCode){var lastVisibleAlert=$(".jAlert:visible:last");lastVisibleAlert.length>0&&lastVisibleAlert.jAlert().closeOnEsc&&lastVisibleAlert.jAlert().closeAlert()}},$.fn.attachjAlert=function(e){return e.preventDefault(),$.jAlert($(this).data()),!1},$.jAlert=function(options){if("current"==options){var latest=$(".jAlert:visible:last");return latest.length>0&&latest.jAlert()}return"attach"==options?($("[data-jAlert]").off("click",$.fn.attachjAlert),$("[data-jAlert]").on("click",$.fn.attachjAlert),$("[data-jalert]").off("click",$.fn.attachjAlert),$("[data-jalert]").on("click",$.fn.attachjAlert),!1):$.fn.jAlert(options)},$.fn.alertOnClick=function(options){$(this).on("click",function(e){return e.preventDefault(),$.jAlert(options),!1})},$.alertOnClick=function(selector,options){$("body").on("click",selector,function(e){return e.preventDefault(),$.jAlert(options),!1})},$.fn.closeAlert=function(remove,onClose){$(this).jAlert().closeAlert(remove,onClose)};var $jAlertResizeTimeout;$(window).resize(function(){window.clearTimeout($jAlertResizeTimeout),$jAlertResizeTimeout=window.setTimeout(function(){$(".jAlert:visible").each(function(){$(this).jAlert().centerAlert()})},200)}),$.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();wrap.find(".ja_loader").remove(),vid_wrap.length>0?vid_wrap.fadeIn("fast"):elem.fadeIn("fast"),"undefined"!=typeof jalert.iframeHeight&&jalert.iframeHeight&&(elem.css("display","block"),elem.height(jalert.iframeHeight)),jalert.centerAlert()}}(jQuery); \ No newline at end of file +(function(b){if(!Date.now){Date.now=function(){return +new Date()}}b.fn.jAlert=function(q){b("body").focus();b("body").blur();var k=["default","green","dark_green","red","dark_red","black","brown","gray","dark_gray","blue","dark_blue","yellow"],p=["xsm","sm","md","lg","xlg","full","auto"],h={xsmall:"xsm",small:"sm",medium:"md",large:"lg",xlarge:"xlg"},d=["white","black"],n=[],c=["animated"],o=[];if(this.length>1){this.each(function(){b.fn.jAlert(q)});return this}if(typeof b(this)[0]!="undefined"){if(b(this)[0]["jAlert"]!="undefined"){return b(this)[0]["jAlert"]}}b.each(b.fn.jAlert.defaults,function(s,t){var r=s.toLowerCase();if(typeof q[r]!=="undefined"){q[s]=q[r]}});q=b.extend({},b.fn.jAlert.defaults,q);if(!q.id){var g=Date.now().toString()+Math.floor(Math.random()*100000);var j="ja_"+g}else{var j=q.id}var i={set:function(r,s){i[r]=s;return i},__set:function(r,s){return i.set(r,s)},get:function(r){return i[r]},__get:function(r){return i.get(r)},centerAlert:function(){var r=b(window).height(),u=i.instance.height(),t=r-u;var s=t/2;s=s>200?s-100:s;s=s<=0?0:s;s=s-1;i.instance.css("margin-top",s+"px");i.instance.css("margin-bottom","0px");b("body").css("overflow","hidden");if(t>5){i.instance.parents(".ja_wrap").css("position","fixed")}else{i.instance.parents(".ja_wrap").css("position","absolute");b("html, body").animate({scrollTop:top-50},200)}return i},animateAlert:function(r){if(r=="hide"){if(i.instance.jAlert().blurBackground){b("body").removeClass("ja_blur")}i.instance.removeClass(i.showAnimation).addClass(i.hideAnimation)}else{if(i.instance.jAlert().blurBackground){b("body").addClass("ja_blur")}i.centerAlert();i.instance.addClass(i.showAnimation).removeClass(i.hideAnimation).show()}return i},closeAlert:function(r,s){if(r!=false){r=true}if(i.instance){i.instance.unbind("DOMSubtreeModified");i.animateAlert("hide");window.setTimeout(function(){var t=i.instance.parents(".ja_wrap");if(r){t.remove()}else{t.hide()}if(typeof s=="function"){s(i.instance)}else{if(typeof i.onClose=="function"){i.onClose(i.instance)}}if(b(".jAlert:visible").length>0){b(".jAlert:visible:last").jAlert().centerAlert()}else{b("body").css("overflow","auto")}},i.animationTimeout)}return i},showAlert:function(t,v,s,r){if(t!=false){t=true}if(v!==false){v=true}if(t){b(".jAlert:visible").jAlert().closeAlert(v)}var u=i.instance.parents(".ja_wrap");b("body").append(u);i.animateAlert("show");if(typeof r=="function"){i.onClose=r}window.setTimeout(function(){if(typeof s=="function"){s(i.instance)}},i.animationTimeout);return i}};b.each(q,function(r,s){i.set(r,s)});i.set("id",j);if(i.content&&i.content.indexOf("#")===0){if(b(i.content).length>0){i.content=b(i.content).html()}}if(i.video&&i.video.indexOf("youtube.com/watch?v=")>-1&&i.video.indexOf("embed")===-1){i.video=i.video.replace("watch?v=","embed/")}if(i.type=="confirm"){if(!i.content){i.content=i.confirmQuestion}i.btns=[{text:i.confirmBtnText,theme:"green","class":"confirmBtn",closeAlert:true,onClick:i.onConfirm},{text:i.denyBtnText,theme:"red","class":"denyBtn",closeAlert:true,onClick:i.onDeny}];i.autofocus=i.confirmAutofocus}if(i.color){i.theme=i.color}if(b.inArray(i.theme,k)==-1){console.log("jAlert Config Error: Invalid theme selection.");return false}c.push("ja_"+i.theme);if(i["class"]){c.push(i["class"])}if(i.classes){c.push(i.classes)}if(i.fullscreen){c.push("ja_fullscreen")}if(i.noPadContent){c.push("ja_no_pad")}if(!i.title){c.push("ja_noTitle")}if(i.width){i.size=i.width}if(i.size&&((typeof i.size=="object"&&(typeof i.size.width=="undefined"||typeof i.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}else{if(!i.size){c.push("ja_sm")}else{if(typeof i.size=="object"){n.push("width: "+i.size.width+";");n.push("height: "+i.size.height+";");c.push("ja_setheight")}else{if(typeof h[i.size]!=="undefined"){i.size=h[i.size]}if(b.inArray(i.size,p)>-1){c.push("ja_"+i.size)}else{n.push("width: "+i.size+";")}}}}if(b.inArray(i.backgroundColor,d)==-1){console.log("jAlert Config Error: Invalid background color selection.");return false}o.push("ja_wrap_"+i.backgroundColor);i.onOpen=[i.onOpen];var e="onload='$.fn.jAlert.mediaLoaded($(this))'",l="
Loading...
";if(i.picture){i.image=i.picture}if(i.image){i.content="
"+l+"
";i.onOpen.unshift(function(s){var r=document.createElement("iframe");r.src=s.jAlert().video;if(r.addEventListener){r.addEventListener("load",function(){b.fn.jAlert.mediaLoaded(b(this))},true)}else{if(r.attachEvent){r.attachEvent("onload",function(){b.fn.jAlert.mediaLoaded(b(this))})}else{r.onload=function(){b.fn.jAlert.mediaLoaded(b(this))}}}s.find(".ja_video").append(r)})}else{if(i.iframe){if(!i.iframeHeight){i.iframeHeight=b(window).height()+"px"}i.content="
"+l+"
";i.onOpen.unshift(function(s){var r=document.createElement("iframe");r.src=s.jAlert().iframe;r.className="ja_iframe";if(r.addEventListener){r.addEventListener("load",function(){b.fn.jAlert.mediaLoaded(b(this))},true)}else{if(r.attachEvent){r.attachEvent("onload",function(){b.fn.jAlert.mediaLoaded(b(this))})}else{r.onload=function(){b.fn.jAlert.mediaLoaded(b(this))}}}s.find(".ja_media_wrap").append(r)})}else{if(i.ajax){i.content="
"+l+"
";onAjaxCallbacks=i.onOpen;i.onOpen=[function(r){b.ajax(r.jAlert().ajax,{async:true,complete:function(s,t){r.find(".ja_media_wrap").replaceWith(s.responseText);b.each(onAjaxCallbacks,function(u,v){v(r)})},error:function(s,u,t){i.onAjaxFail(r,"Error getting content: Code: "+s.status+" : Msg: "+s.statusText)}})}]}}}}var f=function(r){if(typeof r.href=="undefined"){r.href=""}if(typeof r["class"]=="undefined"){r["class"]=""}if(typeof r.theme=="undefined"){r["class"]+=" ja_btn_default"}else{r["class"]+=" ja_btn_"+r.theme}if(typeof r.text=="undefined"){r.text=""}if(typeof r.id=="undefined"){var s=Date.now().toString()+Math.floor(Math.random()*100000);r.id="ja_btn_"+s}if(typeof r.target=="undefined"){r.target="_self"}if(typeof r.closeAlert=="undefined"){r.closeAlert=true}b("body").off("click","#"+r.id);b("body").on("click","#"+r.id,function(v){var t=b(this);if(r.closeAlert){t.parents(".jAlert").jAlert().closeAlert()}var u=true;if(typeof r.onClick=="function"){u=r.onClick(v,t)}if(!u||r.closeAlert){v.preventDefault();return false}return u});return""+r.text+" "};var m=function(t){var s="";s+='
';if(i.closeBtn){s+="
×
"}if(i.title){s+="
"+i.title+"
"}s+='
'+t;if(i.btns){s+='
0&&c.jAlert().closeOnClick){if(!b(d).is(".jAlert *")){c.jAlert().closeAlert()}}};b.fn.jAlert.onEscKeyDown=function(d){if(d.keyCode===27){var c=b(".jAlert:visible:last");if(c.length>0&&c.jAlert().closeOnEsc){c.jAlert().closeAlert()}}};b.fn.attachjAlert=function(c){c.preventDefault();b.jAlert(b(this).data());return false};b.jAlert=function(d){if(d=="current"){var c=b(".jAlert:visible:last");if(c.length>0){return c.jAlert()}return false}if(d=="attach"){b("[data-jAlert]").off("click",b.fn.attachjAlert);b("[data-jAlert]").on("click",b.fn.attachjAlert);b("[data-jalert]").off("click",b.fn.attachjAlert);b("[data-jalert]").on("click",b.fn.attachjAlert);return false}return b.fn.jAlert(d)};b.fn.alertOnClick=function(c){b(this).on("click",function(d){d.preventDefault();b.jAlert(c);return false})};b.alertOnClick=function(c,d){b("body").on("click",c,function(f){f.preventDefault();b.jAlert(d);return false})};b.fn.closeAlert=function(c,d){b(this).jAlert().closeAlert(c,d)};var a;b(window).resize(function(){window.clearTimeout(a);a=window.setTimeout(function(){b(".jAlert:visible").each(function(){b(this).jAlert().centerAlert()})},200)});b.fn.jAlert.mediaLoaded=function(f){var e=f.parents(".ja_media_wrap"),c=e.find(".ja_video"),g=f.parents(".jAlert:first"),d=g.jAlert();e.find(".ja_loader").remove();if(c.length>0){c.fadeIn("fast")}else{f.fadeIn("fast")}if(typeof d.iframeHeight!=="undefined"&&d.iframeHeight){f.css("display","block");f.height(d.iframeHeight)}d.centerAlert()}})(jQuery); \ No newline at end of file From 19cd1d28f78e7180eefd51ee4faf34c3150c837b Mon Sep 17 00:00:00 2001 From: Cristian Gabriel Danasel Date: Tue, 24 Oct 2017 15:33:39 +0100 Subject: [PATCH 03/17] Add auto close after a period of time on readme --- README.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/README.md b/README.md index b6eff64..e3a8d38 100644 --- a/README.md +++ b/README.md @@ -64,6 +64,18 @@ $(function(){ }); ``` +### Auto Close after period of time +```javascript + $.jAlert({ //this is the normal usage + 'title': 'Test', + 'content': 'Howdy', + 'theme': 'green', + 'size': 'xsm' + 'autoClose' : true, + 'closeTime' : 3500 + }); +``` + ### Quick Use (requires jAlert-functions.js!!!) ```javascript alert('hi'); //override is enabled by default From 7b153e5f526cc88663c7385aa528964ca50ee416 Mon Sep 17 00:00:00 2001 From: Cristian Gabriel Danasel Date: Wed, 25 Oct 2017 10:50:14 +0100 Subject: [PATCH 04/17] Add autoclose to default jAlert --- src/jAlert.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/jAlert.js b/src/jAlert.js index 4d630ce..a3f100e 100644 --- a/src/jAlert.js +++ b/src/jAlert.js @@ -797,6 +797,8 @@ '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 + 'autoClose' : false, // Set default autoClose + 'closeTime' : 3000, // Set 3 sec on autoclose /* Variety of buttons you could create (also, an example of how to pass the object From 286393df4d3b578b17d7a619bca4b2a2625f380e Mon Sep 17 00:00:00 2001 From: Cristian Gabriel Danasel Date: Wed, 25 Oct 2017 10:52:32 +0100 Subject: [PATCH 05/17] Update #7b153e5 --- dist/jAlert.min.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dist/jAlert.min.js b/dist/jAlert.min.js index 8552ce3..8ca0d90 100644 --- a/dist/jAlert.min.js +++ b/dist/jAlert.min.js @@ -1 +1 @@ -(function(b){if(!Date.now){Date.now=function(){return +new Date()}}b.fn.jAlert=function(q){b("body").focus();b("body").blur();var k=["default","green","dark_green","red","dark_red","black","brown","gray","dark_gray","blue","dark_blue","yellow"],p=["xsm","sm","md","lg","xlg","full","auto"],h={xsmall:"xsm",small:"sm",medium:"md",large:"lg",xlarge:"xlg"},d=["white","black"],n=[],c=["animated"],o=[];if(this.length>1){this.each(function(){b.fn.jAlert(q)});return this}if(typeof b(this)[0]!="undefined"){if(b(this)[0]["jAlert"]!="undefined"){return b(this)[0]["jAlert"]}}b.each(b.fn.jAlert.defaults,function(s,t){var r=s.toLowerCase();if(typeof q[r]!=="undefined"){q[s]=q[r]}});q=b.extend({},b.fn.jAlert.defaults,q);if(!q.id){var g=Date.now().toString()+Math.floor(Math.random()*100000);var j="ja_"+g}else{var j=q.id}var i={set:function(r,s){i[r]=s;return i},__set:function(r,s){return i.set(r,s)},get:function(r){return i[r]},__get:function(r){return i.get(r)},centerAlert:function(){var r=b(window).height(),u=i.instance.height(),t=r-u;var s=t/2;s=s>200?s-100:s;s=s<=0?0:s;s=s-1;i.instance.css("margin-top",s+"px");i.instance.css("margin-bottom","0px");b("body").css("overflow","hidden");if(t>5){i.instance.parents(".ja_wrap").css("position","fixed")}else{i.instance.parents(".ja_wrap").css("position","absolute");b("html, body").animate({scrollTop:top-50},200)}return i},animateAlert:function(r){if(r=="hide"){if(i.instance.jAlert().blurBackground){b("body").removeClass("ja_blur")}i.instance.removeClass(i.showAnimation).addClass(i.hideAnimation)}else{if(i.instance.jAlert().blurBackground){b("body").addClass("ja_blur")}i.centerAlert();i.instance.addClass(i.showAnimation).removeClass(i.hideAnimation).show()}return i},closeAlert:function(r,s){if(r!=false){r=true}if(i.instance){i.instance.unbind("DOMSubtreeModified");i.animateAlert("hide");window.setTimeout(function(){var t=i.instance.parents(".ja_wrap");if(r){t.remove()}else{t.hide()}if(typeof s=="function"){s(i.instance)}else{if(typeof i.onClose=="function"){i.onClose(i.instance)}}if(b(".jAlert:visible").length>0){b(".jAlert:visible:last").jAlert().centerAlert()}else{b("body").css("overflow","auto")}},i.animationTimeout)}return i},showAlert:function(t,v,s,r){if(t!=false){t=true}if(v!==false){v=true}if(t){b(".jAlert:visible").jAlert().closeAlert(v)}var u=i.instance.parents(".ja_wrap");b("body").append(u);i.animateAlert("show");if(typeof r=="function"){i.onClose=r}window.setTimeout(function(){if(typeof s=="function"){s(i.instance)}},i.animationTimeout);return i}};b.each(q,function(r,s){i.set(r,s)});i.set("id",j);if(i.content&&i.content.indexOf("#")===0){if(b(i.content).length>0){i.content=b(i.content).html()}}if(i.video&&i.video.indexOf("youtube.com/watch?v=")>-1&&i.video.indexOf("embed")===-1){i.video=i.video.replace("watch?v=","embed/")}if(i.type=="confirm"){if(!i.content){i.content=i.confirmQuestion}i.btns=[{text:i.confirmBtnText,theme:"green","class":"confirmBtn",closeAlert:true,onClick:i.onConfirm},{text:i.denyBtnText,theme:"red","class":"denyBtn",closeAlert:true,onClick:i.onDeny}];i.autofocus=i.confirmAutofocus}if(i.color){i.theme=i.color}if(b.inArray(i.theme,k)==-1){console.log("jAlert Config Error: Invalid theme selection.");return false}c.push("ja_"+i.theme);if(i["class"]){c.push(i["class"])}if(i.classes){c.push(i.classes)}if(i.fullscreen){c.push("ja_fullscreen")}if(i.noPadContent){c.push("ja_no_pad")}if(!i.title){c.push("ja_noTitle")}if(i.width){i.size=i.width}if(i.size&&((typeof i.size=="object"&&(typeof i.size.width=="undefined"||typeof i.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}else{if(!i.size){c.push("ja_sm")}else{if(typeof i.size=="object"){n.push("width: "+i.size.width+";");n.push("height: "+i.size.height+";");c.push("ja_setheight")}else{if(typeof h[i.size]!=="undefined"){i.size=h[i.size]}if(b.inArray(i.size,p)>-1){c.push("ja_"+i.size)}else{n.push("width: "+i.size+";")}}}}if(b.inArray(i.backgroundColor,d)==-1){console.log("jAlert Config Error: Invalid background color selection.");return false}o.push("ja_wrap_"+i.backgroundColor);i.onOpen=[i.onOpen];var e="onload='$.fn.jAlert.mediaLoaded($(this))'",l="
Loading...
";if(i.picture){i.image=i.picture}if(i.image){i.content="
"+l+"
";i.onOpen.unshift(function(s){var r=document.createElement("iframe");r.src=s.jAlert().video;if(r.addEventListener){r.addEventListener("load",function(){b.fn.jAlert.mediaLoaded(b(this))},true)}else{if(r.attachEvent){r.attachEvent("onload",function(){b.fn.jAlert.mediaLoaded(b(this))})}else{r.onload=function(){b.fn.jAlert.mediaLoaded(b(this))}}}s.find(".ja_video").append(r)})}else{if(i.iframe){if(!i.iframeHeight){i.iframeHeight=b(window).height()+"px"}i.content="
"+l+"
";i.onOpen.unshift(function(s){var r=document.createElement("iframe");r.src=s.jAlert().iframe;r.className="ja_iframe";if(r.addEventListener){r.addEventListener("load",function(){b.fn.jAlert.mediaLoaded(b(this))},true)}else{if(r.attachEvent){r.attachEvent("onload",function(){b.fn.jAlert.mediaLoaded(b(this))})}else{r.onload=function(){b.fn.jAlert.mediaLoaded(b(this))}}}s.find(".ja_media_wrap").append(r)})}else{if(i.ajax){i.content="
"+l+"
";onAjaxCallbacks=i.onOpen;i.onOpen=[function(r){b.ajax(r.jAlert().ajax,{async:true,complete:function(s,t){r.find(".ja_media_wrap").replaceWith(s.responseText);b.each(onAjaxCallbacks,function(u,v){v(r)})},error:function(s,u,t){i.onAjaxFail(r,"Error getting content: Code: "+s.status+" : Msg: "+s.statusText)}})}]}}}}var f=function(r){if(typeof r.href=="undefined"){r.href=""}if(typeof r["class"]=="undefined"){r["class"]=""}if(typeof r.theme=="undefined"){r["class"]+=" ja_btn_default"}else{r["class"]+=" ja_btn_"+r.theme}if(typeof r.text=="undefined"){r.text=""}if(typeof r.id=="undefined"){var s=Date.now().toString()+Math.floor(Math.random()*100000);r.id="ja_btn_"+s}if(typeof r.target=="undefined"){r.target="_self"}if(typeof r.closeAlert=="undefined"){r.closeAlert=true}b("body").off("click","#"+r.id);b("body").on("click","#"+r.id,function(v){var t=b(this);if(r.closeAlert){t.parents(".jAlert").jAlert().closeAlert()}var u=true;if(typeof r.onClick=="function"){u=r.onClick(v,t)}if(!u||r.closeAlert){v.preventDefault();return false}return u});return""+r.text+" "};var m=function(t){var s="";s+='
';if(i.closeBtn){s+="
×
"}if(i.title){s+="
"+i.title+"
"}s+='
'+t;if(i.btns){s+='
0&&c.jAlert().closeOnClick){if(!b(d).is(".jAlert *")){c.jAlert().closeAlert()}}};b.fn.jAlert.onEscKeyDown=function(d){if(d.keyCode===27){var c=b(".jAlert:visible:last");if(c.length>0&&c.jAlert().closeOnEsc){c.jAlert().closeAlert()}}};b.fn.attachjAlert=function(c){c.preventDefault();b.jAlert(b(this).data());return false};b.jAlert=function(d){if(d=="current"){var c=b(".jAlert:visible:last");if(c.length>0){return c.jAlert()}return false}if(d=="attach"){b("[data-jAlert]").off("click",b.fn.attachjAlert);b("[data-jAlert]").on("click",b.fn.attachjAlert);b("[data-jalert]").off("click",b.fn.attachjAlert);b("[data-jalert]").on("click",b.fn.attachjAlert);return false}return b.fn.jAlert(d)};b.fn.alertOnClick=function(c){b(this).on("click",function(d){d.preventDefault();b.jAlert(c);return false})};b.alertOnClick=function(c,d){b("body").on("click",c,function(f){f.preventDefault();b.jAlert(d);return false})};b.fn.closeAlert=function(c,d){b(this).jAlert().closeAlert(c,d)};var a;b(window).resize(function(){window.clearTimeout(a);a=window.setTimeout(function(){b(".jAlert:visible").each(function(){b(this).jAlert().centerAlert()})},200)});b.fn.jAlert.mediaLoaded=function(f){var e=f.parents(".ja_media_wrap"),c=e.find(".ja_video"),g=f.parents(".jAlert:first"),d=g.jAlert();e.find(".ja_loader").remove();if(c.length>0){c.fadeIn("fast")}else{f.fadeIn("fast")}if(typeof d.iframeHeight!=="undefined"&&d.iframeHeight){f.css("display","block");f.height(d.iframeHeight)}d.centerAlert()}})(jQuery); \ No newline at end of file +(function(b){if(!Date.now){Date.now=function(){return +new Date()}}b.fn.jAlert=function(q){b("body").focus();b("body").blur();var k=["default","green","dark_green","red","dark_red","black","brown","gray","dark_gray","blue","dark_blue","yellow"],p=["xsm","sm","md","lg","xlg","full","auto"],h={xsmall:"xsm",small:"sm",medium:"md",large:"lg",xlarge:"xlg"},d=["white","black"],n=[],c=["animated"],o=[];if(this.length>1){this.each(function(){b.fn.jAlert(q)});return this}if(typeof b(this)[0]!="undefined"){if(b(this)[0]["jAlert"]!="undefined"){return b(this)[0]["jAlert"]}}b.each(b.fn.jAlert.defaults,function(s,t){var r=s.toLowerCase();if(typeof q[r]!=="undefined"){q[s]=q[r]}});q=b.extend({},b.fn.jAlert.defaults,q);if(!q.id){var g=Date.now().toString()+Math.floor(Math.random()*100000);var j="ja_"+g}else{var j=q.id}var i={set:function(r,s){i[r]=s;return i},__set:function(r,s){return i.set(r,s)},get:function(r){return i[r]},__get:function(r){return i.get(r)},centerAlert:function(){var r=b(window).height(),u=i.instance.height(),t=r-u;var s=t/2;s=s>200?s-100:s;s=s<=0?0:s;s=s-1;i.instance.css("margin-top",s+"px");i.instance.css("margin-bottom","0px");b("body").css("overflow","hidden");if(t>5){i.instance.parents(".ja_wrap").css("position","fixed")}else{i.instance.parents(".ja_wrap").css("position","absolute");b("html, body").animate({scrollTop:top-50},200)}return i},animateAlert:function(r){if(r=="hide"){if(i.instance.jAlert().blurBackground){b("body").removeClass("ja_blur")}i.instance.removeClass(i.showAnimation).addClass(i.hideAnimation)}else{if(i.instance.jAlert().blurBackground){b("body").addClass("ja_blur")}i.centerAlert();i.instance.addClass(i.showAnimation).removeClass(i.hideAnimation).show()}return i},closeAlert:function(r,s){if(r!=false){r=true}if(i.instance){i.instance.unbind("DOMSubtreeModified");i.animateAlert("hide");window.setTimeout(function(){var t=i.instance.parents(".ja_wrap");if(r){t.remove()}else{t.hide()}if(typeof s=="function"){s(i.instance)}else{if(typeof i.onClose=="function"){i.onClose(i.instance)}}if(b(".jAlert:visible").length>0){b(".jAlert:visible:last").jAlert().centerAlert()}else{b("body").css("overflow","auto")}},i.animationTimeout)}return i},showAlert:function(t,v,s,r){if(t!=false){t=true}if(v!==false){v=true}if(t){b(".jAlert:visible").jAlert().closeAlert(v)}var u=i.instance.parents(".ja_wrap");b("body").append(u);i.animateAlert("show");if(typeof r=="function"){i.onClose=r}window.setTimeout(function(){if(typeof s=="function"){s(i.instance)}},i.animationTimeout);return i}};b.each(q,function(r,s){i.set(r,s)});i.set("id",j);if(i.content&&i.content.indexOf("#")===0){if(b(i.content).length>0){i.content=b(i.content).html()}}if(i.video&&i.video.indexOf("youtube.com/watch?v=")>-1&&i.video.indexOf("embed")===-1){i.video=i.video.replace("watch?v=","embed/")}if(i.type=="confirm"){if(!i.content){i.content=i.confirmQuestion}i.btns=[{text:i.confirmBtnText,theme:"green","class":"confirmBtn",closeAlert:true,onClick:i.onConfirm},{text:i.denyBtnText,theme:"red","class":"denyBtn",closeAlert:true,onClick:i.onDeny}];i.autofocus=i.confirmAutofocus}if(i.color){i.theme=i.color}if(b.inArray(i.theme,k)==-1){console.log("jAlert Config Error: Invalid theme selection.");return false}c.push("ja_"+i.theme);if(i["class"]){c.push(i["class"])}if(i.classes){c.push(i.classes)}if(i.fullscreen){c.push("ja_fullscreen")}if(i.noPadContent){c.push("ja_no_pad")}if(!i.title){c.push("ja_noTitle")}if(i.width){i.size=i.width}if(i.size&&((typeof i.size=="object"&&(typeof i.size.width=="undefined"||typeof i.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}else{if(!i.size){c.push("ja_sm")}else{if(typeof i.size=="object"){n.push("width: "+i.size.width+";");n.push("height: "+i.size.height+";");c.push("ja_setheight")}else{if(typeof h[i.size]!=="undefined"){i.size=h[i.size]}if(b.inArray(i.size,p)>-1){c.push("ja_"+i.size)}else{n.push("width: "+i.size+";")}}}}if(b.inArray(i.backgroundColor,d)==-1){console.log("jAlert Config Error: Invalid background color selection.");return false}o.push("ja_wrap_"+i.backgroundColor);i.onOpen=[i.onOpen];var e="onload='$.fn.jAlert.mediaLoaded($(this))'",l="
Loading...
";if(i.picture){i.image=i.picture}if(i.image){i.content="
"+l+"
";i.onOpen.unshift(function(s){var r=document.createElement("iframe");r.src=s.jAlert().video;if(r.addEventListener){r.addEventListener("load",function(){b.fn.jAlert.mediaLoaded(b(this))},true)}else{if(r.attachEvent){r.attachEvent("onload",function(){b.fn.jAlert.mediaLoaded(b(this))})}else{r.onload=function(){b.fn.jAlert.mediaLoaded(b(this))}}}s.find(".ja_video").append(r)})}else{if(i.iframe){if(!i.iframeHeight){i.iframeHeight=b(window).height()+"px"}i.content="
"+l+"
";i.onOpen.unshift(function(s){var r=document.createElement("iframe");r.src=s.jAlert().iframe;r.className="ja_iframe";if(r.addEventListener){r.addEventListener("load",function(){b.fn.jAlert.mediaLoaded(b(this))},true)}else{if(r.attachEvent){r.attachEvent("onload",function(){b.fn.jAlert.mediaLoaded(b(this))})}else{r.onload=function(){b.fn.jAlert.mediaLoaded(b(this))}}}s.find(".ja_media_wrap").append(r)})}else{if(i.ajax){i.content="
"+l+"
";onAjaxCallbacks=i.onOpen;i.onOpen=[function(r){b.ajax(r.jAlert().ajax,{async:true,complete:function(s,t){r.find(".ja_media_wrap").replaceWith(s.responseText);b.each(onAjaxCallbacks,function(u,v){v(r)})},error:function(s,u,t){i.onAjaxFail(r,"Error getting content: Code: "+s.status+" : Msg: "+s.statusText)}})}]}}}}var f=function(r){if(typeof r.href=="undefined"){r.href=""}if(typeof r["class"]=="undefined"){r["class"]=""}if(typeof r.theme=="undefined"){r["class"]+=" ja_btn_default"}else{r["class"]+=" ja_btn_"+r.theme}if(typeof r.text=="undefined"){r.text=""}if(typeof r.id=="undefined"){var s=Date.now().toString()+Math.floor(Math.random()*100000);r.id="ja_btn_"+s}if(typeof r.target=="undefined"){r.target="_self"}if(typeof r.closeAlert=="undefined"){r.closeAlert=true}b("body").off("click","#"+r.id);b("body").on("click","#"+r.id,function(v){var t=b(this);if(r.closeAlert){t.parents(".jAlert").jAlert().closeAlert()}var u=true;if(typeof r.onClick=="function"){u=r.onClick(v,t)}if(!u||r.closeAlert){v.preventDefault();return false}return u});return""+r.text+" "};var m=function(t){var s="";s+='
';if(i.closeBtn){s+="
×
"}if(i.title){s+="
"+i.title+"
"}s+='
'+t;if(i.btns){s+='
0&&c.jAlert().closeOnClick){if(!b(d).is(".jAlert *")){c.jAlert().closeAlert()}}};b.fn.jAlert.onEscKeyDown=function(d){if(d.keyCode===27){var c=b(".jAlert:visible:last");if(c.length>0&&c.jAlert().closeOnEsc){c.jAlert().closeAlert()}}};b.fn.attachjAlert=function(c){c.preventDefault();b.jAlert(b(this).data());return false};b.jAlert=function(d){if(d=="current"){var c=b(".jAlert:visible:last");if(c.length>0){return c.jAlert()}return false}if(d=="attach"){b("[data-jAlert]").off("click",b.fn.attachjAlert);b("[data-jAlert]").on("click",b.fn.attachjAlert);b("[data-jalert]").off("click",b.fn.attachjAlert);b("[data-jalert]").on("click",b.fn.attachjAlert);return false}return b.fn.jAlert(d)};b.fn.alertOnClick=function(c){b(this).on("click",function(d){d.preventDefault();b.jAlert(c);return false})};b.alertOnClick=function(c,d){b("body").on("click",c,function(f){f.preventDefault();b.jAlert(d);return false})};b.fn.closeAlert=function(c,d){b(this).jAlert().closeAlert(c,d)};var a;b(window).resize(function(){window.clearTimeout(a);a=window.setTimeout(function(){b(".jAlert:visible").each(function(){b(this).jAlert().centerAlert()})},200)});b.fn.jAlert.mediaLoaded=function(f){var e=f.parents(".ja_media_wrap"),c=e.find(".ja_video"),g=f.parents(".jAlert:first"),d=g.jAlert();e.find(".ja_loader").remove();if(c.length>0){c.fadeIn("fast")}else{f.fadeIn("fast")}if(typeof d.iframeHeight!=="undefined"&&d.iframeHeight){f.css("display","block");f.height(d.iframeHeight)}d.centerAlert()}})(jQuery); \ No newline at end of file From 9dfbf2468829a803b77a43dbc604c346ba48df2d Mon Sep 17 00:00:00 2001 From: Cristian Gabriel Danasel Date: Tue, 7 Nov 2017 20:28:55 +0000 Subject: [PATCH 06/17] Set one parameter for autoclose and remove closeTime --- src/jAlert.js | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/jAlert.js b/src/jAlert.js index a3f100e..886e7f3 100644 --- a/src/jAlert.js +++ b/src/jAlert.js @@ -710,8 +710,7 @@ /* Set Auto usage $.jAlert({ - autoClose : true, - closeTime : 4500 + autoClose : 3500, }); */ if(alert.autoClose) @@ -724,7 +723,7 @@ currentAlert.closeAlert(); } - }, alert.closeTime); + }, alert.autoClose); } alert.instance.bind("DOMSubtreeModified", function(){ alert.centerAlert(); @@ -797,8 +796,7 @@ '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 - 'autoClose' : false, // Set default autoClose - 'closeTime' : 3000, // Set 3 sec on autoclose + '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 From 8701c2b641f613de1d38f1a3508014c6ccf9c0b5 Mon Sep 17 00:00:00 2001 From: Cristian Gabriel Danasel Date: Tue, 7 Nov 2017 20:29:15 +0000 Subject: [PATCH 07/17] Add autoClose on testing --- src/test.html | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/test.html b/src/test.html index 05b4912..c7caeb4 100644 --- a/src/test.html +++ b/src/test.html @@ -90,6 +90,8 @@ Open then close after 2 seconds $.jAlert('current').closeAlert() after 2 seconds buttons with callbacks + +
From f31ed68e83ea52f35141e610b34b45731e442a04 Mon Sep 17 00:00:00 2001 From: Cristian Gabriel Danasel Date: Tue, 7 Nov 2017 20:30:51 +0000 Subject: [PATCH 08/17] Update jAlert Minify --- dist/jAlert.min.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dist/jAlert.min.js b/dist/jAlert.min.js index 8ca0d90..bff527a 100644 --- a/dist/jAlert.min.js +++ b/dist/jAlert.min.js @@ -1 +1 @@ -(function(b){if(!Date.now){Date.now=function(){return +new Date()}}b.fn.jAlert=function(q){b("body").focus();b("body").blur();var k=["default","green","dark_green","red","dark_red","black","brown","gray","dark_gray","blue","dark_blue","yellow"],p=["xsm","sm","md","lg","xlg","full","auto"],h={xsmall:"xsm",small:"sm",medium:"md",large:"lg",xlarge:"xlg"},d=["white","black"],n=[],c=["animated"],o=[];if(this.length>1){this.each(function(){b.fn.jAlert(q)});return this}if(typeof b(this)[0]!="undefined"){if(b(this)[0]["jAlert"]!="undefined"){return b(this)[0]["jAlert"]}}b.each(b.fn.jAlert.defaults,function(s,t){var r=s.toLowerCase();if(typeof q[r]!=="undefined"){q[s]=q[r]}});q=b.extend({},b.fn.jAlert.defaults,q);if(!q.id){var g=Date.now().toString()+Math.floor(Math.random()*100000);var j="ja_"+g}else{var j=q.id}var i={set:function(r,s){i[r]=s;return i},__set:function(r,s){return i.set(r,s)},get:function(r){return i[r]},__get:function(r){return i.get(r)},centerAlert:function(){var r=b(window).height(),u=i.instance.height(),t=r-u;var s=t/2;s=s>200?s-100:s;s=s<=0?0:s;s=s-1;i.instance.css("margin-top",s+"px");i.instance.css("margin-bottom","0px");b("body").css("overflow","hidden");if(t>5){i.instance.parents(".ja_wrap").css("position","fixed")}else{i.instance.parents(".ja_wrap").css("position","absolute");b("html, body").animate({scrollTop:top-50},200)}return i},animateAlert:function(r){if(r=="hide"){if(i.instance.jAlert().blurBackground){b("body").removeClass("ja_blur")}i.instance.removeClass(i.showAnimation).addClass(i.hideAnimation)}else{if(i.instance.jAlert().blurBackground){b("body").addClass("ja_blur")}i.centerAlert();i.instance.addClass(i.showAnimation).removeClass(i.hideAnimation).show()}return i},closeAlert:function(r,s){if(r!=false){r=true}if(i.instance){i.instance.unbind("DOMSubtreeModified");i.animateAlert("hide");window.setTimeout(function(){var t=i.instance.parents(".ja_wrap");if(r){t.remove()}else{t.hide()}if(typeof s=="function"){s(i.instance)}else{if(typeof i.onClose=="function"){i.onClose(i.instance)}}if(b(".jAlert:visible").length>0){b(".jAlert:visible:last").jAlert().centerAlert()}else{b("body").css("overflow","auto")}},i.animationTimeout)}return i},showAlert:function(t,v,s,r){if(t!=false){t=true}if(v!==false){v=true}if(t){b(".jAlert:visible").jAlert().closeAlert(v)}var u=i.instance.parents(".ja_wrap");b("body").append(u);i.animateAlert("show");if(typeof r=="function"){i.onClose=r}window.setTimeout(function(){if(typeof s=="function"){s(i.instance)}},i.animationTimeout);return i}};b.each(q,function(r,s){i.set(r,s)});i.set("id",j);if(i.content&&i.content.indexOf("#")===0){if(b(i.content).length>0){i.content=b(i.content).html()}}if(i.video&&i.video.indexOf("youtube.com/watch?v=")>-1&&i.video.indexOf("embed")===-1){i.video=i.video.replace("watch?v=","embed/")}if(i.type=="confirm"){if(!i.content){i.content=i.confirmQuestion}i.btns=[{text:i.confirmBtnText,theme:"green","class":"confirmBtn",closeAlert:true,onClick:i.onConfirm},{text:i.denyBtnText,theme:"red","class":"denyBtn",closeAlert:true,onClick:i.onDeny}];i.autofocus=i.confirmAutofocus}if(i.color){i.theme=i.color}if(b.inArray(i.theme,k)==-1){console.log("jAlert Config Error: Invalid theme selection.");return false}c.push("ja_"+i.theme);if(i["class"]){c.push(i["class"])}if(i.classes){c.push(i.classes)}if(i.fullscreen){c.push("ja_fullscreen")}if(i.noPadContent){c.push("ja_no_pad")}if(!i.title){c.push("ja_noTitle")}if(i.width){i.size=i.width}if(i.size&&((typeof i.size=="object"&&(typeof i.size.width=="undefined"||typeof i.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}else{if(!i.size){c.push("ja_sm")}else{if(typeof i.size=="object"){n.push("width: "+i.size.width+";");n.push("height: "+i.size.height+";");c.push("ja_setheight")}else{if(typeof h[i.size]!=="undefined"){i.size=h[i.size]}if(b.inArray(i.size,p)>-1){c.push("ja_"+i.size)}else{n.push("width: "+i.size+";")}}}}if(b.inArray(i.backgroundColor,d)==-1){console.log("jAlert Config Error: Invalid background color selection.");return false}o.push("ja_wrap_"+i.backgroundColor);i.onOpen=[i.onOpen];var e="onload='$.fn.jAlert.mediaLoaded($(this))'",l="
Loading...
";if(i.picture){i.image=i.picture}if(i.image){i.content="
"+l+"
";i.onOpen.unshift(function(s){var r=document.createElement("iframe");r.src=s.jAlert().video;if(r.addEventListener){r.addEventListener("load",function(){b.fn.jAlert.mediaLoaded(b(this))},true)}else{if(r.attachEvent){r.attachEvent("onload",function(){b.fn.jAlert.mediaLoaded(b(this))})}else{r.onload=function(){b.fn.jAlert.mediaLoaded(b(this))}}}s.find(".ja_video").append(r)})}else{if(i.iframe){if(!i.iframeHeight){i.iframeHeight=b(window).height()+"px"}i.content="
"+l+"
";i.onOpen.unshift(function(s){var r=document.createElement("iframe");r.src=s.jAlert().iframe;r.className="ja_iframe";if(r.addEventListener){r.addEventListener("load",function(){b.fn.jAlert.mediaLoaded(b(this))},true)}else{if(r.attachEvent){r.attachEvent("onload",function(){b.fn.jAlert.mediaLoaded(b(this))})}else{r.onload=function(){b.fn.jAlert.mediaLoaded(b(this))}}}s.find(".ja_media_wrap").append(r)})}else{if(i.ajax){i.content="
"+l+"
";onAjaxCallbacks=i.onOpen;i.onOpen=[function(r){b.ajax(r.jAlert().ajax,{async:true,complete:function(s,t){r.find(".ja_media_wrap").replaceWith(s.responseText);b.each(onAjaxCallbacks,function(u,v){v(r)})},error:function(s,u,t){i.onAjaxFail(r,"Error getting content: Code: "+s.status+" : Msg: "+s.statusText)}})}]}}}}var f=function(r){if(typeof r.href=="undefined"){r.href=""}if(typeof r["class"]=="undefined"){r["class"]=""}if(typeof r.theme=="undefined"){r["class"]+=" ja_btn_default"}else{r["class"]+=" ja_btn_"+r.theme}if(typeof r.text=="undefined"){r.text=""}if(typeof r.id=="undefined"){var s=Date.now().toString()+Math.floor(Math.random()*100000);r.id="ja_btn_"+s}if(typeof r.target=="undefined"){r.target="_self"}if(typeof r.closeAlert=="undefined"){r.closeAlert=true}b("body").off("click","#"+r.id);b("body").on("click","#"+r.id,function(v){var t=b(this);if(r.closeAlert){t.parents(".jAlert").jAlert().closeAlert()}var u=true;if(typeof r.onClick=="function"){u=r.onClick(v,t)}if(!u||r.closeAlert){v.preventDefault();return false}return u});return""+r.text+" "};var m=function(t){var s="";s+='
';if(i.closeBtn){s+="
×
"}if(i.title){s+="
"+i.title+"
"}s+='
'+t;if(i.btns){s+='
0&&c.jAlert().closeOnClick){if(!b(d).is(".jAlert *")){c.jAlert().closeAlert()}}};b.fn.jAlert.onEscKeyDown=function(d){if(d.keyCode===27){var c=b(".jAlert:visible:last");if(c.length>0&&c.jAlert().closeOnEsc){c.jAlert().closeAlert()}}};b.fn.attachjAlert=function(c){c.preventDefault();b.jAlert(b(this).data());return false};b.jAlert=function(d){if(d=="current"){var c=b(".jAlert:visible:last");if(c.length>0){return c.jAlert()}return false}if(d=="attach"){b("[data-jAlert]").off("click",b.fn.attachjAlert);b("[data-jAlert]").on("click",b.fn.attachjAlert);b("[data-jalert]").off("click",b.fn.attachjAlert);b("[data-jalert]").on("click",b.fn.attachjAlert);return false}return b.fn.jAlert(d)};b.fn.alertOnClick=function(c){b(this).on("click",function(d){d.preventDefault();b.jAlert(c);return false})};b.alertOnClick=function(c,d){b("body").on("click",c,function(f){f.preventDefault();b.jAlert(d);return false})};b.fn.closeAlert=function(c,d){b(this).jAlert().closeAlert(c,d)};var a;b(window).resize(function(){window.clearTimeout(a);a=window.setTimeout(function(){b(".jAlert:visible").each(function(){b(this).jAlert().centerAlert()})},200)});b.fn.jAlert.mediaLoaded=function(f){var e=f.parents(".ja_media_wrap"),c=e.find(".ja_video"),g=f.parents(".jAlert:first"),d=g.jAlert();e.find(".ja_loader").remove();if(c.length>0){c.fadeIn("fast")}else{f.fadeIn("fast")}if(typeof d.iframeHeight!=="undefined"&&d.iframeHeight){f.css("display","block");f.height(d.iframeHeight)}d.centerAlert()}})(jQuery); \ No newline at end of file +(function(b){if(!Date.now){Date.now=function(){return +new Date()}}b.fn.jAlert=function(q){b("body").focus();b("body").blur();var k=["default","green","dark_green","red","dark_red","black","brown","gray","dark_gray","blue","dark_blue","yellow"],p=["xsm","sm","md","lg","xlg","full","auto"],h={xsmall:"xsm",small:"sm",medium:"md",large:"lg",xlarge:"xlg"},d=["white","black"],n=[],c=["animated"],o=[];if(this.length>1){this.each(function(){b.fn.jAlert(q)});return this}if(typeof b(this)[0]!="undefined"){if(b(this)[0]["jAlert"]!="undefined"){return b(this)[0]["jAlert"]}}b.each(b.fn.jAlert.defaults,function(s,t){var r=s.toLowerCase();if(typeof q[r]!=="undefined"){q[s]=q[r]}});q=b.extend({},b.fn.jAlert.defaults,q);if(!q.id){var g=Date.now().toString()+Math.floor(Math.random()*100000);var j="ja_"+g}else{var j=q.id}var i={set:function(r,s){i[r]=s;return i},__set:function(r,s){return i.set(r,s)},get:function(r){return i[r]},__get:function(r){return i.get(r)},centerAlert:function(){var r=b(window).height(),u=i.instance.height(),t=r-u;var s=t/2;s=s>200?s-100:s;s=s<=0?0:s;s=s-1;i.instance.css("margin-top",s+"px");i.instance.css("margin-bottom","0px");b("body").css("overflow","hidden");if(t>5){i.instance.parents(".ja_wrap").css("position","fixed")}else{i.instance.parents(".ja_wrap").css("position","absolute");b("html, body").animate({scrollTop:top-50},200)}return i},animateAlert:function(r){if(r=="hide"){if(i.instance.jAlert().blurBackground){b("body").removeClass("ja_blur")}i.instance.removeClass(i.showAnimation).addClass(i.hideAnimation)}else{if(i.instance.jAlert().blurBackground){b("body").addClass("ja_blur")}i.centerAlert();i.instance.addClass(i.showAnimation).removeClass(i.hideAnimation).show()}return i},closeAlert:function(r,s){if(r!=false){r=true}if(i.instance){i.instance.unbind("DOMSubtreeModified");i.animateAlert("hide");window.setTimeout(function(){var t=i.instance.parents(".ja_wrap");if(r){t.remove()}else{t.hide()}if(typeof s=="function"){s(i.instance)}else{if(typeof i.onClose=="function"){i.onClose(i.instance)}}if(b(".jAlert:visible").length>0){b(".jAlert:visible:last").jAlert().centerAlert()}else{b("body").css("overflow","auto")}},i.animationTimeout)}return i},showAlert:function(t,v,s,r){if(t!=false){t=true}if(v!==false){v=true}if(t){b(".jAlert:visible").jAlert().closeAlert(v)}var u=i.instance.parents(".ja_wrap");b("body").append(u);i.animateAlert("show");if(typeof r=="function"){i.onClose=r}window.setTimeout(function(){if(typeof s=="function"){s(i.instance)}},i.animationTimeout);return i}};b.each(q,function(r,s){i.set(r,s)});i.set("id",j);if(i.content&&i.content.indexOf("#")===0){if(b(i.content).length>0){i.content=b(i.content).html()}}if(i.video&&i.video.indexOf("youtube.com/watch?v=")>-1&&i.video.indexOf("embed")===-1){i.video=i.video.replace("watch?v=","embed/")}if(i.type=="confirm"){if(!i.content){i.content=i.confirmQuestion}i.btns=[{text:i.confirmBtnText,theme:"green","class":"confirmBtn",closeAlert:true,onClick:i.onConfirm},{text:i.denyBtnText,theme:"red","class":"denyBtn",closeAlert:true,onClick:i.onDeny}];i.autofocus=i.confirmAutofocus}if(i.color){i.theme=i.color}if(b.inArray(i.theme,k)==-1){console.log("jAlert Config Error: Invalid theme selection.");return false}c.push("ja_"+i.theme);if(i["class"]){c.push(i["class"])}if(i.classes){c.push(i.classes)}if(i.fullscreen){c.push("ja_fullscreen")}if(i.noPadContent){c.push("ja_no_pad")}if(!i.title){c.push("ja_noTitle")}if(i.width){i.size=i.width}if(i.size&&((typeof i.size=="object"&&(typeof i.size.width=="undefined"||typeof i.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}else{if(!i.size){c.push("ja_sm")}else{if(typeof i.size=="object"){n.push("width: "+i.size.width+";");n.push("height: "+i.size.height+";");c.push("ja_setheight")}else{if(typeof h[i.size]!=="undefined"){i.size=h[i.size]}if(b.inArray(i.size,p)>-1){c.push("ja_"+i.size)}else{n.push("width: "+i.size+";")}}}}if(b.inArray(i.backgroundColor,d)==-1){console.log("jAlert Config Error: Invalid background color selection.");return false}o.push("ja_wrap_"+i.backgroundColor);i.onOpen=[i.onOpen];var e="onload='$.fn.jAlert.mediaLoaded($(this))'",l="
Loading...
";if(i.picture){i.image=i.picture}if(i.image){i.content="
"+l+"
";i.onOpen.unshift(function(s){var r=document.createElement("iframe");r.src=s.jAlert().video;if(r.addEventListener){r.addEventListener("load",function(){b.fn.jAlert.mediaLoaded(b(this))},true)}else{if(r.attachEvent){r.attachEvent("onload",function(){b.fn.jAlert.mediaLoaded(b(this))})}else{r.onload=function(){b.fn.jAlert.mediaLoaded(b(this))}}}s.find(".ja_video").append(r)})}else{if(i.iframe){if(!i.iframeHeight){i.iframeHeight=b(window).height()+"px"}i.content="
"+l+"
";i.onOpen.unshift(function(s){var r=document.createElement("iframe");r.src=s.jAlert().iframe;r.className="ja_iframe";if(r.addEventListener){r.addEventListener("load",function(){b.fn.jAlert.mediaLoaded(b(this))},true)}else{if(r.attachEvent){r.attachEvent("onload",function(){b.fn.jAlert.mediaLoaded(b(this))})}else{r.onload=function(){b.fn.jAlert.mediaLoaded(b(this))}}}s.find(".ja_media_wrap").append(r)})}else{if(i.ajax){i.content="
"+l+"
";onAjaxCallbacks=i.onOpen;i.onOpen=[function(r){b.ajax(r.jAlert().ajax,{async:true,complete:function(s,t){r.find(".ja_media_wrap").replaceWith(s.responseText);b.each(onAjaxCallbacks,function(u,v){v(r)})},error:function(s,u,t){i.onAjaxFail(r,"Error getting content: Code: "+s.status+" : Msg: "+s.statusText)}})}]}}}}var f=function(r){if(typeof r.href=="undefined"){r.href=""}if(typeof r["class"]=="undefined"){r["class"]=""}if(typeof r.theme=="undefined"){r["class"]+=" ja_btn_default"}else{r["class"]+=" ja_btn_"+r.theme}if(typeof r.text=="undefined"){r.text=""}if(typeof r.id=="undefined"){var s=Date.now().toString()+Math.floor(Math.random()*100000);r.id="ja_btn_"+s}if(typeof r.target=="undefined"){r.target="_self"}if(typeof r.closeAlert=="undefined"){r.closeAlert=true}b("body").off("click","#"+r.id);b("body").on("click","#"+r.id,function(v){var t=b(this);if(r.closeAlert){t.parents(".jAlert").jAlert().closeAlert()}var u=true;if(typeof r.onClick=="function"){u=r.onClick(v,t)}if(!u||r.closeAlert){v.preventDefault();return false}return u});return""+r.text+" "};var m=function(t){var s="";s+='
';if(i.closeBtn){s+="
×
"}if(i.title){s+="
"+i.title+"
"}s+='
'+t;if(i.btns){s+='
0&&c.jAlert().closeOnClick){if(!b(d).is(".jAlert *")){c.jAlert().closeAlert()}}};b.fn.jAlert.onEscKeyDown=function(d){if(d.keyCode===27){var c=b(".jAlert:visible:last");if(c.length>0&&c.jAlert().closeOnEsc){c.jAlert().closeAlert()}}};b.fn.attachjAlert=function(c){c.preventDefault();b.jAlert(b(this).data());return false};b.jAlert=function(d){if(d=="current"){var c=b(".jAlert:visible:last");if(c.length>0){return c.jAlert()}return false}if(d=="attach"){b("[data-jAlert]").off("click",b.fn.attachjAlert);b("[data-jAlert]").on("click",b.fn.attachjAlert);b("[data-jalert]").off("click",b.fn.attachjAlert);b("[data-jalert]").on("click",b.fn.attachjAlert);return false}return b.fn.jAlert(d)};b.fn.alertOnClick=function(c){b(this).on("click",function(d){d.preventDefault();b.jAlert(c);return false})};b.alertOnClick=function(c,d){b("body").on("click",c,function(f){f.preventDefault();b.jAlert(d);return false})};b.fn.closeAlert=function(c,d){b(this).jAlert().closeAlert(c,d)};var a;b(window).resize(function(){window.clearTimeout(a);a=window.setTimeout(function(){b(".jAlert:visible").each(function(){b(this).jAlert().centerAlert()})},200)});b.fn.jAlert.mediaLoaded=function(f){var e=f.parents(".ja_media_wrap"),c=e.find(".ja_video"),g=f.parents(".jAlert:first"),d=g.jAlert();e.find(".ja_loader").remove();if(c.length>0){c.fadeIn("fast")}else{f.fadeIn("fast")}if(typeof d.iframeHeight!=="undefined"&&d.iframeHeight){f.css("display","block");f.height(d.iframeHeight)}d.centerAlert()}})(jQuery); \ No newline at end of file From ddb3c41dbe56e0e9339ea3060394a8441827881b Mon Sep 17 00:00:00 2001 From: Cristian Gabriel Danasel Date: Tue, 7 Nov 2017 20:58:00 +0000 Subject: [PATCH 09/17] Fix misspelled on autoClose, write the button as tag --- src/test.html | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/test.html b/src/test.html index c7caeb4..467e084 100644 --- a/src/test.html +++ b/src/test.html @@ -90,8 +90,7 @@ Open then close after 2 seconds $.jAlert('current').closeAlert() after 2 seconds buttons with callbacks - - + Auto Close on autoClose method