最小警报和确认模式对话框插件 jQuery voverlay

  • 源码大小:32.97KB
  • 所需积分:1积分
  • 源码编号:19JP-3611
  • 浏览次数:1129次
  • 最后更新:2023年07月02日
  • 所属栏目:幻灯片
本站默认解压密码:19jp.com 或 19jp_com

简介

voverlay是一个轻量级的模态对话框插件,用于在您的网站上显示简单的警报和确认

专为那些正在寻找强大而优雅的解决方案的开发人员设计,该解决方案可以在弹出模式窗口中显示重要信息,而不会干扰页面的其他功能。

如何使用它:

1.在文档中加载jQuery库和voverlay插件的文件。

  1. <link href="/path/to/voverlay.css" rel="stylesheet" />
  2. <script src="/path/to/cdn/jquery.min.js"></script>
  3. <script src="/path/to/voverlay.js"></script>

2.创建一个基本的警报对话框,并从文档中现有的DOM元素中获取内容。

  1. <div class="example">
  2. <p>Modal Content Here</p>
  3. </div>
  1. .example1 {
  2. /* hide the elemnt on page load */
  3. display: none;
  4. /* your own styles here */
  5. }
  1. $('.example').voverlay('show', {
  2. title: "Basic Modal"
  3. });

3.用JavaScript创建一个确认对话框。

  1. $.voverlay.show({
  2. title: "Confirm Dialog",
  3. html: "Are you sure to delete this entry?",
  4. modalMode: true,
  5. modalButtonsToShow: ["yes", "no", "cancel"],
  6. // callbacks
  7. onModalYes: function () { return true; },
  8. onModalNo: function () { },
  9. onModalCancel: function () { },
  10. });

4.更多定制选项。

  1. $.voverlay.show({
  2.  
  3. // opacity from 0 to 1
  4. maskOpacity: '0.25',
  5.  
  6. // callbacks
  7. onOpen: function () { },
  8. onClose: function () { },
  9.  
  10. // close the modal by clicking on background overlay
  11. onMaskClickClose: false,
  12.  
  13. // min spacing in px
  14. minSpacing: 40,
  15.  
  16. // additional styles
  17. style: {},
  18. // shows close button
  19. showClose: true,
  20.  
  21. // attach the modal to the element
  22. contextMode: false,
  23. // customize action buttons here
  24. modalYesButtonTemplate: function () { return '<input value="Yes" type="button" />'; },
  25. modalNoButtonTemplate: function () { return '<input value="No" type="button" />'; },
  26. modalCancelButtonTemplate: function () { return '<input value="Cancel" type="button" />'; },
  27. // x/y offsets
  28. clientX: "",
  29. clientY: "",
  30. });

预览截图