(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: '', tooltip: 'ts_audio', click: function () { self.show() } }); // create jQuery object from button instance. var $highlight = button.render(); return $highlight; }); this.createDialog = function () { var $box = $('
'); var $frame = $(''); $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(); }; } }) }))