layer-demo.js 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. /*! layer demo */ ;
  2. ! function () {
  3. var gather = {
  4. htdy: $('html, body')
  5. };
  6. //一睹为快
  7. gather.demo1 = $('#demo1');
  8. $('#chutiyan>a').on('click', function () {
  9. var othis = $(this),
  10. index = othis.index();
  11. var p = gather.demo1.children('p').eq(index);
  12. var top = p.position().top;
  13. gather.demo1.animate({
  14. scrollTop: gather.demo1.scrollTop() + top
  15. }, 0);
  16. switch (index) {
  17. case 0:
  18. var icon = -1;
  19. (function changeIcon() {
  20. var index = parent.layer.alert('点击确认更换图标', {
  21. icon: icon,
  22. shadeClose: true,
  23. title: icon === -1 ? '初体验' : 'icon:' + icon
  24. }, changeIcon);
  25. if (8 === ++icon) layer.close(index);
  26. }());
  27. break;
  28. case 1:
  29. var icon = 0;
  30. (function changeIcon1() {
  31. var index = parent.layer.alert('点击确认更换图标', {
  32. icon: icon,
  33. shadeClose: true,
  34. skin: 'layer-ext-moon',
  35. shift: 5,
  36. title: icon === -1 ? '第三方扩展皮肤' : 'icon:' + icon
  37. }, changeIcon1);
  38. if (9 === ++icon) {
  39. parent.layer.confirm('怎么样,是否很喜欢该皮肤,去下载?', {
  40. skin: 'layer-ext-moon'
  41. }, function (index, layero) {
  42. layero.find('.layui-layer-btn0').attr({
  43. href: 'http://layer.layui.com/skin.html',
  44. target: '_blank'
  45. });
  46. parent.layer.close(index);
  47. });
  48. };
  49. }());
  50. break;
  51. case 6:
  52. parent.layer.open({
  53. type: 1,
  54. area: ['420px', '240px'],
  55. skin: 'layui-layer-rim', //加上边框
  56. content: '<div style="padding:20px;">即直接给content传入html字符<br>当内容宽高超过定义宽高,会自动出现滚动条。<br><br><br><br><br><br><br><br><br><br><br>很高兴在下面遇见你</div>'
  57. });
  58. break;
  59. case 7:
  60. parent.layer.open({
  61. type: 1,
  62. skin: 'layui-layer-demo',
  63. closeBtn: false,
  64. area: '350px',
  65. shift: 2,
  66. shadeClose: true,
  67. content: '<div style="padding:20px;">即传入skin:"样式名",然后你就可以为所欲为了。<br>你怎么样给她整容都行<br><br><br>我是华丽的酱油==。</div>'
  68. });
  69. break;
  70. case 8:
  71. layer.tips('Hi,我是tips', this);
  72. break;
  73. case 11:
  74. var ii = parent.layer.load(0, {
  75. shade: false
  76. });
  77. setTimeout(function () {
  78. parent.layer.close(ii)
  79. }, 5000);
  80. break;
  81. case 12:
  82. var iii = parent.layer.load(1, {
  83. shade: [0.1, '#fff']
  84. });
  85. setTimeout(function () {
  86. parent.layer.close(iii)
  87. }, 3000);
  88. break;
  89. case 13:
  90. layer.tips('我是另外一个tips,只不过我长得跟之前那位稍有些不一样。', this, {
  91. tips: [1, '#3595CC'],
  92. time: 4000
  93. });
  94. break;
  95. case 14:
  96. parent.layer.prompt({
  97. title: '输入任何口令,并确认',
  98. formType: 1
  99. }, function (pass) {
  100. parent.layer.prompt({
  101. title: '随便写点啥,并确认',
  102. formType: 2
  103. }, function (text) {
  104. parent.layer.msg('演示完毕!您的口令:' + pass + '<br>您最后写下了:' + text);
  105. });
  106. });
  107. break;
  108. case 15:
  109. parent.layer.tab({
  110. area: ['600px', '300px'],
  111. tab: [{
  112. title: '无题',
  113. content: '<div style="padding:20px; line-height:30px; text-align:center">欢迎体验layer.tab<br>此时此刻不禁让人吟诗一首:<br>一入前端深似海<br>从此妹纸是浮云<br>以下省略七个字<br>。。。。。。。<br>——贤心</div>'
  114. }, {
  115. title: 'TAB2',
  116. content: '<div style="padding:20px;">TAB2该说些啥</div>'
  117. }, {
  118. title: 'TAB3',
  119. content: '<div style="padding:20px;">有一种坚持叫:layer</div>'
  120. }]
  121. });
  122. break;
  123. case 16:
  124. if (gather.photoJSON) {
  125. layer.photos({
  126. photos: gather.photoJSON
  127. });
  128. } else {
  129. $.getJSON('js/demo/photos.json?v=', function (json) {
  130. gather.photoJSON = json;
  131. layer.photos({
  132. photos: json
  133. });
  134. });
  135. }
  136. break;
  137. default:
  138. new Function(p.text())();
  139. break;
  140. }
  141. });
  142. }();