轻量级和高度可定制 jQuery工具提示插件 Zebra_Toltips

  • 源码大小:754.36KB
  • 所需积分:1积分
  • 源码编号:19JP-3218
  • 浏览次数:868次
  • 最后更新:2023年05月19日
  • 所属栏目:工具提示
我要下载
加入收藏
本站默认解压密码:19jp.com 或 19jp_com

简介

Zebra_Tooltips是一个轻量级、高度可定制和跨浏览器的jQuery插件,用于创建简单但智能且具有视觉吸引力的工具提示,具有良好的转换功能,并提供许多配置选项

可以通过JavaScript和/或CSS轻松定制外观。此外,工具提示可以相对于父元素向左、居中或向右对齐

Zebra_Tooltips利用了NOIMAGES(一切都由CSS处理),对于不支持所有花哨内容的浏览器,它会优雅地后退;工具提示也可以附加到任何元素,而不仅仅是锚点标记!

基本用法:

1.在页面上包含所需的CSS文件

  1. <link rel="stylesheet" href="css/zebra_tooltips.css" type="text/css">

2.在你的网页上包括jQuery库和Zebra_Toltips插件

  1. <script type="text/javascript" src="jquery.min.js"></script>
  2. <script type="text/javascript" src="zebra_tooltips.js"></script>

3. The Html

  1. a href="#" class="demo" title="One of the BEST jQuery websites that provide web designers and developers with a simple way to preview and download a variety of Free jQuery Plugins.">jQueryScript.Net</a>

4.在文档上调用插件。

  1. $(document).ready(function() {
  2.  
  3. new $.Zebra_Tooltips($('.demo'));
  4.  
  5. });

5.具有默认值的所有可用选项。

  1. // The speed (in milliseconds) of the animation used to show/hide tooltips.
  2. animation_speed: 250,
  3.  
  4. // The number of pixels the tooltips should use to "slide" into position.
  5. // Set to 0 for no sliding.
  6. animation_offset: 20,
  7.  
  8. // By default, if the users clicks when over a tooltip, the tooltip will
  9. // close (if the tooltip was not open using the API, that is)
  10. // Set this property to FALSE to prevent this behavior.
  11. close_on_click: true,
  12.  
  13. // The content of the tooltip.
  14. // By default, the content of the tooltip is taken from the "title"
  15. // attribute of the element the tooltip is attached to and has priority
  16. // over this property (meaning that if the "title" attribute is set,
  17. // the value of this property is ignored).
  18. // Use this property to set the content of the tooltip when you can't
  19. // or don't want to use the "title" attribute.
  20. content: false,
  21.  
  22. // The delay (in milliseconds) after which to hide the tooltip once the
  23. // mouse moves away from the trigger element or the tooltip.
  24. hide_delay: 100,
  25.  
  26. // Should tooltips remain visible also when the mouse cursor is over
  27. // the tooltips or should the tooltips be visible strictly when the mouse
  28. // cursor is over the parent elements.
  29. keep_visible: true,
  30.  
  31. // Maximum width of the tooltip's content;
  32. max_width: 250,
  33.  
  34. // The tooltip's opacity.
  35. // Must be a value between 0 (completely transparent) and 1 (completely
  36. // opaque)
  37. opacity: '.95',
  38.  
  39.  
  40. // The tooltip's position, relative to the trigger element.
  41. // Can be 'center', 'left' or 'right'.
  42. position: 'center',
  43.  
  44. // If set to TRUE, tooltips will be created on document load, rather than
  45. // only when needed.
  46. prerender: false,
  47.  
  48. // The delay (in milliseconds) after which to show the tooltip once the
  49. // mouse is over the trigger element.
  50. show_delay: 100,
  51.  
  52. // By default, tooltips are shown above the elements they are attached to
  53. // and are shown below only if there isn't enough space above.
  54. // Set the value of this property to "below" if you want to reverse the
  55. // default behavior so that tooltips will be shown below the elements
  56. // they are attached to and will be shown above only there isn't enough
  57. // space below.
  58. // Possible values are "above" and "below".
  59. vertical_alignment: 'above',
  60.  
  61. // How close (in pixels) should the tip of the tooltip be relative to
  62. // the parent element.
  63. vertical_offset: 0

