用户友好 交互式指南插件 jQuery PageGuide

  • 源码大小:84.75KB
  • 所需积分:1积分
  • 源码编号:19JP-3349
  • 浏览次数:551次
  • 最后更新:2023年06月03日
  • 所属栏目:其他
我要下载
加入收藏
本站默认解压密码:19jp.com 或 19jp_com

简介

网页元素指南可以用于多种目的,例如让用户了解新的特性和功能,或者帮助他理解网站的结构。这种工具允许用户与您的网页进行交互并更好地理解它。

在这篇文章中,你会发现一个jQuery页面指南插件,它可以让你创建循序渐进的互动导览,帮助引导你的用户浏览你的网站。让我们开始吧。

特征:

  • 将步骤编号编号编号添加到每个元素中。
  • 激活时高亮显示元素。
  • 允许在同一页面上有多个页面辅助线。
  • 将页面平滑滚动到激活的元素(步骤)。
  • 在页面底部显示一个辅助滑块,使您可以轻松地在步骤之间切换。

如何使用它:

1.首先在文档中加载最新的jQuery PageGuide插件文件。

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

2.为指南创建一个步骤列表。这个数据旅游目标属性应该包含要附加此页面指南步骤的元素的选择器。可以使用以下类来指示每个编号气泡的位置。

  • t页面指南_左
  • t页面指南_右侧
  • t页面指南_顶部
  • t页面指南_底部
  1. <div class="first_element_to_target">
  2. Element 1
  3. </div>
  4. <div id="second_element_to_target">
  5. Element 2
  6. </div>
  7. <div class="third_element_to_target">
  8. Element 3
  9. </div>
  10. ...
  1. <ul id="tlyPageGuide" data-tourtitle="Check out these elements">
  2. <li class="tlypageguide_left" data-tourtarget=".first_element_to_target">
  3. Element 1 Description
  4. </li>
  5. <li class="tlypageguide_right" data-tourtarget="#second_element_to_target">
  6. Element 2 Description
  7. </li>
  8. <li class="tlypageguide_left" data-tourtarget=".third_element_to_target">
  9. Element 3 Description
  10. </li>
  11. ...
  12. </ul>

3.为指南创建一个欢迎弹出窗口。

  1. <div class="tlyPageGuideWelcome">
  2. <p>Welcome to my new page! pageguide is here to help you learn more.</p>
  3. <button class="tlypageguide_start">let's go</button>
  4. <button class="tlypageguide_ignore">not now</button>
  5. <button class="tlypageguide_dismiss">got it, thanks</button>
  6. </div>

4.初始化文档上的PageGuide插件。就是这样。

  1. jQuery(document).ready(function() {
  2. var pageguide = tl.pg.init();
  3. });

5.自定义指南的所有默认插件。

  1. tl.pg.init({
  2.  
  3. // Whether or not to focus on the first visible item immediately on PG open
  4. 'auto_show_first': true,
  5.  
  6. // The CSS selector for the loading element.
  7. // pageguide will wait until this element is no longer visible starting up.
  8. 'loading_selector' : '#loading',
  9.  
  10. // Optional callback for tracking user interactions with pageguide.
  11. // Should be a function taking a single parameter indicating the name of the interaction.
  12. 'track_events_cb': function() { return; },
  13.  
  14. // Optional callback to enlight or adapt interface depending on current documented element.
  15. // Should be a function taking 2 parameters, current and previous data-tourtarget selectors.
  16. 'handle_doc_switch': null,
  17.  
  18. // Optional id for toggling pageguide.
  19. // If not specified then the default button is used.
  20. 'custom_open_button': null,
  21.  
  22. // Visible caption
  23. 'pg_caption' : 'page guide',
  24.  
  25. // Tour title
  26. 'tourtitle': 'Open Page Guide for help',
  27.  
  28. // Check whether or not the welcome message has been dismissed.
  29. // Must return true or false.
  30. // This function should check against whatever state change is made in dismiss_welcome.
  31. 'check_welcome_dismissed': function () {
  32. var key = 'tlypageguide_welcome_shown_' + tl.pg.hashUrl();
  33. // first, try to use localStorage
  34. try {
  35. if (localStorage.getItem(key)) {
  36. return true;
  37. }
  38. // cookie fallback for older browsers
  39. } catch(e) {
  40. if (document.cookie.indexOf(key) > -1) {
  41. return true;
  42. }
  43. }
  44. return false;
  45. },
  46.  
  47. // Permanently dismiss the welcome message, corresponding to check_welcome_dismissed.
  48. 'dismiss_welcome': function () {
  49. var key = 'tlypageguide_welcome_shown_' + tl.pg.hashUrl();
  50. try {
  51. localStorage.setItem(key, true);
  52. } catch(e) {
  53. var exp = new Date();
  54. exp.setDate(exp.getDate() + 365);
  55. document.cookie = (key + '=true; expires=' + exp.toUTCString());
  56. }
  57. },
  58.  
  59. // A function to run once the pageguide ready event fires.
  60. 'ready_callback': null,
  61.  
  62. // Specify whether or not to provide a fallback for css pointer-events in browsers that do not support it
  63. 'pointer_fallback': true,
  64.  
  65. // The css z-index to apply to the tlypageguide_shadow overlay elements
  66. 'default_zindex': 100,
  67.  
  68. // Selector for the ul element whose steps you wish to use in this particular pageguide object
  69. 'steps_element': '#tlyPageGuide',
  70.  
  71. // If set to true, pageguide will run a timer to constantly monitor the DOM for changes in the target elements and adjust the pageguide display (bubbles, overlays, etc) accordingly.
  72. // The timer will only run while pageguide is open.
  73. // Useful for single-page or heavily dynamic apps where pageguide steps or visible DOM elements can change often.
  74. 'auto_refresh': false,
  75.  
  76. // Similar to auto_refresh, welcome_refresh enables a timer to monitor the DOM for new .tlyPageGuideWelcome elements.
  77. // This is useful if your welcome element isn't loaded immediately, or if you want to show different welcome elements on different pages.
  78. // The timer will run constantly, whether or not the pageguide is open, so enable at your discretion.
  79. 'refresh_welcome': false,
  80.  
  81. // How often to poll the DOM for changes.
  82. 'refresh_interval': 500
  83.  
  84. });

预览截图