cmHeheImageForm.jsp 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  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. </style>
  64. <script type="text/javascript">
  65. $(document).ready(function() {
  66. //$("#name").focus();
  67. $("#inputForm").validate({
  68. submitHandler: function(form){
  69. loading('正在提交,请稍等...');
  70. form.submit();
  71. },
  72. errorContainer: "#messageBox",
  73. errorPlacement: function(error, element) {
  74. $("#messageBox").text("输入有误,请先更正。");
  75. if (element.is(":checkbox")||element.is(":radio")||element.parent().is(".input-append")){
  76. error.appendTo(element.parent().parent());
  77. } else {
  78. error.insertAfter(element);
  79. }
  80. }
  81. });
  82. });
  83. </script>
  84. </head>
  85. <body>
  86. <ul class="nav nav-tabs">
  87. <li><a href="${ctx}/hehe/cmHeheImage/">轮播图列表</a></li>
  88. <li class="active"><a href="${ctx}/hehe/cmHeheImage/form?id=${cmHeheImage.id}">${not empty cmHeheImage.id?'编辑':'添加'}</a></li>
  89. </ul><br/>
  90. <form:form id="inputForm" modelAttribute="cmHeheImage" action="${ctx}/hehe/cmHeheImage/save" method="post" class="form-horizontal">
  91. <form:hidden path="id"/>
  92. <sys:message content="${message}"/>
  93. <div class="control-group">
  94. <label class="control-label"><font color="red">*</font>主题:</label>
  95. <div class="controls">
  96. <form:input path="topic" htmlEscape="false" placeholder="最多输入30个汉字" style="position:relative" maxlength="30" class="input-xlarge required"/>
  97. </div>
  98. </div>
  99. <div class="control-group iconBox">
  100. <label class="control-label"><font color="red">*</font>图片:</label>
  101. <div class="controls upload-content" id="imageBox">
  102. <div class="conList">
  103. <form:hidden id="image" path="image" htmlEscape="false" maxlength="255" class="input-xlarge required"/>
  104. <sys:ckfinder input="image" type="images" uploadPath="/photo" selectMultiple="false" maxWidth="100" maxHeight="100"/>
  105. <br>
  106. <label style="margin-left: 20px">建议图片分辨率750px*366px</label>
  107. </div>
  108. </div>
  109. </div>
  110. <div class="control-group">
  111. <label class="control-label"><font color="red">*</font>排序:</label>
  112. <div class="controls">
  113. <form:input path="sort" onkeyup="onlynum(this)" htmlEscape="false" class="input-xlarge required"/>
  114. </div>
  115. </div>
  116. <div class="control-group">
  117. <label class="control-label"><font color="red">*</font>状态:</label>
  118. <div class="controls">
  119. <form:select path="status" class="input-xlarge required">
  120. <form:option value="1" label="启用"/>
  121. <form:option value="2" label="停用"/>
  122. </form:select>
  123. </div>
  124. </div>
  125. <div class="form-actions">
  126. <input id="btnSubmit" class="btn btn-primary" type="submit" value="保 存"/>&nbsp;
  127. <input id="btnCancel" class="btn" type="button" value="返 回" onclick="history.go(-1)"/>
  128. </div>
  129. </form:form>
  130. <script>
  131. $(function () {
  132. $('.upload-content .conList .btn:nth-of-type(1)').html('<div><span>+</span><h5>选择图片</h5></div>');
  133. $('.upload-content .conList .btn:nth-of-type(2)').after('<img class="cancel-upload" src="/static/images/close-btn1.png">').remove();
  134. $('.upload-content .conList').find('.cancel-upload').hide();
  135. var observeEle = document.getElementsByClassName('upload-content')[0];
  136. var MutationObserver = window.MutationObserver || window.WebKitMutationObserver;
  137. var MutationObserverConfig = {
  138. childList: true,
  139. subtree: true,
  140. characterData: true
  141. };
  142. var observer = new MutationObserver(function (mutations) {
  143. $.each(mutations, function (index, item) {
  144. if (item.type === 'childList') {
  145. // 在创建新的 element 时调用
  146. var target = $(item.target),
  147. thisWrapper = target.closest('.conList'),
  148. nextEle = thisWrapper.next();
  149. thisWrapper.find('li').css('z-index', 99);
  150. thisWrapper.find('.cancel-upload').show();
  151. if (nextEle.hasClass('hide-pic')) {
  152. nextEle.removeClass('hide-pic');
  153. }
  154. }
  155. })
  156. });
  157. observer.observe(observeEle, MutationObserverConfig);
  158. $('body').on('click', '.cancel-upload', function () {
  159. var wrapper = $(this).closest('.conList');
  160. wrapper.find('li').css('z-index', '-1');
  161. wrapper.find('input').val('');
  162. $(this).hide();
  163. wrapper.removeClass("hide-pic");
  164. wrapper.parent().append(wrapper.clone());
  165. wrapper.remove();
  166. $(".conList").each(function (i, ele) {
  167. if ($(ele).find("input.input-xlarge").val()) {
  168. $(ele).next().removeClass("hide-pic")
  169. }
  170. })
  171. });
  172. $(window).on("load", function () {
  173. setTimeout(function () {
  174. $("#imageBox").find("input.input-xlarge").each(function (i, ele) {
  175. if ($(ele).val()) {
  176. $(ele).next().find("li").css("z-index", "99");
  177. $(ele).parents(".conList").find(".cancel-upload").show();
  178. $(ele).parents(".conList").next().removeClass("hide-pic")
  179. }
  180. })
  181. }, 200);
  182. });
  183. });
  184. /**
  185. * @param obj
  186. * jquery控制input只能输入数字
  187. */
  188. function onlynum(obj) {
  189. obj.value = obj.value.replace(/[^\d]/g, ""); //清除"数字"以外的字符
  190. }
  191. </script>
  192. </body>
  193. </html>