| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160 |
- define([], function () {
- if (Config.modulename == 'admin' && Config.controllername == 'index' && Config.actionname == 'index') {
- require.config({
- paths: {
- 'fastchat': '../addons/fastchat/js/fastchat'
- },
- shim: {
- 'fastchat': {
- deps: ['css!../addons/fastchat/css/fastchat.css'],
- exports: 'FastChat'
- }
- }
- });
- require(['fastchat'], function (FastChat) {
- FastChat.initialize(document.domain, 'admin');
- });
- } else {
- if (window.parent.Config && window.parent.Config.modulename == 'admin') {
- window.FastChat = window.parent.FastChat;
- // 一键添加会话窗口
- $(document).on('click', '.fastchat_user', function (e) {
- FastChat.forecast_add_session(e);
- });
- } else {
- require.config({
- paths: {
- 'fastchat': '../addons/fastchat/js/fastchat'
- },
- shim: {
- 'fastchat': {
- deps: ['css!../addons/fastchat/css/fastchat.css'],
- exports: 'FastChat'
- }
- }
- });
- require(['fastchat'], function (FastChat) {
- FastChat.initialize(document.domain, window.parent.Config.modulename);
- });
- }
- }
- require.config({
- paths: {
- 'summernote': '../addons/summernote/lang/summernote-zh-CN.min'
- },
- shim: {
- 'summernote': ['../addons/summernote/js/summernote.min', 'css!../addons/summernote/css/summernote.min.css'],
- }
- });
- require(['form', 'upload'], function (Form, Upload) {
- var _bindevent = Form.events.bindevent;
- Form.events.bindevent = function (form) {
- _bindevent.apply(this, [form]);
- try {
- //绑定summernote事件
- if ($(Config.summernote.classname || '.editor', form).length > 0) {
- var selectUrl = typeof Config !== 'undefined' && Config.modulename === 'index' ? 'user/attachment' : 'general/attachment/select';
- require(['summernote'], function () {
- var imageButton = function (context) {
- var ui = $.summernote.ui;
- var button = ui.button({
- contents: '<i class="fa fa-file-image-o"/>',
- tooltip: __('Choose'),
- click: function () {
- parent.Fast.api.open(selectUrl + "?element_id=&multiple=true&mimetype=image/", __('Choose'), {
- callback: function (data) {
- var urlArr = data.url.split(/\,/);
- $.each(urlArr, function () {
- var url = Fast.api.cdnurl(this, true);
- context.invoke('editor.insertImage', url);
- });
- }
- });
- return false;
- }
- });
- return button.render();
- };
- var attachmentButton = function (context) {
- var ui = $.summernote.ui;
- var button = ui.button({
- contents: '<i class="fa fa-file"/>',
- tooltip: __('Choose'),
- click: function () {
- parent.Fast.api.open(selectUrl + "?element_id=&multiple=true&mimetype=*", __('Choose'), {
- callback: function (data) {
- var urlArr = data.url.split(/\,/);
- $.each(urlArr, function () {
- var url = Fast.api.cdnurl(this, true);
- var node = $("<a href='" + url + "'>" + url + "</a>");
- context.invoke('insertNode', node[0]);
- });
- }
- });
- return false;
- }
- });
- return button.render();
- };
- $(Config.summernote.classname || '.editor', form).each(function () {
- $(this).summernote($.extend(true, {}, {
- height: isNaN(Config.summernote.height) ? null : parseInt(Config.summernote.height),
- minHeight: parseInt(Config.summernote.minHeight || 250),
- toolbar: Config.summernote.toolbar,
- followingToolbar: parseInt(Config.summernote.followingToolbar),
- placeholder: Config.summernote.placeholder || '',
- airMode: parseInt(Config.summernote.airMode) || false,
- lang: 'zh-CN',
- fontNames: [
- 'Arial', 'Arial Black', 'Serif', 'Sans', 'Courier',
- 'Courier New', 'Comic Sans MS', 'Helvetica', 'Impact', 'Lucida Grande',
- "Open Sans", "Hiragino Sans GB", "Microsoft YaHei",
- '微软雅黑', '宋体', '黑体', '仿宋', '楷体', '幼圆',
- ],
- fontNamesIgnoreCheck: [
- "Open Sans", "Microsoft YaHei",
- '微软雅黑', '宋体', '黑体', '仿宋', '楷体', '幼圆'
- ],
- buttons: {
- image: imageButton,
- attachment: attachmentButton,
- },
- dialogsInBody: true,
- callbacks: {
- onChange: function (contents) {
- $(this).val(contents);
- $(this).trigger('change');
- },
- onInit: function () {
- },
- onImageUpload: function (files) {
- var that = this;
- //依次上传图片
- for (var i = 0; i < files.length; i++) {
- Upload.api.send(files[i], function (data) {
- var url = Fast.api.cdnurl(data.url, true);
- $(that).summernote("insertImage", url, 'filename');
- });
- }
- }
- }
- }, $(this).data("summernote-options") || {}));
- });
- });
- }
- } catch (e) {
- }
- };
- });
- });
|