OWL ITS + 탐지시스템(인터넷 진흥원)
jhjang
2021-10-14 b74776268dd3eb2bc57744928d6f7150ffcd4ec2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
(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
        factory(window.jQuery);
    }
}(function ($) {
    $.extend($.summernote.options, {
        template: {
            list: []
        }
    });
 
    // Extends plugins for adding templates.
    //  - plugin is external module for customizing.
    $.extend($.summernote.plugins, {
        /**
         * @param {Object} context - context object has status of editor.
         */
        'template': function (context) {
            // ui has renders to build ui elements.
            //  - you can create a button with `ui.button`
            var ui      = $.summernote.ui;
            var options = context.options.template;
 
            // add hello button
            context.memo('button.template', function () {
                // create button
                var button = ui.buttonGroup([
                    ui.button({
                        className: 'dropdown-toggle',
                        contents: '<span class="template"/> Template <span class="caret"></span>',
                        tooltip: 'Insert Template',
                        data: {
                            toggle: 'dropdown'
                        }
                    }),
                    ui.dropdown({
                        className: 'dropdown-template',
                        items: options.list,
                        click: function (event) {
                            var $button = $(event.target);
                            var value   = $button.data('value');
                            var path    = options.path + '/' + value + '.html';
 
                            $.get(path)
                                .done(function (data) {
                                    var node = document.createElement('span');
                                    node.innerHTML = data;
                                    context.invoke('editor.insertNode', node);
                                }).fail(function () {
                                alert('template not found in ' + path);
                            });
                        }
                    })
                ]);
 
                // create jQuery object from button instance.
                return button.render();
            });
        }
    });
}));