/** * bootbox.js [v4.2.0] * * http://bootboxjs.com/license.txt */ (function(a,b){if(typeof define==="function"&&define.amd){define(["jquery"],b)}else{if(typeof exports==="object"){module.exports=b(require("jquery"))}else{a.bootbox=b(a.jQuery)}}}(this,function init(i,c){var m={dialog:"",header:"",footer:"",closeButton:"",form:"
",inputs:{text:"",textarea:"",email:"",select:"",checkbox:"
",date:"",time:"",number:"",password:""}};var f={locale:"en",backdrop:true,animate:true,className:null,closeButton:true,show:true,container:"body"};var h={};function p(r){var q=a[f.locale];return q?q[r]:a.en[r]}function d(s,r,t){s.stopPropagation();s.preventDefault();var q=i.isFunction(t)&&t(s)===false;if(!q){r.modal("hide")}}function j(s){var q,r=0;for(q in s){r++}return r}function k(s,r){var q=0;i.each(s,function(t,u){r(t,u,q++)})}function b(q){var s;var r;if(typeof q!=="object"){throw new Error("Please supply an object of options")}if(!q.message){throw new Error("Please specify a message")}q=i.extend({},f,q);if(!q.buttons){q.buttons={}}q.backdrop=q.backdrop?"static":false;s=q.buttons;r=j(s);k(s,function(v,u,t){if(i.isFunction(u)){u=s[v]={callback:u}}if(i.type(u)!=="object"){throw new Error("button with key "+v+" must be an object")}if(!u.label){u.label=v}if(!u.className){if(r<=2&&t===r-1){u.className="btn-primary"}else{u.className="btn-default"}}});return q}function g(r,s){var t=r.length;var q={};if(t<1||t>2){throw new Error("Invalid argument length")}if(t===2||typeof r[0]==="string"){q[s[0]]=r[0];q[s[1]]=r[1]}else{q=r[0]}return q}function l(s,q,r){return i.extend(true,{},s,g(q,r))}function e(t,u,s,r){var q={className:"bootbox-"+t,buttons:o.apply(null,u)};return n(l(q,r,s),u)}function o(){var u={};for(var s=0,q=arguments.length;s").attr("label",C.group)}D=r[C.group]}D.append("")});k(r,function(B,C){y.append(C)});y.val(A.value);break;case"checkbox":var z=i.isArray(A.value)?A.value:[A.value];w=A.inputOptions||[];if(!w.length){throw new Error("prompt with checkbox requires options")}if(!w[0].value||!w[0].text){throw new Error("given options in wrong format")}y=i("
");k(w,function(B,C){var D=i(m.inputs[A.inputType]);D.find("input").attr("value",C.value);D.find("label").append(C.text);k(z,function(E,F){if(F===C.value){D.find("input").prop("checked",true)}});y.append(D)});break}if(A.placeholder){y.attr("placeholder",A.placeholder)}if(A.pattern){y.attr("pattern",A.pattern)}q.append(y);q.on("submit",function(B){B.preventDefault();x.find(".btn-primary").click()});x=h.dialog(A);x.off("shown.bs.modal");x.on("shown.bs.modal",function(){y.focus()});if(s===true){x.modal("show")}return x};h.dialog=function(s){s=b(s);var t=i(m.dialog);var q=t.find(".modal-body");var w=s.buttons;var u="";var v={onEscape:s.onEscape};k(w,function(y,x){u+="";v[y]=x.callback});q.find(".bootbox-body").html(s.message);if(s.animate===true){t.addClass("fade")}if(s.className){t.addClass(s.className)}if(s.title){q.before(m.header)}if(s.closeButton){var r=i(m.closeButton);if(s.title){t.find(".modal-header").prepend(r)}else{r.css("margin-top","-10px").prependTo(q)}}if(s.title){t.find(".modal-title").html(s.title)}if(u.length){q.after(m.footer);t.find(".modal-footer").html(u)}t.on("hidden.bs.modal",function(x){if(x.target===this){t.remove()}});t.on("shown.bs.modal",function(){t.find(".btn-primary:first").focus()});t.on("escape.close.bb",function(x){if(v.onEscape){d(x,t,v.onEscape)}});t.on("click",".modal-footer button",function(y){var x=i(this).data("bb-handler");d(y,t,v[x])});t.on("click",".bootbox-close-button",function(x){d(x,t,v.onEscape)});t.on("keyup",function(x){if(x.which===27){t.trigger("escape.close.bb")}});i(s.container).append(t);t.modal({backdrop:s.backdrop,keyboard:false,show:false});if(s.show){t.modal("show")}return t};h.setDefaults=function(){var q={};if(arguments.length===2){q[arguments[0]]=arguments[1]}else{q=arguments[0]}i.extend(f,q)};h.hideAll=function(){i(".bootbox").modal("hide")};var a={br:{OK:"OK",CANCEL:"Cancelar",CONFIRM:"Sim"},da:{OK:"OK",CANCEL:"Annuller",CONFIRM:"Accepter"},de:{OK:"OK",CANCEL:"Abbrechen",CONFIRM:"Akzeptieren"},en:{OK:"OK",CANCEL:"Cancel",CONFIRM:"OK"},es:{OK:"OK",CANCEL:"Cancelar",CONFIRM:"Aceptar"},fi:{OK:"OK",CANCEL:"Peruuta",CONFIRM:"OK"},fr:{OK:"OK",CANCEL:"Annuler",CONFIRM:"D'accord"},he:{OK:"אישור",CANCEL:"ביטול",CONFIRM:"אישור"},it:{OK:"OK",CANCEL:"Annulla",CONFIRM:"Conferma"},lt:{OK:"Gerai",CANCEL:"Atšaukti",CONFIRM:"Patvirtinti"},lv:{OK:"Labi",CANCEL:"Atcelt",CONFIRM:"Apstiprināt"},nl:{OK:"OK",CANCEL:"Annuleren",CONFIRM:"Accepteren"},no:{OK:"OK",CANCEL:"Avbryt",CONFIRM:"OK"},pl:{OK:"OK",CANCEL:"Anuluj",CONFIRM:"Potwierdź"},ru:{OK:"OK",CANCEL:"Отмена",CONFIRM:"Применить"},sv:{OK:"OK",CANCEL:"Avbryt",CONFIRM:"OK"},tr:{OK:"Tamam",CANCEL:"İptal",CONFIRM:"Onayla"},zh_CN:{OK:"OK",CANCEL:"取消",CONFIRM:"确认"},zh_TW:{OK:"OK",CANCEL:"取消",CONFIRM:"確認"}};h.init=function(q){return init(q||i)};return h}));