118 lines
3.0 KiB
JavaScript
118 lines
3.0 KiB
JavaScript
(function (factory) {
|
|
/* global define */
|
|
if (typeof define === 'function' && define.amd) {
|
|
// AMD. Register as an anonymous module.
|
|
define(['jquery'], factory);
|
|
} else if (typeof module === 'object' && module.exports) {
|
|
// Node/CommonJS
|
|
module.exports = factory(require('jquery'));
|
|
} else {
|
|
// Browser globals: jQuery
|
|
factory(window.jQuery);
|
|
}
|
|
}(function ($) {
|
|
|
|
$.extend($.summernote.plugins, {
|
|
|
|
'ts_attach': function (context) {
|
|
var self = this;
|
|
|
|
var ui = $.summernote.ui;
|
|
var $editor = context.layoutInfo.editor;
|
|
var options = context.options;
|
|
var lang = options.langInfo;
|
|
|
|
|
|
context.memo('button.ts_attach', function () {
|
|
|
|
var button = ui.button({
|
|
contents: '<i class="fas fa-paperclip"></i>',
|
|
tooltip: 'ts_attach',
|
|
click: function () {
|
|
self.show()
|
|
}
|
|
});
|
|
|
|
// create jQuery object from button instance.
|
|
var $highlight = button.render();
|
|
return $highlight;
|
|
});
|
|
|
|
|
|
|
|
|
|
this.createDialog = function () {
|
|
|
|
var $box = $('<div />');
|
|
var $frame = $('<iframe width="100%" height="444" frameborder="0" scrolling="no" src="'+siteUrl+'index.php?app=attach&ac=editor&ts=list" />');
|
|
$box.append($frame);
|
|
return $box.html();
|
|
};
|
|
|
|
|
|
|
|
this.showAttachDialog = function () {
|
|
return $.Deferred(function () {
|
|
ui.onDialogShown(self.$dialog, function () {
|
|
|
|
});
|
|
|
|
ui.onDialogHidden(self.$dialog, function () {
|
|
|
|
});
|
|
|
|
ui.showDialog(self.$dialog);
|
|
|
|
});
|
|
};
|
|
|
|
|
|
|
|
this.show = function () {
|
|
|
|
|
|
this.showAttachDialog().then(function () {
|
|
self.$dialog.modal('hide');
|
|
context.invoke('editor.restoreRange');
|
|
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
this.initialize = function () {
|
|
var $container = options.dialogsInBody ? $(document.body) : $editor;
|
|
|
|
var body = [''].join('');
|
|
|
|
this.$dialog = ui.dialog({
|
|
className: 'ts-attach',
|
|
title: '我的附件',
|
|
body: this.createDialog(),
|
|
footer: body,
|
|
//callback: function ($node) {
|
|
// $node.find('.modal-body').css({
|
|
// 'max-height': 300,
|
|
// 'overflow': 'scroll'
|
|
// });
|
|
//}
|
|
}).render().appendTo($container);
|
|
};
|
|
|
|
|
|
|
|
|
|
this.destroy = function () {
|
|
ui.hideDialog(this.$dialog);
|
|
this.$dialog.remove();
|
|
};
|
|
|
|
|
|
|
|
|
|
}
|
|
})
|
|
|
|
})) |