layer.html 9.7 KB

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