addons.js 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. define([], function () {
  2. if (Config.modulename == 'admin' && Config.controllername == 'index' && Config.actionname == 'index') {
  3. require.config({
  4. paths: {
  5. 'fastchat': '../addons/fastchat/js/fastchat'
  6. },
  7. shim: {
  8. 'fastchat': {
  9. deps: ['css!../addons/fastchat/css/fastchat.css'],
  10. exports: 'FastChat'
  11. }
  12. }
  13. });
  14. require(['fastchat'], function (FastChat) {
  15. FastChat.initialize(document.domain, 'admin');
  16. });
  17. } else {
  18. if (window.parent.Config && window.parent.Config.modulename == 'admin') {
  19. window.FastChat = window.parent.FastChat;
  20. // 一键添加会话窗口
  21. $(document).on('click', '.fastchat_user', function (e) {
  22. FastChat.forecast_add_session(e);
  23. });
  24. } else {
  25. require.config({
  26. paths: {
  27. 'fastchat': '../addons/fastchat/js/fastchat'
  28. },
  29. shim: {
  30. 'fastchat': {
  31. deps: ['css!../addons/fastchat/css/fastchat.css'],
  32. exports: 'FastChat'
  33. }
  34. }
  35. });
  36. require(['fastchat'], function (FastChat) {
  37. FastChat.initialize(document.domain, window.parent.Config.modulename);
  38. });
  39. }
  40. }
  41. window.UEDITOR_HOME_URL = Config.__CDN__ + "/assets/addons/ueditor/";
  42. require.config({
  43. paths: {
  44. 'ueditor.config': '../addons/ueditor/ueditor.config',
  45. 'ueditor': '../addons/ueditor/ueditor.all.min',
  46. 'ueditor.zh': '../addons/ueditor/i18n/zh-cn/zh-cn',
  47. 'zeroclipboard': '../addons/ueditor/third-party/zeroclipboard/ZeroClipboard.min',
  48. },
  49. shim: {
  50. 'ueditor': {
  51. deps: ['zeroclipboard', 'ueditor.config'],
  52. exports: 'UE',
  53. init: function (ZeroClipboard) {
  54. //导出到全局变量,供ueditor使用
  55. window.ZeroClipboard = ZeroClipboard;
  56. },
  57. },
  58. 'ueditor.zh': ['ueditor']
  59. }
  60. });
  61. require(['form', 'upload'], function (Form, Upload) {
  62. var _bindevent = Form.events.bindevent;
  63. Form.events.bindevent = function (form) {
  64. _bindevent.apply(this, [form]);
  65. try {
  66. //绑定editor事件
  67. require(['ueditor', 'ueditor.zh'], function (UE, undefined) {
  68. UE.list = [];
  69. window.UEDITOR_CONFIG['uploadService'] = function (context, editor) {
  70. return {
  71. Upload: () => { return Upload },
  72. Fast: () => { return Fast },
  73. }
  74. };
  75. $(Config.ueditor.classname || '.editor', form).each(function () {
  76. var id = $(this).attr("id");
  77. var name = $(this).attr("name");
  78. $(this).removeClass('form-control');
  79. UE.list[id] = UE.getEditor(id, {
  80. allowDivTransToP: false, //阻止div自动转p标签
  81. initialFrameWidth: '100%',
  82. initialFrameHeight: 320,
  83. autoFloatEnabled: false,
  84. baiduMapAk: Config.ueditor.baiduMapAk || '', //百度地图api密钥(ak)
  85. // autoHeightEnabled: true, //自动高度
  86. zIndex: 90,
  87. xssFilterRules: false,
  88. outputXssFilter: false,
  89. inputXssFilter: false,
  90. catchRemoteImageEnable: true,
  91. imageAllowFiles: '',//允许上传的图片格式,编辑器默认[".png", ".jpg", ".jpeg", ".gif", ".bmp"]
  92. });
  93. UE.list[id].addListener("contentChange", function () {
  94. $('#' + id).val(this.getContent());
  95. $('textarea[name="' + name + '"]').val(this.getContent());
  96. })
  97. });
  98. })
  99. } catch (e) {
  100. console.log('绑定editor事件', e)
  101. }
  102. }
  103. });
  104. });