addons.js 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. define([], function () {
  2. require(['form', 'upload'], function (Form, Upload) {
  3. var _bindevent = Form.events.bindevent;
  4. Form.events.bindevent = function (form) {
  5. _bindevent.apply(this, [form]);
  6. try {
  7. //绑定summernote事件
  8. if ($(".summernote,.editor", form).size() > 0) {
  9. require(['summernote'], function () {
  10. $(".summernote,.editor", form).summernote({
  11. height: 250,
  12. lang: 'zh-CN',
  13. fontNames: [
  14. 'Arial', 'Arial Black', 'Serif', 'Sans', 'Courier',
  15. 'Courier New', 'Comic Sans MS', 'Helvetica', 'Impact', 'Lucida Grande',
  16. "Open Sans", "Hiragino Sans GB", "Microsoft YaHei",
  17. '微软雅黑', '宋体', '黑体', '仿宋', '楷体', '幼圆',
  18. ],
  19. fontNamesIgnoreCheck: [
  20. "Open Sans", "Microsoft YaHei",
  21. '微软雅黑', '宋体', '黑体', '仿宋', '楷体', '幼圆'
  22. ],
  23. toolbar: [
  24. ['style', ['style', 'undo', 'redo']],
  25. ['font', ['bold', 'italic', 'underline', 'strikethrough', 'clear']],
  26. ['fontname', ['color', 'fontname', 'fontsize']],
  27. ['para', ['ul', 'ol', 'paragraph', 'height']],
  28. ['table', ['table', 'hr']],
  29. ['insert', ['link', 'picture', 'video']],
  30. ['view', ['fullscreen', 'codeview', 'help']]
  31. ],
  32. dialogsInBody: true,
  33. callbacks: {
  34. onChange: function (contents) {
  35. $(this).val(contents);
  36. $(this).trigger('change');
  37. },
  38. onInit: function () {
  39. $('.note-toolbar').css('z-index', 10); //修复浮动层遮挡下拉浮窗问题
  40. },
  41. onImageUpload: function (files) {
  42. var that = this;
  43. //依次上传图片
  44. for (var i = 0; i < files.length; i++) {
  45. Upload.api.send(files[i], function (data) {
  46. var url = Fast.api.cdnurl(data.url);
  47. $(that).summernote("insertImage", url, 'filename');
  48. });
  49. }
  50. }
  51. }
  52. });
  53. });
  54. }
  55. } catch (e) {
  56. }
  57. };
  58. });
  59. });