基于bootstrap4封装的消息对话框组件

news/2025/2/23 1:13:45/文章来源:https://www.cnblogs.com/liylllove/p/18567340

在线预览   下载

 

这是一款基于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');
},{
  // options settings here
  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', {
 
    // 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
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');
    }
     
});

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.hqwc.cn/news/840812.html

如若内容造成侵权/违法违规/事实不符,请联系编程知识网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

在暴雨中追逐一只白色的猫

写在前面234 字 | 希望 | 苦难 | 永恒 | 唯心主义与唯物主义正文我在暴雨中追逐一只白色的猫,毛发柔顺如云,如羽毛。雨落我身,不亲近猫。 <br />白色的猫左跳右跳,跳上月球,跳上没有暴雨的广寒宫。我听见有人哭,有人笑。 <br />我在暴雨中望着白色的月球,雨…

用于自然语言处理的循环神经网络RNN

前一篇:《人工智能模型学习到的知识是怎样的一种存在?》 序言:在人工智能领域,卷积神经网络(CNN)备受瞩目,但神经网络的种类远不止于此。实际上,不同类型的神经网络各有其独特的应用场景。在接下来的几节中,我将带大家走近循环神经网络(RNN),深入了解其原理及其在处…

【牛客训练记录】牛客周赛 Round 69

训练情况赛后反思 好吧,D 题没想到二进制枚举,以为 \(O(2^knm)\) 不可做。。。 A题 要求要等差数列,我们先求公差,为两元素的最大值-最小值,再在最大值的基础上加上公差即可。 #include <bits/stdc++.h> // #define int long long #define endl \nusing namespace s…

【windows】Windows10休眠文件太大,更改 hiberfil.sys 文件大小

Windows将内存数据复制到磁盘来支持电脑休眠,系统在将内存内容保留在磁盘上之后对其进行压缩,从而将所需的磁盘空间减少到小于系统上的物理内存总量。 如果发现自己电脑 hiber.sys 文件变得太大并占用磁盘空间,您可能需要考虑减小它。现在在 Windows 10 中,默认情况下 hibe…

云计算基础

免责声明 学习视频来自 B 站up主泷羽sec,如涉及侵权马上删除文章。 笔记的只是方便各位师傅学习知识,以下代码、网站只涉及学习内容,其他的都与本人无关,切莫逾越法律红线,否则后果自负。 B站地址:https://space.bilibili.com/350329294 云计算基础 在过去,搭建一个应用…

matlab: 检查程序运行效率

profile onqiu_ji_fenprofile viewer

LeetCode 1837[K进制表示下的各位数字总和]

LeetCode 1837[K进制表示下的各位数字总和]题目 链接 LeetCode 1837[K进制表示下的各位数字总和] 详情实例提示题解 思路 进制转换,遍历求和 代码 class Solution { public:int sumBase(int n, int k) {int iSum = 0;while (n > 0){iSum += n % k;n = n / k;}return iSum;}…

【PHP漏洞】PHPMyAdmin写shell的几种方式

phpMyAdmin是一个以PHP为基础,以web方式架构在服务器上的MySQL的数据库管理工具。让管理者可以通过Web接口来管理MySQL数据库。 查看phpmyadmin版本: /phpMyAdmin/README在高版本中无法写入一句话 mysql新特性secure_file_priv会对读写文件产生影响,该参数用来限制导入导出查…

rebuttal 摘录(3)

link: https://www.iikx.com/news/article/8915.html小过原创心得: 如果分数低,就当锻炼自己rebuttal的能力了;你想,分数低你还能回复那么多(至少你自己觉得挺有道理的),那么以后遇到分数高的,不是手到擒来吗?哈哈哈哈https://www.cnblogs.com/marsggbo/p/14278583.ht…

jmeter之操作数据库

一、下载jdbc 驱动,安装jdbc驱动2、将驱动存放在4个路径下 (1)C:\Program Files\Java\jre1.8.0_60\lib (2)第二个存放的包 C:\Program Files\Java\jre1.8.0_60\lib\ext (3)第三个存放的包(4)存放第四个包 E:\dcs\two\jmeter(14)\apache-jmeter-3.3\lib\ext 2、在测试…

不仅仅是Excel,这些工具让协作更简单!

在现代办公中,团队协作和信息共享变得愈发重要。随着Excel多人协同编辑功能的普及,工作效率和团队协作水平有了显著提升。通过多人同时编辑同一文档,无论是数据分析、财务报表,还是项目计划,团队成员都能实时看到彼此的修改,避免了版本冲突和重复劳动,提高了工作效率。除…