
在线预览 下载
这是一款基于bootstrap4封装的消息对话框组件。该消息组件包括dialog,alert,confirm,input,success,error,notice。并且对话框支持鼠标或手指触摸拖拽。
使用方法
在页面中引入下面的文件。
lt;link rel="stylesheet" href="bootstrap-4.0.0-dist/css/bootstrap.css"gt;
lt;link rel="stylesheet" href="./css/bs4.pop.css"gt;
lt;script src="js/jquery-2.1.1.min.js" type="text/javascript"gt;lt;/scriptgt;
lt;script src="bootstrap-4.0.0-dist/js/bootstrap.js"gt;lt;/scriptgt;
lt;script src="./js/bs4.pop.js"gt;lt;/scriptgt;
|
alert
bs4pop.alert( 'Alert Dialog' , function (){
console.log( 'You Just Clicked Okay Button' );
},{
title: 'Alert Dialog' ,
hideRemove: true ,
width: 500,
btns: [
{
label: 'Okay' ,
onClick(){
if (cb){
return cb();
}
}
}
]
});
|
confirm
bs4pop.confirm( 'Are You Sure?' , function (sure){
console.log( 'Are You Sure:' , sure);
},{
title: 'Confirmation Dialog' ,
hideRemove: true ,
btns: [
{
label: 'Confirm' ,
onClick(){
if (cb){
return cb( true );
}
}
},
{
label: 'Cancel' ,
className: 'btn-default' ,
onClick(){
if (cb){
return cb( false );
}
}
}
]
});
|
prompt
bs4pop.prompt( 'Username:' , 'Input Placeholder' , function (sure, value){
console.log( 'I am:' , value);
},{
title: 'Prompt Dialog' ,
hideRemove: true ,
width: 500,
btns: [
{
label: 'Okay' ,
onClick(){
if (cb){
return cb( true , $input.val());
}
}
},
{
label: 'Cancel' ,
className: 'btn-default' ,
onClick(){
if (cb){
return cb( false , $input.val());
}
}
}
]
});
|
notice
var myNofitication = bs4pop.notice( 'Notification Message' , {
type: 'primary' ,
position: 'topcenter' ,
appendType: 'append' ,
closeBtn: false ,
autoClose: 2000,
className: ''
})
|
dialog
var myDialog = bs4pop.dialog({
id: '' ,
title: '' ,
content: '' ,
className: '' ,
width: 500,
height: '' ,
target: 'body' ,
closeBtn: true ,
hideRemove: true ,
escape: true ,
autoFocus: true ,
show: true ,
backdrop: true ,
btns: [],
drag: true ,
onShowStart: function (){
},
onShowEnd: function (){
},
onHideStart: function (){
},
onHideEnd: function (){
},
onDragStart: function (){
console.log( 'onDragStart' );
},
onDragEnd: function (){
},
onDrag: function (){
console.log( 'onDrag' );
}
});
|