@@ -0,0 +1,118 @@
|
||||
(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_audio': 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_audio', function () {
|
||||
|
||||
var button = ui.button({
|
||||
contents: '<i class="fas fa-headphones"></i>',
|
||||
tooltip: 'ts_audio',
|
||||
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=audio&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-audio',
|
||||
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();
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
})
|
||||
|
||||
}))
|
||||
Reference in New Issue
Block a user