6.回调函数。

  1. // Event fired before a tooltip is hidden.
  2. //
  3. // The callback function receives as arguments the element the
  4. // tooltip is attached to, and the tooltip element.
  5. //
  6. // If the callback function returns boolean FALSE, the tooltip will
  7. // not be hidden.
  8. onBeforeHide: null,
  9.  
  10. // Event fired after a tooltip is hidden.
  11. //
  12. // The callback function receives as arguments the element the
  13. // tooltip is attached to, and the tooltip element.
  14. onHide: null,
  15.  
  16. // Event fired before a tooltip is shown.
  17. //
  18. // The callback function receives as arguments the element the
  19. // tooltip is attached to, and the tooltip element.
  20. //
  21. // If the callback function returns boolean FALSE, the tooltip will
  22. // not be shown.
  23. onBeforeShow: null,
  24.  
  25. // Event fired after a tooltip is shown.
  26. //
  27. // The callback function receives as arguments the element the
  28. // tooltip is attached to, and the tooltip element.
  29. onShow: null

7.API方法。

  1. var myTooltip = new $.Zebra_Tooltips($('.demo'));
  2.  
  3. // shows the tooltip
  4. myTooltip.show(element, [destroy = FALSE])
  5.  
  6. // hides the tooltip
  7. hide(element, [destroy = FALSE])

更新日志:

v2.3.0版本(2023-01-22)

  • 修复了一个长期存在的问题,即包装会在没有明显原因的情况下发生,主要发生在带有短消息的工具提示中

v2.2.0 (2021-10-06)

  • 将焦点事件绑定到父元素,以便在使用TAB键时打开和关闭工具提示,使工具提示更易于访问; 
  • 增加了对noConflict模式下jQuery的支持;

v2.2.0 (2021-10-06)

  • 将焦点事件绑定到父元素,以便在使用TAB键时打开和关闭工具提示,使工具提示更易于访问; 
  • 增加了对noConflict模式下jQuery的支持;

v2.1.1版本(2020-07-20)

  • 已将SASS文件添加到dist文件夹

v2.1.0版本(2020-03-16)

  • 已修复Bug

v2.0.5版本(2018-10-14)

  • 使用Clean CSS缩小CSS大小
  • 修复了多个工具提示都使用相同内容的错误
  • 修复了一个问题,即自上次提交以来,传递给构造函数的选项不再被应用;谢谢Gianluca Finocchiaro!

v2.0.2版本(2018-07-09)

  • 添加了版本号作为公共属性-即使您只有缩小的源代码,也有助于查找版本号
  • 现在还可以通过数据属性设置属性

v2.0.1版本(2018-07-09)

  • 性能调整

v2.0.0版本(2018-07-08)

  • 删除了背景色和颜色属性
  • 使用&times;用于关闭按钮而不是x
  • 已将特性default_position重命名为vertical_lignalign
  • 如果附加到onBeforeShow和onBeforeHide事件的回调函数返回布尔值FALSE,则相应的操作将被取消
  • 工具提示的样式已经更新,并添加了3个主题

v1.3.1 (2017-12-18)

  • 将CSS移植到SASS
  • 小的源代码调整
  • 明确说明RGBA值可用于背景颜色
  • 一些样式更新
  • 不再设置字体大小
  • 错误修复

v1.2.4 (2017-05-17)

  • 小的源代码调整

v1.2.3(2016年1月17日)

  • 增加了“严格使用”

v1.2.2 (2015-01-16)

  • “title”属性不再被删除
  • 在示例中将jQuery更新为1.12.0
  • 增加了Grunt集成,用于自动化JSHint和Uglify流程
  • 增加了与Bower的集成

v1.2.1 (2013-11-26)

  • 添加了新的“default_position”属性

v1.2.0(2013年10月19日)

  • 更新的文件和参考资料

预览截图