layer.html 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288
  1. <!DOCTYPE html>
  2. <html lang="zh">
  3. <head>
  4. <th:block th:include="include :: header('弹层组件')" />
  5. <style>
  6. /* 解决layer相册层弹出时导致页面自动滚动 */
  7. html {height: auto;}
  8. </style>
  9. </head>
  10. <body class="gray-bg">
  11. <div class="wrapper wrapper-content fadeInRight">
  12. <div class="row">
  13. <div class="col-sm-6">
  14. <div class="ibox">
  15. <div class="ibox-title">
  16. <h5>信息框</h5>
  17. </div>
  18. <div class="ibox-content" id="test">
  19. <p>通过调用<code>$.modal.alert()</code>实现。 </p>
  20. <button type="button" class="btn btn-primary" onclick="$.modal.alert('Hi,你好!')">普通</button>
  21. <button type="button" class="btn btn-success" onclick="$.modal.alertSuccess('Hi,你好!')">成功</button>
  22. <button type="button" class="btn btn-warning" onclick="$.modal.alertWarning('Hi,你好!')">警告</button>
  23. <button type="button" class="btn btn-danger" onclick="$.modal.alertError('Hi,你好!')">失败</button>
  24. </div>
  25. </div>
  26. </div>
  27. <div class="col-sm-6">
  28. <div class="ibox">
  29. <div class="ibox-title">
  30. <h5>提示框</h5>
  31. </div>
  32. <div class="ibox-content">
  33. <p>通过调用<code>$.modal.msg()</code>实现。 </p>
  34. <button type="button" class="btn btn-primary" onclick="$.modal.msg('Hi,你好!')">普通</button>
  35. <button type="button" class="btn btn-success" onclick="$.modal.msgSuccess('Hi,你好!')">成功</button>
  36. <button type="button" class="btn btn-warning" onclick="$.modal.msgWarning('Hi,你好!')">警告</button>
  37. <button type="button" class="btn btn-danger" onclick="$.modal.msgError('Hi,你好!')">失败</button>
  38. </div>
  39. </div>
  40. </div>
  41. </div>
  42. <div class="row">
  43. <div class="col-sm-6">
  44. <div class="ibox">
  45. <div class="ibox-title">
  46. <h5>询问框</h5>
  47. </div>
  48. <div class="ibox-content">
  49. <p>通过调用<code>$.modal.confirm()</code>实现。 </p>
  50. <button type="button" class="btn btn-primary" id="button-confirm">询问按钮</button>
  51. </div>
  52. </div>
  53. </div>
  54. <div class="col-sm-6">
  55. <div class="ibox ">
  56. <div class="ibox-title">
  57. <h5>消息提示并刷新父窗体</h5>
  58. </div>
  59. <div class="ibox-content">
  60. <p>通过调用<code>$.modal.msgReload()</code>实现。 </p>
  61. <button type="button" class="btn btn-primary" id="button-msgReload">提示刷新按钮</button>
  62. </div>
  63. </div>
  64. </div>
  65. <div class="col-sm-6">
  66. <div class="ibox">
  67. <div class="ibox-title">
  68. <h5>普通弹出层</h5>
  69. </div>
  70. <div class="ibox-content">
  71. <p>通过调用<code>$.modal.open()</code>实现。 </p>
  72. <button type="button" class="btn btn-primary" id="button-open-1">默认</button>
  73. <button type="button" class="btn btn-success" id="button-open-2">设置宽高</button>
  74. <button type="button" class="btn btn-warning" id="button-open-3">回调函数</button>
  75. <button type="button" class="btn btn-danger" id="button-open-4">自定义选项</button>
  76. <button type="button" class="btn btn-primary" id="button-open-5">全屏弹出</button>
  77. </div>
  78. </div>
  79. </div>
  80. <div class="col-sm-6">
  81. <div class="ibox">
  82. <div class="ibox-title">
  83. <h5>选卡页方式</h5>
  84. </div>
  85. <div class="ibox-content">
  86. <p>通过调用<code>$.modal.openTab()</code>实现。 </p>
  87. <button type="button" class="btn btn-primary" id="button-open-6">新窗口打开</button>
  88. <button type="button" class="btn btn-warning" id="button-open-7">关闭当前</button>
  89. <button type="button" class="btn btn-primary" id="button-open-14">选卡页同一页签打开</button>
  90. <button type="button" class="btn btn-warning" id="button-open-15">关闭指定</button>
  91. </div>
  92. </div>
  93. </div>
  94. <div class="col-sm-6">
  95. <div class="ibox">
  96. <div class="ibox-title">
  97. <h5>其他内容</h5>
  98. </div>
  99. <div class="ibox-content">
  100. <p>通过调用<code>layer</code>实现。 </p>
  101. <button type="button" class="btn btn-primary" id="button-open-8">tab层</button>
  102. <button type="button" class="btn btn-primary" id="button-open-9">prompt层</button>
  103. <button type="button" class="btn btn-primary" id="button-open-10">捕获页</button>
  104. <button type="button" class="btn btn-primary" id="button-open-16">相册层</button>
  105. </div>
  106. </div>
  107. </div>
  108. <div class="col-sm-6">
  109. <div class="ibox">
  110. <div class="ibox-title">
  111. <h5>遮罩层</h5>
  112. </div>
  113. <div class="ibox-content">
  114. <p>通过调用<code>blockUI</code>实现。 </p>
  115. <button type="button" class="btn btn-primary" id="button-open-11">打开</button>
  116. <button type="button" class="btn btn-warning" id="button-open-12">关闭</button>
  117. <button type="button" class="btn btn-primary" id="button-open-13">layer遮罩</button>
  118. </div>
  119. </div>
  120. </div>
  121. <div class="col-sm-12">
  122. <div class="ibox">
  123. <div class="ibox-title">
  124. <label class="font-noraml">相关参数详细信息</label>
  125. <div><a href="http://doc.ruoyi.vip/#/standard/zjwd?id=layer" target="_blank">http://doc.ruoyi.vip/#/standard/zjwd?id=layer</a></div>
  126. </div>
  127. </div>
  128. </div>
  129. </div>
  130. <th:block th:include="include :: footer" />
  131. <script type="text/javascript">
  132. var prefix = ctx + "demo/modal";
  133. $("#button-confirm").click(function(){
  134. $.modal.confirm("确认要点击确定吗?", function() {
  135. $.modal.alert("ok");
  136. });
  137. })
  138. $("#button-msgReload").click(function(){
  139. $.modal.msgReload("保存成功,正在刷新数据请稍后……", modal_status.SUCCESS);
  140. })
  141. $("#button-open-1").click(function(){
  142. $.modal.open('添加用户', prefix + "/form");
  143. })
  144. $("#button-open-2").click(function(){
  145. $.modal.open('添加用户', prefix + "/form", '900', '320');
  146. })
  147. $("#button-open-3").click(function(){
  148. $.modal.open('添加用户', prefix + "/form", '900', '320', callback);
  149. })
  150. $("#button-open-4").click(function(){
  151. var btn = ['<i class="fa fa-check"></i> 点我回调', '<i class="fa fa-close"></i> 点我关闭'];
  152. var options = {
  153. title: '添加用户',
  154. width: "900",
  155. height: "320",
  156. url: prefix + "/form",
  157. btn: btn,
  158. callBack: doSubmit
  159. };
  160. $.modal.openOptions(options);
  161. })
  162. function doSubmit(index, layero) {
  163. alert("进入了自定义选项提交方法");
  164. }
  165. function callback(index, layero) {
  166. alert("进入了回调函数提交方法");
  167. }
  168. $("#button-open-5").click(function(){
  169. $.modal.openFull('添加用户', prefix + "/form");
  170. })
  171. $("#button-open-6").click(function(){
  172. $.modal.openTab('添加用户', prefix + "/form");
  173. })
  174. $("#button-open-7").click(function(){
  175. $.modal.closeTab();
  176. })
  177. $("#button-open-8").click(function(){
  178. //tab层
  179. layer.tab({
  180. area: ['600px', '300px'],
  181. tab: [{
  182. title: 'TAB1',
  183. content: '内容1'
  184. },
  185. {
  186. title: 'TAB2',
  187. content: '内容2'
  188. },
  189. {
  190. title: 'TAB3',
  191. content: '内容3'
  192. }]
  193. });
  194. })
  195. $("#button-open-9").click(function(){
  196. layer.prompt({title: '输入任何口令,并确认', formType: 1}, function(pass, index){
  197. layer.close(index);
  198. layer.prompt({title: '随便写点啥,并确认', formType: 2}, function(text, index){
  199. layer.close(index);
  200. layer.msg('演示完毕!您的口令:'+ pass +'<br>您最后写下了:'+text);
  201. });
  202. });
  203. })
  204. $("#button-open-10").click(function(){
  205. layer.open({
  206. type: 1,
  207. shade: false,
  208. title: false, //不显示标题
  209. content: $('#test'), //捕获的元素,注意:最好该指定的元素要存放在body最外层,否则可能被其它的相对元素所影响
  210. cancel: function(){
  211. layer.msg('捕获就是从页面已经存在的元素上,包裹layer的结构', {time: 5000, icon:6});
  212. }
  213. });
  214. })
  215. $("#button-open-11").click(function(){
  216. $.modal.loading("数据加载中");
  217. })
  218. $("#button-open-12").click(function(){
  219. $.modal.closeLoading();
  220. })
  221. $("#button-open-13").click(function(){
  222. layer.load(0, {shade: false}); // 0代表加载的风格,支持0-2
  223. })
  224. $("#button-open-14").click(function(){
  225. $.modal.parentTab('添加用户', prefix + "/form");
  226. })
  227. $("#button-open-15").click(function(){
  228. // 需要关闭窗口的url
  229. $.modal.closeTab(prefix + "/form");
  230. })
  231. $("#button-open-16").click(function(){
  232. var json = {
  233. "title": "若依相册", //相册标题
  234. "id": 123, //相册id
  235. "start": 0, //初始显示的图片序号,默认0
  236. "data": [ //相册包含的图片,数组格式
  237. {
  238. "alt": "默认头像",
  239. "pid": 1, //图片id
  240. "src": "/img/profile.jpg", //原图地址
  241. "thumb": "/img/profile.jpg" //缩略图地址
  242. },
  243. {
  244. "alt": "打赏",
  245. "pid": 2, //图片id
  246. "src": "/img/pay.png", //原图地址
  247. "thumb": "/img/pay.png" //缩略图地址
  248. }
  249. ]
  250. };
  251. layer.photos({
  252. photos: json,
  253. closeBtn: 0, //右上角按钮,可通过配置1和2来展示,如果不显示,则closeBtn: 0
  254. anim: 5 //0-6的选择,指定弹出图片动画类型,默认随机(请注意,3.0之前的版本用shift参数)
  255. });
  256. })
  257. </script>
  258. </body>
  259. </html>