(function($) {window. Ewin=function () { var html = ' <div id= ' [id] "class=" Modal Fade "role=" dialog "aria-labelledby=" Modallabel "> ' + ' <div class= "Modal-dialog modal-sm" > ' + ' <div class= "modal-content" > ' + ' < ;d IV class= "Modal-header" > ' + ' <button type= "button" class= "Close" data-dismiss= "modal" >& Lt;span aria-hidden= "true" >x</span><span class= "sr-only" >Close</span></button> ' + ' ; vardialogdhtml = ' <div id= "[id]" class= "Modal Fade" role= "dialog" aria-labelledby= "Modallabel" > ' + ' & Lt;div class= "Modal-dialog" > ' + ' <div class= "modal-content" > ' + ' <di V class= "Modal-header" > ' + ' <button type= "button" class= "Close" data-dismiss= "modal" >< Span aria-hidden= "true" >x</span><span class= "sr-only" >Close</span></button> ' + '
; varReg =NewREGEXP ("\\[" ([^\\[\\]]*?) \ \] ", ' IgM '); varGenerateid =function () { varDate =NewDate (); return' MDL ' +date.valueof (); } varinit =function(options) {Options=$.extend ({}, {title:"Action Tips", message:"Prompt Content", Btnok:Determine, Btncl:Cancel, Width:200, Auto:false}, Options|| {}); varModalid =Generateid (); varContent = Html.replace (Reg,function(node, key) {return{id:modalid, Title:options.title, Message:options.messag E, BtnOk:options.btnok, BtnCancel:options.btncl}[key]; }); $(' Body '). append (content); $(' # ' +modalid). Modal ({width:options.width, backdrop:' Static ' }); $(' # ' + modalid). On (' Hide.bs.modal ',function(e) {$ (' Body '). Find (' # ' +modalid). Remove (); }); returnModalid; } return{alert:function(options) {if(typeofOptions = = ' String ') {Options={message:options}; } varID =init (options); varmodal = $ (' # ' +ID); Modal.find ('. Ok '). Removeclass (' btn-success '). addclass (' btn-primary ')); Modal.find ('. Cancel '). Hide (); return{id:id, on:function(callback) {if(Callback && CallbackinstanceofFunction) {Modal.find ('. Ok '). Click (function() {Callback (true); }); }}, Hide:function(callback) {if(Callback && CallbackinstanceofFunction) {Modal.on (' Hide.bs.modal ',function(e) {callback (E); }); } } }; }, confirm:function(options) {varID =init (options); varmodal = $ (' # ' +ID); Modal.find ('. Ok '). Removeclass (' Btn-primary '). addclass (' btn-success ')); Modal.find ('. Cancel '). Show (); return{id:id, on:function(callback) {if(Callback && CallbackinstanceofFunction) {Modal.find ('. Ok '). Click (function() {Callback (true); }); Modal.find ('. Cancel '). Click (function() {Callback (false); }); }}, Hide:function(callback) {if(Callback && CallbackinstanceofFunction) {Modal.on (' Hide.bs.modal ',function(e) {callback (E); }); } } }; }, Dialog:function(options) {Options=$.extend ({}, {title:' Title ', URL:‘‘, Width:800, Height:550, Onready:function() {}, Onshown:function(e) {}}, Options|| {}); varModalid =Generateid (); varContent = Dialogdhtml.replace (Reg,function(node, key) {return{id:modalid, Title:options.title}[key]; }); $(' Body '). append (content); vartarget = $ (' # ' +modalid); Target.find ('. Modal-body '). Load (Options.url); if(Options.onready ()) Options.onReady.call (target); Target.modal (); Target.on (' Shown.bs.modal ',function(e) {if(Options.onready (e)) Options.onReady.call (target, E); }); Target.on (' Hide.bs.modal ',function(e) {$ (' Body '). Find (target). Remove (); }); } } }();}) (jQuery);
Examples of Use
$ (function () { /// ewin.alert ("haha"); Ewin.confirm ({message: "OK Delete"}). On (function (e) { console.log (e); }); })
Popup box-based bootstrap and jquery custom Popup