cmHeheRelatedImagesForm.jsp 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. <%@ page contentType="text/html;charset=UTF-8" %>
  2. <%@ include file="/WEB-INF/views/include/taglib.jsp"%>
  3. <html>
  4. <head>
  5. <title>图片管理</title>
  6. <meta name="decorator" content="default"/>
  7. <style>
  8. .iconBox {
  9. font-size: 0;
  10. }
  11. .controls .conList {
  12. display: inline-block;
  13. margin-right: 15px;
  14. }
  15. .conList .btn:nth-of-type(1) {
  16. margin-left: 25px;
  17. }
  18. .upload-content {
  19. margin-top: -70px;
  20. }
  21. .upload-content .conList .btn:nth-of-type(1) {
  22. width: 90px;
  23. height: 100px;
  24. border: 2px solid #eee;
  25. background: #fff;
  26. position: relative;
  27. }
  28. .upload-content .conList .btn:nth-of-type(1) > div {
  29. position: absolute;
  30. top: 50%;
  31. left: 50%;
  32. transform: translate(-50%, -50%);
  33. color: #666;
  34. }
  35. .upload-content .conList .btn:nth-of-type(1) span {
  36. font-size: 35px;
  37. }
  38. .upload-content .conList .btn:nth-of-type(1) h5 {
  39. color: #666;
  40. }
  41. .cancel-upload {
  42. background: transparent;
  43. border: none;
  44. box-shadow: none;
  45. position: relative;
  46. top: -38px;
  47. left: -25px;
  48. cursor: pointer;
  49. z-index: 100;
  50. }
  51. .upload-content .conList ol li {
  52. width: 114px;
  53. min-height: 80px;
  54. text-align: center;
  55. background: #fff;
  56. position: relative;
  57. top: 120px;
  58. margin-left: 2px;
  59. }
  60. .hide-pic {
  61. display: none !important;
  62. }
  63. .paramRow {
  64. margin-top: 10px;
  65. }
  66. </style>
  67. <script type="text/javascript">
  68. $(document).ready(function() {
  69. //$("#name").focus();
  70. $("#inputForm").validate({
  71. submitHandler: function(form){
  72. var image = $("#image").val();
  73. if (image === '') {
  74. alertx("请上传二维码图片");
  75. return false;
  76. }
  77. loading('正在提交,请稍等...');
  78. form.submit();
  79. },
  80. errorContainer: "#messageBox",
  81. errorPlacement: function(error, element) {
  82. $("#messageBox").text("输入有误,请先更正。");
  83. if (element.is(":checkbox")||element.is(":radio")||element.parent().is(".input-append")){
  84. error.appendTo(element.parent().parent());
  85. } else {
  86. error.insertAfter(element);
  87. }
  88. }
  89. });
  90. });
  91. </script>
  92. </head>
  93. <body>
  94. <ul class="nav nav-tabs">
  95. <li class="active"><a href="${ctx}/hehe/cmHeheRelatedImages/form?id=1">首页二维码</a></li>
  96. </ul><br/>
  97. <form:form id="inputForm" modelAttribute="cmHeheRelatedImages" action="${ctx}/hehe/cmHeheRelatedImages/save" method="post" class="form-horizontal">
  98. <form:hidden path="id"/>
  99. <sys:message content="${message}"/>
  100. <div class="control-group iconBox">
  101. <label class="control-label"><span class="help-inline"><font color="red">*</font> </span>二维码:</label>
  102. <div class="controls upload-content" id="imageBox1">
  103. <div class="conList">
  104. <form:hidden id="image" path="image" htmlEscape="false" maxlength="255" class="input-xlarge required"/>
  105. <sys:ckfinder input="image" type="images" uploadPath="/photo" selectMultiple="false" maxWidth="100"
  106. maxHeight="100"/>
  107. <br>
  108. <label style="margin-left: 150px">建议图片分辨率500px*500px</label>
  109. </div>
  110. </div>
  111. </div>
  112. <div class="form-actions">
  113. <input id="btnSubmit" class="btn btn-primary" type="submit" value="保 存"/>&nbsp;
  114. <input id="btnCancel" class="btn" type="button" value="返 回" onclick="history.go(-1)"/>
  115. </div>
  116. </form:form>
  117. <script>
  118. $(function () {
  119. $('.upload-content .conList .btn:nth-of-type(1)').html('<div><span>+</span><h5>选择图片</h5></div>');
  120. $('.upload-content .conList .btn:nth-of-type(2)').after('<img class="cancel-upload" src="/static/images/close-btn1.png">').remove();
  121. $('.upload-content .conList').find('.cancel-upload').hide();
  122. var MutationObserver = window.MutationObserver || window.WebKitMutationObserver;
  123. var MutationObserverConfig = {
  124. childList: true,
  125. subtree: true,
  126. characterData: true
  127. };
  128. var observer = new MutationObserver(function (mutations) {
  129. $.each(mutations, function (index, item) {
  130. if (item.type === 'childList') {
  131. // 在创建新的 element 时调用
  132. var target = $(item.target),
  133. thisWrapper = target.closest('.conList'),
  134. nextEle = thisWrapper.next();
  135. thisWrapper.find('li').css('z-index', 99);
  136. thisWrapper.find('.cancel-upload').show();
  137. if (nextEle.hasClass('hide-pic')) {
  138. nextEle.removeClass('hide-pic');
  139. }
  140. }
  141. })
  142. });
  143. var observeEle = document.getElementsByClassName('upload-content')[0];
  144. observer.observe(observeEle, MutationObserverConfig)
  145. $('body').on('click', '.cancel-upload', function () {
  146. var wrapper = $(this).closest('.conList');
  147. wrapper.find('li').css('z-index', '-1');
  148. wrapper.find('input').val('');
  149. $(this).hide();
  150. wrapper.removeClass("hide-pic");
  151. wrapper.parent().append(wrapper.clone());
  152. wrapper.remove();
  153. $(".conList").each(function (i, ele) {
  154. if ($(ele).find("input.input-xlarge").val()) {
  155. $(ele).next().removeClass("hide-pic")
  156. }
  157. })
  158. });
  159. $(window).on("load", function () {
  160. setTimeout(function () {
  161. $("#imageBox1").find("input.input-xlarge").each(function (i, ele) {
  162. if ($(ele).val()) {
  163. $(ele).next().find("li").css("z-index", "99");
  164. $(ele).parents(".conList").find(".cancel-upload").show();
  165. $(ele).parents(".conList").next().removeClass("hide-pic")
  166. }
  167. });
  168. }, 200);
  169. });
  170. });
  171. </script>
  172. </body>
  173. </html>