微小警报对话框和Toast通知插件 jQuery MSalert

  • 源码大小:8.77KB
  • 所需积分:1积分
  • 源码编号:19JP-3601
  • 浏览次数:497次
  • 最后更新:2023年07月01日
  • 所属栏目:其他
本站默认解压密码:19jp.com 或 19jp_com

简介

一个轻量级的jQuery弹出插件,用于创建可定制的、看起来很棒的提醒/确认对话框和toast通知,而不会破坏您网站的现有设计

如何使用它:

1.要开始,请包括微软警报.js脚本加载后最新的jQuery库。

  1. <script src="/path/to/cdn/jquery.min.js"></script>
  2. <script src="/path/to/MSalert.js"></script>

2.创建一个基本警报对话框。

  1. MSalert.principal({
  2. // 'gear', 'error', 'warning', 'success'
  3. icon:'warning',
  4.  
  5. // dialog title
  6. title: 'Are You Sure',
  7.  
  8. // dialog content
  9. description: 'Are you sure to delete this entry?',
  10.  
  11. // footer content
  12. extra: 'Check Out the Console Log (F12)',
  13.  
  14. })

3.创建一个确认对话框,该对话框将根据用户选择返回true或false。

  1. MSalert.principal({
  2.  
  3. // 'gear', 'error', 'warning', 'success'
  4. icon:'warning',
  5.  
  6. // dialog title
  7. title: 'Are You Sure',
  8.  
  9. // dialog content
  10. description: 'Are you sure to delete this entry?',
  11.  
  12. // footer content
  13. extra: 'Check Out the Console Log (F12)',
  14.  
  15. // enable confirm/cancel buttons
  16. button: true,
  17.  
  18. }).then(result =>{
  19. console.log('Result Promise', result)
  20. })

4.创建受材料设计启发的toast通知,该通知将在超时后自动取消。

  1. MSalert.alerta({
  2.  
  3. // append the notification to this container
  4. id:'container',
  5.  
  6. // toast message
  7. text : 'Success Message',
  8.  
  9. // 'up', 'down', or 'right'
  10. position: 'right',
  11.  
  12. // 'success', 'warning', or 'error'
  13. status: "success",
  14.  
  15. // auto dimiss after 3 seconds
  16. duration: 3000,
  17. })

预览截图