基于bootstrap4,封装的消息组件 dialog, alert, confirm, prompt, notice,支持鼠标及手势拖拽 (surface笔记本)
支持鼠标、触摸屏、触摸笔,没啥好说的,看示例。
支持 webpack 模块化
API文档,直接看 bs4.pop.js 源码,很简单
在页面中引入下面的文件。
alert
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | 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
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | 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
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | 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
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | var myNofitication = bs4pop.notice( 'Notification Message' , { // primary, secondary, success, danger, warning, info, light, dark type: 'primary' , // topleft, topcenter, topright, bottomleft, bottomcenter, bottonright, center position: 'topcenter' , // append, prepend appendType: 'append' , // shows close button closeBtn: false , // auto dismisses after 2 seconds autoClose: 2000, // CSS class className: '' }) |
dialog
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 | var myDialog = bs4pop.dialog({ // dialog title id: '' , // dialog title title: '' , // dialog content: string, element, jQuery object content: '' , // custom CSS class className: '' , // width/height width: 500, height: '' , // parent container target: 'body' , // shows close button closeBtn: true , // removes the dialog from the DOM after hidden hideRemove: true , // closes the dialog by pressing ESC key escape: true , // sets focus to the dialog on init autoFocus: true , // shows the dialog on init show: true , // shows backdrop // true, false, static backdrop: true , // custom action buttons // [{label: 'Button', className: 'btn-primary',onClick(cb){}}] btns: [], // enables draggable drag: true , // callback functions onShowStart: function (){ // console.log('onShowStart'); }, onShowEnd: function (){ // console.log('onShowEnd'); }, onHideStart: function (){ // console.log('onHideStart'); }, onHideEnd: function (){ // console.log('onHideEnd'); }, onDragStart: function (){ console.log( 'onDragStart' ); }, onDragEnd: function (){ // console.log('onDragEnd'); }, onDrag: function (){ console.log( 'onDrag' ); } }); |
特别申明:
本站所有资源都是由网友投稿发布,或转载各大下载站,请自行检测软件的完整性!
本站所有资源仅供学习与参考,请勿用于商业用途,否则产生的一切后果将由您自己承担!
如有侵权请联系我们删除下架,联系方式:lei1294551502@163.com