%PDF- %PDF-
Direktori : /home1/dimen328/libertysa.com.br/admin/media/jAlert-master/src/ |
Current File : //home1/dimen328/libertysa.com.br/admin/media/jAlert-master/src/jAlert-v3.min.js |
/* * * jAlert v.3 Made with love by Versatility Werks (http://flwebsites.biz) MIT Licensed * * */ !function(o){o.fn.jAlert=function(t){var n=this,e=["default","green","red","black","blue","yellow"],i=["xsm","sm","md","lg","xlg","full"],s=["white","black"],a=[],r=["animated"],c=[];if(n.length>1)return n.each(function(){o(this).jAlert(n.options)}),this;if(n.options=o.extend({},o.fn.jAlert.defaults,t),n.instance=!1,"confirm"==n.options.type&&(n.options.content||(n.options.content=n.options.confirmQuestion),n.options.btns=[{text:n.options.confirmBtnText,theme:"green","class":"confirmBtn",closeAlert:!0,onClick:n.options.onConfirm},{text:n.options.denyBtnText,theme:"red","class":"denyBtn",closeAlert:!0,onClick:n.options.onDeny}],n.options.autofocus=n.options.confirmAutofocus),-1==o.inArray(n.options.theme,e))return console.log("jAlert Config Error: Invalid theme selection."),!1;if(r.push("ja_"+n.options.theme),!n.options.id){var l=Date.now().toString()+Math.floor(1e5*Math.random());n.options.id="ja_"+l}if(n.options["class"]&&r.push(n.options["class"]),n.options.classes&&r.push(n.options.classes),n.options.title||r.push("ja_noTitle"),n.options.size&&("string"==typeof n.options.size&&-1==o.inArray(n.options.size,i)||"object"==typeof n.options.size&&("undefined"==typeof n.options.size.width||"undefined"==typeof n.options.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(n.options.size?"object"==typeof n.options.size?(a.push("width: "+n.options.size.width+";"),a.push("height: "+n.options.size.height+";")):r.push("ja_"+n.options.size):r.push("ja_sm"),-1==o.inArray(n.options.backgroundColor,s))return console.log("jAlert Config Error: Invalid background color selection."),!1;c.push("ja_wrap_"+n.options.backgroundColor),("object"==typeof n.options.btns||"array"==typeof n.options.btns||n.options.autofocus)&&(n.options.closeOnClick=!1),n.options.onOpen=[n.options.onOpen];var d="onload='$.fn.jAlert.mediaLoaded($(this))'",p="<div class='ja_loader'>Loading...</div>";n.options.image?(n.options.content="<div class='ja_media_wrap'>"+p+"<img src='"+n.options.image+"' class='ja_img' "+d+"'",n.options.imageWidth&&(n.options.content+=" style='width: "+n.options.imageWidth+"'"),n.options.content+="></div>"):n.options.video?(n.options.content="<div class='ja_media_wrap'>"+p+"<div class='ja_video'></div></div>",n.options.onOpen.unshift(function(t){var n=document.createElement("iframe");n.src=t.options.video,n.addEventListener?n.addEventListener("load",function(){o.fn.jAlert.mediaLoaded(o(this))},!0):n.attachEvent?n.attachEvent("onload",function(){o.fn.jAlert.mediaLoaded(o(this))}):n.onload=function(){o.fn.jAlert.mediaLoaded(o(this))},t.find(".ja_video").append(n)})):n.options.iframe?(n.options.iframeHeight||(n.options.iframeHeight=.9*o(window).height()+"px"),n.options.content="<div class='ja_media_wrap'>"+p+"</div>",n.options.onOpen.unshift(function(t){var n=document.createElement("iframe");n.src=t.options.iframe,n.height=t.options.iframeHeight,n.className="ja_iframe",n.addEventListener?n.addEventListener("load",function(){o.fn.jAlert.mediaLoaded(o(this))},!0):n.attachEvent?n.attachEvent("onload",function(){o.fn.jAlert.mediaLoaded(o(this))}):n.onload=function(){o.fn.jAlert.mediaLoaded(o(this))},t.find(".ja_media_wrap").append(n)})):n.options.ajax&&(n.options.content="<div class='ja_media_wrap'>"+p+"</div>",onAjaxCallbacks=n.options.onOpen,n.options.onOpen=[function(t){o.ajax(t.options.ajax,{async:!0,complete:function(n){t.find(".ja_media_wrap").replaceWith(n.responseText),o.each(onAjaxCallbacks,function(o,n){n(t)})},error:function(o){t.options.onAjaxFail(t,"Error getting content: Code: "+o.status+" : Msg: "+o.statusText)}})}]),n.centerAlert=function(){var t=o(window).height(),e=n.instance.height(),i=t-e,s=i/2;s>200&&(s-=100),0>=s&&(s=0),n.instance.css("margin-top",s+"px"),o("body").css("overflow","hidden"),i>5?n.instance.parents(".ja_wrap").css("position","fixed"):(n.instance.parents(".ja_wrap").css("position","absolute"),o("html, body").animate({scrollTop:s-50},200))};var f=function(o,t){"hide"==o?t.removeClass(n.options.showAnimation).addClass(n.options.hideAnimation):(t.centerAlert(),t.addClass(n.options.showAnimation).removeClass(n.options.hideAnimation).show())},u=function(t){if("undefined"==typeof t.href&&(t.href=""),"undefined"==typeof t["class"]&&(t["class"]=""),t["class"]+="undefined"==typeof t.theme?" ja_btn_default":" ja_btn_"+t.theme,"undefined"==typeof t.text&&(t.text=""),"undefined"==typeof t.id){var n=Date.now().toString()+Math.floor(1e5*Math.random());t.id="ja_btn_"+n}return"undefined"==typeof t.target&&(t.target="_self"),"undefined"==typeof t.closeAlert&&(t.closeAlert=!0),o("body").on("click","#"+t.id,function(n){var e=o(this);t.closeAlert&&e.parents(".jAlert").closeAlert();var i=!0;return"function"==typeof t.onClick&&(i=t.onClick(n,e)),!i||t.closeAlert?(n.preventDefault(),!1):i}),"<a href='"+t.href+"' id='"+t.id+"' target='"+t.target+"' class='ja_btn "+t["class"]+"'>"+t.text+"</a> "};n.closeAlert=function(t,e){var i=o(this);return 0!=t&&(t=!0),i.length&&(i.unbind("DOMSubtreeModified"),f("hide",i),window.setTimeout(function(){var s=i.parents(".ja_wrap");t?s.remove():s.hide(),"function"==typeof e?e(i):"function"==typeof n.options.onClose&&n.options.onClose(i),o(".jAlert").length>0?o(".jAlert:last").centerAlert():o("body").css("overflow","auto")},n.options.animationTimeout)),this},n.showAlert=function(t,e,i,s){var a=o(this);0!=t&&(t=!0),e!==!1&&(e=!0),t&&o(".jAlert:visible").closeAlert(e);var r=a.parents(".ja_wrap");o("body").append(r),f("show",a),"function"==typeof s&&(n.options.onClose=s),window.setTimeout(function(){"function"==typeof i&&i(a)},n.options.animationTimeout)};var h=function(t){var e="";e+='<div class="ja_wrap '+c.join(" ")+'"><div class="jAlert '+r.join(" ")+'" style="'+a.join(" ")+'" id="'+n.options.id+'"><div>',n.options.closeBtn&&(e+="<div class='closejAlert ja_close",n.options.closeBtnAlt&&(e+=" ja_close_alt"),e+="'>X</div>"),n.options.title&&(e+="<div class='ja_title'><div>"+n.options.title+"</div></div>"),e+='<div class="ja_body">'+t,n.options.btns&&(e+='<div class="ja_btn_wrap ',n.options.btnBackground&&(e+="optBack"),e+='">'),"object"==typeof n.options.btns[0]?o.each(n.options.btns,function(o,t){"object"==typeof t&&(e+=u(t))}):"object"==typeof n.options.btns?e+=u(n.options.btns):n.options.btns&&console.log("jAlert Config Error: Incorrect value for btns (must be object or array of objects): "+n.options.btns),n.options.btns&&(e+="</div>"),e+="</div></div></div></div>";var i=o(e);return n.options.replaceOtherAlerts&&o(".jAlert:visible").closeAlert(),o("body").append(i),n.instance=o("#"+n.options.id),f("show",n.instance),n.options.closeBtn&&n.instance.on("click",".closejAlert",function(t){return t.preventDefault(),o(this).parents(".jAlert").closeAlert(),!1}),n.options.closeOnClick&&(o(document).off("mouseup",o.fn.jAlert.onMouseUp),o(document).on("mouseup",o.fn.jAlert.onMouseUp)),n.options.closeOnEsc&&(o(document).off("keydown",o.fn.jAlert.onEscKeyDown),o(document).on("keydown",o.fn.jAlert.onEscKeyDown)),n.options.onOpen&&o.each(n.options.onOpen,function(o,t){t(n.instance)}),n.options.autofocus&&n.instance.find(n.options.autofocus).focus(),n.instance.bind("DOMSubtreeModified",function(){n.instance.centerAlert()}),n.instance};return n.initialize=function(){return n.options.content||n.options.image||n.options.video||n.options.iframe||n.options.ajax?(n.options.content||(n.options.content=""),h(n.options.content)):(console.log("jAlert potential error: No content defined"),h(""))},n.initialize(),n},o.fn.jAlert.defaults={title:!1,content:!1,image:!1,imageWidth:"auto",video:!1,ajax:!1,onAjaxFail:function(o,t){o.closeAlert(),errorAlert(t)},iframe:!1,iframeHeight:!1,"class":"",classes:"",id:!1,showAnimation:"fadeInUp",hideAnimation:"fadeOutDown",animationTimeout:600,theme:"default",backgroundColor:"black",size:!1,replaceOtherAlerts:!1,closeOnClick:!1,closeOnEsc:!0,closeBtn:!0,closeBtnAlt:!1,btns:!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(o){return o.preventDefault(),console.log("confirmed"),!1},onDeny:function(o){return o.preventDefault(),!1}},o.fn.jAlert.onMouseUp=function(){var t=o(".jAlert:visible:last");t.options.closeOnClick&&t.closeAlert()},o.fn.jAlert.onEscKeyDown=function(t){if(27===t.keyCode){var n=o(".jAlert:visible:last");n.options.closeOnEsc&&n.closeAlert()}},o.jAlert=function(t){return o.fn.jAlert(t)},o.fn.alertOnClick=function(t){o(this).on("click",function(n){return n.preventDefault(),o.jAlert(t),!1})},o.alertOnClick=function(t,n){o("body").on("click",t,function(t){return t.preventDefault(),o.jAlert(n),!1})};var t;o(window).resize(function(){window.clearTimeout(t),t=window.setTimeout(function(){o(".jAlert:visible").each(function(){o(this).centerAlert()})},200)}),o.fn.jAlert.mediaLoaded=function(o){var t=o.parents(".ja_media_wrap"),n=t.find(".ja_video");t.find(".ja_loader").remove(),n.length>0?n.fadeIn("fast"):o.fadeIn("fast"),o.parents(".jAlert").centerAlert()}}(jQuery);