zhuguifei
2026-03-10 2c1fd10c6fbabb8e9f0e9f07fe66fb36c008e883
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
/**
* jQuery EasyUI 1.3.6
* Copyright (c) 2009-2014 www.jeasyui.com. All rights reserved.
*
* Licensed under the GPL or commercial licenses
* To use it on other terms please contact author: info@jeasyui.com
* http://www.gnu.org/licenses/gpl.txt
* http://www.jeasyui.com/license_commercial.php
*
* jQuery EasyUI ueditor Plugin Extensions 1.0 beta
* jQuery EasyUI ueditor 插件扩展
* jquery.ueditor.js
* 二次开发 流云
* 最近更新:2014-06-04
*
* 依赖项:
*   1、jquery.jdirk.js v1.0 beta late
*   2、jeasyui.extensions.js v1.0 beta late
 
*   3、ueditor/themes/default/css/ueditor.css
*   4、ueditor/ueditor.config.js
*   5、ueditor/ueditor.all.js
*   6、ueditor/lang/zh-cn/zh-cn.js
*
* Copyright (c) 2013-2014 ChenJianwei personal All rights reserved.
* http://www.chenjianwei.org
*/
(function ($, undefined) {
 
    function create(target) {
        var t = $(target).addClass("ueditor-f"),
            isDiv = /^(?:div)$/i.test(target.nodeName), isText = /^(?:textarea)$/i.test(target.nodeName),
            html = isText ? (t.val() || t.text()) : t.html(),
            state = $.data(target, "ueditor"), opts = state.options,
            name = t.attr("name"), id = state.editorId = "ueditor_" + $.util.guid("N"),
            panel = state.panel = isDiv ? t.addClass("ueditor-panel").empty() : $("<div class=\"ueditor-panel\"></div>").insertAfter(t.hide().empty()).append(t),
            textarea = state.textarea = $("<textarea id=\"" + id + "\"" + (name ? " name=\"" + name + "\"" : "") + "></textarea>").appendTo(panel);
        if (name) {
            t.attr("ueditorName", name).removeAttr("name");
        }
        if (html) { textarea.val(html); }
 
        if (opts.value) {
            opts.initialContent = String(opts.value);
        }
        opts.originalValue = html || opts.initialContent;
        if (opts.template) {
            opts.toolbars = opts.toolbarsTemplate[opts.template]
        }
 
        state.panel.panel($.extend({}, opts, {
            noheader: true,
            onDestroy: $.fn.panel.defaults.onDestroy,
            onResize: function (width, height) {
                $.fn.panel.defaults.onResize.apply(this, arguments);
                $.extend(opts, { width: width, height: height });
                setEditorSize(target);
                if ($.isFunction(opts.onResize)) { opts.onResize.apply(target, arguments); }
            }
        }));
 
        state.wrapper = state.panel.panel("body").addClass("ueditor-wrapper");
 
        state.editor = UE.getEditor(id, opts);
 
        initialEvents(target);
        initialState(target);
        setValidation(target);
    };
 
    function initialEvents(target) {
        var state = $.data(target, "ueditor"), opts = state.options;
        $.each($.fn.ueditor.events, function (i, n) {
            var eventName = "on" + n, e = opts[eventName];
            state.editor.addListener(n, function () {
                if (n == "contentChange") {
                    var val = opts.value = $(target).ueditor("getValue");
                    state.textarea.val(val);
                }
                if (n == "setHeight") {
                    var body = $(state.editor.body), height = body.parent().height();
                    body.height(height);
                }
                if ($.isFunction(e)) { return e.apply(target, arguments); }
            });
        });
    };
 
    function initialState(target) {
        var state = $.data(target, "ueditor"), opts = state.options, checkCount = 20;
        checkState();
        function checkState() {
            state.edui = state.textarea.prev();
            state.eduieditor = state.edui.find(">div.edui-editor");
            state.toolbarbox = state.eduieditor.find(">div.edui-editor-toolbarbox");
            state.iframeholder = state.eduieditor.find(">div.edui-editor-iframeholder");
            state.bottomContainer = state.eduieditor.find(">div.edui-editor-bottomContainer");
            state.scalelayer = state.eduieditor.find(">div[id$=scalelayer]");
 
            if (state.editor.iframe && state.editor.iframe.parentNode && state.editor.iframe.parentNode.style && state.editor.body) {
                setEditorSize(target);
                setEditorDisabled(target, opts.disabled);
            } else {
                if (--checkCount) {
                    $.util.exec(checkState, 100);
                }
            }
        };
    };
 
 
    function getOptions(target) {
        var state = $.data(target, "ueditor"), opts = state.panel.panel("options");
        return $.extend(state.options, {
            title: opts.title, iconCls: opts.iconCls, width: opts.width, height: opts.height, left: opts.left, top: opts.top,
            cls: opts.cls, headerCls: opts.headerCls, bodyCls: opts.bodyCls, style: opts.style, fit: opts.fit, border: opts.border,
            doSize: opts.doSize, noheader: opts.noheader, collapsible: opts.collapsible, minimizable: opts.minimizable, maximizable: opts.maximizable,
            closable: opts.closable, collapsed: opts.collapsed, minimized: opts.minimized, maximized: opts.maximized, closed: opts.closed
        });
    };
 
 
 
 
    function setEditorSize(target) {
        var t = $(target), state = $.data(target, "ueditor");
        if (state && state.toolbarbox && state.bottomContainer && state.scalelayer && state.iframeholder && state.eduieditor && state.editor) {
            var opts = state.options, size = t._fit(),
                vwidth = size.width - (opts.border ? 0 : 2);
            state.iframeholder.width(vwidth);
            state.eduieditor.width(vwidth);
 
            var vheight = size.height - state.toolbarbox.height() - state.bottomContainer.height() - state.scalelayer.height() - (opts.border ? 0 : 2);
            state.editor.setHeight(vheight);
        }
    };
 
    function resize(target, param) {
        var state = $.data(target, "ueditor");
        state.panel.panel("resize", param);
    };
 
 
 
    function setEditorDisabled(target, disabled, except) {
        var state = $.data(target, "ueditor"), opts = state.options, d = disabled ? true : false;
        opts.disabled = d;
        return state.editor[d ? "setDisabled" : "setEnabled"](except);
    };
 
    function showEditor(target) {
        var state = $.data(target, "ueditor"), opts = state.options;
        opts.isShow = true;
        state.panel.panel("open");
        state.editor.setShow();
        return getOptions(target);
    };
 
    function hideEditor(target) {
        var state = $.data(target, "ueditor"), opts = state.options;
        opts.isShow = false;
        state.editor.setHide();
        state.panel.panel("close");
        return getOptions(target);
    };
 
 
    function destroy(target) {
        var t = $(target), state = $.data(target, "ueditor");
        if (state) {
            if (state.editor) {
                if (state.editor.fontset) {
                    state.editor.fontset.dialog("destroy");
                }
                state.editor.destroy();
            }
            if (state.panel) { state.panel.panel("destroy"); }
        }
        t.remove();
    };
 
    function sync(target, formId) {
        var state = $.data(target, "ueditor");
        if (formId) {
            return state.editor.sync();
        } else {
            return state.editor.sync(formId);
        }
    };
 
    function addshortcutkey(target, param) {
        var state = $.data(target, "ueditor");
        return state.editor.addshortcutkey(param);
    };
 
    function setFocus(target, toEnd) {
        var state = $.data(target, "ueditor");
        if (typeof toEnd == "boolean") {
            return state.editor.focus(toEnd);
        } else {
            return state.editor.focus();
        }
    };
 
    function execCommand(target, cmdName) {
        var state = $.data(target, "ueditor");
        return state.editor.execCommand(cmdName);
    };
 
    function queryCommandState(target, cmdName) {
        var state = $.data(target, "ueditor");
        return state.editor.queryCommandState(cmdName);
    };
 
    function queryCommandValue(target, cmdName) {
        var state = $.data(target, "ueditor");
        return state.editor.queryCommandValue(cmdName);
    };
 
    function hasContents(target, tags) {
        var state = $.data(target, "ueditor");
        if (tags) {
            var array = $.util.likeArrayNotString(tags) ? tags : []
            return state.editor.hasContents(array);
        } else {
            return state.editor.hasContents();
        }
    };
 
    function reset(target) {
        var state = $.data(target, "ueditor"), opts = state.options;
        setValue(target, opts.originalValue);
        return state.editor.reset();
    };
 
    function getLang(target, path) {
        var state = $.data(target, "ueditor");
        return state.editor.getLang(path);
    };
 
    function getContentLength(target, ingoneHtml) {
        var state = $.data(target, "ueditor");
        if (typeof ingoneHtml == "boolean") {
            return state.editor.getContentLength(ingoneHtml);
        } else {
            return state.editor.getContentLength();
        }
    };
 
    function addInputRule(target, rule) {
        var state = $.data(target, "ueditor");
        return state.editor.addInputRule(rule);
    };
 
    function addOutputRule(target, rule) {
        var state = $.data(target, "ueditor");
        return state.editor.addOutputRule(rule);
    };
 
 
 
 
 
    function getValue(target, param) {
        var state = $.data(target, "ueditor"), opts = state.options;
        return $(target).ueditor(opts.valueMethod, param);
    };
 
    function getContent(target, filter) {
        var state = $.data(target, "ueditor");
        return $.isFunction(filter) ? state.editor.getContent(filter) : state.editor.getContent();
    };
 
    function getAllHtml(target) {
        var state = $.data(target, "ueditor");
        return state.editor.getAllHtml();
    };
 
    function getPlainTxt(target) {
        var state = $.data(target, "ueditor");
        return state.editor.getPlainTxt();
    };
 
    function getContentTxt(target) {
        var state = $.data(target, "ueditor");
        return state.editor.getContentTxt();
    };
 
 
    function setValue(target, value, isAppendTo) {
        var state = $.data(target, "ueditor");
        if (isAppendTo) {
            return state.editor.setContent(value, true);
        } else {
            return state.editor.setContent(value);
        }
    };
 
    function setContent(target, param) {
        var state = $.data(target, "ueditor");
        param = param || "";
        if (typeof param == "string") {
            return state.editor.setContent(param);
        } else {
            return state.editor.setContent(param.value, param.isAppendTo);
        }
    };
 
    function clear(target) {
        var state = $.data(target, "ueditor");
        state.editor.execCommand("cleardoc");
    };
 
 
 
 
 
    function hideTip(target) {
        var state = $.data(target, "ueditor");
        state.tip = false;
        state.wrapper.tooltip("hide");
    };
 
    function showTip(target) {
        var state = $.data(target, "ueditor"), opts = state.options;
        state.wrapper.tooltip($.extend({}, opts.tipOptions, { content: opts.missingMessage, position: opts.tipPosition, deltaX: opts.deltaX })).tooltip("show");
        state.tip = true;
    };
 
    function repositionTip(target) {
        var state = $.data(target, "ueditor");
        if (state && state.tip) {
            state.wrapper.tooltip("reposition");
        }
    };
 
    function initializeValidate(target) {
        var t = $(target), state = $.data(target, "ueditor"), opts = state.options;
        state.wrapper.unbind(".ueditor");
        if (opts.novalidate) {
            return;
        }
        state.wrapper.bind("focus.ueditor", function () {
            state.validating = true;
            state.value = undefined;
            (function () {
                if (state.validating) {
                    var value = t.ueditor("getContentTxt");
                    if (state.value != value) {
                        state.value = value;
                        if (state.timer) {
                            clearTimeout(state.timer);
                        }
                        state.timer = setTimeout(function () { t.ueditor("validate"); }, opts.delay);
                    } else {
                        repositionTip(target);
                    }
                    setTimeout(arguments.callee, 200);
                }
            })();
        }).bind("blur.ueditor", function () {
            if (state.timer) {
                clearTimeout(state.timer);
                state.timer = undefined;
            }
            state.validating = false;
            hideTip(target);
        }).bind("mouseenter.ueditor", function () {
            if (state.wrapper.hasClass("ueditor-invalid")) {
                showTip(target);
            }
        }).bind("mouseleave.ueditor", function () {
            if (!state.validating) {
                hideTip(target);
            }
        });
    };
 
    function validate(target) {
        var t = $(target), state = $.data(target, "ueditor"), opts = state.options,
            value = t.ueditor("getContentTxt");
        state.wrapper.removeClass("ueditor-invalid");
        hideTip(target);
        if (!opts.novalidate && opts.required && $.string.isNullOrWhiteSpace(value) && !t.is(":disabled") && !state.wrapper.hasClass("ueditor-disabled")) {
            state.wrapper.addClass("ueditor-invalid");
            if (state.validating) {
                showTip(target);
            }
            return false;
        }
        return true;
    };
 
    function setValidation(target, novalidate) {
        var state = $.data(target, "ueditor"), opts = state.options;
        if (novalidate != undefined && novalidate != null) {
            opts.novalidate = novalidate;
        }
        if (opts.novalidate) {
            state.wrapper.find("div.edui-editor").removeClass("ueditor-invalid");
            hideTip(target);
        }
        initializeValidate(target);
    };
 
 
 
 
 
 
 
 
 
    $.fn.ueditor = function (options, param) {
        if (typeof options == "string") {
            return $.fn.ueditor.methods[options](this, param);
        }
        options = options || {};
        return this.each(function () {
            var state = $.data(this, "ueditor");
            if (state) {
                $.extend(state.options, options);
            } else {
                $.data(this, "ueditor", { options: $.extend({}, $.fn.ueditor.defaults, $.fn.ueditor.parseOptions(this), options) });
                create(this);
            }
        });
    };
 
 
    $.fn.ueditor.events = [
        "ready", "destroy", "reset", "focus", "langReady",
        "beforeExecCommand", "afterExecCommand", "firstBeforeExecCommand",
        "beforeGetContent", "afterGetContent", "getAllHtml", "beforeSetContent", "afterSetContent",
        "selectionchange", "beforeSelectionChange", "afterSelectionChange", "contentChange", "setHeight"
    ];
    $.fn.ueditor.toolbars = window.UEDITOR_CONFIG.toolbars;
    //$.fn.ueditor.toolbars = [[
    //    'fullscreen', 'source', '|', 'undo', 'redo', '|',
    //    'bold', 'italic', 'underline', 'fontborder', 'strikethrough', 'superscript', 'subscript', 'removeformat', 'formatmatch', 'autotypeset', 'blockquote', 'pasteplain', '|', 'forecolor', 'backcolor', 'insertorderedlist', 'insertunorderedlist', 'selectall', 'cleardoc', '|',
    //    'rowspacingtop', 'rowspacingbottom', 'lineheight', '|',
    //    'customstyle', 'paragraph', 'fontfamily', 'fontsize', '|',
    //    'directionalityltr', 'directionalityrtl', 'indent', '|',
    //    'justifyleft', 'justifycenter', 'justifyright', 'justifyjustify', '|', 'touppercase', 'tolowercase', '|',
    //    'link', 'unlink', 'anchor', '|', 'imagenone', 'imageleft', 'imageright', 'imagecenter', '|',
    //    'insertimage', 'emotion', 'scrawl', 'insertvideo', 'music', 'attachment', 'map', 'gmap', 'insertframe', 'insertcode', 'webapp', 'pagebreak', 'template', 'background', '|',
    //    'horizontal', 'date', 'time', 'spechars', 'snapscreen', 'wordimage', '|',
    //    'inserttable', 'deletetable', 'insertparagraphbeforetable', 'insertrow', 'deleterow', 'insertcol', 'deletecol', 'mergecells', 'mergeright', 'mergedown', 'splittocells', 'splittorows', 'splittocols', 'charts', '|',
    //    'print', 'preview', 'searchreplace', 'help', 'drafts'
    //]];
    $.fn.ueditor.parseOptions = function (target) {
        return $.extend({}, $.parser.parseOptions(target, [
            "lang", "theme", "charset", "initialContent", "textarea", "wordCountMsg", "tabNode", "sourceEditor", "value", "templet", "valueMethod",
            "missingMessage", "tipPosition",
            {
                enableAutoSave: "boolean", isShow: "boolean", focus: "boolean", fullscreen: "boolean", readonly: "boolean",
                imagePopup: "boolean", emotionLocalization: "boolean", pasteplain: "boolean", wordCount: "boolean", elementPathEnabled: "boolean",
                autoHeightEnabled: "boolean", scaleEnabled: "boolean", tableDragable: "boolean", sourceEditorFirst: "boolean",
                fit: "boolean", disabled: "boolean", border: "boolean",
                required: "boolean", novalidate: "boolean", autosave: "boolean"
            },
            {
                saveInterval: "number", zIndex: "number", maximumWords: "number", tabSize: "number", width: "number", height: "number",
                deltaX: "number"
            }
        ]));
    };
 
 
 
 
 
 
 
 
    $.fn.ueditor.buttons = {
        defaults: {
            name: null, label: null, iconCss: "background-position: 0 0;",
            execCommand: function (cmd) { },
            queryCommandState: function () { },
            queryCommandValue: function () { },
            onInit: function (editor) { }
        },
        list: [],
 
        styleTagID: "ueditorCss_" + $.util.guid("N"),
 
        append: function (button, init) {
            var b = $.extend({}, $.fn.ueditor.buttons.defaults, button),
                editorui = baidu.editor.ui, ci = b.name;
 
            UEDITOR_CONFIG.toolbars[0].push(b.name);
            for (var lang in b.label) {
                UE.I18N[lang].labelMap[b.name] = b.label[lang];
            }
 
            editorui[ci] = function (cmd) {
                return function (editor) {
                    var ui = new editorui.Button({
                        className: 'edui-for-' + cmd,
                        title: editor.options.labelMap[cmd] || editor.getLang("labelMap." + cmd) || '',
                        onclick: function () {
                            editor.execCommand(cmd);
                        },
                        theme: editor.options.theme,
                        showText: false
                    });
                    editorui.buttons[cmd] = ui;
                    editor.addListener('selectionchange', function (type, causeByUi, uiReady) {
                        var state = editor.queryCommandState(cmd);
                        if (state == -1) {
                            ui.setDisabled(true);
                            ui.setChecked(false);
                        } else {
                            if (!uiReady) {
                                ui.setDisabled(false);
                                ui.setChecked(state);
                            }
                        }
                    });
                    //下面这行代码为该插件添加的,使得ueditor编辑器在初始化该按钮时执行一个事件函数;
                    if ($.isFunction(b.onInit)) { $.util.exec(function () { b.onInit.call(ui, editor); }); }
                    return ui;
                };
            }(ci);
 
            UE.commands[b.name] = $.extend({}, b);
 
            var styleText = " .edui-for-" + b.name + " .edui-icon {" + (b.iconCss ? b.iconCss : "") + "}",
                style = $("#" + $.fn.ueditor.buttons.styleTagID);
            if (style.length) {
                styleText = (style.text() || style.html()) + "\n" + styleText;
                if ($.util.browser.msie && $.util.browser.version < 9) {
                    style.remove();
                    $.util.addCss(styleText).attr("id", $.fn.ueditor.buttons.styleTagID);
                } else {
                    style.text(styleText);
                }
            } else {
                $.util.addCss(styleText).attr("id", $.fn.ueditor.buttons.styleTagID);
            }
 
            if (!init) {
                $.fn.ueditor.buttons.list.push(b);
            }
        }
    };
    $.each($.fn.ueditor.buttons.list, function (i, btn) {
        $.fn.ueditor.buttons.append(btn, true);
    });
 
 
 
 
 
 
 
    $.fn.ueditor.buttons.refreshFontSet = {
        name: "fontset", iconCss: "background-position: -720px 0;",
        label: { "zh-cn": "字体设置" },
        execCommand: function (cmd) {
            var editor = this, offset = $(editor.container).offset(),
                fontset = editor.fontset ? editor.fontset : editor.fontset = createDialog(),
                fopts = fontset.dialog("options");
            fopts.closed ? fontset.dialog("open").dialog("move", { top: offset.top - 50, left: offset.left }) : fontset.dialog("close");
 
            function createDialog() {
                var fontset = $.easyui.showDialog({
                    noheader: true, modal: false, resizable: false, draggable: false, closed: true, autoDestroy: false, border: false, topMost: false,
                    width: 260, height: 50, top: offset.top - 50, left: offset.left,
                    enableSaveButton: false, enableCloseButton: false, enableApplyButton: false,
                    onOpen: function () { $.fn.ueditor.buttons.refreshFontSet.refresh(editor); },
                    content: "<div class=\"ueditor-fontset-container\"></div>"
                });
                $.util.exec(function () {
                    var cc = fontset.find(".ueditor-fontset-container"), config = UE.I18N[editor.ui.lang], fontfamily = [], fontsize = [];
                    for (var n in config.fontfamily) {
                        fontfamily.push({ value: config.fontfamily[n], text: config.fontfamily[n] });
                    }
                    for (var i = 0; i < editor.ui.fontsize.length; i++) {
                        fontsize.push({ value: editor.ui.fontsize[i] + "px", text: editor.ui.fontsize[i] + "px" });
                    }
                    fontset.fontfamily = $("<input class=\"ueditor-fontset-fontfamily\" type=\"text\" />").appendTo(cc).combobox({
                        width: 70, panelWidth: 120, editable: false, data: fontfamily,
                        formatter: function (r) {
                            return "<span style=\"font-family: " + r.text + ";\">" + r.text + "</span>";
                        },
                        onSelect: function (r) { editor.execCommand("fontfamily", r.text); },
                        onShowPanel: function () { fontset.fontsize.combobox("hidePanel"); }
                    });
                    fontset.fontsize = $("<input class=\"ueditor-fontset-fontsize\" type=\"text\" />").appendTo(cc).combobox({
                        width: 70, panelWidth: 120, editable: false, data: fontsize,
                        formatter: function (r) {
                            return "<span style=\"font-size: " + r.text + ";\">" + r.text + "</span>";
                        },
                        onSelect: function (r) { editor.execCommand("fontsize", r.text); },
                        onShowPanel: function () { fontset.fontfamily.combobox("hidePanel"); }
                    });
                    fontset.bold = $("<a></a>").appendTo(cc).linkbutton({
                        plain: true, toggle: true, iconCls: "icon-standard-text-bold", onClick: function () {
                            editor.execCommand("bold");
                        }
                    });
                    fontset.italic = $("<a></a>").appendTo(cc).linkbutton({
                        plain: true, toggle: true, iconCls: "icon-standard-text-italic", onClick: function () {
                            editor.execCommand("italic");
                        }
                    });
                    fontset.underline = $("<a></a>").appendTo(cc).linkbutton({
                        plain: true, toggle: true, iconCls: "icon-standard-text-underline", onClick: function () {
                            editor.execCommand("underline");
                        }
                    });
 
                    editor.addListener("focus", function () {
                        cc.find(".combobox-f").combobox("hidePanel");
                    });
                });
                return fontset;
            };
        },
        queryCommandState: function () {
            var editor = this;
            $.fn.ueditor.buttons.refreshFontSet.refresh(editor);
            return editor.fontset ? (editor.fontset.dialog("options").closed ? 0 : 1) : 0;
        },
        refresh: function (editor) {
            var fontfamily = editor.queryCommandValue("fontfamily"), fontsize = editor.queryCommandValue("fontsize"),
                bold = editor.queryCommandState("bold"), italic = editor.queryCommandState("italic"), underline = editor.queryCommandState("underline");
            if (editor.fontset && !editor.fontset.dialog("options").closed) {
                if (editor.fontset.fontfamily && fontfamily) {
                    var data = editor.fontset.fontfamily.combobox("getData"), array = fontfamily.split(","), b = false;
                    $.each(array, function (i, family) {
                        if (b) { return; }
                        family = $.trim(family);
                        if ($.array.contains(data, family, function (r) { return r.value == family; })) {
                            editor.fontset.fontfamily.combobox("setValue", family);
                            b = true;
                        }
                    });
                    if (!b) { editor.fontset.fontfamily.combobox("setValue", "arial"); }
                }
                if (editor.fontset.fontsize) {
                    editor.fontset.fontsize.combobox("setValue", fontsize);
                }
                if (editor.fontset.bold) {
                    editor.fontset.bold.linkbutton(bold == 1 ? "select" : "unselect");
                }
                if (editor.fontset.italic) {
                    editor.fontset.italic.linkbutton(italic == 1 ? "select" : "unselect");
                }
                if (editor.fontset.underline) {
                    editor.fontset.underline.linkbutton(underline == 1 ? "select" : "unselect");
                }
            }
        }
    };
    $.fn.ueditor.buttons.append($.fn.ueditor.buttons.refreshFontSet);
 
 
 
 
    //  提供外部调用公共方法 $.easyui.showUeditorDialog 用于快速创建 Ueditor 富文本 HTML 编辑器对话框;
    //  该方法的参数 options 参考继承于方法 $.easyui.showDialog 和插件 easyui-ueditor 的参数格式,在在此基础上增加了如下描述的属性:
    //      title   : string
    //      value   : string
    //      onEnter : function(val, eueditor, editor, btn)
    //      onCancel: function(val, eueditor, editor, btn)
    //      ... 
    //  返回值:返回创建的 easyui-dialog 对象;
    $.easyui.showUeditorDialog = function (options) {
        if (options && options.topMost && $ != $.util.$ && $.util.$.easyui.showUeditorDialog) {
            return $.util.$.easyui.showUeditorDialog.apply(this, options);
        }
        var opts = $.extend({}, $.easyui.showUeditorDialog.defaults, options || {}),
            ueditor, editor, value = opts.value,
            dia = $.easyui.showDialog($.extend({}, opts, {
                content: "<div class=\"ueditor-dialog-container\"></div>",
                enableApplyButton: false, topMost: false,
                onDestroy: function () { if (ueditor) { ueditor.ueditor("destroy"); } },
                onResize: function () {
                    var ret = $.fn.dialog.defaults.onResize.apply(this, arguments);
                    if ($.isFunction(opts.onResize)) { opts.onResize.apply(this, arguments); }
                    return ret;
                },
                onSave: function () { return opts.onEnter.call(dia, value, ueditor, editor, this); },
                onClose: function () {
                    if (editor && editor.fontset) { editor.fontset.dialog("close"); }
                    return opts.onCancel.call(dia, value, ueditor, editor, this);
                },
                onMove: function () {
                    var ret = $.fn.dialog.defaults.onMove.apply(this, arguments);
                    if (editor && editor.fontset && !editor.fontset.dialog("options").closed) {
                        var offset = $(editor.container).offset();
                        editor.fontset.dialog("open").dialog("move", { top: offset.top - 50, left: offset.left })
                    }
                    return ret;
                },
                onBeforeDestroy: function () {
                    if (editor && editor.fontset) { editor.fontset.dialog("destroy"); }
                }
            }));
        $.util.exec(function () {
            var container = dia.find(".ueditor-dialog-container").ueditor($.extend({}, opts, {
                fit: true, border: false, value: value, autosave: false, enableAutoSave: false,
                onResize: $.fn.ueditor.defaults.onResize,
                oncontentChange: function () {
                    value = $(this).ueditor("options").value;
                    if ($.isFunction(opts.oncontentChange)) { opts.oncontentChange.apply(this, arguments); }
                }
            }));
            dia.ueditor = ueditor = container;
            dia.editor = editor = container.ueditor("editor");
        });
        return dia;
    };
 
 
    $.easyui.showUeditorDialog.defaults = {
        title: "Html 编辑器窗口",
        iconCls: "icon-standard-application-form-edit",
        width: 665, height: 480, minWidth: 400, minHeight: 240,
        maximizable: true,
        collapsible: true,
        value: null, zIndex: 20000, focus: true, template: "normal",
        onEnter: function (val, editor, btn) { },
        onCancel: function (val, editor, btn) { }
    };
 
 
 
 
 
 
 
    $.fn.ueditor.methods = {
 
        options: function (jq) { return getOptions(jq[0]); },
 
        panel: function (jq) { return $.data(jq[0], "ueditor").panel; },
 
        editor: function (jq) { return $.data(jq[0], "ueditor").editor; },
 
        textarea: function (jq) { return $.data(jq[0], "ueditor").textarea; },
 
        resize: function (jq, size) { return jq.each(function () { resize(this, size); }); },
 
 
        //  销毁编辑器实例
        destroy: function (jq) { return jq.each(function () { destroy(this); }); },
 
        //  同步数据到编辑器所在的form 从编辑器的容器节点向上查找form元素
        //      若找到,就同步编辑内容到找到的form里,为提交数据做准备,主要用于是手动提交的情况 后台取得数据的键值,使用你容器上的name属性
        //      如果没有就使用参数里的textarea项
        sync: function (jq, formId) { return jq.each(function () { sync(this, formId); }); },
 
        //  为编辑器的编辑命令提供快捷键 这个接口是为插件扩展提供的接口,主要是为新添加的插件,如果需要添加快捷键,所提供的接口
        //  该方法的参数 param 表示命令名和快捷键键值对对象,多个按钮的快捷键用“+”分隔,格式如 { "Bold" : "ctrl+66", "Italic" : "ctrl+73" }
        addshortcutkey: function (jq, param) { return jq.each(function () { return jq.each(function () { addshortcutkey(this, param); }); }); },
 
        //  获取编辑器的内容。 可以通过参数定义编辑器内置的判空规则
        getContent: function (jq, filter) { return getContent(jq[0], filter); },
 
        //  取得完整的html代码,可以直接显示成完整的html文档
        getAllHtml: function (jq) { return getAllHtml(jq[0]); },
 
        //  得到编辑器的纯文本内容,但会保留段落格式
        getPlainTxt: function (jq) { return getPlainTxt(jq[0]); },
 
        //  获取编辑器中的纯文本内容,没有段落格式
        getContentTxt: function (jq) { return getContentTxt(jq[0]); },
 
        //  设置编辑器的内容,可修改编辑器当前的html内容;该方法的参数 param 可以为以下类型;
        //      String:value
        //      Object:{ value, isAppendTo }
        setContent: function (jq, param) { return jq.each(function () { setContent(this, param); }); },
 
        //  让编辑器获得焦点,默认focus到编辑器头部,toEnd确定focus位置
        focus: function (jq, toEnd) { return jq.each(function () { setFocus(this, toEnd); }); },
 
        //  执行编辑命令cmdName,完成富文本编辑效果
        execCommand: function (jq, cmdName) { return execCommand(jq[0], cmdName); },
 
        //  根据传入的command命令,查选编辑器当前的选区,根据命令返回相关的值
        queryCommandState: function (jq, cmdName) { return queryCommandState(jq[0], cmdName); },
 
        //  根据传入的command命令,查选编辑器当前的选区,根据命令返回相关的值
        queryCommandValue: function (jq, cmdName) { return queryCommandValue(jq[0], cmdName); },
 
        //  检查编辑区域中是否有内容,若包含参数tags中的节点类型,直接返回true
        hasContents: function (jq, tags) { return hasContents(jq[0], tags); },
 
        //  重置编辑器,可用来做多个tab使用同一个编辑器实例
        reset: function (jq) { return jq.each(function () { reset(this); }); },
 
        //  设置当前编辑区域可以编辑,except中的命令除外
        setEnabled: function (jq, except) { return jq.each(function () { setEditorDisabled(this, false, except); }); },
 
        //  设置当前编辑区域不可编辑,except中的命令除外
        setDisabled: function (jq, except) { return jq.each(function () { setEditorDisabled(this, true, except); }); },
 
        //  显示编辑器
        setShow: function (jq) { return jq.each(function () { showEditor(this); }); },
 
        //  隐藏编辑器
        setHide: function (jq) { return jq.each(function () { hideEditor(this); }); },
 
        //  根据指定的路径,获取对应的语言资源
        getLang: function (jq, path) { return getLang(jq[0], path); },
 
        //  计算编辑器html内容或纯文本字符串的长度
        getContentLength: function (jq, ingoneHtml) { return getContentLength(jq[0], ingoneHtml); },
 
        //  注册输入过滤规则
        addInputRule: function (jq, rule) { return jq.each(function () { addInputRule(this, rule); }); },
 
        //  注册输出过滤规则
        addOutputRule: function (jq, rule) { return jq.each(function () { addOutputRule(this, rule); }); },
 
 
        //  同 setShow 方法
        show: function (jq) { return jq.each(function () { showEditor(this); }); },
 
        //  同 setHide 方法
        hide: function (jq) { return jq.each(function () { hideEditor(this); }); },
 
        //  同 setEnabled 方法
        enable: function (jq, except) { return jq.each(function () { setEditorDisabled(this, false, except); }); },
 
        //  同 setDisabled 方法
        disable: function (jq, except) { return jq.each(function () { setEditorDisabled(this, true, except); }); },
 
        //  参数 param 同 getContent 的参数 filter。
        getValue: function (jq, param) { return getValue(jq[0], param); },
 
        //
        setValue: function (jq, value) { return jq.each(function () { setValue(this, value); }); },
 
        //
        append: function (jq, value) { return jq.each(function () { setValue(this, value, true); }); },
 
        //  同 focus 方法;
        setFocus: function (jq, toEnd) { return jq.each(function () { setFocus(this, toEnd); }); },
 
        //  清空文档
        clear: function (jq) { return jq.each(function () { clear(this); }); },
 
 
        validate: function (jq) { return jq.each(function () { validate(this); }); },
 
        isValid: function (jq) { return validate(jq[0]); },
 
        enableValidation: function (jq) { return jq.each(function () { setValidation(this, false) }); },
 
        disableValidation: function (jq) { return jq.each(function () { setValidation(this, true) }); }
    };
 
    $.fn.ueditor.defaults = {
 
        //  工具栏上的所有的功能按钮和下拉框,可以在new编辑器的实例时选择自己需要的从新定义
        toolbars: $.fn.ueditor.toolbars,
        //  语言配置项,默认是zh-cn
        lang: "zh-cn",
        //  是否启用自动保存
        enableAutoSave: true,
        //  自动保存间隔时间, 单位ms
        saveInterval: 500,
        //  主题配置项,默认是default。
        theme: "default",
        //  针对getAllHtml方法,会在对应的head标签中增加该编码设置。
        charset: "utf-8",
        //  常用配置项目
        isShow: true,
        //  初始化编辑器的内容,也可以通过textarea/script给值,看官网例子
        initialContent: "",
        //  提交表单时,服务器获取编辑器提交内容的所用的参数
        textarea: "editorValue",
        //  初始化时,是否让编辑器获得焦点true或false
        focus: false,
        //  是否开启初始化时即全屏,默认为 false
        fullscreen: false,
        //  编辑器初始化结束后,编辑区域是否是只读的,默认是false
        readonly: false,
        //  编辑器层级的基数,默认是900
        zIndex: 900,
        //  图片操作的浮层开关,默认打开
        imagePopup: true,
        //  是否开启表情本地化,默认关闭。若要开启请确保emotion文件夹下包含官网提供的images表情文件夹
        emotionLocalization: false,
        //  是否默认为纯文本粘贴。false为不使用纯文本粘贴,true为使用纯文本粘贴
        pasteplain: false,
        //  字号列表
        fontsize: [10, 11, 12, 14, 16, 18, 20, 24, 36],
        //  段落格式列表,值留空时支持多语言自动识别,若配置,则以配置值为准
        paragraph: { p: "", h1: "", h2: "", h3: "", h4: "", h5: "", h6: "" },
        //  段前间距 值和显示的名字相同
        rowspacingtop: ['5', '10', '15', '20', '25'],
        //  段后间距 值和显示的名字相同
        rowspacingbottom: ['5', '10', '15', '20', '25'],
        //行内间距 值和显示的名字相同
        lineheight: ['1', '1.5', '1.75', '2', '3', '4', '5'],
        //快捷菜单,即选中部分文字后浮现出的快捷菜单内容
        shortcutMenu: ["fontfamily", "fontsize", "bold", "italic", "underline", "forecolor", "backcolor", "insertorderedlist", "insertunorderedlist"],
        //  是否开启字数统计
        wordCount: true,
        //  允许的最大字符数
        maximumWords: 10000,
        //  字数统计提示,{#count}代表当前字数,{#leave}代表还可以输入多少字符数,留空支持多语言自动切换,否则按此配置显示
        wordCountMsg: "当前已输入 {#count} 个字符,您还可以输入{#leave} 个字符",
        //  点击tab键时移动的距离,tabSize倍数
        tabSize: 4,
        //  tabNode什么字符做为单位
        tabNode: "&nbsp;",
        //  是否启用元素路径,默认是显示
        elementPathEnabled: true,
        //  是否自动长高,默认true
        autoHeightEnabled: true,
        //  是否可以拉伸长高,默认false
        scaleEnabled: false,
        //  表格是否可以拖拽
        tableDragable: true,
        //  源码的查看方式,codemirror 是代码高亮,textarea是文本框,默认是codemirror
        sourceEditor: "codemirror",
        //  编辑器初始化完成后是否进入源码模式,默认为 false
        sourceEditorFirst: false,
 
        //  开关右键菜单,默认为true
        enableContextMenu: true,
 
        //  指定产出的列表中是否嵌套P标签,默认是false
        disablePInList: false,
 
        //  指定粘贴时是否是只保留标签模式,默认是false
        retainOnlyLabelPasted: false,
 
        //  指定编辑器是否启用自动保存草稿功能,默认是true
        autosave: true,
 
 
        //  编辑器准备就绪后会触发该事件
        onready: function () { },
 
        //  执行destroy方法,会触发该事件
        ondestroy: function () { },
 
        //  执行reset方法,会触发该事件
        onreset: function () { },
 
        //  执行focus方法,会触发该事件
        onfocus: function () { },
 
        //  语言加载完成会触发该事件
        onlangReady: function () { },
 
        //  运行命令之后会触发该命令
        onbeforeExecCommand: function () { },
 
        //  运行命令之后会触发该命令
        onafterExecCommand: function () { },
 
        //  运行命令之前会触发该命令
        onfirstBeforeExecCommand: function () { },
 
        //  在getContent方法执行之前会触发该事件
        onbeforeGetContent: function () { },
 
        //  在getContent方法执行之后会触发该事件
        onafterGetContent: function () { },
 
        //  在getAllHtml方法执行时会触发该事件
        ongetAllHtml: function () { },
 
        //  在setContent方法执行之前会触发该事件
        onbeforeSetContent: function () { },
 
        //  在setContent方法执行之后会触发该事件
        onafterSetContent: function () { },
 
        //  每当编辑器内部选区发生改变时,将触发该事件
        onselectionchange: function () { },
 
        //  在所有selectionchange的监听函数执行之前,会触发该事件
        onbeforeSelectionChange: function () { },
 
        //  在所有selectionchange的监听函数执行完之后,会触发该事件
        onafterSelectionChange: function () { },
 
        //  编辑器内容发生改变时会触发该事件
        oncontentChange: function () { },
 
        //  当调用 setHeight 方法重置编辑器高度时触发
        onsetHeight: function () { }
    };
 
    $.extend($.fn.ueditor.defaults, {
 
        fit: false,
 
        border: true,
 
        width: 600,
 
        height: 150,
        //  同 initialContent,表示初始化编辑器的内容;不过其优先级高于 initialContent 和 textarea/script 的 innerText;
        //  当设置了该属性后,初始化编辑器的内容将被强制设为该属性值,而无论是否设置了 initialContent 或 textarea/script 的 innerText;
        value: null,
 
        toolbarsTemplate: {
            //
            simple: [[
                'fontset', '|', 'forecolor', 'backcolor',
                //'fontfamily', 'fontsize', 'forecolor', 'backcolor', 'bold', 'italic', 'underline',
                '|', 'emotion', 'scrawl', '|', 'snapscreen', 'insertimage', 'attachment', '|', 'source'//, 'preview'
            ]],
            normal: [[
                'bold', 'italic', 'underline',
                '|', 'fontfamily', 'fontsize', 'forecolor', 'backcolor',
                '|', 'justifyleft', 'justifycenter', 'justifyright', 'justifyjustify',
                '|', 'insertorderedlist', 'insertunorderedlist',
                '|', 'indent', 'blockquote', 'link', 'formatmatch',
                '|', 'source'//, 'preview'
            ]],
            //
            rich: [[]],
            full: $.fn.ueditor.toolbars
        },
 
        template: "normal",
        //  getValue 方法所使用的内部取值方法
        valueMethod: "getContent",
        //  编辑器初始化完成后是否立即将其执行 setDisabled 操作使其禁用;
        disabled: false,
 
 
        codeMirrorJsUrl: undefined,
        codeMirrorCssUrl: undefined,
        autoHeightEnabled: false,
        scaleEnabled: false,
 
 
        required: false,
        missingMessage: "该编辑框不能为空.",
        //  "left", "right", "top", "bottom"
        tipPosition: "right",
        deltaX: 0,
        tipOptions: $.fn.validatebox.defaults.tipOptions,
        novalidate: false,
 
 
        //  当调整编辑器大小时,触发该事件
        onResize: function (width, height) { }
    });
 
 
    $.parser.plugins.push("ueditor");
 
    if ($.fn.form && $.isArray($.fn.form.otherList)) {
        $.fn.form.otherList.push("ueditor");
        //$.array.insert($.fn.form.otherList, 0, "ueditor");
    }
 
})(jQuery);