news_edit.html 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247
  1. <extend name="Public:base" />
  2. <block name="content">
  3. <div class="page-header">
  4. <h1>
  5. {$breadcrumb2}
  6. <small>
  7. <i class="icon-double-angle-right"></i>
  8. {$crumbs}
  9. </small>
  10. </h1>
  11. </div>
  12. <div class="row">
  13. <div class="col-xs-12">
  14. <form action="<?php echo $action; ?>" method="post" enctype="multipart/form-data" id="validation-form" class="form-horizontal">
  15. <notempty name="Think.get.id">
  16. <input name="nr_id" type="hidden" value="{$Think.get.id}" />
  17. </notempty>
  18. <div class="form-group required">
  19. <label class="col-sm-2 control-label" for="input-image">
  20. <span title="" data-toggle="tooltip" data-original-title="上传360x200的图片">封面</span>
  21. </label>
  22. <div class="col-sm-10" id="thumb">
  23. <a href="#" data-toggle="image" class="img-thumbnail">
  24. <img osctype="image" <if condition="$reply['thumb']">
  25. src="__ROOT__/<?php echo resize($reply['thumb'],100,100); ?>"
  26. <else />
  27. src="__ROOT__/Common/image/no_image_100x100.jpg"
  28. </if> />
  29. </a>
  30. <input osctype="image_input" type="hidden" name="thumb" value="{$reply.thumb|default=''}" id="input-image" />
  31. </div>
  32. </div>
  33. <div class="form-group">
  34. <label class="col-sm-2 control-label no-padding-left"> * 关键字 </label>
  35. <div class="col-sm-10">
  36. <div class="clearfix">
  37. <input name="keyword" id="keyword" class="col-xs-10 col-sm-10" placeholder="关键字" value="{$reply.keyword|default=''}" type="text">
  38. </div>
  39. </div>
  40. </div>
  41. <div class="form-group">
  42. <label class="col-sm-2 control-label no-padding-left"> * 标题 </label>
  43. <div class="col-sm-10">
  44. <div class="clearfix">
  45. <input name="title" id="title" class="col-xs-10 col-sm-10" placeholder="标题" value="{$reply.title|default=''}" type="text">
  46. </div>
  47. </div>
  48. </div>
  49. <div class="form-group">
  50. <label class="col-sm-2 control-label no-padding-left"> URL </label>
  51. <div class="col-sm-10">
  52. <div class="clearfix">
  53. <input name="url" id="url" class="col-xs-10 col-sm-10" placeholder="URL" value="{$reply.url|default=''}" type="text">
  54. </div>
  55. </div>
  56. </div>
  57. <div class="form-group">
  58. <label class="col-sm-2 control-label"> 内容摘要</label>
  59. <div class="col-sm-10">
  60. <div class="clearfix">
  61. <textarea id="description" class="form-control" placeholder="内容摘要" rows="5" name="description">{$reply.description|default=''}</textarea>
  62. </div>
  63. </div>
  64. </div>
  65. <div class="form-group">
  66. <label class="col-sm-2 control-label">启用</label>
  67. <div class="col-sm-10">
  68. <label class="radio-inline">
  69. <input type="radio" checked="checked" value="1" name="status">是</label>
  70. <label class="radio-inline">
  71. <input type="radio" value="0" name="status">否</label>
  72. </div>
  73. </div>
  74. <div class="form-group">
  75. <label class="col-sm-1 control-label no-padding-left"> </label>
  76. <div class="col-sm-11">
  77. <input name="send" type="submit" value="提交" class="btn btn-primary" />
  78. </div>
  79. </div>
  80. </form>
  81. </div>
  82. </div>
  83. </block>
  84. <block name="javascript">
  85. <style>
  86. .table thead > tr > td, .table tbody > tr > td {
  87. vertical-align: middle;
  88. }
  89. .table thead td span[data-toggle="tooltip"]:after, label.control-label span:after {
  90. font-family: FontAwesome;
  91. color: #1E91CF;
  92. content: "\f059";
  93. margin-left: 4px;
  94. }
  95. </style>
  96. <script src="__JS__/jquery.validate.min.js"></script>
  97. <script src="__PUBLIC__/fileupload/jquery.ui.widget.js"></script>
  98. <script src="__PUBLIC__/fileupload/jquery.fileupload.js"></script>
  99. <script>
  100. $(function(){
  101. // tooltips on hover button-upload
  102. $('[data-toggle=\'tooltip\']').tooltip({container: 'body', html: true});
  103. // Makes tooltips work on ajax generated content
  104. //$(document).ajaxStop(function() {
  105. // $('[data-toggle=\'tooltip\']').tooltip({container: 'body'});
  106. //});
  107. <present name="Think.get.id">
  108. Oscshop.setValue("status", {$reply.status|default=1});
  109. </present>
  110. $('#validation-form').validate({
  111. errorElement: 'div',
  112. errorClass: 'help-block',
  113. focusInvalid: false,
  114. rules: {
  115. keyword: {
  116. required: true,
  117. minlength: 1
  118. },
  119. title: {
  120. required: true
  121. }
  122. },
  123. messages: {
  124. keyword: {
  125. required: "必填",
  126. minlength: "不得少于1个字"
  127. },
  128. title: {
  129. required: "必填"
  130. }
  131. },
  132. highlight: function (e) {
  133. $(e).closest('.form-group').removeClass('has-info').addClass('has-error');
  134. },
  135. success: function (e) {
  136. $(e).closest('.form-group').removeClass('has-error').addClass('has-info');
  137. $(e).remove();
  138. },
  139. errorPlacement: function (error, element) {
  140. error.insertAfter(element.parent());
  141. },
  142. });
  143. $(document).delegate('a[data-toggle=\'image\']', 'click', function(e) {
  144. e.preventDefault();
  145. var element = this;
  146. $(element).popover({
  147. html: true,
  148. placement: 'right',
  149. trigger: 'manual',
  150. content: function() {
  151. return '<button type="button" id="button-image" class="btn btn-primary"><i class="icon-edit"></i></button> <button type="button" id="button-clear" class="btn btn-danger"><i class="icon-trash"></i></button>';
  152. }
  153. });
  154. $(element).popover('toggle');
  155. $('#button-image').on('click', function() {
  156. $('#modal-image').remove();
  157. $('#form-upload').remove();
  158. $('body').prepend('<form enctype="multipart/form-data" id="form-upload" style="display: none;"><input osctype="btn_upload_image" type="file" name="file" /></form>');
  159. $('#form-upload input[name=\'file\']').trigger('click');
  160. $(element).popover('hide');
  161. $('[osctype="btn_upload_image"]').fileupload({
  162. dataType: 'json',
  163. url: "{:U('Image/upload_image',array('dir'=>'wechat_news'))}",
  164. add: function(e, data) {
  165. $parent = $('#thumb');
  166. $input = $parent.find('[osctype="image_input"]');
  167. $img = $parent.find('[osctype="image"]');
  168. data.formData = {old_product_image:$input.val()};
  169. $img.attr('src', "__IMG__/loading.gif");
  170. data.submit();
  171. },
  172. done: function (e,data) {
  173. var image=data.result;
  174. $parent = $('#thumb');
  175. $input = $parent.find('[osctype="image_input"]');
  176. $img = $parent.find('[osctype="image"]');
  177. if(image) {
  178. // $img.prev('i').hide();
  179. $img.attr('src', '__ROOT__'+image.image_thumb);
  180. $img.show();
  181. $input.val(image.image);
  182. } else {
  183. alert('上传失败');
  184. }
  185. }
  186. });
  187. });
  188. $('#button-clear').on('click', function() {
  189. $(element).find('img').attr('src', $(element).find('img').attr('data-placeholder'));
  190. $(element).parent().find('input').attr('value', '');
  191. $(element).popover('hide');
  192. });
  193. });
  194. });
  195. </script>
  196. </block>