Xtiper

Xtiper 是一款整合 PC 、移动端的弹层弹窗(甚至还有弹幕)解决方案。采用原生的 javascript 编写,体积小,不依赖任何 js 库,不加载任何图片,使用方便。

目前为 2023-04-04 提交的版本。查看 最新版本

此脚本不应直接安装,它是一个供其他脚本使用的外部库。如果您需要使用该库,请在脚本元属性加入:// @require https://update.gf.qytechs.cn/scripts/449512/1170662/Xtiper.js

  1. (function () {
  2. let cssResource = `@charset "utf-8";
  3. .xtiper{position:relative;}
  4. .xtiper_msg{transition-timing-function:ease-out;transition-duration:.2s;transition-property:transform,opacity;}
  5. .xtiper_msg{position:fixed;left:50%;z-index:99999;overflow:hidden;max-width:752px;min-height:50px;border-radius:3px;box-shadow:0 0 10px rgba(0,0,0,.2);font-size:14px;line-height:50px;opacity:0;}
  6. .xtiper_msg_black{background-color:rgba(0,0,0,.75);color:#fff;}
  7. .xtiper_msg_white{background-color:rgba(255,255,255,.95);color:#222;}
  8. .xtiper_msg_middle{top:50%;margin-top:-25px;transform:scale(0,0);}
  9. .xtiper_msg_top{top:0;transform:translate(0,-100%) scale(1,1);}
  10. .xtiper_msg_bottom{bottom:0;transform:translate(0,100%) scale(1,1);}
  11. .xtiper_msg.xon{opacity:1;}
  12. .xtiper_msg_middle.xon{transform:scale(1,1);}
  13. .xtiper_msg_top.xon{transform:translate(0,0) scale(1,1);}
  14. .xtiper_msg_bottom.xon{transform:translate(0,0) scale(1,1);}
  15. .xtiper_msg p{padding:0 24px;word-spacing:nowrap;}
  16. .xtiper_danmu{left:0;border:3px solid transparent;background-origin:content-box;font-weight:700;font-size:16px;opacity:1;transition-property:none;}
  17. .xtiper_danmu_animate{animation:danmu_animate 6s 1 linear;-webkit-animation:danmu_animate 6s 1 linear;}
  18. .xtiper_danmu_light{border:3px solid red;}
  19. @keyframes danmu_animate{100%{transform:translateX(-102%);}
  20. }
  21. .xtiper_tips{position:absolute;z-index:99999;max-width:200px;box-shadow:0 0 5px rgba(0,0,0,.3);opacity:0;transition-timing-function:ease-in;transition-duration:.1s;transition-property:opacity,transform;transform:scale(0,0);}
  22. .xtiper_tips.xon{opacity:1;transition-duration:.2s;transform:scale(1,1);}
  23. .xtiper_tips p{position:relative;z-index:2;padding:10px 16px;border-radius:3px;background-color:#000;color:#fff;font-size:12px;line-height:18px;}
  24. .xtiper_tips em{position:absolute;z-index:1;display:block;width:10px;height:10px;background-color:#000;box-shadow:0 0 5px rgba(0,0,0,.3);transform:rotate(45deg);}
  25. .xtiper_tips_left em{top:12px;right:-4px;}
  26. .xtiper_tips_right em{top:12px;left:-4px;}
  27. .xtiper_tips_top em{bottom:-4px;left:12px;}
  28. .xtiper_tips_bottom em{top:-4px;left:12px;}
  29. .xtiper_win{z-index:99999;}
  30. .xtiper_win_fixed{position:fixed;top:0;left:0;z-index:99999;width:100%;height:100%;}
  31. .xtiper_bg{position:absolute;top:0;left:0;z-index:1;width:100%;height:100%;background-color:rgba(0,0,0,0);transition-timing-function:ease-in;transition-duration:.1s;transition-property:background-color,opacity;}
  32. .xtiper_bg.xmin{display:none;}
  33. .xtiper_bg_white{background-color:rgba(255,255,255,0);transition:50ms ease-in;}
  34. .xtiper_win.xon .xtiper_bg{background-color:rgba(0,0,0,.5);}
  35. .xtiper_win.xon .xtiper_bg_white{background-color:rgba(255,255,255,.5);transition:50ms ease-in;}
  36. .xtiper_main{position:absolute;z-index:2;width:300px;background-color:#fff;box-shadow:0 0 10px rgba(0,0,0,.2);opacity:0;transition-timing-function:ease-in;transition-duration:.15s;transition-property:opacity,transform;transform:scale(0,0);}
  37. .xtiper_main.xapp{background-color:transparent;}
  38. .xtiper_main_photo{transition-property:opacity,transform,height,top;}
  39. .xtiper_main_photo.xon{transition-property:opacity,transform,height;}
  40. .xtiper_win.xon .xtiper_main{opacity:1;transform:scale(1,1);}
  41. .xtiper_win.xon .xtiper_bg,.xtiper_win.xon .xtiper_main{transition-timing-function:ease-in;transition-duration:.2s;}
  42. .xtiper_win.xoff .xtiper_bg{opacity:0;}
  43. .xtiper_win.xoff .xtiper_main{opacity:0;transform:scale(0,0);}
  44. .xtiper_tit{position:relative;padding:0 18px;height:40px;background-color:#f8f8f8;color:#222;font-size:14px;line-height:40px;cursor:move;user-select:none;}
  45. .xtiper_tit:after{position:absolute;bottom:0;left:0;display:block;width:100%;height:1px;background-color:#eee;content:"";}
  46. .xtiper_tit_none{height:8px;background-color:#f0f0f0;}
  47. .xtiper_tit.xminmax{cursor:default;}
  48. .xtiper_tit p{overflow:hidden;margin-right:28px;text-overflow:ellipsis;white-space:nowrap;}
  49. .xtiper_tit.xmcss1 p{margin-right:62px;}
  50. .xtiper_tit.xmcss2 p{margin-right:96px;}
  51. .xtiper_tit.xmin p{margin-right:62px;}
  52. .xtiper_minmax{position:absolute;top:5px;right:6px;}
  53. .xtiper_close{z-index:10;}
  54. .xtiper_close,.xtiper_max,.xtiper_min{position:relative;float:left;box-sizing:border-box;margin-right:4px;width:30px;height:30px;background-position:center center;background-size:18px;background-repeat:no-repeat;cursor:pointer;}
  55. .xtiper_minmax div:last-child{margin-right:0;}
  56. .xtiper_close:after,.xtiper_close:before{position:absolute;top:14px;left:8px;display:block;width:14px;height:2px;background-color:#2d2c3b;content:"";}
  57. .xtiper_close:before{transform:rotate(45deg);}
  58. .xtiper_close:after{transform:rotate(-45deg);}
  59. .xtiper_close:hover,.xtiper_max:hover,.xtiper_min:hover{opacity:.8;}
  60. .xtiper_close:after,.xtiper_close:before{transition-timing-function:ease-in;transition-duration:.2s;transition-property:transform;}
  61. .xtiper_close:hover:before{transform:rotate(135deg);}
  62. .xtiper_close:hover:after{transform:rotate(45deg);}
  63. .xtiper_close_notit{position:absolute;top:-10px;right:-10px;margin-right:0;border:3px solid #fff;border-radius:50%;background-color:#333;transition-timing-function:ease-in;transition-duration:.2s;transition-property:background-color;}
  64. .xtiper_close_notit:after,.xtiper_close_notit:before{top:11px;left:5px;background-color:#fff;}
  65. .xtiper_close_notit:hover{background-color:#2b84d0;opacity:1;}
  66. .xtiper_close_notitmin:after,.xtiper_close_notitmin:before{top:7px;left:3px;width:10px;}
  67. .xtiper_close_notitmin{width:20px;height:20px;border-width:2px;}
  68. .xtiper_close_photoapp{top:6px;right:6px;background-color:transparent;}
  69. .xtiper_close_photoapp:hover{background-color:transparent;}
  70. .xtiper_close_photoapp:hover:before{transform:rotate(45deg);}
  71. .xtiper_close_photoapp:hover:after{transform:rotate(-45deg);}
  72. .xtiper_close_load{position:absolute;top:0;right:0;}
  73. .xtiper_photo{position:relative;overflow:hidden;transition-property:transform,opacity;}
  74. .xtiper_photo_ul{padding:0 60px;height:100%;}
  75. .xtiper_photo_ul ul{position:relative;overflow:hidden;height:calc(100% - 26px);}
  76. .xtiper_photo_li{position:absolute;top:0;left:0;width:100%;height:100%;text-align:center;opacity:0;transition-timing-function:ease-out;transition-duration:.3s;transition-property:transform,opacity;transform:scale(0,0);}
  77. .xtiper_photo_li.xon{opacity:1;transform:scale(1,1);}
  78. .xtiper_photo_li.xold_prev{transform:scale(1,1) translate(100%,0);}
  79. .xtiper_photo_li.xold_next{transform:scale(1,1) translate(-100%,0);}
  80. .xtiper_sheet{position:absolute;bottom:0;left:0;z-index:2;width:100%;background-color:#fff;transition:.1s ease-in;transition-property:transform;transform:translate(0,100%);}
  81. .xtiper_sheet_tit,.xtiper_sheet_ul{background-color:#efeff4;}
  82. .xtiper_win.xon .xtiper_sheet{transition:.2s ease-in;transform:translate(0,0);}
  83. .xtiper_win.xoff .xtiper_sheet{transform:translateY(100%);}
  84. .xtiper_sheet_left{text-align:left;}
  85. .xtiper_sheet_right{text-align:right;}
  86. .xtiper_sheet_center{text-align:center;}
  87. .xtiper_sheet_tit{padding:15px;color:#222;font-weight:700;font-size:15px;line-height:20px;}
  88. .xtiper_sheet_li{height:48px;border-top:1px solid #d9d9d9;background-color:#fff;color:#222;font-size:14px;line-height:48px;cursor:pointer;user-select:none;-ms-user-select:none;}
  89. .xtiper_sheet_li a{display:block;width:100%;color:#222;text-decoration:none;}
  90. .xtiper_sheet_li a:hover{color:#222;text-decoration:none;}
  91. .xtiper_sheet_li p{padding:0 15px;}
  92. .xtiper_sheet_li.xlast{margin-top:8px;border-top:0;}
  93. .xtiper_min{background-image:url("data:image/svg+xml,%3Csvg width='600' height='600' viewBox='0 0 1024 1024' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M949.2 560.2H74.8c-26.6 0-48.2-21.6-48.2-48.2 0-26.6 21.6-48.2 48.2-48.2H949.2c26.6 0 48.2 21.6 48.2 48.2 0 26.6-21.6 48.2-48.2 48.2z' fill='%232d2c3b'/%3E%3C/svg%3E");}
  94. .xtiper_min.xon{margin-right:0;background-image:url("data:image/svg+xml,%3Csvg width='2000' height='2000' viewBox='0 0 1024 1024' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M879.1 783.6h-60.4a34.3 34.3 0 0 1 0-68.6h60.4c14.3 0 26.6-11.8 26.6-26.6V142.6c0-14.3-11.8-26.6-26.6-26.6H332.8c-14.3 0-26.6 11.8-26.6 26.6v60.4a34.3 34.3 0 0 1-68.6 0V142.6c0-52.2 42.5-94.72 94.72-94.7h546.3c52.2 0 94.72 42.5 94.72 94.7v546.3c0.5 52.2-42.5 94.72-94.2 94.7z' fill='%232c2c2c'/%3E%3Cpath d='M708.1 964.3H162.3c-57.9 0-103.9-47.1-103.9-103.9V312.6c0-57.9 47.1-103.9 103.9-103.9h546.3c57.9 0 103.9 47.1 103.9 103.9v546.8c0.5 58.4-46.08 104.96-104.4 104.96zM162.3 276.72c-19.5 0-35.84 16.4-35.84 35.8v546.8c0 19.5 16.4 35.84 35.84 35.84h546.3c19.5 0 35.84-16.4 35.84-35.84V312.6c0-19.5-16.4-35.84-35.84-35.8H162.3z' fill='%232d2c3b'/%3E%3C/svg%3E");}
  95. .xtiper_max{background-image:url("data:image/svg+xml,%3Csvg width='600' height='600' viewBox='0 0 1024 1024' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M944.0 0.8H79.1C35.8 0.8 0.3 36.2 0.3 79.4v864.5c0 43.2 35.4 78.6 78.7 78.6h865.9c43.3 0 78.7-35.4 78.7-78.6V79.4C1023.7 36.2 988.3 0.8 944.0 0.8z m0 943.1H79.1V79.4h865.9v864.5z m0 0' fill='%23231814'/%3E%3Cpath d='M342.8 735.7l137.8-137.5c15.7-15.7 15.7-39.3 0-55.0-15.7-15.7-39.4-15.7-55.1 0l-137.8 137.5-90.5-90.4V826.0h236.2l-90.5-90.4z m228.3-243.6c11.8 0 19.7-3.9 27.6-11.8l137.8-137.5 90.5 90.4V197.3H590.7l90.5 90.4-137.8 137.5c-15.7 15.7-15.7 39.3 0 55.0 7.9 7.9 19.7 11.8 27.5 11.8z m0 0' fill='%232d2c3b'/%3E%3C/svg%3E");}
  96. .xtiper_max.xon{background-image:url("data:image/svg+xml,%3Csvg width='600' height='600' viewBox='0 0 1024 1024' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M944.0 0.8H79.1C35.8 0.8 0.3 36.2 0.3 79.4v864.5c0 43.2 35.4 78.6 78.7 78.6h865.9c43.3 0 78.7-35.4 78.7-78.6V79.4C1023.7 36.2 988.3 0.8 944.0 0.8z m0 943.1H79.1V79.4h865.9v864.5z m0 0' fill='%23231814'/%3E%3Cpath d='M346.7 621.7l-137.8 137.5c-15.7 15.7-15.7 39.3 0 55.0 15.7 15.7 39.4 15.7 55.1 0l137.8-137.5 90.5 90.4V531.3H256.2l90.5 90.4zM787.5 197.3c-11.8 0-19.7 3.9-27.6 11.8l-137.8 137.5-90.5-90.4v235.8h236.2l-90.5-90.4 137.8-137.5c15.7-15.7 15.7-39.3 0-55.0-7.9-7.9-19.7-11.8-27.5-11.8z' fill='%232d2c3b'/%3E%3C/svg%3E");}
  97. .xtiper_times{color:#e85445;}
  98. .xtiper_pad{padding:15px;}
  99. .xtiper_tip{overflow:hidden;min-height:60px;font-size:14px;line-height:20px;}
  100. .xtiper_btn ul{display:flex;overflow:hidden;border-top:1px solid #eaeaea;background-color:#fff;text-align:center;}
  101. .xtiper_btn ul:after{clear:both;display:block;content:"";}
  102. .xtiper_btn li{position:relative;float:left;overflow:hidden;}
  103. .xtiper_btn li:after{position:absolute;top:0;right:0;display:block;overflow:hidden;width:1px;height:40px;background-color:#eaeaea;content:"";}
  104. .xtiper_btn li.xactive:after{background-color:rgba(255,255,255,.2);}
  105. .xtiper_btn1 li{float:none;width:100%;}
  106. .xtiper_btn2 li{width:50%;}
  107. .xtiper_btn3 li{width:33.3%;-webkit-box-flex:1;-ms-flex:1;flex:1;}
  108. .xtiper_btn4 li{width:25%;-webkit-box-flex:1;-ms-flex:1;flex:1;}
  109. .xtiper_btn li button{width:100%;height:40px;border:0;background-color:#fff;color:#222;font-size:14px;cursor:pointer;}
  110. .xtiper_btn li.xactive button{color:#fff;}
  111. .xtiper_btn li.xactive button{background-color:#a8a8a8;}
  112. .xtiper_btn_hello .xtiper_btnbor,.xtiper_btn_hello li.xactive button,.xtiper_btn_success .xtiper_btnbor,.xtiper_btn_success li.xactive button{background-color:#37b72c;}
  113. .xtiper_btn_error .xtiper_btnbor,.xtiper_btn_error li.xactive button{background-color:#e75445;}
  114. .xtiper_btn_ask .xtiper_btnbor,.xtiper_btn_ask li.xactive button,.xtiper_btn_warning .xtiper_btnbor,.xtiper_btn_warning li.xactive button{background-color:#f89310;}
  115. .xtiper_btn1 li.xactive button{background-color:#fff;color:#222;}
  116. .xtiper_btn li:last-child:after{display:none;}
  117. .xtiper_btn li button:hover{opacity:.9;}
  118. .xtiper_btnbor{position:relative;overflow:hidden;width:100%;height:4px;background-color:#c3c3c3;}
  119. .xtiper_btnbor:after{position:absolute;top:0;left:0;display:block;width:100%;height:4px;background-color:rgba(0,0,0,.1);content:"";}
  120. .xtiper_btn1 .xtiper_btnbor:after{display:none;}
  121. .xtiper_btn2 li:nth-child(2){opacity:.92;}
  122. .xtiper_btn3 li:nth-child(1){opacity:.84;}
  123. .xtiper_btn3 li:nth-child(2){opacity:.92;}
  124. .xtiper_btn4 li:nth-child(1){opacity:.76;}
  125. .xtiper_btn4 li:nth-child(2){opacity:.84;}
  126. .xtiper_btn4 li:nth-child(3){opacity:.92;}
  127. .xtiper_pr{position:relative;}
  128. .xtiper_content{position:relative;overflow:auto;height:100%;}
  129. .xtiper_content.xtit{height:calc(100% - 40px);}
  130. .xtiper_content.xmin{height:calc(100% - 8px);}
  131. .xtiper_over{overflow:hidden;}
  132. .xtiper_content .zw{position:absolute;top:0;left:0;display:none;overflow:hidden;width:100%;height:100%;}
  133. .xtiper_main.xon .xtiper_content .zw{display:block;}
  134. .xtiper_con{padding-top:8px;padding-bottom:12px;}
  135. .xtiper_con_icon{padding-left:42px;}
  136. .xtiper_conin{overflow-x:hidden;overflow-y:auto;max-height:400px;}
  137. .xtiper_conin::-webkit-scrollbar{width:5px;}
  138. .xtiper_conin::-webkit-scrollbar-track{border-radius:3px;background-color:#f1f1f1;}
  139. .xtiper_conin::-webkit-scrollbar-thumb{border-radius:3px;background-color:#c1c1c1;}
  140. .xtiper_loadin{position:absolute;top:50%;left:50%;z-index:2;display:block;margin-top:-17px;margin-left:-17px;width:34px;height:34px;opacity:0;transition:.1s ease-in;transition-property:opacity;}
  141. .xtiper_loadin span{position:absolute;top:36px;left:50%;margin-left:-140px;width:280px;height:24px;color:#222;text-align:center;white-space:nowrap;font-size:14px;line-height:24px;}
  142. .xtiper_win.xon .xtiper_loadin{opacity:1;transition:.2s ease-in;}
  143. .xtiper_icon{position:absolute;top:0;left:0;display:inline-block;width:34px;height:34px;background-size:100% 100%;background-repeat:no-repeat;vertical-align:middle;}
  144. .xtiper_icon img{width:34px;height:34px;}
  145. .xtiper_icon_min{position:static;top:auto;left:auto;margin-right:5px;width:20px;height:20px;transform:translateY(-1px);}
  146. .xtiper_icon_min img{width:20px;height:20px;}
  147. .xtiper_icon_success{background-image:url("data:image/svg+xml,%3Csvg width='600' height='600' viewBox='0 0 1024 1024' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M512.7 0.1C230.4 0.1 0.8 229.8 0.8 512.1c0 282.3 229.6 511.9 511.0 511.9 282.3 0 511.9-229.6 511.9-511.9C1024.6 229.8 795.0 0.1 512.7 0.1z m0 950.5c-241.8 0-438.5-196.7-438.5-438.5 0-241.8 196.7-438.5 438.5-438.5 241.7 0 438.5 196.6 438.5 438.5-0.0 241.7-196.8 438.5-438.5 438.5z' fill='%2337b72c'/%3E%3Cpath d='M754.8 337.0L470.1 630.1l-178.5-155.2c-15.8-13.7-39.7-12.0-53.4 3.7-13.7 15.8-12.0 39.7 3.7 53.4l205.2 178.4a37.7 37.7 0 0 0 10.9 6.7 37.8 37.8 0 0 0 15.9 2.7 37.9 37.9 0 0 0 15.2-3.0c0.0-0.0 0.0 0.0 0.0-0.0a37.7 37.7 0 0 0 10.4-7.7l309.4-317.5c14.6-14.0 14.3-38.9-0.7-53.5-14.0-14.6-38.9-14.3-53.5 0.7z' fill='%2337b72c'/%3E%3C/svg%3E");}
  148. .xtiper_icon_error{background-image:url("data:image/svg+xml,%3Csvg width='600' height='600' viewBox='0 0 1024 1024' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M512.7 1023.0C230.4 1023.0 0.7 794.4 0.7 512.1 0.8 229.8 230.4 0.1 512.7 0.1c282.3 0 511.9 229.6 511.9 511.0 0 282.2-229.6 511.9-511.9 511.9z m0-950.4c-241.8 0-438.5 196.6-438.5 438.5 0 241.7 196.7 438.5 438.5 438.5 241.7 0 438.5-196.7 438.5-438.5 0-241.8-196.8-438.5-438.5-438.5z m51.4 439.0l158.1-156.3c14.4-14.2 14.5-37.4 0.3-51.7-14.2-15.4-37.4-14.5-52.6-0.3l-157.4 156.5-155.9-156.4c-15.3-15.2-37.4-14.3-51.7 0-14.3 14.2-14.3 37.4 0 51.7l155.7 156.1-157.0 155.3c-14.4 14.2-14.5 37.3-0.3 51.7 7.2 7.2 16.6 10.9 25.0 10.9 9.3 0 18.6-3.6 25.8-10.6l157.2-155.5 158.4 159.0c7.2 6.2 16.6 10.7 25.0 10.7 9.3 0 18.7-4.5 25.8-10.6 14.3-14.3 14.4-37.4 0.1-51.7l-158.3-158.8z' fill='%23e75445'/%3E%3C/svg%3E");}
  149. .xtiper_icon_warning{background-image:url("data:image/svg+xml,%3Csvg width='600' height='600' viewBox='0 0 1024 1024' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M512.7 0.1C230.4 0.1 0.8 229.8 0.8 512.1c0 282.3 229.6 511.9 511.0 511.9 282.3 0 511.9-229.6 511.9-511.9C1024.6 229.8 795.0 0.1 512.7 0.1z m0 950.5c-241.8 0-438.5-196.7-438.5-438.5 0-241.8 196.7-438.5 438.5-438.5 241.7 0 438.5 196.6 438.5 438.5 0 241.7-196.8 438.5-438.5 438.5z' fill='%23f89310'/%3E%3Cpath d='M511.6 681.4c-15.5 0-28.6 5.4-39.4 16.1s-16.1 23.7-16.1 38.0c0 17.5 5.6 31.1 16.8 40.8 11.2 9.7 24.3 14.6 39.4 14.6 14.8 0 27.7-4.9 38.8-14.8 11.1-9.9 16.6-23.4 16.6-40.6 0-15.3-5.5-28.3-16.4-38.0-10.0-10.7-24.2-16.1-39.7-16.1zM514.5 232.4c-17.5 0-31.6 5.7-42.3 17.2s-16.1 27.4-16.1 47.9c0 15.0 1.1 39.8 3.3 74.3l11.8 177.0c2.2 22.9 5.9 39.0 11.1 51.2 5.2 11.2 14.4 16.8 27.7 16.8 13.1 0 22.4-5.8 28.1-17.4 5.7-11.6 9.4-28.2 11.1-49.9l15.9-182.2c1.7-16.7 2.6-33.3 2.6-49.5 0-27.6-3.6-48.7-10.7-63.4-7.2-14.7-21.3-21.0-42.5-21.0z' fill='%23f89310'/%3E%3C/svg%3E");}
  150. .xtiper_icon_ask{background-image:url("data:image/svg+xml,%3Csvg width='600' height='600' viewBox='0 0 1024 1024' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M512.7 0.1C230.4 0.1 0.8 229.8 0.8 512.1c0 282.3 229.6 511.9 511.0 511.9 282.3 0 511.9-229.6 511.9-511.9C1024.6 229.8 795.0 0.1 512.7 0.1z m0 950.5c-241.8 0-438.5-196.7-438.5-438.5 0-241.8 196.7-438.5 438.5-438.5 241.7 0 438.5 196.6 438.5 438.5 0 241.7-196.8 438.5-438.5 438.5z' fill='%23f89310'/%3E%3Cpath d='M513.9 681.3c-15.8 0-29.1 5.3-39.9 15.9-10.8 10.6-16.3 23.7-16.3 39.2 0 17.5 5.6 31.1 16.8 40.8 11.2 9.7 24.3 14.6 39.4 14.6 14.5 0 27.3-4.9 38.4-14.8 11.1-9.9 16.6-23.4 16.6-40.6 0-15.5-5.3-28.6-15.9-39.2-10.6-10.6-23.7-15.9-39.2-15.9zM617.4 252.0c-27.3-13.2-58.9-19.8-94.6-19.8-38.4 0-72.1 7.9-100.9 23.7-28.8 15.8-50.8 35.7-65.8 59.7-15.0 24.0-22.5 47.7-22.5 71.1 0 11.3 4.7 21.9 14.2 31.6 9.5 9.7 21.1 14.6 34.9 14.6 23.4 0 39.3-13.9 47.7-41.8 8.9-26.6 19.7-46.7 32.5-60.4 12.8-13.7 32.8-20.5 59.9-20.5 23.2 0 42.1 6.8 56.7 20.3 14.7 13.6 21.0 30.2 21.0 49.9 0 10.1-2.4 19.5-7.2 28.1-4.8 8.6-10.7 16.4-17.7 23.5s-18.4 17.4-34.2 31.2c-17.0 15.8-32.3 29.4-42.9 40.8-10.6 11.5-19.1 24.8-25.5 39.9-6.4 15.2-9.6 33.1-9.6 53.8 0 16.5 4.4 28.0 13.1 37.3 8.7 8.4 19.5 12.6 32.3 12.6 24.6 0 39.3-12.8 43.0-38.4 2.7-12.1 4.7-20.5 6.1-25.3 1.4-4.8 3.3-9.6 5.7-14.4 2.5-4.8 6.2-10.1 11.3-15.9 5.0-5.8 11.8-12.5 20.1-20.1 30.3-27.1 51.3-46.4 63.0-57.8 11.7-11.5 21.8-25.1 30.3-40.8 8.5-15.8 12.7-34.1 12.7-55.1 0-26.6-7.5-51.2-22.4-73.9-14.9-22.7-36.0-40.6-63.4-53.8z' fill='%23f89310'/%3E%3C/svg%3E");}
  151. .xtiper_icon_hello{background-image:url("data:image/svg+xml,%3Csvg width='600' height='600' viewBox='0 0 1024 1024' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M512.7 0.1C230.4 0.1 0.8 229.8 0.8 512.1c0 282.3 229.6 511.9 511.0 511.9 282.3 0 511.9-229.6 511.9-511.9C1024.6 229.8 795.0 0.1 512.7 0.1z m0 950.5c-241.8 0-438.5-196.7-438.5-438.5 0-241.8 196.7-438.5 438.5-438.5 241.7 0 438.5 196.6 438.5 438.5-0.0 241.7-196.8 438.5-438.5 438.5z' fill='%2337b72c'/%3E%3Cpath d='M355.5 478.0c9.8-9.7 15.2-22.5 15.2-36.2v-72.1c0-27.0-22.8-50.8-50.7-50.8-28.0 0-50.8 22.8-50.8 50.8v72.1c0 27.0 22.8 50.8 50.8 50.8 13.3 0 25.9-5.1 35.5-14.6zM706.5 615.4c-13.7-11.8-37.6-8.9-49.4 4.9-41.6 46.3-84.9 65.0-145.1 65.0-62.8 0-100.7-17.2-144.8-65.7-12.2-14.2-35.0-17.0-49.7-5.2-15.1 13.1-17.4 35.3-5.0 49.9 59.1 66.8 114.9 92.8 199.5 92.8 82.0 0 145.4-29.5 199.6-92.9 12.1-13.0 9.8-36.7-5.1-49.6zM704.0 319.8c-28.0 0-50.7 22.8-50.7 50.8v72.1c0 28.1 22.8 50.8 50.7 50.8 28.0 0 50.7-22.8 50.7-50.8v-72.1c0-27.0-22.8-50.8-50.7-50.8z' fill='%2337b72c'/%3E%3C/svg%3E");}
  152. .xtiper_icon_load{background-image:url("data:image/svg+xml,%3Csvg width='600' height='600' viewBox='0 0 1024 1024' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M979.73 513.01c-0.96-1.70-2.66-2.65-4.46-2.65h-69.90c0-84.45-26.02-162.63-70.11-227.32-0.53-0.85-0.95-1.91-1.52-2.76-4.57-6.59-9.67-11.69-14.55-19.02-1.81-2.37-3.51-4.78-5.42-7.12-7.22-8.92-14.87-17.20-22.73-25.38-0.74-0.85-1.49-1.59-2.23-2.34-25.50-26.88-56.41-49.50-89.13-67.56-0.83-0.53-1.70 0-2.55-1.49-9.35-5.10-19.02-9.77-28.89-14.13-2.44 0-4.78-2.23-7.22-3.29-8.39-3.51-15.94-6.59-25.6-8.50-4.15-1.38-8.18-2.86-12.32-4.15-7.54-2.23-15.30-4.16-23.05-6.05-5.21-1.17-10.31-2.55-15.62-3.51-2.12-0.42-3.18-1.17-6.37-1.49-7.33-1.28-14.77-2.02-22.10-2.98-2.65-0.30-4.25-0.74-7.91 0-13.28-1.27-26.45-2.23-39.63-2.23-80.51 0-159.12 24.96-226.58 72.76-21.46 15.30-26.77 45.25-11.68 67.02 15.09 21.78 44.72 27.09 66.28 11.79l3.31-0.71c52.37-36.11 112.60-55.77 176.33-54.92a329.67 329.67 0 0 1 24.64 1.24c3.29 0.32 6.59 0.85 9.99 1.27 6.37 0.85 12.75 1.70 18.00 2.97 3.83 0.75 7.65 1.70 11.37 2.66 6.16 1.48 12.20 2.92 18.16 4.68 2.87 0.85 5.64 1.91 8.50 2.86 6.90 2.34 13.70 4.78 20.39 7.54 1.49 0.64 2.98 1.38 4.46 2.02 7.86 3.47 15.51 7.11 22.94 11.15 0.32 0.21 0.64 0.32 0 0.53 25.18 14.02 48.23 31.55 68.52 51.95 0.32 0.32 0.63 0.74 0.96 0 6.27 5.31 12.32 13.06 17.95 19.97 1.17 1.48 2.34 3.08 3.51 4.56 41.22 52.16 66.07 118.12 66.07 189.93h-69.89c-1.81 0-3.51 0.96-4.46 2.65-0.96 1.70-0.74 3.72 0.21 5.21l117.38 178.24c0.96 1.38 2.44 2.33 3.19 2.33 1.70 0 3.29-0.95 3.19-2.33l117.38-178.24c0.96-1.52 1.17-3.51 0.21-5.21zM687.56 761.37l-3.30 0.71c-52.37 36.11-112.60 55.77-176.33 54.92a329.29 329.29 0 0 1-24.64-1.25c-3.29-0.32-6.59-0.85-9.99-1.27-6.37-0.85-12.75-1.70-19.00-2.97-3.83-0.74-7.65-1.70-11.36-2.66-6.17-1.48-12.20-2.92-18.16-4.67-2.87-0.85-5.64-1.91-8.50-2.87-6.90-2.33-13.70-4.78-20.39-7.54-1.49-0.64-2.98-1.38-4.46-2.02-7.86-3.47-15.51-7.11-22.94-11.15-0.32-0.21-0.64-0.32 0-0.53-25.18-14.02-48.22-31.55-68.52-51.95-0.32-0.32-0.63-0.74-0.95 0-6.27-5.31-12.32-13.06-17.95-19.97-1.17-1.49-2.35-3.08-3.51-4.56-41.21-52.16-66.07-118.12-66.07-189.93h69.89c1.81 0 3.51-0.96 4.46-2.65 0.96-1.70 0.74-3.72-0.21-5.21L168.24 327.54c-0.96-1.38-2.45-2.34-3.19-2.34-1.70 0-3.29 0.95-3.19 2.34L44.48 505.79c-0.95 1.52-1.17 3.50-0.22 5.21 0.96 1.70 2.66 2.65 4.46 2.65h69.90c0 84.45 26.02 162.63 70.11 227.32 0.53 0.85 0.95 1.91 1.52 2.76 4.57 6.59 9.67 11.69 14.55 19.02 1.81 2.37 3.51 4.78 5.42 7.12 7.22 8.92 14.87 17.20 22.73 25.38 0.74 0.85 1.49 1.59 2.23 2.34 25.50 26.87 56.41 49.50 89.13 67.55 0.83 0.53 1.70 0 2.55 1.49 9.35 5.10 19.02 9.77 28.90 14.13 2.44 0 4.78 2.23 7.22 3.29 8.39 3.51 15.94 6.59 25.60 8.50 4.14 1.38 8.18 2.87 12.32 4.15 7.54 2.23 15.30 4.16 23.05 6.05 5.21 1.17 10.30 2.55 15.62 3.50 2.12 0.42 3.19 1.17 6.37 1.49 7.33 1.28 14.77 2.02 22.10 2.97 2.66 0.30 4.25 0.75 7.91 0 13.28 1.28 26.45 2.23 39.63 2.23 80.51 0 159.12-24.96 226.58-72.76 21.45-15.30 26.77-45.26 11.68-67.02-15.08-21.78-44.72-27.09-66.28-11.79z' fill='%23333333'/%3E%3C/svg%3E");}
  153. .xtiper_icon_load{animation:revolve 1.5s infinite linear;-webkit-animation:revolve 1.5s infinite linear;}
  154. @keyframes revolve{0%{transform:rotate(0);}
  155. 100%{transform:rotate(360deg);}
  156. }
  157. @media (max-width:760px){.xtiper_msg{max-width:80%;}
  158. }
  159. @media (max-width:480px){.xtiper_msg{max-width:300px;}
  160. .xtiper_photo_ul{padding:0;}
  161. .xtiper_photo_btn{display:none;}
  162. }
  163. .xtiper_photo_li p{position:absolute;top:50%;width:100%;max-height:100%;min-height:100px;background-color:#fff;background-position:center center;background-size:contain;background-repeat:no-repeat;transform:translate(0,-50%);}
  164. .xtiper_photo_li a{position:relative;z-index:2;display:block;width:100%;height:100%;}
  165. .xtiper_photo_load{position:absolute;top:50%;left:50%;z-index:1;margin-top:-17px;margin-left:-17px;}
  166. .xtiper_photo_li img{visibility:hidden;max-width:100%;}
  167. .xtiper_photo_li.xapp img{position:relative;z-index:2;visibility:visible;width:100%;}
  168. .xtiper_photo_btn{position:absolute;top:50%;z-index:2;overflow:hidden;width:32px;height:46px;cursor:pointer;transform:translate(0,-50%);}
  169. .xtiper_photo_prev{left:16px;}
  170. .xtiper_photo_next{right:16px;}
  171. .xtiper_photo_btn:after,.xtiper_photo_btn:before{position:absolute;z-index:1;display:block;width:26px;height:4px;border-radius:4px;background-color:#666;content:"";}
  172. .xtiper_photo_btn:hover{opacity:.7;}
  173. .xtiper_photo_prev:before{top:13px;left:3px;transform:rotate(-45deg);}
  174. .xtiper_photo_prev:after{top:29px;left:3px;transform:rotate(45deg);}
  175. .xtiper_photo_next:before{top:13px;right:3px;transform:rotate(45deg);}
  176. .xtiper_photo_next:after{top:29px;right:3px;transform:rotate(-45deg);}
  177. .xtiper_photo_num{position:absolute;bottom:5px;left:50%;z-index:10;overflow:hidden;height:26px;text-align:center;font-size:13px;line-height:26px;transform:translate(-50%,0);user-select:none;-ms-user-select:none;}
  178. .xtiper_nummax{padding-left:8px;}
  179. .xtiper_nummax,.xtiper_photo_num{display:none;}
  180. .xtiper_nummax.xon,.xtiper_photo_num.xon{display:inline-block;}
  181. `;
  182. let cssResourceNode = document.createElement("style");
  183. cssResourceNode.setAttribute("type", "text/css");
  184. cssResourceNode.setAttribute("data-insert-from", "xtiper");
  185. cssResourceNode.innerHTML = cssResource;
  186. if (document.head) {
  187. document.head.append(cssResourceNode);
  188. } else if (document.documentElement) {
  189. if (document.documentElement.childNodes.length === 0) {
  190. document.documentElement.appendChild(cssResourceNode);
  191. } else {
  192. document.documentElement.insertBefore(
  193. cssResourceNode,
  194. document.documentElement.childNodes[
  195. document.documentElement.childNodes.length - 1
  196. ]
  197. );
  198. }
  199. } else {
  200. throw new Error("未找到可以插入到页面中的元素");
  201. }
  202. })();
  203.  
  204. /*
  205. * author: ovsexia
  206. * version: 2.7.1
  207. * name: Xtiper
  208. * describe: 弹层弹窗解决方案
  209. * License: Mozilla Public License Version 2.0
  210. */
  211.  
  212. !(function (window, undefined) {
  213. let Xclass = function (config) {
  214. let that = this;
  215.  
  216. //按钮失焦
  217. that.loseblur();
  218.  
  219. //客户端
  220. that.ifmob = /Android|webOS|iPhone|iPod|BlackBerry/i.test(
  221. navigator.userAgent
  222. );
  223.  
  224. //主id
  225. let rand = Math.random().toString().split(".")[1];
  226. let mainid = "xtiper_" + rand;
  227. that.mainid = mainid;
  228.  
  229. //参数配置
  230. config = that.namefix(config);
  231. that.c = config;
  232. let xcstr = "";
  233. if (
  234. typeof config.reset != "undefined" &&
  235. config.reset !== null &&
  236. config.reset === false
  237. ) {
  238. for (let key in config) {
  239. if (config[key] != null) {
  240. xcstr += config[key].toString();
  241. }
  242. }
  243. that.xcstr = that.xcstrRep(xcstr);
  244. } else {
  245. that.xcstr = xcstr;
  246. }
  247.  
  248. //关闭
  249. if (config.model == "close") {
  250. that.close(config.closeid);
  251. return false;
  252. }
  253.  
  254. //关闭
  255. if (config.model == "closeAll") {
  256. that.closeAll();
  257. return false;
  258. }
  259.  
  260. //入口
  261. that.creat();
  262. };
  263.  
  264. Xclass.pt = Xclass.prototype;
  265.  
  266. //让所有按钮失去焦点
  267. Xclass.pt.loseblur = function () {
  268. let button = document.getElementsByTagName("button");
  269. if (button.length > 0) {
  270. for (let i = 0; i < button.length; i++) {
  271. button[i].blur();
  272. }
  273. }
  274. let input = document.getElementsByTagName("input");
  275. if (input.length > 0) {
  276. for (let i = 0; i < input.length; i++) {
  277. input_type = input[i].getAttribute("type");
  278. if (input_type && (input_type == "button" || input_type == "submit")) {
  279. input[i].blur();
  280. }
  281. }
  282. }
  283. };
  284.  
  285. Xclass.pt.creat = function () {
  286. let that = this;
  287. let c = that.c;
  288.  
  289. //1.构造内部html
  290. let html = that.html();
  291. if (!html) {
  292. return false;
  293. }
  294.  
  295. //2.输出html代码到body
  296. let body = document.body;
  297. let div = document.createElement("div");
  298. div.setAttribute("id", that.mainid);
  299. div.setAttribute("class", "xtiper");
  300. div.innerHTML = html;
  301. body.appendChild(div);
  302. let xtipdiv = document.getElementById(that.mainid);
  303. that.xtipdiv = xtipdiv;
  304.  
  305. //3.添加classname、属性
  306. that.attr();
  307.  
  308. //4.添加动画效果
  309. that.on();
  310.  
  311. //5.后续处理
  312. that.after();
  313. };
  314.  
  315. //参数名称补全
  316. Xclass.pt.namefix = function (c) {
  317. //方位
  318. if (c.pos) {
  319. c.pos = c.pos.toLowerCase();
  320. if (c.pos == "t") {
  321. c.pos = "top";
  322. } else if (c.pos == "b") {
  323. c.pos = "bottom";
  324. } else if (c.pos == "l") {
  325. c.pos = "left";
  326. } else if (c.pos == "r") {
  327. c.pos = "right";
  328. } else if (c.pos == "m") {
  329. c.pos = "middle";
  330. }
  331. }
  332.  
  333. //类型
  334. if (c.type) {
  335. c.type = c.type.toLowerCase();
  336. if (c.type == "r") {
  337. c.type = "ready";
  338. } else if (c.type == "n") {
  339. c.type = "noready";
  340. } else if (c.type == "notready") {
  341. c.type = "noready";
  342. } else if (c.type == "u") {
  343. c.type = "url";
  344. } else if (c.type == "h") {
  345. c.type = "html";
  346. } else if (c.type == "p") {
  347. c.type = "photo";
  348. } else if (c.type == "w") {
  349. c.type = "white";
  350. } else if (c.type == "b") {
  351. c.type = "black";
  352. } else if (c.type == "a") {
  353. c.type = "alert";
  354. } else if (c.type == "c") {
  355. c.type = "confirm";
  356. }
  357. }
  358.  
  359. c.iconColor = "";
  360. //图标
  361. if (c.icon) {
  362. if (typeof c.icon == "object") {
  363. c.iconColor = c.icon[1];
  364. c.icon = c.icon[0];
  365. }
  366. c.icon = c.icon.toLowerCase();
  367. c.iconFlag = true;
  368. if (c.icon == "s") {
  369. c.icon = "success";
  370. } else if (c.icon == "e") {
  371. c.icon = "error";
  372. } else if (c.icon == "w") {
  373. c.icon = "warning";
  374. } else if (c.icon == "a") {
  375. c.icon = "ask";
  376. } else if (c.icon == "h") {
  377. c.icon = "hello";
  378. }
  379. if (
  380. c.icon !== "success" &&
  381. c.icon !== "error" &&
  382. c.icon !== "warning" &&
  383. c.icon !== "ask" &&
  384. c.icon !== "hello"
  385. ) {
  386. c.iconFlag = false;
  387. }
  388. }
  389.  
  390. //文字对齐
  391. if (c.align) {
  392. c.align = c.align.toLowerCase();
  393. if (c.align == "l") {
  394. c.align = "left";
  395. } else if (c.align == "c") {
  396. c.align = "center";
  397. } else if (c.align == "r") {
  398. c.align = "right";
  399. }
  400. }
  401. return c;
  402. };
  403.  
  404. //构造内部html
  405. Xclass.pt.html = function () {
  406. let that = this;
  407. let c = that.c;
  408. let xtipdiv = that.xtipdiv;
  409.  
  410. let html = "";
  411. //短消息
  412. if (c.model == "msg") {
  413. html += "<p>";
  414. if (c.icon) {
  415. html +=
  416. c.iconFlag === true
  417. ? '<i class="xtiper_icon xtiper_icon_' +
  418. c.icon +
  419. ' xtiper_icon_min"></i>'
  420. : '<img class="xtiper_icon xtiper_icon_min" src="' +
  421. c.icon +
  422. '" />';
  423. }
  424. html += c.tip + "</p>";
  425. }
  426. //弹幕
  427. else if (c.model == "danmu") {
  428. let danmuli = document.getElementsByClassName("xtiper_danmu");
  429. if (danmuli.length > 300 || document.hidden) {
  430. return false;
  431. }
  432.  
  433. html += "<p>";
  434. if (c.icon) {
  435. html +=
  436. c.iconFlag === true
  437. ? '<i class="xtiper_icon xtiper_icon_' +
  438. c.icon +
  439. ' xtiper_icon_min"></i>'
  440. : '<img class="xtiper_icon xtiper_icon_min" src="' +
  441. c.icon +
  442. '" />';
  443. }
  444. html += c.tip + "</p>";
  445. }
  446. //气泡层
  447. else if (c.model == "tips") {
  448. that.newelement = document.getElementById(c.element) || c.element;
  449. if (c.bgcolor) {
  450. html +=
  451. '<p style="background-color:' +
  452. c.bgcolor +
  453. ";" +
  454. (c.color ? " color:" + c.color + ';"' : "") +
  455. '">' +
  456. c.tip +
  457. "</p>";
  458. } else {
  459. html += "<p>" + c.tip + "</p>";
  460. }
  461. html += '<em style="background-color:' + c.bgcolor + ';"></em>';
  462. if (c.closeBtn === true) {
  463. html +=
  464. '<div class="xtiper_close xtiper_close_notit xtiper_close_notitmin"></div>';
  465. }
  466. }
  467. //弹窗层
  468. else if (c.model == "win") {
  469. if (c.type == "alert") {
  470. c.btn = c.btn != null ? c.btn : ["确定"];
  471. c.btn1 = c.btn1 != null ? c.btn1 : null;
  472. c.btn2 = null;
  473. c.btn3 = null;
  474. c.btn4 = null;
  475. } else if (c.type == "confirm") {
  476. c.btn = c.btn != null ? c.btn : ["确定", "取消"];
  477. c.btn1 = c.btn1 != null ? c.btn1 : null;
  478. c.btn2 = c.btn2 != null ? c.btn2 : null;
  479. c.btn3 = c.btn3 != null ? c.btn3 : null;
  480. c.btn4 = c.btn4 != null ? c.btn4 : null;
  481. }
  482.  
  483. xtiper_con_icon = c.icon ? " xtiper_con_icon" : "";
  484. let btnclass = new Array();
  485. btnclass[0] = c.btn1 != null ? ' class="xactive"' : "";
  486. btnclass[1] = c.btn2 != null ? ' class="xactive"' : "";
  487. btnclass[2] = c.btn3 != null ? ' class="xactive"' : "";
  488. btnclass[3] = c.btn4 != null ? ' class="xactive"' : "";
  489. if (c.btnbg && c.btnbg.length) {
  490. //自定义按钮颜色
  491. for (let i = 0; i < c.btnbg.length; i++) {
  492. btnclass[i] = c.btnbg[i] === true ? ' class="xactive"' : "";
  493. }
  494. }
  495.  
  496. let btnfun = new Array();
  497. btnfun[0] = c.btn1 || null;
  498. btnfun[1] = c.btn2 || null;
  499. btnfun[2] = c.btn3 || null;
  500. btnfun[3] = c.btn4 || null;
  501. that.btnfun = btnfun;
  502.  
  503. if (c.maxWidth) {
  504. c.width = that.maxSize(c.width, c.maxWidth);
  505. }
  506.  
  507. if (c.shade === true) {
  508. html += '<div class="xtiper_bg"></div>';
  509. }
  510. html +=
  511. '<div class="xtiper_main"' +
  512. (c.width ? 'style="width:' + c.width + ';"' : "") +
  513. ">";
  514. html +=
  515. '<div class="xtiper_tit"><p>' +
  516. c.title +
  517. '</p><div class="xtiper_minmax">';
  518. if (c.min === true) {
  519. html += '<div class="xtiper_min"></div>';
  520. }
  521. html += '<div class="xtiper_close"></div>';
  522. html += "</div></div>";
  523. let iconer = that.iconer();
  524. html +=
  525. '<div class="xtiper_pad"><div class="xtiper_pr"><div class="xtiper_tip">' +
  526. iconer +
  527. '<div class="xtiper_con' +
  528. xtiper_con_icon +
  529. '"><div class="xtiper_conin">' +
  530. c.tip;
  531. if (c.type == "alert" && c.times > 0) {
  532. c.times++;
  533. html += '(<span class="xtiper_times">' + c.times + "</span>)";
  534. }
  535. html += "</div></div></div></div></div>";
  536. html +=
  537. '<div class="xtiper_btn' +
  538. (c.icon && c.iconFlag === true ? " xtiper_btn_" + c.icon : "") +
  539. " xtiper_btn" +
  540. c.btn.length +
  541. '"><ul>';
  542.  
  543. for (let i = 0; i < 4; i++) {
  544. if (c.btn[i]) {
  545. html +=
  546. "<li" +
  547. btnclass[i] +
  548. "><button" +
  549. (btnclass[i] && c.iconColor && c.type == "confirm"
  550. ? ' style="background-color:' + c.iconColor + '"'
  551. : "") +
  552. ">" +
  553. c.btn[i] +
  554. "</button></li>";
  555. }
  556. }
  557.  
  558. html +=
  559. '</ul><div class="xtiper_btnbor"' +
  560. (c.iconColor ? ' style="background-color:' + c.iconColor + '"' : "") +
  561. "></div></div></div>";
  562. }
  563. //页面层
  564. else if (c.model == "open") {
  565. //是否已经触发过
  566. ifxoff = that.findxoff();
  567. if (ifxoff === true) {
  568. return false;
  569. }
  570.  
  571. if (c.maxWidth) {
  572. c.width = that.maxSize(c.width, c.maxWidth);
  573. }
  574. if (c.maxHeight) {
  575. c.height = that.maxSize(c.height, c.maxHeight);
  576. }
  577.  
  578. //满屏页面不能最大化
  579. if (c.width == "100%" && c.height == "100%") {
  580. c.max = false;
  581. }
  582. let width = that.getsize(c.width);
  583. let height = that.getsize(c.height) || ["", ""];
  584. if (height[1] == "%") {
  585. let bheight = (window.innerHeight * height[0]) / 100;
  586. height[0] = Math.round(bheight);
  587. height[1] = "px";
  588. }
  589. let height_css = "";
  590. if (c.title) {
  591. height_css = " xtit";
  592. } else {
  593. if (c.move === true) {
  594. height_css = " xmin";
  595. }
  596. }
  597.  
  598. let newcontent;
  599. let xtiper_over = "";
  600. if (c.over === false) {
  601. xtiper_over = " xtiper_over";
  602. }
  603. if (c.type == "ready" || c.type == "noready") {
  604. //内容
  605. let fir = c.content.substr(0, 1),
  606. element,
  607. content,
  608. reg;
  609. if (fir == "#") {
  610. element = document.getElementById(
  611. c.content.substr(1, c.content.length)
  612. );
  613. } else if (fir == ".") {
  614. element = document.getElementsByClassName(
  615. c.content.substr(1, c.content.length)
  616. )[0];
  617. } else {
  618. return false;
  619. }
  620. if (!element) {
  621. return false;
  622. }
  623. if (c.type == "ready") {
  624. content = element.outerHTML;
  625. //过滤主div标签的id
  626. regid = /\#([A-z0-9_-]*)/;
  627. content_id = c.content.match(regid);
  628. if (content_id && content_id[1]) {
  629. //reg = /\s+(id\=["']idname["'])/g;
  630. reg = new RegExp("\\s+(id\\=[\"']" + content_id[1] + "[\"'])", "g");
  631. content = content.replace(reg, "");
  632. }
  633. } else {
  634. content = element.innerHTML;
  635. reg = /\<\!\-{2}[\s\n]*([\S\s]*)[\s\n]*\-{2}\>/;
  636. let match = content.match(reg);
  637. if (!match || !match[1]) {
  638. return false;
  639. }
  640. content = match[1];
  641. }
  642. newcontent =
  643. '<div class="xtiper_content' +
  644. xtiper_over +
  645. "" +
  646. height_css +
  647. '"' +
  648. (c.bgcolor ? ' style="background-color:' + c.bgcolor + '"' : "") +
  649. ">" +
  650. content +
  651. "</div>";
  652. } else if (c.type == "url") {
  653. //页面
  654. let scrolling = "auto";
  655. if (c.over === false) {
  656. scrolling = "no";
  657. }
  658. newcontent =
  659. '<div class="xtiper_content' +
  660. height_css +
  661. ' xtiper_over"' +
  662. (c.bgcolor ? ' style="background-color:' + c.bgcolor + '"' : "") +
  663. '><div class="zw"></div><iframe parentid="' +
  664. that.mainid +
  665. '" id="' +
  666. that.mainid +
  667. '_id" name="' +
  668. that.mainid +
  669. '_name" scrolling="' +
  670. scrolling +
  671. '" allowtransparency="true" frameborder="0" src="' +
  672. c.content +
  673. '" style="width:100%; height:100%;"></iframe></div>';
  674. } else if (c.type == "html") {
  675. //html代码
  676. newcontent =
  677. '<div class="xtiper_content' +
  678. xtiper_over +
  679. "" +
  680. height_css +
  681. '"' +
  682. (c.bgcolor ? ' style="background-color:' + c.bgcolor + '"' : "") +
  683. ">" +
  684. c.content +
  685. "</div>";
  686. } else if (c.type == "photo") {
  687. //相册
  688. let img = document.getElementsByTagName("img");
  689. if (img.length == 0) {
  690. return false;
  691. }
  692. let photo = new Array();
  693. for (let i = 0; i < img.length; i++) {
  694. if (that.dataset(img[i], "xphoto") == c.content) {
  695. photo.push(img[i]);
  696. }
  697. }
  698. if (!photo || photo.length == 0) {
  699. return false;
  700. }
  701. let li =
  702. '<div class="xtiper_photo_num' +
  703. (c.iftitle === true ? " xon" : "") +
  704. '"' +
  705. (c.color ? 'style="color:' + c.color + ';"' : "") +
  706. '><span class="xtiper_words"></span><span class="xtiper_nummax' +
  707. (c.iforder === true ? " xon" : "") +
  708. '"><span class="xtiper_num">' +
  709. c.index +
  710. "</span> / " +
  711. photo.length +
  712. "</span></div>";
  713. if (photo.length > 1) {
  714. li +=
  715. '<div class="xtiper_photo_btn xtiper_photo_prev"></div><div class="xtiper_photo_btn xtiper_photo_next"></div>';
  716. }
  717. li += '<div class="xtiper_photo_ul"><ul>';
  718. let xhref, xsrc;
  719. let xindex = c.index - 1;
  720. for (let i = 0; i < photo.length; i++) {
  721. xhref = that.dataset(photo[i], "xhref")
  722. ? that.dataset(photo[i], "xhref")
  723. : "";
  724. xsrc = that.dataset(photo[i], "xsrc")
  725. ? that.dataset(photo[i], "xsrc")
  726. : photo[i].src;
  727. li +=
  728. '<li class="xtiper_photo_li' +
  729. (i == xindex ? " xon" : "") +
  730. (that.ifmob === true ? " xapp" : "") +
  731. '" data-xtitle="' +
  732. photo[i].title +
  733. '"><p style="background-image:url(\'' +
  734. xsrc +
  735. "');\">" +
  736. (xhref ? '<a href="' + xhref + '" target="_blank">' : "") +
  737. '<img src="' +
  738. xsrc +
  739. '">' +
  740. (xhref ? "</a>" : "") +
  741. (i == xindex && that.ifmob === true
  742. ? '<span class="xtiper_icon xtiper_icon_load xtiper_photo_load"></span>'
  743. : "") +
  744. "</p></li>";
  745. }
  746. li += "</ul></div>";
  747. newcontent =
  748. '<div class="xtiper_content' +
  749. xtiper_over +
  750. "" +
  751. height_css +
  752. '"' +
  753. (c.bgcolor ? ' style="background-color:' + c.bgcolor + '"' : "") +
  754. ">" +
  755. li +
  756. "</div>";
  757. }
  758.  
  759. if (c.shade === true) {
  760. html += '<div class="xtiper_bg"></div>';
  761. }
  762. if (c.app === true) {
  763. html +=
  764. '<div class="xtiper_sheet' +
  765. (that.ifmob === true && c.type == "photo" ? " xapp" : "") +
  766. '" style="height:' +
  767. height[0] +
  768. "" +
  769. height[1] +
  770. ';">';
  771. if (c.title) {
  772. html +=
  773. '<div class="xtiper_sheet_tit xtiper_sheet_left">' +
  774. c.title +
  775. "</div>";
  776. }
  777. } else {
  778. html +=
  779. '<div class="xtiper_main' +
  780. (that.ifmob === true && c.type == "photo" ? " xapp" : "") +
  781. '" style="width:' +
  782. width[0] +
  783. "" +
  784. width[1] +
  785. "; height:" +
  786. height[0] +
  787. "" +
  788. height[1] +
  789. ';">';
  790. if (c.title) {
  791. html +=
  792. '<div class="xtiper_tit' +
  793. (c.move === true ? "" : " xminmax") +
  794. '"><p>' +
  795. c.title +
  796. '</p><div class="xtiper_minmax">';
  797. if (c.min === true) {
  798. html += '<div class="xtiper_min"></div>';
  799. }
  800. if (c.max === true) {
  801. html += '<div class="xtiper_max"></div>';
  802. }
  803. if (c.closeBtn === true) {
  804. html += '<div class="xtiper_close"></div>';
  805. }
  806. html += "</div></div>";
  807. } else {
  808. if (c.move === true) {
  809. html += '<div class="xtiper_tit xtiper_tit_none"></div>';
  810. }
  811. if (c.closeBtn === true) {
  812. html +=
  813. '<div class="xtiper_close xtiper_close_notit' +
  814. (c.photoapp === true ? " xtiper_close_photoapp" : "") +
  815. '"></div>';
  816. }
  817. }
  818. }
  819. html += newcontent;
  820. html += "</div>";
  821. }
  822. //加载层
  823. else if (c.model == "load") {
  824. html =
  825. '<div class="xtiper_bg xtiper_bg_white"></div><div class="xtiper_loadin"><div class="xtiper_icon xtiper_icon_load"></div>';
  826. if (c.tip) {
  827. html += "<span>" + c.tip + "</span>";
  828. }
  829. html += "</div>";
  830. if (c.closeBtn === true) {
  831. html += '<div class="xtiper_close xtiper_close_load"></div>';
  832. }
  833. }
  834. //面板菜单
  835. else if (c.model == "sheet") {
  836. let btnfun = new Array();
  837. btnfun[0] = c.btn1 ? c.btn1 : null;
  838. btnfun[1] = c.btn2 ? c.btn2 : null;
  839. btnfun[2] = c.btn3 ? c.btn3 : null;
  840. btnfun[3] = c.btn4 ? c.btn4 : null;
  841. btnfun[4] = c.btn5 ? c.btn5 : null;
  842. btnfun[5] = c.btn6 ? c.btn6 : null;
  843. btnfun[6] = c.btn7 ? c.btn7 : null;
  844. btnfun[7] = c.btn8 ? c.btn8 : null;
  845. that.btnfun = btnfun;
  846.  
  847. let align = "xtiper_sheet_" + c.align;
  848.  
  849. html += '<div class="xtiper_bg"></div><div class="xtiper_sheet">';
  850. if (c.title) {
  851. html +=
  852. '<div class="xtiper_sheet_tit ' + align + '">' + c.title + "</div>";
  853. }
  854. html += '<ul class="xtiper_sheet_ul ' + align + '">';
  855. let licon, href, target;
  856. for (let i = 0; i < c.btn.length; i++) {
  857. if (btnfun[i]) {
  858. if (typeof btnfun[i] == "function") {
  859. licon = "<p>" + c.btn[i] + "</p>";
  860. } else {
  861. if (typeof btnfun[i] == "object") {
  862. href = btnfun[i][0];
  863. target = btnfun[i][1] ? btnfun[i][1] : "";
  864. if (target && target.substr(0, 1) != "_") {
  865. target = "_" + target;
  866. }
  867. target = ' target="' + target + '"';
  868. } else {
  869. href = btnfun[i];
  870. target = "";
  871. }
  872. licon =
  873. '<a href="' +
  874. href +
  875. '"' +
  876. target +
  877. "><p>" +
  878. c.btn[i] +
  879. "</p></a>";
  880. }
  881. } else {
  882. licon = "<p>" + c.btn[i] + "</p>";
  883. }
  884. html += '<li class="xtiper_sheet_li">' + licon + "</li>";
  885. }
  886. if (!c.force) {
  887. html +=
  888. '<li class="xtiper_sheet_li xlast"><p>' + c.btnClose + "</p></li>";
  889. }
  890. html += "</ul></div>";
  891. }
  892. return html;
  893. };
  894.  
  895. Xclass.pt.iconer = function () {
  896. let that = this;
  897. let c = that.c;
  898.  
  899. let html = "";
  900. if (c.icon) {
  901. if (c.iconFlag === true) {
  902. html = '<i class="xtiper_icon xtiper_icon_' + c.icon + '"></i>';
  903. } else {
  904. html = '<img class="xtiper_icon" src="' + c.icon + '" />';
  905. }
  906. }
  907. return html;
  908. };
  909.  
  910. Xclass.pt.findxoff = function () {
  911. let that = this;
  912. let c = that.c;
  913.  
  914. let xoff = document.getElementsByClassName("xtiper");
  915. let xoffdiv;
  916. for (let i = 0; i < xoff.length; i++) {
  917. let xcstr = that.dataset(xoff[i], "xcstr");
  918. if (xcstr && xcstr == that.xcstr) {
  919. xoffdiv = xoff[i];
  920. }
  921. }
  922.  
  923. if (xoffdiv) {
  924. that.xtipdiv = xoffdiv;
  925. that.mainid = xoffdiv.getAttribute("id");
  926. xoffdiv.style.zIndex = c.zindex;
  927. setTimeout(function () {
  928. let maincss = c.app === true ? "xtiper_sheet" : "xtiper_main";
  929. let xtiper_main = xoffdiv.getElementsByClassName(maincss)[0];
  930. let data_width = that.dataset(xoffdiv, "xwidth");
  931. let data_height = that.dataset(xoffdiv, "xheight");
  932. let xleft = (window.innerWidth - data_width) / 2;
  933. let xtop = (window.innerHeight - data_height) / 2;
  934. if (maincss == "xtiper_main") {
  935. xtiper_main.style.width = data_width + "px";
  936. xtiper_main.style.height = data_height + "px";
  937. xtiper_main.style.left = xleft + "px";
  938. xtiper_main.style.top = xtop + "px";
  939. let xtiper_min = xoffdiv.getElementsByClassName("xtiper_min")[0];
  940. let xtiper_max = xoffdiv.getElementsByClassName("xtiper_max")[0];
  941. if (xtiper_min) {
  942. xtiper_min.style.display = "";
  943. xtiper_min.classList.remove("xon");
  944. }
  945. if (xtiper_max) {
  946. xtiper_max.style.display = "";
  947. xtiper_max.classList.remove("xon");
  948. }
  949. }
  950. if (c.lock === true) {
  951. that.lock();
  952. }
  953. xoffdiv.classList.remove("xoff");
  954. }, 1);
  955. return true;
  956. } else {
  957. return false;
  958. }
  959. };
  960.  
  961. //设置data
  962. Xclass.pt.dataset = function (element, datakey, dataval) {
  963. //读取
  964. if (dataval == null) {
  965. if (element) {
  966. return element.getAttribute("data-" + datakey);
  967. }
  968. }
  969. //设置
  970. else {
  971. element.setAttribute("data-" + datakey, dataval);
  972. }
  973. };
  974.  
  975. //添加classname、属性
  976. Xclass.pt.attr = function () {
  977. let that = this;
  978. let c = that.c;
  979. let xtipdiv = that.xtipdiv;
  980.  
  981. //短消息
  982. if (c.model == "msg") {
  983. xtipdiv.classList.add("xtiper_msg");
  984. xtipdiv.classList.add("xtiper_msg_" + c.pos);
  985. xtipdiv.classList.add("xtiper_msg_" + c.type);
  986. xtipdiv.style.whiteSpace = "nowrap";
  987.  
  988. let xwidth = xtipdiv.offsetWidth;
  989. xwidth = xwidth / 2;
  990. xtipdiv.style.marginLeft = "-" + xwidth + "px";
  991. xtipdiv.style.whiteSpace = "";
  992. }
  993. //弹幕
  994. else if (c.model == "danmu") {
  995. xtipdiv.classList.add("xtiper_msg");
  996. xtipdiv.classList.add("xtiper_msg_" + c.type);
  997. xtipdiv.classList.add("xtiper_danmu");
  998.  
  999. function randomNum(n, m) {
  1000. return Math.round(Math.random() * (m - n)) + n;
  1001. }
  1002.  
  1003. let bheight = Math.round(window.innerHeight * 0.65);
  1004. let danmuTop = randomNum(10, bheight);
  1005. let bwidth = document.body.offsetWidth + 22;
  1006. xtipdiv.style.transform = "translateX(" + bwidth + "px)";
  1007. xtipdiv.style.top = danmuTop + "px";
  1008.  
  1009. let danmuli = document.getElementsByClassName("xtiper_danmu");
  1010. if (danmuli.length > 1) {
  1011. if (c.light === true) {
  1012. xtipdiv.classList.add("xtiper_danmu_light");
  1013. }
  1014. }
  1015. }
  1016. //气泡层
  1017. else if (c.model == "tips") {
  1018. xtipdiv.classList.add("xtiper_tips");
  1019. xtipdiv.classList.add("xtiper_tips_" + c.pos);
  1020. xtipdiv.style.width = xtipdiv.offsetWidth + "px";
  1021.  
  1022. //定位
  1023. let newelement = document.getElementById(c.element) || c.element;
  1024. let S = document.documentElement.scrollTop || document.body.scrollTop;
  1025. let C = newelement.getBoundingClientRect();
  1026. let W = newelement.offsetWidth;
  1027. let H = newelement.offsetHeight;
  1028. let dtop = S + C.top;
  1029. let dleft = C.left;
  1030. let B = 10;
  1031.  
  1032. if (c.pos == "left") {
  1033. let selfWidth = xtipdiv.offsetWidth;
  1034. dleft = dleft - selfWidth - B;
  1035. } else if (c.pos == "right") {
  1036. dleft = dleft + W + B;
  1037. } else if (c.pos == "top") {
  1038. let selfHeight = xtipdiv.offsetHeight;
  1039. dtop = dtop - selfHeight - B;
  1040. } else if (c.pos == "bottom") {
  1041. dtop = dtop + H + B;
  1042. }
  1043. xtipdiv.style.left = dleft + "px";
  1044. xtipdiv.style.top = dtop + "px";
  1045. }
  1046. //弹窗层
  1047. else if (c.model == "win" || c.model == "open") {
  1048. xtipdiv.classList.add("xtiper_win");
  1049. if (c.shade === true) {
  1050. xtipdiv.classList.add("xtiper_win_fixed");
  1051. }
  1052. let maincss = c.app === true ? "xtiper_sheet" : "xtiper_main";
  1053. let xtiper_main = xtipdiv.getElementsByClassName(maincss)[0];
  1054. let xtiper_tit = xtipdiv.getElementsByClassName("xtiper_tit")[0];
  1055. //原始窗口大小
  1056. that.dataset(xtipdiv, "xwidth", xtiper_main.offsetWidth);
  1057. that.dataset(xtipdiv, "xheight", xtiper_main.offsetHeight);
  1058. if (c.reset === false) {
  1059. that.dataset(xtipdiv, "xreset", 1);
  1060. }
  1061.  
  1062. if (c.model == "open" && that.xcstr) {
  1063. that.dataset(xtipdiv, "xcstr", that.xcstr);
  1064. }
  1065.  
  1066. if (c.min === true || c.max === true) {
  1067. let xmcss = "xmcss";
  1068. let y = 0;
  1069. if (c.min === true) {
  1070. y++;
  1071. }
  1072. if (c.max === true) {
  1073. y++;
  1074. }
  1075. xmcss = xmcss + y;
  1076. if (xtiper_tit) {
  1077. xtiper_tit.classList.add(xmcss);
  1078. }
  1079. }
  1080.  
  1081. let xleft, xtop;
  1082. if (c.model == "win") {
  1083. let width = that.getsize(c.width);
  1084. if (width && width[1] == "%") {
  1085. xleft = (100 - width[0]) / 2 + "%";
  1086. } else {
  1087. xleft = (window.innerWidth - xtiper_main.offsetWidth) / 2 + "px";
  1088. }
  1089. xtop = (window.innerHeight - xtiper_main.offsetHeight) / 2 + "px";
  1090. xtiper_main.style.height = xtiper_main.offsetHeight + "px";
  1091. xtiper_main.style.left = xleft;
  1092. xtiper_main.style.top = xtop;
  1093. } else if (c.model == "open") {
  1094. if (c.type == "ready") {
  1095. xtiper_main.getElementsByClassName(
  1096. "xtiper_content"
  1097. )[0].firstChild.style.display = "";
  1098. }
  1099.  
  1100. if (c.app === false) {
  1101. let width = that.getsize(c.width);
  1102.  
  1103. if (c.type == "photo" && c.autoHeight === true) {
  1104. let xindex = c.index - 1;
  1105. let imgdiv = xtipdiv
  1106. .getElementsByClassName("xtiper_photo_li")
  1107. [xindex].getElementsByTagName("img")[0];
  1108. imgdiv.onload = function () {
  1109. let img = imgdiv.offsetHeight;
  1110. img = img + 100;
  1111. if (img > window.innerHeight) {
  1112. if (c.title) {
  1113. img = window.innerHeight;
  1114. } else {
  1115. img = window.innerHeight - 26;
  1116. }
  1117. }
  1118. xtop = (window.innerHeight - img) / 2;
  1119. xtop = c.y ? xtop + c.y : xtop;
  1120. xtop = xtop + "px";
  1121. xtiper_main.style.height = img + "px";
  1122.  
  1123. if (width[1] == "%") {
  1124. xleft = (100 - width[0]) / 2;
  1125. xleft = c.x ? xleft + c.x : xleft;
  1126. xleft = xleft + width[1];
  1127. } else {
  1128. xleft = (window.innerWidth - xtiper_main.offsetWidth) / 2;
  1129. xleft = c.x ? xleft + c.x : xleft;
  1130. xleft = xleft + "px";
  1131. }
  1132. xtiper_main.style.left = xleft;
  1133. xtiper_main.style.top = xtop;
  1134. };
  1135. } else {
  1136. xtiper_main.style.height = xtiper_main.offsetHeight + "px";
  1137. xtop = (window.innerHeight - xtiper_main.offsetHeight) / 2;
  1138. xtop = c.y ? xtop + c.y : xtop;
  1139. xtop = xtop + "px";
  1140. }
  1141.  
  1142. if (width[1] == "%") {
  1143. xleft = (100 - width[0]) / 2;
  1144. xleft = c.x ? xleft + c.x : xleft;
  1145. xleft = xleft + width[1];
  1146. } else {
  1147. xleft = (window.innerWidth - xtiper_main.offsetWidth) / 2;
  1148. xleft = c.x ? xleft + c.x : xleft;
  1149. xleft = xleft + "px";
  1150. }
  1151.  
  1152. xtiper_main.style.left = xleft;
  1153. xtiper_main.style.top = xtop;
  1154. }
  1155. }
  1156.  
  1157. if (c.shade === false) {
  1158. xtiper_main.style.position = "fixed";
  1159. }
  1160. }
  1161. //加载层
  1162. else if (c.model == "load") {
  1163. xtipdiv.classList.add("xtiper_win");
  1164. xtipdiv.classList.add("xtiper_win_fixed");
  1165. }
  1166. //面板菜单
  1167. else if (c.model == "sheet") {
  1168. xtipdiv.classList.add("xtiper_win");
  1169. xtipdiv.classList.add("xtiper_win_fixed");
  1170. }
  1171.  
  1172. if (c.zindex) {
  1173. xtipdiv.style.zIndex = c.zindex;
  1174. }
  1175. };
  1176.  
  1177. //添加动画效果
  1178. Xclass.pt.on = function () {
  1179. let that = this;
  1180. let c = that.c;
  1181. let xtipdiv = that.xtipdiv;
  1182.  
  1183. setTimeout(function () {
  1184. xtipdiv.classList.add("xon");
  1185. }, 1);
  1186. };
  1187.  
  1188. //后续处理
  1189. Xclass.pt.after = function () {
  1190. let that = this;
  1191. let c = that.c;
  1192. let xtipdiv = that.xtipdiv;
  1193.  
  1194. //短消息、气泡层
  1195. if (c.model == "msg" || c.model == "tips") {
  1196. //自动关闭
  1197. that.autoClose();
  1198.  
  1199. if (c.model == "tips") {
  1200. //绑定关闭按钮及遮罩点击关闭
  1201. that.shade();
  1202. }
  1203. }
  1204. //弹幕
  1205. else if (c.model == "danmu") {
  1206. that.danmuStar();
  1207. xtipdiv.addEventListener("mouseenter", function () {
  1208. that.danmuStop();
  1209. });
  1210. xtipdiv.addEventListener("mouseleave", function () {
  1211. that.danmuStar();
  1212. });
  1213. }
  1214. //弹窗层、页面层
  1215. else if (c.model == "win" || c.model == "open") {
  1216. if (c.model == "win") {
  1217. //绑定按钮事件
  1218. let button = xtipdiv.getElementsByTagName("button");
  1219. let btnfun = that.btnfun;
  1220. for (let i = 0; i < 4; i++) {
  1221. that.bclick(button[i], btnfun[i], true);
  1222. }
  1223. }
  1224.  
  1225. //绑定最小化
  1226. if (c.min) {
  1227. let minbtn = xtipdiv.getElementsByClassName("xtiper_min")[0];
  1228. if (minbtn) {
  1229. minbtn.addEventListener("click", function () {
  1230. that.minmax("min");
  1231. });
  1232. }
  1233. }
  1234.  
  1235. //绑定最大化
  1236. if (c.max) {
  1237. let maxbtn = xtipdiv.getElementsByClassName("xtiper_max")[0];
  1238. if (maxbtn) {
  1239. maxbtn.addEventListener("click", function () {
  1240. that.minmax("max");
  1241. });
  1242. }
  1243. }
  1244.  
  1245. //绑定鼠标拖动
  1246. if (c.move === true) {
  1247. that.drag(true);
  1248. }
  1249.  
  1250. //绑定关闭按钮及遮罩点击关闭
  1251. that.shade();
  1252.  
  1253. //绑定键盘事件
  1254. if (c.model == "win" || c.model == "open") {
  1255. that.key();
  1256. }
  1257.  
  1258. //自动关闭
  1259. if (c.model == "win" && c.type == "alert" && c.times > 0) {
  1260. that.autoClose();
  1261. }
  1262.  
  1263. //相册按钮
  1264. if (c.type == "photo") {
  1265. that.photo();
  1266.  
  1267. let xindex = c.index - 1;
  1268. let li = xtipdiv.getElementsByClassName("xtiper_photo_li")[xindex];
  1269. let xtiper_words = xtipdiv.getElementsByClassName("xtiper_words")[0];
  1270. xtiper_words.innerHTML = that.dataset(li, "xtitle");
  1271. }
  1272.  
  1273. //回调函数
  1274. if (c.success && typeof c.success == "function") {
  1275. c.success(that);
  1276. }
  1277. }
  1278. //加载层
  1279. else if (c.model == "load") {
  1280. //自动关闭
  1281. that.autoClose();
  1282.  
  1283. //绑定关闭按钮
  1284. that.shade();
  1285. }
  1286. //面板菜单
  1287. else if (c.model == "sheet") {
  1288. //绑定关闭按钮及遮罩点击关闭
  1289. that.shade();
  1290. let btnfun = that.btnfun;
  1291.  
  1292. let xtipdiv_appli = xtipdiv.getElementsByClassName("xtiper_sheet_li");
  1293. let btnlen = xtipdiv_appli.length;
  1294. if (!c.force) {
  1295. btnlen = btnlen - 1;
  1296. }
  1297.  
  1298. //绑定按钮事件
  1299. for (let i = 0; i < btnlen; i++) {
  1300. that.bclick(xtipdiv_appli[i], btnfun[i]);
  1301. }
  1302.  
  1303. if (!c.force) {
  1304. xtipdiv_appli[btnlen].addEventListener("click", function () {
  1305. that.close();
  1306. if (c.end) {
  1307. c.end();
  1308. }
  1309. });
  1310. }
  1311. }
  1312.  
  1313. //锁定滚动条
  1314. that.lock();
  1315. };
  1316.  
  1317. Xclass.pt.ulli = function (li, aa, xx, yy, close) {
  1318. let that = this;
  1319. let xtipdiv = that.xtipdiv;
  1320. let xtiper_content = xtipdiv.getElementsByClassName("xtiper_content")[0];
  1321. let opacity;
  1322.  
  1323. for (let i = 0; i < li.length; i++) {
  1324. if (li[i].classList.contains("xon") === true) {
  1325. if (aa == "left") {
  1326. if (xx) {
  1327. li[i].style.left = xx + "px";
  1328. } else {
  1329. li[i].style.left = "";
  1330. }
  1331. } else {
  1332. li[i].style.left = xx + "px";
  1333. li[i].style.top = yy + "px";
  1334. opacity = 1 - ((yy / 4) * 3) / 120;
  1335. if (opacity < 0) {
  1336. opacity = 0;
  1337. }
  1338. xtiper_content.style.backgroundColor =
  1339. "rgba(0, 0, 0, " + opacity + ")";
  1340. if (close === true) {
  1341. if (yy > 120) {
  1342. that.close();
  1343. } else {
  1344. li[i].style.left = "";
  1345. li[i].style.top = "";
  1346. xtiper_content.style.backgroundColor = "rgba(0, 0, 0, 1)";
  1347. }
  1348. }
  1349. }
  1350. }
  1351. }
  1352. };
  1353.  
  1354. Xclass.pt.photo = function () {
  1355. let that = this;
  1356. let c = that.c;
  1357. let xtipdiv = that.xtipdiv;
  1358.  
  1359. let ul = xtipdiv.getElementsByClassName("xtiper_photo_ul")[0];
  1360. let li = xtipdiv.getElementsByClassName("xtiper_photo_li");
  1361. let prev = xtipdiv.getElementsByClassName("xtiper_photo_prev")[0];
  1362. let next = xtipdiv.getElementsByClassName("xtiper_photo_next")[0];
  1363.  
  1364. if (prev && li.length > 1) {
  1365. prev.addEventListener("click", function () {
  1366. that.photoBtn("prev");
  1367. });
  1368. }
  1369. if (next && li.length > 1) {
  1370. next.addEventListener("click", function () {
  1371. that.photoBtn("next");
  1372. });
  1373. }
  1374.  
  1375. //移动端
  1376. if (that.ifmob === true && li.length > 1) {
  1377. let aa = null;
  1378. let moveX1, moveX2, moveY1, moveY2, xx, yy;
  1379. ul.addEventListener("touchstart", function (e) {
  1380. moveX1 = e.changedTouches[0].pageX;
  1381. moveY1 = e.changedTouches[0].pageY;
  1382. that.touchmove(false);
  1383. });
  1384.  
  1385. ul.addEventListener("touchmove", function (e) {
  1386. moveX2 = e.changedTouches[0].pageX;
  1387. moveY2 = e.changedTouches[0].pageY;
  1388. xx = moveX2 - moveX1;
  1389. yy = moveY2 - moveY1;
  1390. if (Math.abs(xx) > Math.abs(yy)) {
  1391. aa = aa ? aa : "left";
  1392. } else {
  1393. aa = aa ? aa : "top";
  1394. }
  1395. that.ulli(li, aa, xx, yy);
  1396. });
  1397.  
  1398. ul.addEventListener("touchend", function (e) {
  1399. if (moveX1 > moveX2) {
  1400. if (moveX1 - moveX2 > 40 && aa == "left") {
  1401. that.photoBtn("next");
  1402. }
  1403. } else {
  1404. if (moveX2 - moveX1 > 40 && aa == "left") {
  1405. that.photoBtn("prev");
  1406. }
  1407. }
  1408. that.ulli(li, aa, "", yy, true);
  1409. aa = null;
  1410. });
  1411.  
  1412. ul.addEventListener("click", function (e) {
  1413. that.close();
  1414. });
  1415. } else {
  1416. ul.addEventListener("touchstart", function (e) {
  1417. return false;
  1418. });
  1419.  
  1420. ul.addEventListener("touchend", function (e) {
  1421. return false;
  1422. });
  1423.  
  1424. ul.addEventListener("click", function (e) {
  1425. return false;
  1426. });
  1427. }
  1428. };
  1429.  
  1430. Xclass.pt.photoBtn = function (type) {
  1431. let that = this;
  1432. let c = that.c;
  1433. let xtipdiv = that.xtipdiv;
  1434.  
  1435. let li = xtipdiv.getElementsByClassName("xtiper_photo_li");
  1436. let xtiper_main = xtipdiv.getElementsByClassName("xtiper_main")[0];
  1437. if (xtiper_main.classList.contains("xtiper_main_photo") === true) {
  1438. return false;
  1439. }
  1440. xtiper_main.classList.add("xtiper_main_photo");
  1441. let index = 0,
  1442. old = 0;
  1443. for (let i = 0; i < li.length; i++) {
  1444. if (li[i].classList.contains("xon") === true) {
  1445. index = old = i;
  1446. }
  1447. }
  1448. if (type == "prev") {
  1449. index--;
  1450. if (index < 0) {
  1451. index = li.length - 1;
  1452. }
  1453. } else if (type == "next") {
  1454. index++;
  1455. if (index > li.length - 1) {
  1456. index = 0;
  1457. }
  1458. }
  1459.  
  1460. that.now = index;
  1461.  
  1462. let xnum = index + 1;
  1463. let xtiper_num = xtiper_main.getElementsByClassName("xtiper_num")[0];
  1464. xtiper_num.innerHTML = xnum;
  1465. let xtiper_words = xtiper_main.getElementsByClassName("xtiper_words")[0];
  1466.  
  1467. let img;
  1468. for (let i = 0; i < li.length; i++) {
  1469. if (i == index) {
  1470. li[i].classList.add("xon");
  1471. xtiper_words.innerHTML = that.dataset(li[i], "xtitle");
  1472. xtiper_num.innerHTML = xnum;
  1473. if (c.autoHeight === true) {
  1474. img = li[i].getElementsByTagName("img")[0].offsetHeight;
  1475. img = img + 100;
  1476. if (img > window.innerHeight) {
  1477. if (c.title) {
  1478. img = window.innerHeight;
  1479. } else {
  1480. img = window.innerHeight - 26;
  1481. }
  1482. }
  1483. xtiper_main.style.height = img + "px";
  1484. xtiper_main.style.top = (window.innerHeight - img) / 2 + "px";
  1485. }
  1486. } else {
  1487. li[i].classList.remove("xon");
  1488. }
  1489. if (i == old) {
  1490. li[i].classList.add("xold_" + type);
  1491. } else {
  1492. li[i].classList.remove("xold_prev");
  1493. li[i].classList.remove("xold_next");
  1494. }
  1495. }
  1496. setTimeout(function () {
  1497. li[old].classList.remove("xold_" + type);
  1498. xtiper_main.classList.remove("xtiper_main_photo");
  1499. }, 401);
  1500. };
  1501.  
  1502. Xclass.pt.appScroll = function (e) {
  1503. e.preventDefault();
  1504. };
  1505.  
  1506. Xclass.pt.touchmove = function (type) {
  1507. let that = this;
  1508.  
  1509. if (type === false) {
  1510. document.body.addEventListener("touchmove", that.appScroll, {
  1511. passive: false,
  1512. });
  1513. } else {
  1514. document.body.removeEventListener("touchmove", that.appScroll, {
  1515. passive: false,
  1516. });
  1517. }
  1518. };
  1519.  
  1520. Xclass.pt.xcstrRep = function (str) {
  1521. str = str.replace(/[\s\n\r]/g, ""); //空格换行回车
  1522. str = encodeURIComponent(str).toLowerCase();
  1523.  
  1524. let reparr = [
  1525. [/true/g, "1"],
  1526. [/false/g, "0"],
  1527. [/%/g, ""],
  1528. [/\(/g, ""],
  1529. [/\)/g, ""],
  1530. [/open/g, "o"],
  1531. [/ready/g, "r"],
  1532. [/noready/g, "n"],
  1533. [/url/g, "u"],
  1534. [/html/g, "h"],
  1535. [/photo/g, "p"],
  1536. [/function/g, "f"],
  1537. [/99999/g, "9"],
  1538. ];
  1539. for (let i = 0; i < reparr.length; i++) {
  1540. str = str.replace(reparr[i][0], reparr[i][1]);
  1541. }
  1542.  
  1543. return str;
  1544. };
  1545.  
  1546. Xclass.pt.maxSize = function (oldval, newval) {
  1547. let that = this;
  1548.  
  1549. let oldsize = that.getsize(oldval) || "";
  1550. let newsize = that.getsize(newval);
  1551. if (oldsize && oldsize[1] == "px" && newsize[1] == "%") {
  1552. if (oldsize[0] > window.innerWidth) {
  1553. return (newsize[0] > 100 ? 100 : newsize[0]) + "%";
  1554. } else {
  1555. return oldval;
  1556. }
  1557. } else {
  1558. return oldval;
  1559. }
  1560. };
  1561.  
  1562. //弹幕开始
  1563. Xclass.pt.danmuStar = function () {
  1564. let that = this;
  1565. let c = that.c;
  1566. let xtipdiv = that.xtipdiv;
  1567.  
  1568. xtipdiv.classList.add("xtiper_danmu_animate");
  1569. if (xtipdiv.style.animationDuration == "") {
  1570. xtipdiv.style.animationDuration = "6s";
  1571. }
  1572.  
  1573. let danmutime = Number(xtipdiv.style.animationDuration.replace(/s/, ""));
  1574. that.dataset(xtipdiv, "xdanmu", danmutime);
  1575.  
  1576. that.outtime = setTimeout(function () {
  1577. that.close();
  1578. }, danmutime * 1000 + 1);
  1579. };
  1580.  
  1581. //弹幕停止
  1582. Xclass.pt.danmuStop = function () {
  1583. let that = this;
  1584. let c = that.c;
  1585. let xtipdiv = that.xtipdiv;
  1586.  
  1587. let bwidth = document.body.offsetWidth + 22;
  1588. let newtranslate = xtipdiv.getBoundingClientRect().left;
  1589. xtipdiv.style.transform = "translateX(" + newtranslate + "px)";
  1590.  
  1591. if (that.outtime) {
  1592. clearInterval(that.outtime);
  1593. that.outtime = null;
  1594. }
  1595.  
  1596. let progress = newtranslate / bwidth;
  1597. let lesstime = 6 * progress;
  1598. if (lesstime < 0.4) {
  1599. lesstime = 0.4;
  1600. }
  1601. that.dataset(xtipdiv, "xdanmu", lesstime);
  1602. xtipdiv.style.animationDuration = lesstime + "s";
  1603. xtipdiv.classList.remove("xtiper_danmu_animate");
  1604. };
  1605.  
  1606. //绑定按钮事件
  1607. Xclass.pt.bclick = function (btn, fun, ifclose) {
  1608. let that = this;
  1609.  
  1610. if (btn) {
  1611. if (fun && typeof fun == "function") {
  1612. btn.addEventListener("click", function () {
  1613. fun();
  1614. that.close();
  1615. });
  1616. } else {
  1617. if (ifclose === true) {
  1618. btn.addEventListener("click", function () {
  1619. that.close();
  1620. });
  1621. }
  1622. }
  1623. }
  1624. };
  1625.  
  1626. //自动关闭
  1627. Xclass.pt.autoClose = function () {
  1628. let that = this;
  1629. let c = that.c;
  1630. let xtipdiv = that.xtipdiv;
  1631.  
  1632. //倒计时
  1633. if (xtipdiv.getElementsByClassName("xtiper_times")[0]) {
  1634. let times = c.times - 1;
  1635. let i = times;
  1636. let fn = function () {
  1637. xtiper_times = xtipdiv.getElementsByClassName("xtiper_times")[0];
  1638. xtiper_times.innerHTML = i;
  1639. if (i <= 0) {
  1640. that.close();
  1641. clearInterval(that.timer);
  1642. that.timer = null;
  1643. }
  1644. i--;
  1645. };
  1646. that.timer = setInterval(fn, 1000);
  1647. fn();
  1648. } else {
  1649. let times = c.times;
  1650. if (times && times != 0) {
  1651. setTimeout(function () {
  1652. that.close();
  1653. }, times * 1000);
  1654. }
  1655. }
  1656. };
  1657.  
  1658. //锁定滚动条
  1659. Xclass.pt.lock = function () {
  1660. let that = this;
  1661. let c = that.c;
  1662. let xtipdiv = that.xtipdiv;
  1663.  
  1664. if (c.lock === true) {
  1665. that.dataset(xtipdiv, "xlock", 1);
  1666. document.documentElement.style.overflowY = "hidden";
  1667. that.touchmove(false);
  1668. }
  1669. };
  1670.  
  1671. //解除锁定滚动条
  1672. Xclass.pt.unlock = function () {
  1673. let that = this;
  1674. let flag = 0;
  1675. let winli = document.getElementsByClassName("xtiper_win");
  1676.  
  1677. for (let i = 0; i < winli.length; i++) {
  1678. if (
  1679. that.dataset(winli[i], "xlock") == 1 &&
  1680. winli[i].classList.contains("xoff") === false
  1681. ) {
  1682. flag++;
  1683. }
  1684. if (
  1685. winli[i].classList.contains("xoff") === true &&
  1686. winli[i].getAttribute("id") == that.mainid
  1687. ) {
  1688. flag++;
  1689. }
  1690. }
  1691. if (flag <= 1) {
  1692. document.documentElement.style.overflowY = "";
  1693. }
  1694. that.touchmove(true);
  1695. };
  1696.  
  1697. //绑定最大化、最小化
  1698. Xclass.pt.minmax = function (mtype, act) {
  1699. let that = this;
  1700. let c = that.c;
  1701. let xtipdiv = that.xtipdiv;
  1702.  
  1703. let iftype, setwidth, setheight;
  1704. if (mtype == "min") {
  1705. iftype = that.dataset(xtipdiv, "xmin");
  1706. setwidth = "190px";
  1707. setheight = "40px";
  1708. } else if (mtype == "max") {
  1709. iftype = that.dataset(xtipdiv, "xmax");
  1710. setwidth = "100%";
  1711. setheight = "100%";
  1712. }
  1713.  
  1714. let xtiper_tit = xtipdiv.getElementsByClassName("xtiper_tit")[0];
  1715. let xtiper_main = xtipdiv.getElementsByClassName("xtiper_main")[0];
  1716. let xtiper_content = xtipdiv.getElementsByClassName("xtiper_content")[0];
  1717. let minbtn = xtipdiv.getElementsByClassName("xtiper_min")[0];
  1718. let maxbtn = xtipdiv.getElementsByClassName("xtiper_max")[0];
  1719. let xtiper_bg = xtipdiv.getElementsByClassName("xtiper_bg")[0];
  1720.  
  1721. if (iftype == 1 || act == 1) {
  1722. //还原
  1723. xtiper_main.style.width = that.dataset(xtipdiv, "xwidth") + "px";
  1724. xtiper_main.style.height = that.dataset(xtipdiv, "xheight") + "px";
  1725. let data_width = xtiper_main.offsetWidth;
  1726. let data_height = xtiper_main.offsetHeight;
  1727. let xleft = (window.innerWidth - data_width) / 2;
  1728. let xtop = (window.innerHeight - data_height) / 2;
  1729. xtiper_main.style.left = xleft + "px";
  1730. xtiper_main.style.top = xtop + "px";
  1731. xtiper_tit.classList.remove("xminmax");
  1732. xtiper_tit.classList.remove("xmin");
  1733. xtiper_tit.getElementsByTagName("p")[0].setAttribute("title", "");
  1734. that.dataset(xtipdiv, "xmin", "");
  1735. that.dataset(xtipdiv, "xmax", "");
  1736. if (minbtn) {
  1737. minbtn.classList.remove("xon");
  1738. minbtn.style.display = "";
  1739. }
  1740. if (maxbtn) {
  1741. maxbtn.classList.remove("xon");
  1742. maxbtn.style.display = "";
  1743. }
  1744. that.drag(true);
  1745.  
  1746. //最小化还原遮罩
  1747. if (
  1748. (c.model == "win" || c.model == "open") &&
  1749. c.shade === true &&
  1750. c.min === true
  1751. ) {
  1752. xtipdiv.classList.add("xtiper_win_fixed");
  1753. xtiper_bg.classList.remove("xmin");
  1754. xtiper_main.style.position = "";
  1755. }
  1756. } else {
  1757. //变形
  1758. xtiper_main.style.width = setwidth;
  1759. xtiper_main.style.height = setheight;
  1760. xtiper_tit.classList.add("xminmax");
  1761.  
  1762. if (mtype == "min") {
  1763. xtiper_tit.classList.add("xmin");
  1764. xtiper_tit
  1765. .getElementsByTagName("p")[0]
  1766. .setAttribute(
  1767. "title",
  1768. xtiper_tit.getElementsByTagName("p")[0].innerHTML
  1769. );
  1770. that.dataset(xtipdiv, "xmin", 1);
  1771. xtiper_main.style.top = "auto";
  1772. xtiper_main.style.bottom = "0";
  1773. xtiper_main.style.left = "0";
  1774. minbtn.classList.add("xon");
  1775. if (maxbtn) {
  1776. maxbtn.style.display = "none";
  1777. }
  1778.  
  1779. //最小化关闭遮罩
  1780. if (
  1781. (c.model == "win" || c.model == "open") &&
  1782. c.shade === true &&
  1783. c.min === true
  1784. ) {
  1785. xtipdiv.classList.remove("xtiper_win_fixed");
  1786. xtiper_bg.classList.add("xmin");
  1787. xtiper_main.style.position = "fixed";
  1788. }
  1789. } else if (mtype == "max") {
  1790. that.dataset(xtipdiv, "xmax", 1);
  1791. xtiper_main.style.top = "0";
  1792. xtiper_main.style.left = "0";
  1793. maxbtn.classList.add("xon");
  1794. if (minbtn) {
  1795. minbtn.style.display = "none";
  1796. }
  1797. }
  1798. that.drag(false);
  1799. }
  1800. };
  1801.  
  1802. //绑定鼠标拖动
  1803. Xclass.pt.drag = function (open) {
  1804. let that = this;
  1805. let c = that.c;
  1806. let xtipdiv = that.xtipdiv;
  1807.  
  1808. let drag = xtipdiv.getElementsByClassName("xtiper_tit")[0];
  1809. if (!drag) {
  1810. return false;
  1811. }
  1812. let drag_main = xtipdiv.getElementsByClassName("xtiper_main")[0];
  1813.  
  1814. if (open === true) {
  1815. drag.onmousedown = function (event) {
  1816. //允许3/4的区域拖动到页面外
  1817. let overX = (drag_main.offsetWidth / 4) * 3;
  1818. let overY = (drag_main.offsetHeight / 4) * 3;
  1819.  
  1820. drag_main.classList.add("xon");
  1821. event = event || window.event;
  1822. let diffX = event.clientX - drag_main.offsetLeft;
  1823. let diffY = event.clientY - drag_main.offsetTop;
  1824. if (typeof drag_main.setCapture !== "undefined") {
  1825. drag_main.setCapture();
  1826. }
  1827. document.onmousemove = function (event) {
  1828. event = event || window.event;
  1829. let moveX = event.clientX - diffX;
  1830. let moveY = event.clientY - diffY;
  1831. if (moveX < -overX) {
  1832. moveX = -overX;
  1833. } else if (
  1834. moveX >
  1835. document.body.offsetWidth - drag_main.offsetWidth + overX
  1836. ) {
  1837. moveX = document.body.offsetWidth - drag_main.offsetWidth + overX;
  1838. }
  1839. if (moveY < 0) {
  1840. moveY = 0;
  1841. } else if (
  1842. moveY >
  1843. window.innerHeight - drag_main.offsetHeight + overY
  1844. ) {
  1845. moveY = window.innerHeight - drag_main.offsetHeight + overY;
  1846. }
  1847. drag_main.style.left = moveX + "px";
  1848. drag_main.style.top = moveY + "px";
  1849. };
  1850. document.onmouseup = function (event) {
  1851. drag_main.classList.remove("xon");
  1852. this.onmousemove = null;
  1853. this.onmouseup = null;
  1854. //修复低版本ie bug
  1855. if (typeof drag_main.releaseCapture != "undefined") {
  1856. drag_main.releaseCapture();
  1857. }
  1858. };
  1859. };
  1860. } else {
  1861. drag.onmousedown = function (event) {
  1862. return false;
  1863. document.onmousemove = function (event) {
  1864. return false;
  1865. };
  1866. document.onmouseup = function (event) {
  1867. return false;
  1868. };
  1869. };
  1870. }
  1871. };
  1872.  
  1873. //绑定关闭按钮及遮罩点击关闭
  1874. Xclass.pt.shade = function () {
  1875. let that = this;
  1876. let c = that.c;
  1877. let xtipdiv = that.xtipdiv;
  1878.  
  1879. let close = xtipdiv.getElementsByClassName("xtiper_close")[0];
  1880. if (close) {
  1881. close.addEventListener("click", function () {
  1882. that.close();
  1883. if (c.end && typeof c.end == "function") {
  1884. c.end();
  1885. }
  1886. });
  1887. }
  1888.  
  1889. if (c.shadeClose) {
  1890. let bg = xtipdiv.getElementsByClassName("xtiper_bg")[0];
  1891. bg.addEventListener("click", function () {
  1892. if (c.model == "sheet" && c.force) {
  1893. xtip.msg(c.force);
  1894. return false;
  1895. } else {
  1896. that.close();
  1897. if (c.end && typeof c.end == "function") {
  1898. c.end();
  1899. }
  1900. }
  1901. });
  1902. }
  1903. };
  1904.  
  1905. //键盘事件
  1906. Xclass.pt.key = function () {
  1907. let that = this;
  1908. let c = that.c;
  1909. let xtipdiv = that.xtipdiv;
  1910.  
  1911. document.onkeydown = function (event) {
  1912. let e = event || window.event || arguments.callee.caller.arguments[0];
  1913. if (e) {
  1914. if (e.keyCode == 27) {
  1915. //按 Esc
  1916. that.close();
  1917. } else if (e.keyCode == 13) {
  1918. //按 Enter
  1919. if (c.model == "win") {
  1920. //多按钮取消回车事件
  1921. if (c.btn2 || c.btn3) {
  1922. return false;
  1923. }
  1924. that.close();
  1925. if (c.btn1 && typeof c.btn1 == "function") {
  1926. c.btn1();
  1927. c.btn1 = null;
  1928. }
  1929. return false;
  1930. }
  1931. } else {
  1932. return e;
  1933. }
  1934. }
  1935. };
  1936. };
  1937.  
  1938. /*
  1939. * 关闭层
  1940. * 关闭层id
  1941. * 是否检查锁定层 checkLock
  1942. */
  1943. Xclass.pt.close = function (closeid) {
  1944. let that = this;
  1945. let c = that.c;
  1946. let checkLock = false;
  1947. let xtipdiv = null;
  1948.  
  1949. if (closeid) {
  1950. xtipdiv = document.getElementById(closeid);
  1951. if (!xtipdiv) {
  1952. return false;
  1953. }
  1954. if (that.dataset(xtipdiv, "xlock") == 1) {
  1955. checkLock = true;
  1956. }
  1957. } else {
  1958. xtipdiv = that.xtipdiv;
  1959. if (c.lock === true) {
  1960. checkLock = true;
  1961. }
  1962. }
  1963.  
  1964. if (!xtipdiv) {
  1965. return false;
  1966. }
  1967.  
  1968. //弹幕类型不用延时
  1969. let closenow = false;
  1970. if (xtipdiv.classList.contains("xtiper_danmu") === true) {
  1971. closenow = true;
  1972. } else {
  1973. closenow = false;
  1974. }
  1975.  
  1976. //不用延时关闭
  1977. if (closenow === true) {
  1978. let parent_xtipdiv = xtipdiv.parentNode;
  1979. if (parent_xtipdiv) {
  1980. parent_xtipdiv.removeChild(xtipdiv);
  1981. }
  1982. } else {
  1983. if (that.dataset(xtipdiv, "xreset") == 1) {
  1984. xtipdiv.classList.add("xoff");
  1985. if (c.lock === true) {
  1986. that.unlock();
  1987. }
  1988. setTimeout(function () {
  1989. xtipdiv.style.zIndex = "-99999";
  1990. if (c.min === true) {
  1991. that.minmax("min", 1);
  1992. }
  1993. if (c.max === true) {
  1994. that.minmax("max", 1);
  1995. }
  1996. if (c.model == "open" && c.type == "photo") {
  1997. if (that.ifmob === true) {
  1998. let xtiper_content =
  1999. xtipdiv.getElementsByClassName("xtiper_content")[0];
  2000. xtiper_content.style.backgroundColor = "rgba(0, 0, 0, 1)";
  2001. }
  2002. let li = xtipdiv.getElementsByClassName("xtiper_photo_li");
  2003. if (li.length > 0) {
  2004. for (let i = 0; i < li.length; i++) {
  2005. li[i].style.left = "";
  2006. li[i].style.top = "";
  2007. }
  2008. }
  2009. }
  2010. }, 201);
  2011. } else {
  2012. xtipdiv.classList.remove("xon");
  2013. setTimeout(function () {
  2014. let parent_xtipdiv = xtipdiv.parentNode;
  2015. if (parent_xtipdiv) {
  2016. parent_xtipdiv.removeChild(xtipdiv);
  2017. }
  2018. }, 201);
  2019. }
  2020. }
  2021.  
  2022. //关闭层有锁定属性的才执行解除锁定
  2023. if (checkLock === true) {
  2024. that.unlock();
  2025. }
  2026. };
  2027.  
  2028. /*
  2029. * 关闭所有层
  2030. */
  2031. Xclass.pt.closeAll = function () {
  2032. let that = this;
  2033.  
  2034. let msgall = document.getElementsByClassName("xtiper");
  2035. if (msgall.length <= 0) {
  2036. return false;
  2037. }
  2038. for (let i = 0; i < msgall.length; i++) {
  2039. that.close(msgall[i].getAttribute("id"));
  2040. }
  2041. document.documentElement.style.overflowY = "";
  2042. that.touchmove(true);
  2043. };
  2044.  
  2045. //单位处理
  2046. Xclass.pt.getsize = function (size) {
  2047. if (size) {
  2048. reg = /([0-9]+)(px|\%)/;
  2049. size_arr = size.match(reg);
  2050. arr = new Array();
  2051. arr[0] = Number(size_arr[1]);
  2052. arr[1] = size_arr[2];
  2053. return arr;
  2054. }
  2055. };
  2056.  
  2057. //设置高度
  2058. Xclass.pt.setSize = function (type, px) {
  2059. let that = this;
  2060. let c = that.c;
  2061. if (c.model == "open") {
  2062. let xtipdiv = that.xtipdiv;
  2063. let xtiper_main = xtipdiv.getElementsByClassName("xtiper_main")[0];
  2064. px = parseInt(px);
  2065. if (type == "height") {
  2066. let xtop = (window.innerHeight - px) / 2;
  2067. xtiper_main.style.height = px + "px";
  2068. xtiper_main.style.top = xtop + "px";
  2069. }
  2070. }
  2071. };
  2072.  
  2073. //设置高度
  2074. Xclass.pt.setHeight = function (px) {
  2075. let that = this;
  2076. that.setSize("height", px);
  2077. };
  2078.  
  2079. window.xtip = {
  2080. ver: "2.7.1",
  2081.  
  2082. msg: function (tip, config) {
  2083. if (!tip) {
  2084. return false;
  2085. }
  2086. config = config || {};
  2087. let o = {};
  2088. o.model = "msg";
  2089. o.tip = tip;
  2090. o.times = config.times || 2;
  2091. o.type = config.type || "black";
  2092. o.pos = config.pos || "middle";
  2093. o.icon = config.icon || "";
  2094. o.zindex = config.zindex || 99999;
  2095.  
  2096. return this.run(o);
  2097. },
  2098.  
  2099. danmu: function (tip, config) {
  2100. if (!tip) {
  2101. return false;
  2102. }
  2103. config = config || {};
  2104. let o = {};
  2105. o.model = "danmu";
  2106. o.tip = tip;
  2107. o.type = config.type || "black";
  2108. o.icon = config.icon || "";
  2109. o.light = config.light != null ? config.light : false;
  2110. o.zindex = config.zindex || 99999;
  2111.  
  2112. return this.run(o);
  2113. },
  2114.  
  2115. tips: function (tip, element, config) {
  2116. if (!tip || !element) {
  2117. return false;
  2118. }
  2119. config = config || {};
  2120. let o = {};
  2121. o.model = "tips";
  2122. o.tip = tip;
  2123. if (typeof element == "string") {
  2124. let fir = element.substr(0, 1);
  2125. if (fir == "#") {
  2126. element = element.substr(1, element.length);
  2127. }
  2128. }
  2129. o.element = element;
  2130. o.bgcolor = config.bgcolor || "#000000";
  2131. if (config.color) {
  2132. o.color = config.color;
  2133. } else {
  2134. let reg = /rgba\((255\,){3}[0-9.]+/;
  2135. let rgba = reg.test(o.bgcolor);
  2136. if (
  2137. o.bgcolor == "#fff" ||
  2138. o.bgcolor == "#ffffff" ||
  2139. o.bgcolor == "white" ||
  2140. o.bgcolor == "rgb(255, 255, 255)" ||
  2141. o.bgcolor == "rgba(255, 255, 255)" ||
  2142. rgba === true
  2143. ) {
  2144. o.color = "#333333";
  2145. } else {
  2146. o.color = "#ffffff";
  2147. }
  2148. }
  2149. o.times = config.times || 2;
  2150. o.pos = config.pos || "right";
  2151. o.closeBtn = config.closeBtn || false;
  2152. o.zindex = config.zindex || 99999;
  2153.  
  2154. return this.run(o);
  2155. },
  2156.  
  2157. alert: function (tip, config) {
  2158. config = config || {};
  2159. let o = {};
  2160. o.type = "alert";
  2161. o.tip = tip || "";
  2162. o.icon = config.icon || "";
  2163. o.title = config.title || "提示";
  2164. if (config.btn) {
  2165. o.btn = typeof config.btn == "string" ? [config.btn] : [config.btn[0]];
  2166. } else {
  2167. o.btn = ["确定"];
  2168. }
  2169. o.btn1 = config.btn1 != null ? config.btn1 : null;
  2170. o.btnbg = [];
  2171. o.times = config.times || 0;
  2172. o.shade = config.shade != null ? config.shade : true;
  2173. if (o.shade === true) {
  2174. o.shadeClose = config.shadeClose != null ? config.shadeClose : true;
  2175. } else {
  2176. o.shadeClose = false;
  2177. }
  2178.  
  2179. return this.win(o);
  2180. },
  2181.  
  2182. confirm: function (tip, config) {
  2183. config = config || {};
  2184. let o = {};
  2185. o.type = "confirm";
  2186. o.tip = tip || "";
  2187. o.icon = config.icon || "warning";
  2188. o.title = config.title || "警告";
  2189. o.btn = config.btn || ["确定", "取消"];
  2190. if (o.btn && o.btn.length > 2) {
  2191. let newbtn = [];
  2192. for (let i = 0; i < 2; i++) {
  2193. newbtn.push(o.btn[i]);
  2194. }
  2195. o.btn = newbtn;
  2196. }
  2197. o.btn1 = config.btn1 != null ? config.btn1 : null;
  2198. o.btn2 = config.btn2 != null ? config.btn2 : null;
  2199. o.btnbg = [true, false];
  2200. o.shade = config.shade != null ? config.shade : true;
  2201. if (o.shade === true) {
  2202. o.shadeClose = config.shadeClose != null ? config.shadeClose : true;
  2203. } else {
  2204. o.shadeClose = false;
  2205. }
  2206.  
  2207. return this.win(o);
  2208. },
  2209.  
  2210. win: function (config) {
  2211. if (!config) {
  2212. return false;
  2213. }
  2214. let o = {};
  2215. o.model = "win";
  2216. o.tip = config.tip || "";
  2217. o.times = config.times || 0;
  2218. o.type = config.type || "confirm";
  2219. o.icon = config.icon || "";
  2220. o.title = config.title || "提示";
  2221. o.shade = config.shade != null ? config.shade : true;
  2222. if (o.shade === true) {
  2223. o.shadeClose = config.shadeClose != null ? config.shadeClose : true;
  2224. } else {
  2225. o.shadeClose = false;
  2226. }
  2227. o.lock = config.lock || false;
  2228. o.btn = config.btn || null;
  2229. if (o.btn && o.btn.length > 4) {
  2230. let newbtn = [];
  2231. for (let i = 0; i < 4; i++) {
  2232. newbtn.push(o.btn[i]);
  2233. }
  2234. o.btn = newbtn;
  2235. }
  2236. o.btn1 = config.btn1 != null ? config.btn1 : null;
  2237. o.btn2 = config.btn2 != null ? config.btn2 : null;
  2238. o.btn3 = config.btn3 != null ? config.btn3 : null;
  2239. o.btn4 = config.btn4 != null ? config.btn4 : null;
  2240. o.btnbg = config.btnbg || [];
  2241. o.width = config.width || "";
  2242. o.maxWidth = config.maxWidth || "";
  2243. o.end = typeof config.end == "function" ? config.end : null;
  2244. o.min = config.min != null ? config.min : false;
  2245. o.move = true;
  2246. o.app = false;
  2247. o.zindex = config.zindex || 99999;
  2248. o.success = config.success || null;
  2249.  
  2250. return this.run(o);
  2251. },
  2252.  
  2253. photo: function (content, config) {
  2254. if (!content) {
  2255. return false;
  2256. }
  2257. config = config || {};
  2258. let o = {};
  2259. o.type = "photo";
  2260. o.title = config.title || "";
  2261. o.autoHeight = config.height ? false : true;
  2262. o.width = config.width || "600px";
  2263. o.height = config.height || "400px";
  2264. o.content = content;
  2265. o.app = config.app != null ? config.app : false;
  2266. o.lock = true;
  2267. o.reset = true;
  2268. o.index = config.index || 1;
  2269. o.iftitle = config.iftitle != null ? config.iftitle : true;
  2270. o.iforder = config.iforder != null ? config.iforder : true;
  2271.  
  2272. return this.open(o);
  2273. },
  2274.  
  2275. photoApp: function (content, config) {
  2276. if (!content) {
  2277. return false;
  2278. }
  2279. config = config || {};
  2280. let o = {};
  2281. o.type = "photo";
  2282. o.width = "100%";
  2283. o.height = "100%";
  2284. o.bgcolor = "rgba(0, 0, 0, 1)";
  2285. o.title = false;
  2286. o.move = false;
  2287. o.shade = true;
  2288. o.shadeClose = false;
  2289. o.closeBtn = true;
  2290. o.content = content;
  2291. o.photoapp = true;
  2292. o.lock = true;
  2293. o.reset = true;
  2294. o.index = config.index || 1;
  2295. o.iftitle = config.iftitle != null ? config.iftitle : true;
  2296. o.iforder = config.iforder != null ? config.iforder : true;
  2297.  
  2298. return this.open(o);
  2299. },
  2300.  
  2301. open: function (config) {
  2302. if (!config == null || !config.type || !config.content) {
  2303. return false;
  2304. }
  2305. let o = {};
  2306. o.model = "open";
  2307. o.type = config.type;
  2308. o.content = config.content;
  2309. o.id = config.id || "";
  2310. o.title = config.title || "";
  2311. if (config.autoHeight) {
  2312. o.autoHeight = config.autoHeight;
  2313. } else {
  2314. o.autoHeight = config.height ? false : true;
  2315. }
  2316. o.width = config.width || "600px";
  2317. o.height = config.height || "400px";
  2318. o.maxWidth = config.maxWidth || "";
  2319. o.maxHeight = config.maxHeight || "";
  2320. o.x = config.x || "";
  2321. o.y = config.y || "";
  2322. o.x = sizef(o.x);
  2323. o.y = sizef(o.y);
  2324. function sizef(str) {
  2325. if (str) {
  2326. if (!isNaN(str)) {
  2327. return Number(str);
  2328. } else {
  2329. let reg = /\-?[0-9\.]*(px|%)*/,
  2330. match,
  2331. num;
  2332. if (str) {
  2333. match = str.match(reg);
  2334. if (!match[1] || (match[1] && match[1] == "px")) {
  2335. match[0] = match[0].replace(/px/g, "");
  2336. num = Number(match[0]);
  2337. } else {
  2338. num = "";
  2339. }
  2340. return num;
  2341. }
  2342. }
  2343. } else {
  2344. return "";
  2345. }
  2346. }
  2347.  
  2348. o.bgcolor = config.bgcolor || "";
  2349. let reg = /rgba\((0\,){3}[0-9.]+/;
  2350. let rgba = reg.test(o.bgcolor);
  2351. if (
  2352. o.bgcolor == "#000" ||
  2353. o.bgcolor == "#000000" ||
  2354. o.bgcolor == "black" ||
  2355. o.bgcolor == "rgb(0, 0, 0)" ||
  2356. o.bgcolor == "rgba(0, 0, 0)" ||
  2357. rgba === true
  2358. ) {
  2359. o.color = "#ffffff";
  2360. } else {
  2361. o.color = "";
  2362. }
  2363. o.shade = config.shade != null ? config.shade : true;
  2364. if (o.shade === true) {
  2365. o.shadeClose = config.shadeClose != null ? config.shadeClose : true;
  2366. } else {
  2367. o.shadeClose = false;
  2368. }
  2369. o.end = typeof config.end == "function" ? config.end : null;
  2370. o.min = config.min != null ? config.min : false;
  2371. o.max = config.max != null ? config.max : false;
  2372. o.closeBtn = config.closeBtn != null ? config.closeBtn : true;
  2373. o.move = config.move != null ? config.move : true;
  2374. o.lock = config.lock != null ? config.lock : false;
  2375. o.over = config.over != null ? config.over : true;
  2376. o.index = config.index || 1;
  2377. o.app = config.app != null ? config.app : false;
  2378. if (o.app === true) {
  2379. if (o.type == "photo") {
  2380. return this.photoApp(o.content, o.index);
  2381. } else {
  2382. o.height = config.height || "";
  2383. o.lock = true;
  2384. o.shade = true;
  2385. o.shadeClose = true;
  2386. }
  2387. }
  2388. o.reset = config.reset != null ? config.reset : true;
  2389. o.zindex = config.zindex || 99999;
  2390. o.photoapp = config.photoapp || false;
  2391. o.iftitle = config.iftitle != null ? config.iftitle : true;
  2392. o.iforder = config.iforder != null ? config.iforder : true;
  2393. o.success = config.success || null;
  2394.  
  2395. return this.run(o);
  2396. },
  2397.  
  2398. load: function (tip, config) {
  2399. config = config || {};
  2400. let o = {};
  2401. o.model = "load";
  2402. o.tip = tip || "";
  2403. o.times = config.times || 0;
  2404. o.lock = config.lock != null ? config.lock : false;
  2405. o.zindex = config.zindex || 99999;
  2406. o.closeBtn = config.closeBtn != null ? config.closeBtn : false;
  2407.  
  2408. return this.run(o);
  2409. },
  2410.  
  2411. sheet: function (config) {
  2412. if (!config || !config.btn) {
  2413. return false;
  2414. }
  2415. let o = {};
  2416. o.model = "sheet";
  2417. o.title = config.title || "";
  2418. o.align = config.align || "center";
  2419. let btn = new Array();
  2420. for (let i = 0; i < 8; i++) {
  2421. if (config.btn[i]) {
  2422. btn[i] = config.btn[i];
  2423. }
  2424. }
  2425. o.btn = btn;
  2426. o.btn1 = config.btn1 || null;
  2427. o.btn2 = config.btn2 || null;
  2428. o.btn3 = config.btn3 || null;
  2429. o.btn4 = config.btn4 || null;
  2430. o.btn5 = config.btn5 || null;
  2431. o.btn6 = config.btn6 || null;
  2432. o.btn7 = config.btn7 || null;
  2433. o.btn8 = config.btn8 || null;
  2434.  
  2435. o.force = config.force || "";
  2436. o.btnClose = config.btnClose || "取消";
  2437. o.lock = true;
  2438. o.shadeClose = true;
  2439. o.end = typeof config.end == "function" ? config.end : null;
  2440. o.zindex = config.zindex || 99999;
  2441.  
  2442. return this.run(o);
  2443. },
  2444.  
  2445. //核心方法
  2446. run: function (options) {
  2447. let x = new Xclass(options);
  2448. return x.mainid;
  2449. },
  2450.  
  2451. close: function (closeid) {
  2452. let o = {};
  2453. o.model = "close";
  2454. o.closeid = closeid;
  2455.  
  2456. return this.run(o);
  2457. },
  2458.  
  2459. closeAll: function () {
  2460. let o = {};
  2461. o.model = "closeAll";
  2462.  
  2463. return this.run(o);
  2464. },
  2465. };
  2466. })(window);

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址