edit.html 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  1. <include file="public@header" />
  2. </head>
  3. <body>
  4. <div class="wrap js-check-wrap">
  5. <ul class="nav nav-tabs">
  6. <li><a href="{:url('Adminpage/index')}">页面管理</a></li>
  7. <li class="active"><a >页面文章</a></li>
  8. </ul>
  9. <form class="form-horizontal js-ajax-form margin-top-20" action="{:url('Adminpage/edit_post')}" method="post" enctype="multipart/form-data">
  10. <input type="hidden" name="post[id]" value="{$info['id']}" />
  11. <table class="table table-bordered">
  12. <tr>
  13. <th width="80">分类</th>
  14. <td>
  15. <select class="form-control" id="input-post_type" name="post[post_type]">
  16. <option value="0">单页面</option>
  17. </select>
  18. <span class="form-required">*</span>
  19. </td>
  20. </tr>
  21. <tr>
  22. <th>标题</th>
  23. <td>
  24. <input type="text" class="form-control" id="input-post_title" name="post[post_title]" id="title" required value="{$info['post_title']}" placeholder="请输入标题"/>
  25. <span class="form-required">*</span>
  26. </td>
  27. </tr>
  28. <tr>
  29. <th>内容</th>
  30. <td>
  31. <script type="text/plain" id="content" name="post[post_content]">{$info['post_content']}</script>
  32. </td>
  33. </tr>
  34. </table>
  35. <div class="form-group">
  36. <button type="submit" class="btn btn-primary js-ajax-submit">{:lang('SAVE')}</button>
  37. <a class="btn btn-default" href="{:url('Adminpage/index')}">{:lang('BACK')}</a>
  38. </div>
  39. </form>
  40. </div>
  41. <script src="__STATIC__/js/admin.js"></script>
  42. <script type="text/javascript">
  43. //编辑器路径定义
  44. var editorURL = GV.WEB_ROOT;
  45. </script>
  46. <script type="text/javascript" src="__STATIC__/ueditor/ueditor.config.js"></script>
  47. <script type="text/javascript" src="__STATIC__/ueditor/ueditor.all.min.js"></script>
  48. <script type="text/javascript">
  49. $(function() {
  50. /////---------------------
  51. Wind.use('validate', 'ajaxForm', 'artDialog', function() {
  52. //javascript
  53. //编辑器
  54. editorcontent = new baidu.editor.ui.Editor();
  55. editorcontent.render('content');
  56. try {
  57. editorcontent.sync();
  58. } catch (err) {
  59. }
  60. //增加编辑器验证规则
  61. jQuery.validator.addMethod('editorcontent', function() {
  62. try {
  63. editorcontent.sync();
  64. } catch (err) {
  65. }
  66. return editorcontent.hasContents();
  67. });
  68. var form = $('form.js-ajax-forms');
  69. //ie处理placeholder提交问题
  70. if ($.browser && $.browser.msie) {
  71. form.find('[placeholder]').each(function() {
  72. var input = $(this);
  73. if (input.val() == input.attr('placeholder')) {
  74. input.val('');
  75. }
  76. });
  77. }
  78. var formloading = false;
  79. //表单验证开始
  80. form.validate({
  81. //是否在获取焦点时验证
  82. onfocusout : false,
  83. //是否在敲击键盘时验证
  84. onkeyup : false,
  85. //当鼠标掉级时验证
  86. onclick : false,
  87. //验证错误
  88. showErrors : function(errorMap, errorArr) {
  89. //errorMap {'name':'错误信息'}
  90. //errorArr [{'message':'错误信息',element:({})}]
  91. try {
  92. $(errorArr[0].element).focus();
  93. art.dialog({
  94. id : 'error',
  95. icon : 'error',
  96. lock : true,
  97. fixed : true,
  98. background : "#CCCCCC",
  99. opacity : 0,
  100. content : errorArr[0].message,
  101. cancelVal : '确定',
  102. cancel : function() {
  103. $(errorArr[0].element).focus();
  104. }
  105. });
  106. } catch (err) {
  107. }
  108. },
  109. //验证规则
  110. rules : {
  111. 'post[post_title]' : {
  112. required : 1
  113. },
  114. 'post[post_content]' : {
  115. editorcontent : true
  116. }
  117. },
  118. //验证未通过提示消息
  119. messages : {
  120. 'post[post_title]' : {
  121. required : '请输入标题'
  122. },
  123. 'post[post_content]' : {
  124. editorcontent : '内容不能为空'
  125. }
  126. },
  127. //给未通过验证的元素加效果,闪烁等
  128. highlight : false,
  129. //是否在获取焦点时验证
  130. onfocusout : false,
  131. //验证通过,提交表单
  132. submitHandler : function(forms) {
  133. if (formloading)
  134. return;
  135. $(forms).ajaxSubmit({
  136. url : form.attr('action'), //按钮上是否自定义提交地址(多按钮情况)
  137. dataType : 'json',
  138. beforeSubmit : function(arr, $form, options) {
  139. formloading = true;
  140. },
  141. success : function(data, statusText, xhr, $form) {
  142. formloading = false;
  143. if (data.status) {
  144. setCookie("refersh_time", 1);
  145. //添加成功
  146. Wind.use("artDialog", function() {
  147. art.dialog({
  148. id : "succeed",
  149. icon : "succeed",
  150. fixed : true,
  151. lock : true,
  152. background : "#CCCCCC",
  153. opacity : 0,
  154. content : data.info,
  155. button : [ {
  156. name : '继续添加?',
  157. callback : function() {
  158. reloadPage(window);
  159. return true;
  160. },
  161. focus : true
  162. }, {
  163. name : '返回列表页',
  164. callback : function() {
  165. location = "{:Url('Adminpage/index')}";
  166. return true;
  167. }
  168. } ]
  169. });
  170. });
  171. } else {
  172. artdialog_alert(data.info);
  173. }
  174. }
  175. });
  176. }
  177. });
  178. });
  179. ////-------------------------
  180. });
  181. </script>
  182. </body>
  183. </html>