script.blade.php 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <script>
  2. var ue = UE.getEditor('container', {
  3. autoHeightEnabled: false,
  4. initialFrameHeight: 500
  5. });
  6. ue.ready(function () {
  7. //此处为支持laravel5 csrf ,根据实际情况修改,目的就是设置 _token 值.
  8. ue.execCommand('serverparam', '_token', '{{ csrf_token() }}');
  9. });
  10. $('#base-form').ajaxForm({
  11. success: function (result) {
  12. if (result.status) {
  13. swal({
  14. title: "保存成功!",
  15. text: "",
  16. type: "success"
  17. }, function () {
  18. location = '{{route('admin.bai.jia.article.index')}}';
  19. });
  20. } else {
  21. swal("保存失败!", result.message, "error");
  22. }
  23. }
  24. });
  25. $(function () {
  26. var uploader = WebUploader.create({
  27. auto: true,
  28. swf: '{{url(env("APP_URL").'/assets/backend/libs/webuploader-0.1.5/Uploader.swf')}}',
  29. server: '{{route('upload.image',['_token'=>csrf_token()])}}',
  30. pick: '#filePicker',
  31. fileVal: 'upload_image',
  32. accept: {
  33. title: 'Images',
  34. extensions: 'gif,jpg,jpeg,bmp,png',
  35. mimeTypes: 'image/*'
  36. }
  37. });
  38. uploader.on('uploadSuccess', function (file, response) {
  39. $('.article-img').attr('src', response.url).show();
  40. $("input[name='img']").val(response.url)
  41. });
  42. var authorUploader = WebUploader.create({
  43. auto: true,
  44. swf: '{{url(env("APP_URL").'/assets/backend/libs/webuploader-0.1.5/Uploader.swf')}}',
  45. server: '{{route('upload.image',['_token'=>csrf_token()])}}',
  46. pick: '#AuthorAvatarPicker',
  47. fileVal: 'upload_image',
  48. accept: {
  49. title: 'Images',
  50. extensions: 'gif,jpg,jpeg,bmp,png',
  51. mimeTypes: 'image/*'
  52. }
  53. });
  54. authorUploader.on('uploadSuccess', function (file, response) {
  55. $('.author_avatar').attr('src', response.url).show();
  56. $("input[name='author_avatar']").val(response.url)
  57. });
  58. })
  59. </script>