note.blade.php 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. @extends('admin/site/side_layout')
  2. @section('right')
  3. <div class="wrapper wrapper-content animated fadeInRight">
  4. <div class="row">
  5. <div class="col-sm-12">
  6. <div class="ibox float-e-margins">
  7. <div class="ibox-content">
  8. <div id="readDiv">
  9. <p id="preview">
  10. </p>
  11. <button type="button" onclick="units.changeMode('edit')" class="btn btn-success">编辑模式</button>
  12. </div>
  13. <form method="get" class="form-horizontal" id="form" style="display: none">
  14. <div class="form-group">
  15. <label class="col-sm-2 control-label" for="content">备注:</label>
  16. <div class="col-sm-8">
  17. <!-- 编辑器容器 -->
  18. <script id="content" name="content"
  19. type="text/plain">{!! $data->content??'' !!}</script>
  20. </div>
  21. </div>
  22. <div class="hr-line-dashed"></div>
  23. <div class="form-group">
  24. <div class="col-sm-4 col-sm-offset-2">
  25. <button class="btn btn-primary" type="button"
  26. onclick="units.save({{$data->id??0}})">
  27. 保存
  28. </button>
  29. {{--<button type="button" class="btn btn-success" onclick="units.changeMode('read')">阅读模式</button>--}}
  30. </div>
  31. </div>
  32. </form>
  33. </div>
  34. </div>
  35. </div>
  36. </div>
  37. </div>
  38. @endsection
  39. @section('footer_extend')
  40. @include('vendor.ueditor.assets')
  41. <script>
  42. var ue = UE.getEditor('content');
  43. ue.ready(function () {
  44. ue.setHeight(300);
  45. });
  46. setTimeout(function () {
  47. $("#preview").html(ue.getContent())
  48. }, 1000);
  49. var units = {
  50. save: function (id) {
  51. var data = tips.getFormValues('#form');
  52. var ajaxConfig = {
  53. url: '/admin/sites/{{$siteId}}/articles-note',
  54. type: 'post',
  55. data: data,
  56. success: function (result) {
  57. layer.msg(result.message, {icon: 6, time: 1000}, function () {
  58. units.changeMode('read')
  59. });
  60. }
  61. };
  62. tips.ajax(ajaxConfig);
  63. },
  64. changeMode:function (mode) {
  65. if(mode==='edit') {
  66. $("#readDiv").hide();
  67. $("#form").show();
  68. } else {
  69. $("#preview").html(ue.getContent());
  70. $("#readDiv").show();
  71. $("#form").hide();
  72. }
  73. }
  74. };
  75. </script>
  76. @endsection