-
Notifications
You must be signed in to change notification settings - Fork 1
/
bsbox2-bundle.min.js
6 lines (6 loc) · 3.52 KB
/
bsbox2-bundle.min.js
1
2
3
4
5
6
/*
* bsbox 2.0.1.0
* required: jQuery
* Author: Cres Jie Labasano
* Email: [email protected]
*/!function(t,o){"use strict";if(!o)return console.error("jQuery is required"),0;var e={title:"Message",type:""},n={sticky:!1,timeout:5e3,type:"success",closeBtn:!0,template:"alert",message:"Bsbox Notification",closeOnClick:!0,transitionIn:"slideDown",transitionOut:"slideUp",location:"bottom left"},i=".bsbox-notif-container",s={dialog:function(t){var e="",n="";t.title&&(e='<div class="modal-header box-header box-'+t.type+'" ><button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button><h4 class="modal-title">'+t.title+"</h4></div>"),t.message&&(n='<div class="modal-body box-'+(t.type&&!t.title?t.type:"")+'">'+t.message+"</div>");var i=o('<div id="bsboxDialog" class="modal fade"><div class="modal-dialog"><div class="modal-content">'+e+n+"</div></div></div>");if(t.buttons){i.find(".modal-content").append('<div class="modal-footer"></div>');for(var s=0;s<t.buttons.length;s++){var a=t.buttons[s],r=o('<button class="btn"></button>').html(a.text).on(a.on);a.class&&r.addClass(a.class),a.attr&&r.attr(a.attr),i.find(".modal-footer").append(r)}}return i},notication:{alert:function(t){var e=o('<div class="alert alert-'+t.type+'" style="display:none"></div>').html(t.message);if(t.closeBtn){var n=o('<button class="close">×</button>');e.prepend(n)}return e}}},a=function(t){var e=function(t){t&&(t="."+t.replace(/ /gi,"."));var e=i+t;if(o(e).length)return o(e);var n=o('<div class="'+e.replace(/\./gi," ")+'"></div>');return o("body").append(n),n}(t.location),n=s.notication[t.template](t);return t.sticky||setTimeout(a.close,t.timeout,n,t),t.closeOnClick&&n.click(function(){a.close(o(this),t)}),e.append(n),n.data("bsboxNotif.options",t)[t.transitionIn]()};a.close=function(t,o){t[o.transitionOut]({complete:function(){this.remove()}})},t.bsbox={dialog:function(t){t=t.constructor==Object?o.extend({},e,t):o.extend({},e,{message:t});var n=s.dialog(t).on("hidden.bs.modal",function(){this.remove()});return o("body").append(n),n.modal("show")},notif:function(t){return t=t.constructor==Object?o.extend({},n,t):o.extend({},n,{message:t}),a(t)},version:"2.0.1.0"},o.extend(bsbox.notif,{close:function(t){a.close(t,t.data("bsboxNotif.options"))},addTemplate:function(t,o){return s.notification[t]=o,this}})}(window,jQuery),function(t,o,e){"use strict";if(void 0===o&&void 0===e)return console.error("jQuery and bsbox are required"),0;e.alert=function(t,n){var i={title:"",buttons:[{text:"OK",attr:{"data-dismiss":"modal"},class:"btn-primary"}]};t.constructor==String?i.message=t:i=o.extend(i,t);var s=e.dialog(i);return s.on("hidden.bs.modal",n),s},e.confirm=function(t,n){var i={message:"",confirmText:"Confirm text",buttons:[{text:t&&t.confirmText?t.confirmText:"Ok",attr:{"data-dismiss":"modal"},class:"btn-primary",on:{click:function(){s=!0}}},{text:t&&t.cancelText?t.cancelText:"Cancel",attr:{"data-dismiss":"modal"},class:"btn-danger"}]};t.constructor==String?i.title=t:i=o.extend(i,t);var s=!1,a=e.dialog(i);return n&&a.on("hidden.bs.modal",function(t){n.call(this,s)}),a},e.prompt=function(t,n){var i,s={message:'<input type="text" class="form-control" id="bsbox_prompt_input">',buttons:[{text:"OK",attr:{"data-dismiss":"modal"},class:"btn-primary",on:{click:function(){i=o(this).parents(".modal").find("#bsbox_prompt_input").val()}}},{text:"Cancel",attr:{"data-dismiss":"modal"},class:"btn-danger"}]};t.constructor==String?s.title=t:s=o.extend(s,t);var a=e.dialog(s);return n&&a.on("hidden.bs.modal",function(t){n.call(this,i)}),a}}(window,jQuery,bsbox);