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
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
/**
* 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 toolbar Plugin Extensions 1.0 beta
* jQuery EasyUI toolbar 插件扩展
* jquery.toolbar.js
* 二次开发 流云
* 最近更新:2014-05-07
*
* 依赖项:
*   1、jquery.jdirk.js
*   2、jeasyui.extensions.js
*   3、jeasyui.extensions.linkbutton
*   4、jeasyui.extensions.validatebox
*   5、combo
*   5、numberbox
*   6、numberspinner
*   6、timespinner
*   7、datebox
*   7、datetimebox
*   7、combobox
*   7、combotree
*   7、combogrid
*   8、jeasyui.extensions.combo
*   9、jeasyui.extensions.combobox
*   10、jeasyui.extensions.menu
*   11、jeasyui.extensions.panel
*   12、jeasyui.extensions.window
*   13、jeasyui.extensions.dialog
*   14、jeasyui.extensions.tree
*   15、jeasyui.extensions.combotree
*   16、jeasyui.extensions.datagrid
*   17、jeasyui.extensions.combogrid
*   18、jeasyui.extensions.searchbox
*   19、jeasyui.extensions.comboicons
*   20、jeasyui.extensions.comboselector
*   21、jeasyui.extensions.my97
*
* Copyright (c) 2013-2014 ChenJianwei personal All rights reserved.
* http://www.chenjianwei.org
*/
(function ($, undefined) {
 
    function initialize(target) {
        var t = $(target), isDiv = /^(?:div)$/i.test(target.nodeName), cc = t.children(),
            toolbar = isDiv ? t : $("<div></div>").insertAfter(t).append(t);
        if (!isDiv) {
            toolbar.attr({ "class": t.attr("class"), "style": t.attr("style") }).removeClass("easyui-toolbar");
            t.children().each(function () { toolbar.append(this); });
            t.hide();
        }
        var state = $.data(target, "toolbar"), opts = state.options;
        state.toolbar = toolbar.addClass("dialog-toolbar toolbar");
        t.addClass("toolbar-f");
 
        state.wrapper = $("<table class='toolbar-wrapper' cellspacing='0' cellpadding='0' ></table>").appendTo(toolbar);
        appendItem(target, cc);
 
        setSize(target, { width: opts.width, height: opts.height });
        toolbar.bind("_resize", function () {
            setSize(target);
        });
    };
 
    function setSize(target, size) {
        var t = $(target), state = $.data(target, "toolbar"),
            toolbar = state.toolbar, opts = state.options;
        size = $.extend({ width: opts.width, height: opts.height }, size || {});
        toolbar.css({
            width: size.width, height: size.height
        });
        $.extend(opts, size);
        $.util.exec(function () {
            setAlign(target, opts.align);
            setValign(target, opts.valign);
        });
        opts.onResize.call(target, $.isNumeric(size.width) ? size.width : toolbar.width(), $.isNumeric(size.height) ? size.height : toolbar.height());
    };
 
    function setAlign(target, align) {
        align = String(align);
        if (!$.array.contains(["left", "center", "right"], align.toLowerCase())) { return; }
        var t = $(target), state = $.data(target, "toolbar"),
            wrapper = state.wrapper, opts = state.options, left = 0;
        opts.align = align;
        wrapper.removeClass("toolbar-align-left toolbar-align-center toolbar-align-right").addClass("toolbar-align-" + align);
    };
 
    function setValign(target, valign) {
        valign = String(valign);
        if (!$.array.contains(["top", "middle", "bottom"], valign.toLowerCase())) { return; }
        var t = $(target), state = $.data(target, "toolbar"),
            toolbar = state.toolbar, wrapper = state.wrapper, opts = state.options,
            outerHeight = toolbar.height(), height = wrapper.height(), top;
        opts.valign = valign;
        wrapper.removeClass("toolbar-valign-top toolbar-valign-middle toolbar-valign-bottom").addClass("toolbar-valign-" + valign);
        switch (valign) {
            case "top": top = 0; break;
            case "middle": top = (outerHeight - height) / 2; break;
            case "bottom": top = (outerHeight - height); break;
        }
        wrapper.css("top", Math.max(top, 0));
    };
 
 
 
    function appendItemToContainer(target, container, item) {
        var state = $.data(target, "toolbar"), opts = state.options;
        if ($.util.isDOM(item)) {
            var cell = $(item).addClass("toolbar-item").appendTo(container), text = cell.text();
            if (/^(?:div|span)$/i.test(cell[0].nodeName) && $.array.contains(["-", "—", "|"], text)) {
                cell.addClass("dialog-tool-separator").empty();
                $.data(cell[0], "toolbar-item-data", {
                    actions: opts.itemOptions.separator, target: cell, options: {}, type: "separator", container: container
                });
            } else {
                $.data(cell[0], "toolbar-item-data", {
                    actions: null, target: cell, options: null, type: "custom", container: container
                });
            }
        } else if ($.array.contains(["string", "number", "date"], $.type(item))) {
            item = $.string.trim(item);
            if ($.array.contains(["-", "—", "|"], item)) {
                appendItemToContainer(target, container, { type: "separator" });
            } else if ($.string.isHtmlText(item)) {
                $(item).each(function () { appendItemToContainer(target, container, this); });
            } else {
                appendItemToContainer(target, container, { type: "label", options: { text: item } });
            }
        } else {
            var itemOpts = $.extend({}, opts.itemOptions, item || {}),
                actions = opts.itemTypes[itemOpts.type];
            if (!actions || !actions.init) { return; }
            var tItem = actions.init(container[0], itemOpts.options || itemOpts).addClass("toolbar-item");
            if (itemOpts.id) { tItem.attr("id", itemOpts.id); }
            if (itemOpts.name) { tItem.attr("name", itemOpts.name); }
            if (itemOpts.cls) { container.addClass(itemOpts.cls); }
            if (itemOpts.itemCls) { tItem.addClass(itemOpts.itemCls); }
            if (itemOpts.style) { container.css(itemOpts.style); }
            if (itemOpts.itemStyle) { tItem.css(itemOpts.itemStyle); }
            if (itemOpts.width) { container.css("width", itemOpts.width); }
            if (itemOpts.align) { container.css("text-align", itemOpts.align); }
            if (itemOpts.htmlAttr) { tItem.attr(itemOpts.htmlAttr); }
            $.data(tItem[0], "toolbar-item-data", {
                actions: actions, target: tItem, options: itemOptions.options, type: itemOpts.type, container: container
            });
        }
    };
 
    function appendItemOption(target, item) {
        if (!item) { return; }
        var state = $.data(target, "toolbar"),
            tr = state.wrapper.find("tr:last");
        if (!tr.length) { tr = $("<tr class='toolbar-row'></tr>").appendTo(state.wrapper); }
        var container = $("<td class='toolbar-item-container'></td>").appendTo(tr);
        appendItemToContainer(target, container, item);
    };
 
    function appendItem(target, item) {
        if (!item) { return; }
        if ($.array.likeArrayNotString(item)) {
            if (item.length) {
                $.each(item, function (i, n) { appendItem(target, n); });
            }
        } else if ($.isFunction(item)) {
            appendItem(target, item.call(target), false);
        } else {
            appendItemOption(target, item);
        }
    }
 
 
 
 
    function getItemIndex(target, item) {
        var ret = -1;
        if (!item) { return ret; }
        item = $(item);
        var t = $(target), wrapper = t.toolbar("wrapper"), tr = wrapper.find("tr:last");
        if (!tr.length || $.contains(tr[0], item[0])) { return ret; }
        ret = item.closest("toolbar-item-container").index();
        return ret;
    }
 
    function getItem(target, index) {
        if (index == null || index == undefined) { return null; }
        var item = null, itemEle, t = $(target), wrapper = t.toolbar("wrapper"), tr = wrapper.find("tr:last");
        if (!tr.length) { return item; }
        var tds = tr.find(">td.toolbar-item-container"), td = null;
        if ($.isNumeric(index)) {
            if (tds.length >= index && index >= 0) { itemEle = tds.eq(index).find(".toolbar-item"); }
        }
        if (itemEle && itemEle.length) {
            item = $.data(itemEle[0], "toolbar-item-data");
        }
        return item;
    };
 
    function getItems(target) {
        var ret = [], t = $(target), wrapper = t.toolbar("wrapper");
        wrapper.find("tr:last>td.toolbar-item-container .toolbar-item").each(function () {
            var item = $.data(this, "toolbar-item-data");
            if (item) { ret.push(item); }
        });
        return ret;
    };
 
    function removeItem(target, index) {
        var item = getItem(target, index);
        if (item) {
            if (item.actions && $.isFunction(item.actions.destroy)) { actions.destroy(item.target[0]); }
            item.container.remove();
        }
    };
 
    function updateItem(target, param) {
        if (!param || !$.isNumeric(param.index) || !param.item) { return; }
        var item = getItem(target, param.index), container = item.container.empty();
        appendItemToContainer(target, container, param.item)
    };
 
 
 
 
    function clear(target) {
        var state = $.data(target, "toolbar");
        state.wrapper.empty();
        state.data = null;
    };
 
    function loadData(target, data) {
        var state = $.data(target, "toolbar"), opts = state.options;
        state.data = opts.loadFilter.call(target, data);
        state.wrapper.empty();
        appendItem(target, state.data);
        opts.onLoadSuccess.call(target, data);
    };
 
    function request(target, queryParams) {
        var state = $.data(target, "toolbar"), opts = state.options;
        opts.queryParams = queryParams || {};
        if (opts.onBeforeLoad.call(target, opts.queryParams) == false) return;
        opts.loader.call(target, opts.queryParams, function (data) {
            loadData(target, data);
        }, function () {
            opts.onLoadError.apply(this, arguments);
        });
    };
 
    function getData(target) {
        return $.data(target, "toolbar").data;
    };
 
    function getValues(target) {
        return $(target).serializeObject();
    };
 
 
 
 
    function setItemFocus(target, index) {
        var item = getItem(target, index);
        if (item) {
            if (item.actions && $.isFunction(item.actions.setFocus)) {
                item.actions.setFocus(item.target[0]);
            } else {
                item.target.focus();
            }
        }
    };
 
    function setItemValue(target, param) {
        if (!param || !$.isNumeric(param.index)) { return; }
        var item = getItem(target, param.index);
        if (item && item.actions && $.isFunction(item.actions.setValue)) {
            item.actions.setValue(item.target[0], param.value);
        }
    };
 
    function getItemValue(target, index) {
        var item = getItem(target, index), ret = null;
        if (item) {
            ret = item.actions && $.isFunction(item.actions.getValue) ? item.actions.getValue(item.target[0]) : item.target[0].value;
        }
        return ret;
    };
 
    function resizeItem(target, param) {
        if (!param || !$.isNumeric(param.index) || !param.width) { return; }
        var item = getItem(target, index);
        if (item) {
            if (item.actions && $.isFunction(item.actions.resize)) {
                item.actions.resize(item.target[0], param.width);
            } else {
                item.target.width(param.width);
            }
        }
    };
 
 
    function enableItem(target, index) {
        var item = getItem(target, index);
        if (item && item.actions && $.isFunction(item.actions.enable)) {
            item.actions.enable(item.target[0]);
        }
    };
 
    function disableItem(target, index) {
        var item = getItem(target, index);
        if (item && item.actions && $.isFunction(item.actions.disable)) {
            item.actions.disable(item.target[0]);
        }
    };
 
    function enable(target) {
        var items = getItems(target);
        $.each(items, function (i, item) {
            if (item.actions && $.isFunction(item.actions.enable)) {
                item.actions.enable(item.target[0]);
            }
        });
    };
 
    function disable(target) {
        var items = getItems(target);
        $.each(items, function (i, item) {
            if (item.actions && $.isFunction(item.actions.disable)) {
                item.actions.disable(item.target[0]);
            }
        });
    };
 
    function destroy(target) {
        var t = $(target), state = $.data(target, "toolbar");
        if (state.toolbar) {
            state.toolbar.each(function () { destroyContent(this); }).remove();
        }
        t.remove();
    };
 
    function destroyContent(target) {
        var t = $(target);
        t.find(".combo-f").each(function () { $(this).combo("destroy"); });
        t.find(".m-btn").each(function () { $(this).menubutton("destroy"); });
        t.find(".s-btn").each(function () { $(this).splitbutton("destroy"); });
        t.find(".tooltip-f").each(function () { $(this).tooltip("destroy"); });
        t.children("div").each(function () { $(this)._fit(false); });
    };
 
 
 
    var itemTypes = {
        separator: {
            init: function (container) {
                return $("<div class='dialog-tool-separator'></div>").appendTo(container);
            }
        },
        label: {
            defaults: { text: " " },
            init: function (container, options) {
                var opts = $.extend({}, this.defaults, options || {});
                return $("<span class='toolbar-item-label'></span>").text(opts.text).appendTo(container);
            },
            enable: function (target) {
                $(target).removeClass("toolbar-item-label-disabled");
            },
            disable: function (target) {
                $(target).addClass("toolbar-item-label-disabled");
            }
        },
        button: {
            defaults: { plain: true, iconCls: "icon-ok" },
            init: function (container, options) {
                var opts = $.extend({}, this.defaults, options || {}),
                    handler = opts.onclick || opts.handler,
                    btn = $("<a class='toolbar-item-button'></a>").appendTo(container);
                if (handler) {
                    handler = $.string.toFunction(handler);
                }
                return btn.linkbutton($.extend(opts, {
                    onClick: function () {
                        if ($.isFunction(handler)) {
                            handler.call(this, $(container).closest("table.toolbar-wrapper")[0]);
                        }
                    }
                }));
            },
            enable: function (target) {
                $(target).linkbutton("enable");
            },
            disable: function (target) {
                $(target).linkbutton("disable");
            }
        },
        textbox: {
            defaults: { value: null, disabled: false, width: null },
            init: function (container, options) {
                var opts = $.extend({}, this.defaults, options || {}),
                    box = $("<input type='text' class='toolbar-item-input' />").appendTo(container);
                if (opts.value) { this.setValue(box[0], opts.value); }
                if (opts.disabled) { this.disable(box[0]); }
                if (opts.width) { this.resize(box[0], opts.width); }
                return box;
            },
            setValue: function (target, value) {
                $(target).val(value);
            },
            getValue: function (target) {
                return $(target).val();
            },
            resize: function (target, width) {
                $(target)._outerWidth(width);
            },
            enable: function (target) {
                $(target).removeAttr("disabled", true);
            },
            disable: function (target) {
                $(target).attr("disabled", true);
            }
        },
        checkbox: {
            defaults: { checked: false, disabled: false, text: " " },
            init: function (container, options) {
                options = options || {};
                var opts = $.extend({}, this.defaults, $.util.isString(options) ? { text: options } : options),
                    label = $("<label class='toolbar-item-checkbox'></label>").appendTo(container),
                    box = $("<input type='checkbox' class='toolbar-item-checkbox-input' />").appendTo(label),
                    span = $("<span class='toolbar-item-checkbox-text'></span>").text(opts.text).appendTo(label);
                if (opts.checked) { this.setValue(box[0], opts.checked); }
                if (opts.disabled) { this.disable(box[0]); }
                return box;
            },
            setValue: function (target, value) {
                $(target).attr("checked", value ? true : false);
            },
            getValue: function (target) {
                return $(target)[0].checked;
            },
            enable: function (target) {
                $(target).removeAttr("disabled").parent().find(">span.toolbar-item-checkbox-text").removeClass("toolbar-item-checkbox-disabled");
            },
            disable: function (target) {
                $(target).attr("disabled", true).parent().find(">span.toolbar-item-checkbox-text").addClass("toolbar-item-checkbox-disabled");
            }
        },
        validatebox: {
            defaults: { value: null, disabled: false, width: null },
            init: function (container, options) {
                var opts = $.extend({}, this.defaults, options || {}),
                    box = $("<input type='text' class='toolbar-item-input' />").appendTo(container).validatebox(opts);
                if (opts.value) { this.setValue(box[0], opts.value); }
                if (opts.disabled) { this.disable(box[0]); }
                if (opts.width) { this.resize(box[0], opts.width); }
                return box;
            },
            setValue: function (target, value) {
                $(target).val(value);
            },
            getValue: function (target) {
                return $(target).val();
            },
            resize: function (target, width) {
                $(target)._outerWidth(width);
            },
            enable: function (target) {
                $(target).removeAttr("disabled");
            },
            disable: function (target) {
                $(target).attr("disabled", true);
            }
        },
        numberbox: {
            defaults: { width: null },
            init: function (container, options) {
                var opts = $.extend({}, this.defaults, options || {}),
                    box = $("<input type='text' class='toolbar-item-input' />").appendTo(container).numberbox(opts);
                if (opts.width) { this.resize(box[0], opts.width); }
                return box;
            },
            destroy: function (target) {
                $(target).numberbox("destroy");
            },
            setValue: function (target, value) {
                $(target).numberbox("setValue", value);
            },
            getValue: function (target) {
                return $(target).numberbox("getValue");
            },
            resize: function (target, width) {
                $(target)._outerWidth(width);
            },
            enable: function (target) {
                $(target).numberbox("enable");
            },
            disable: function (target) {
                $(target).numberbox("disable");
            }
        },
        numberspinner: {
            defaults: {},
            init: function (container, options) {
                var opts = $.extend({}, this.defaults, options || {}),
                    box = $("<input type='text' class='toolbar-item-input' />").appendTo(container).numberspinner(opts);
                return box;
            },
            destroy: function (target) {
                $(target).numberspinner("destroy");
            },
            setValue: function (target, value) {
                $(target).numberspinner("setValue", value);
            },
            getValue: function (target) {
                return $(target).numberspinner("getValue");
            },
            resize: function (target, width) {
                $(target).numberspinner("resize", width);
            },
            enable: function (target) {
                $(target).numberspinner("enable");
            },
            disable: function (target) {
                $(target).numberspinner("disable");
            }
        },
        timespinner: {
            defaults: {},
            init: function (container, options) {
                var opts = $.extend({}, this.defaults, options || {}),
                    box = $("<input type='text' class='toolbar-item-input' />").appendTo(container).timespinner(opts);
                return box;
            },
            destroy: function (target) {
                $(target).timespinner("destroy");
            },
            setValue: function (target, value) {
                $(target).timespinner("setValue", value);
            },
            getValue: function (target) {
                return $(target).timespinner("getValue");
            },
            resize: function (target, width) {
                $(target).timespinner("resize", width);
            },
            enable: function (target) {
                $(target).timespinner("enable");
            },
            disable: function (target) {
                $(target).timespinner("disable");
            }
        },
        datebox: {
            defaults: {},
            init: function (container, options) {
                var opts = $.extend({}, this.defaults, options || {}),
                    box = $("<input type='text' class='toolbar-item-input' />").appendTo(container).datebox(opts);
                return box;
            },
            destroy: function (target) {
                $(target).datebox("destroy");
            },
            setValue: function (target, value) {
                $(target).datebox("setValue", value);
            },
            getValue: function (target) {
                return $(target).datebox("getValue");
            },
            resize: function (target, width) {
                $(target).datebox("resize", width);
            },
            enable: function (target) {
                $(target).datebox("enable");
            },
            disable: function (target) {
                $(target).datebox("disable");
            },
            setFocus: function (target) {
                $(target).datebox("textbox").focus();
            }
        },
        datetimebox: {
            defaults: {},
            init: function (container, options) {
                var opts = $.extend({}, this.defaults, options || {}),
                    box = $("<input type='text' class='toolbar-item-input' />").appendTo(container).datetimebox(opts);
                return box;
            },
            destroy: function (target) {
                $(target).datetimebox("destroy");
            },
            setValue: function (target, value) {
                $(target).datetimebox("setValue", value);
            },
            getValue: function (target) {
                return $(target).datetimebox("getValue");
            },
            resize: function (target, width) {
                $(target).datetimebox("resize", width);
            },
            enable: function (target) {
                $(target).datetimebox("enable");
            },
            disable: function (target) {
                $(target).datetimebox("disable");
            },
            setFocus: function (target) {
                $(target).datetimebox("textbox").focus();
            }
        },
        combo: {
            defaults: {},
            init: function (container, options) {
                var opts = $.extend({}, this.defaults, options || {}),
                    box = $("<input type='text' class='toolbar-item-input' />").appendTo(container).combo(opts);
                return box;
            },
            destroy: function (target) {
                $(target).combo("destroy");
            },
            setValue: function (target, value) {
                $(target).combo($.util.likeArrayNotString(value) ? "setValues" : "setValue", value);
            },
            getValue: function (target) {
                var combo = $(target), opts = combo.combo("options");
                return $(target).combo(opts.multiples ? "getValues" : "getValue");
            },
            resize: function (target, width) {
                $(target).combo("resize", width);
            },
            enable: function (target) {
                $(target).combo("enable");
            },
            disable: function (target) {
                $(target).combo("disable");
            },
            setFocus: function (target) {
                $(target).combo("textbox").focus();
            }
        },
        combobox: {
            defaults: {},
            init: function (container, options) {
                var opts = $.extend({}, this.defaults, options || {}),
                    box = $("<input type='text' class='toolbar-item-input' />").appendTo(container).combobox(opts);
                return box;
            },
            destroy: function (target) {
                $(target).combobox("destroy");
            },
            setValue: function (target, value) {
                $(target).combobox($.util.likeArrayNotString(value) ? "setValues" : "setValue", value);
            },
            getValue: function (target) {
                var combo = $(target), opts = combo.combobox("options");
                return $(target).combobox(opts.multiples ? "getValues" : "getValue");
            },
            resize: function (target, width) {
                $(target).combobox("resize", width);
            },
            enable: function (target) {
                $(target).combobox("enable");
            },
            disable: function (target) {
                $(target).combobox("disable");
            },
            setFocus: function (target) {
                $(target).combobox("textbox").focus();
            }
        },
        combotree: {
            defaults: {},
            init: function (container, options) {
                var opts = $.extend({}, this.defaults, options || {}),
                    box = $("<input type='text' class='toolbar-item-input' />").appendTo(container).combotree(opts);
                return box;
            },
            destroy: function (target) {
                $(target).combotree("destroy");
            },
            setValue: function (target, value) {
                $(target).combotree($.util.likeArrayNotString(value) ? "setValues" : "setValue", value);
            },
            getValue: function (target) {
                var combo = $(target), opts = combo.combotree("options");
                return $(target).combotree(opts.multiples ? "getValues" : "getValue");
            },
            resize: function (target, width) {
                $(target).combotree("resize", width);
            },
            enable: function (target) {
                $(target).combotree("enable");
            },
            disable: function (target) {
                $(target).combotree("disable");
            },
            setFocus: function (target) {
                $(target).combotree("textbox").focus();
            }
        },
        combogrid: {
            defaults: {},
            init: function (container, options) {
                var opts = $.extend({}, this.defaults, options || {}),
                    box = $("<input type='text' class='toolbar-item-input' />").appendTo(container).combogrid(opts);
                return box;
            },
            destroy: function (target) {
                $(target).combogrid("destroy");
            },
            setValue: function (target, value) {
                $(target).combogrid($.util.likeArrayNotString(value) ? "setValues" : "setValue", value);
            },
            getValue: function (target) {
                var combo = $(target), opts = combo.combogrid("options");
                return $(target).combogrid(opts.multiples ? "getValues" : "getValue");
            },
            resize: function (target, width) {
                $(target).combogrid("resize", width);
            },
            enable: function (target) {
                $(target).combogrid("enable");
            },
            disable: function (target) {
                $(target).combogrid("disable");
            },
            setFocus: function (target) {
                $(target).combogrid("textbox").focus();
            }
        },
        comboicons: {
            defaults: {},
            init: function (container, options) {
                var opts = $.extend({}, this.defaults, options || {}),
                    box = $("<input type='text' class='toolbar-item-input' />").appendTo(container).comboicons(opts);
                return box;
            },
            destroy: function (target) {
                $(target).comboicons("destroy");
            },
            setValue: function (target, value) {
                $(target).comboicons($.util.likeArrayNotString(value) ? "setValues" : "setValue", value);
            },
            getValue: function (target) {
                var combo = $(target), opts = combo.comboicons("options");
                return $(target).comboicons(opts.multiples ? "getValues" : "getValue");
            },
            resize: function (target, width) {
                $(target).comboicons("resize", width);
            },
            enable: function (target) {
                $(target).comboicons("enable");
            },
            disable: function (target) {
                $(target).comboicons("disable");
            },
            setFocus: function (target) {
                $(target).comboicons("textbox").focus();
            }
        },
        comboselector: {
            defaults: {},
            init: function (container, options) {
                var opts = $.extend({}, this.defaults, options || {}),
                    box = $("<input type='text' class='toolbar-item-input' />").appendTo(container).comboselector(opts);
                return box;
            },
            destroy: function (target) {
                $(target).comboselector("destroy");
            },
            setValue: function (target, value) {
                $(target).comboselector($.util.likeArrayNotString(value) ? "setValues" : "setValue", value);
            },
            getValue: function (target) {
                var combo = $(target), opts = combo.comboselector("options");
                return $(target).comboselector(opts.multiples ? "getValues" : "getValue");
            },
            resize: function (target, width) {
                $(target).comboselector("resize", width);
            },
            enable: function (target) {
                $(target).comboselector("enable");
            },
            disable: function (target) {
                $(target).comboselector("disable");
            },
            setFocus: function (target) {
                $(target).comboselector("textbox").focus();
            }
        },
        my97: {
            defaults: {},
            init: function (container, options) {
                var opts = $.extend({}, this.defaults, options || {}),
                    box = $("<input type='text' class='toolbar-item-input' />").appendTo(container).my97(opts);
                return box;
            },
            destroy: function (target) {
                $(target).my97("destroy");
            },
            setValue: function (target, value) {
                $(target).my97($.util.likeArrayNotString(value) ? "setValues" : "setValue", value);
            },
            getValue: function (target) {
                var combo = $(target), opts = combo.my97("options");
                return $(target).my97(opts.multiples ? "getValues" : "getValue");
            },
            resize: function (target, width) {
                $(target).my97("resize", width);
            },
            enable: function (target) {
                $(target).my97("enable");
            },
            disable: function (target) {
                $(target).my97("disable");
            },
            setFocus: function (target) {
                $(target).my97("textbox").focus();
            }
        },
        searchbox: {
            defaults: {},
            init: function (container, options) {
                var opts = $.extend({}, this.defaults, options || {}),
                    box = $("<input type='text' class='toolbar-item-input' />").appendTo(container);
                if (opts.searcher) {
                    opts.searcher = $.string.toFunction(opts.searcher);
                }
                return box.searchbox(opts);
            },
            destroy: function (target) {
                $(target).searchbox("destroy");
            },
            setValue: function (target, value) {
                $(target).searchbox("setValue", value);
            },
            getValue: function (target) {
                return $(target).searchbox("getValue");
            },
            resize: function (target, width) {
                $(target).searchbox("resize", width);
            },
            enable: function (target) {
                $(target).searchbox("enable");
            },
            disable: function (target) {
                $(target).searchbox("disable");
            },
            setFocus: function (target) {
                $(target).searchbox("textbox").focus();
            }
        }
    }, itemOptions = {
        id: null,
        name: null,
        type: "button",
        options: null,
        cls: null,
        style: null,
        itemCls: null,
        itemStyle: null,
        width: null,
        align: null,
        htmlAttr: null
    }, loader = function (param, success, error) {
        var opts = $(this).toolbar("options");
        if (!opts.url) { return false; }
        $.ajax({
            type: opts.method, url: opts.url, data: param, dataType: "json",
            success: function (data) {
                success(data);
            }, error: function () {
                error.apply(this, arguments);
            }
        });
    }, loadFilter = function (data) {
        return $.array.likeArrayNotString(data) ? data : [];
    };
 
    itemTypes.text = itemTypes.textbox;
    itemTypes.linkbutton = itemTypes.button;
 
 
 
 
 
    $.fn.toolbar = function (options, param) {
        if (typeof options == "string") {
            return $.fn.toolbar.methods[options](this, param);
        }
        options = options || {};
        return this.each(function () {
            var state = $.data(this, "toolbar");
            if (state) {
                $.extend(state.options, options);
            } else {
                state = $.data(this, "toolbar", {
                    options: $.extend({}, $.fn.toolbar.defaults, $.fn.toolbar.parseOptions(this), options)
                });
            }
            initialize(this);
            if (state.options.data) {
                loadData(this, state.options.data);
            }
            request(this);
        });
    };
 
    $.fn.toolbar.parseOptions = function (target) {
        return $.extend({}, $.parser.parseOptions(target, ["url", "data", "method", "width", "height", "align", "valign"]));
    };
 
 
    $.fn.toolbar.methods = {
 
        //  获取当前 easyui-toolbar 控件的 options 参数对象;
        //  返回值:返回当前 easyui-toolbar 控件的 options 参数对象,为一个 JSON-Object。
        options: function (jq) { return $.data(jq[0], 'toolbar').options; },
 
        //  获取当前 easyui-toolbar 控件的工具栏包装器对象;
        //  返回值:返回当前 easyui-toolbar 控件的工具栏包装器对象;该方法返回一个包含 html-table 的 jQuery 对象。
        wrapper: function (jq) { return $.data(jq[0], "toolbar").wrapper; },
 
        //  获取当前 easyui-toolbar 控件的工具栏外框对象;
        //  返回值:返回当前 easyui-toolbar 控件的工具栏外框对象;该方法返回一个包含 html-div 的 jQuery 对象。
        toolbar: function (jq) { return $.data(jq[0], "toolbar").toolbar; },
 
        //  设置当前 easyui-toolbar 控件的尺寸大小;该方法的参数 size 为一个 JSON-Object,该参数定义如下属性:
        //      width : 表示工具栏的新宽度;如果设置为数值类型,则表示像素宽度;如果设置为 "auto",则表示自适应最大宽度;
        //      height: 表示工具栏的新高度;如果设置为数值类型,则表示像素高度;如果设置为 "auto",则表示自适应一行按钮的高度;
        //  返回值:返回表示当前 easyui-toolbar 控件的 jQuery 链式对象。
        resize: function (jq, size) { return jq.each(function () { setSize(this, size); }); },
 
        //  设置当前 easyui-toolbar 控件的工具栏项水平居中方式;该方法的参数 align 为一个 String 类型值,其可以被定义的值限定为如下范围:
        //      left  :
        //      right :
        //      center:
        //  返回值:返回表示当前 easyui-toolbar 控件的 jQuery 链式对象。
        align: function (jq, align) { return jq.each(function () { setAlign(this, align); }); },
 
        //  设置当前 easyui-toolbar 控件的工具栏项垂直居中方式;该方法的参数 valign 为一个 String 类型值,其可以被定义的值限定为如下范围:
        //      top   :
        //      middle:
        //      bottom:
        //  返回值:返回表示当前 easyui-toolbar 控件的 jQuery 链式对象。
        valign: function (jq, valign) { return jq.each(function () { setValign(this, valign); }); },
 
        //  获取当前 easyui-toolbar 控件的所有工具栏子项数据;
        //  返回值:返回表示当前 easyui-toolbar 控件的所有工具栏子项数据所构成的一个数组,数组的每个元素格式参考 getItem 方法的返回值。
        getItems: function (jq) { return getItems(jq[0]); },
 
        //  获取当前 easyui-toolbar 控件的指定位置的工具栏子项数据;该方法的参数 index 表示要获取的工具栏子项的索引号,从 0 开始计数;
        //  返回值:返回表示当前 easyui-toolbar 控件指定位置的工具栏子项数据所构成的一个包含如下属性的 JSON-Object:
        //      actions:    表示该工具栏子项的初始化构造器;其值为 $.fn.toolbar.defaults.itemTypes 中的一个子项;
        //      options:    表示该工具栏子项初始化时的 options 参数数据;
        //      target :    表示该工具栏子项包含 "toolbar-item" 样式类的元素的 jQuery-DOM 对象;
        //      type   :    表示该工具栏子项的类型,如果是自定义加载的 html-DOM 对象则为 "custom"
        //      container:  表示该工具栏子项所在的 jQuery-DOM(html-td) 对象;
        getItem: function (jq, index) { return getItem(jq[0], index); },
 
        //  获取指定的工具栏子项在当前 easyui-toolbar 控件中的索引号;
        //      该方法的参数 item 表示一个工具栏子项,为一个 String 格式的 jQuery 选择器,或者是一个 HTML-DOM 对象,或者是一个 jQuery-DOM 对象。
        //  返回值:返回指定的工具栏子项在当前 easyui-toolbar 控件中的索引号,从 0 开始计数;
        //      如果 item 所示的对象不存在于当前 easyui-toolbar 中,则返回 -1。
        getItemIndex: function (jq, item) { return getItemIndex(jq[0], item); },
 
        //  获取当前 easyui-toolbar 控件加载的所有数据;仅在初始化该控件指定的 data 参数、通过 loadData 方法加载的数据和通过 url 远程加载的数据,才会被返回;
        //  返回值:返回一个数组对象,数组中的每一项都表示一个工具栏子项的数据格式(返回数据的格式参考 loadData 方法的参数 data 的数据格式)。
        getData: function (jq) { return getData(jq[0]); },
 
        //  获取当前 easyui-toolbar 控件中所有输入控件的输入值集合;
        //  返回值:返回一个 JSON-Object 对象,该对象中每个属性表示工具栏中一个具备输入值功能的子项控件,其值为输入控件当前的值;
        getValues: function (jq) { return getValues(jq[0]); },
 
        //  在当前 easyui-toolbar 中增加一个工具栏项;该方法的参数 item 可以定义为如下类型:
        //      1、jQuery-DOM 对象:
        //      2、HTML-DOM 对象:
        //      3、String 类型:可以为以下类型:
        //          a:"-"、"—"、"|",表示分割线的 separator
        //          b:"<" 开头和 ">" 结尾切字符串度大于等于3,表示 HTML 代码段;
        //          c:"\t"、"\n",表示换行
        //          d:其他长度大于 0 的字符串,表示 label。
        //      4、JSON-Object 对象:
        //          id      : 
        //          type    : $.fn.toolbar.defaults.itemTypes 中定义的工具栏项类型,例如 separator、label、button、textbox、checkbox、numberbox、validatebox、combobox、combotree、combogrid 等;
        //          options : 初始化该工具栏项的参数;
        //          style   :
        //          itemCls :
        //          width   :
        //          align   :
        //      5、Array 数组类型:
        //  返回值:返回表示当前 easyui-toolbar 控件的 jQuery 链式对象。
        appendItem: function (jq, item) { return jq.each(function () { appendItem(this, item); }); },
 
        //  在当前的 easyui-toolbar 中移除一个工具栏项;该方法的参数 index 表示要删除的工具栏项的索引号,从 0 开始计数;
        //  返回值:返回表示当前 easyui-toolbar 控件的 jQuery 链式对象。
        removeItem: function (jq, index) { return jq.each(function () { removeItem(this, index); }); },
 
        //  将当前 easyui-toolbar 中指定位置的工具栏项替换成另一个工具栏项;该方法的参数 param 为一个 JSON-Object,包含如下属性定义:
        //      index:  表示要替换的工具栏项的索引号,从 0 开始计数;
        //      item:   参考 appendItem 方法的参数 item。
        //  返回值:返回表示当前 easyui-toolbar 控件的 jQuery 链式对象。
        updateItem: function (jq, param) { return jq.each(function () { updateItem(this, param); }); },
 
        //  启用当前 easyui-toolbar 控件的某个工具栏子项;该方法的参数 index 表示要操作的工具栏子项的索引号,从 0 开始计数;
        //  返回值:返回表示当前 easyui-toolbar 控件的 jQuery 链式对象。
        enableItem: function (jq, index) { return jq.each(function () { enableItem(this, index); }); },
 
        //  禁用当前 easyui-toolbar 控件的某个工具栏子项;该方法的参数 index 表示要操作的工具栏子项的索引号,从 0 开始计数;
        //  返回值:返回表示当前 easyui-toolbar 控件的 jQuery 链式对象。
        disableItem: function (jq, index) { return jq.each(function () { disableItem(this, index); }); },
 
        //  设置当前 easyui-toolbar 控件中指定索引号工具栏子项使其获取焦点;该方法的参数 param 为一个 JSON-Object,包含如下属性定义:
        //      index: 表示要设置值的工具栏子项的索引号,从 0 开始计数;
        //      value: 表示要设置的新值;
        //  返回值:返回表示当前 easyui-toolbar 控件的 jQuery 链式对象。
        setItemFocus: function (jq, index) { return jq.each(function () { setItemFocus(this, index); }); },
 
        //  设置当前 easyui-toolbar 控件中指定索引号工具栏子项的值;该方法的参数 param 为一个 JSON-Object,包含如下属性定义:
        //      index: 表示要设置值的工具栏子项的索引号,从 0 开始计数;
        //      value: 表示要设置的新值;
        //  返回值:返回表示当前 easyui-toolbar 控件的 jQuery 链式对象。
        //  备注:仅当 index 指定的工具栏子项存在且支持赋值(setValue)操作时,该方法才生效;
        setItemValue: function (jq, param) { return jq.each(function () { setItemValue(this, param); }); },
 
        //  获取当前 easyui-toolbar 控件中指定索引号工具栏子项的值;方法的参数 index 表示要获取值的工具栏子项的索引号,从 0 开始计数;
        //  返回值:返回指定索引号位置的工具栏子项的值;
        //  备注:仅当 index 指定的工具栏子项存在且支持取值(getValue)操作时,该方法才生效;
        getItemValue: function (jq, index) { return getItemValue(jq[0], index); },
 
        //  重新设置当前 easyui-toolbar 控件中指定索引号工具栏子项的宽度值;该方法的参数 param 为一个 JSON-Object,包含如下属性定义:
        //      index: 表示要设置宽度值的工具栏子项的索引号,从 0 开始计数;
        //      width: 表示要设置的新宽度值;
        //  返回值:返回表示当前 easyui-toolbar 控件的 jQuery 链式对象。
        //  备注:仅当 index 指定的工具栏子项存在且支持 resize 操作时,该方法才生效;
        resizeItem: function (jq, param) { return jq.each(function () { resizeItem(this, param); }); },
 
        //  启用当前 easyui-toolbar 控件的所有工具栏子项;
        //  返回值:返回表示当前 easyui-toolbar 控件的 jQuery 链式对象。
        enable: function (jq) { return jq.each(function () { enable(this); }); },
 
        //  禁用当前 easyui-toolbar 控件的所有工具栏子项;
        //  返回值:返回表示当前 easyui-toolbar 控件的 jQuery 链式对象。
        disable: function (jq) { return jq.each(function () { disable(this); }); },
 
        //  清空当前 easyui-toolbar 控件的所有工具栏子项;
        //  返回值:返回表示当前 easyui-toolbar 控件的 jQuery 链式对象。
        clear: function (jq) { return jq.each(function () { clear(this); }); },
 
        //  请求远程 url 地址所示的服务器数据并重新加载当前 easyui-toolbar 控件的所有工具栏子项;该方法的参数 queryParams 为一个 JSON-Object,表示请求远程数据时发送的查询参数;
        //  返回值:返回表示当前 easyui-toolbar 控件的 jQuery 链式对象。
        //  备注:执行该方法会清空当前 easyui-toolbar 控件中原来的所有子项控件。
        load: function (jq, queryParams) { return jq.each(function () { request(this, queryParams); }); },
 
        //  以指定的数据重新加载当前 easyui-toolbar 控件的所有工具栏子项;该方法的参数 data 为一个数组,表示请求远程数据时发送的查询参数;数组中的每项都表示一个待加载的工具栏子项,其可以定义为如下类型:
        //      1、jQuery-DOM 对象:
        //      2、HTML-DOM 对象:
        //      3、String 类型:可以为以下类型:
        //          a:"-"、"—"、"|",表示分割线的 separator
        //          b:"<" 开头和 ">" 结尾切字符串度大于等于3,表示 HTML 代码段;
        //          c:"\t"、"\n",表示换行
        //          d:其他长度大于 0 的字符串,表示 label。
        //      4、JSON-Object 对象:
        //          id      : 
        //          type    : $.fn.toolbar.defaults.itemTypes 中定义的工具栏项类型,例如 separator、label、button、textbox、checkbox、numberbox、validatebox、combobox、combotree、combogrid 等;
        //          options : 初始化该工具栏项的参数;
        //          style   :
        //          itemCls :
        //          width   :
        //          align   :
        //  返回值:返回表示当前 easyui-toolbar 控件的 jQuery 链式对象。
        //  备注:执行该方法会清空当前 easyui-toolbar 控件中原来的所有子项控件。
        loadData: function (jq, data) { return jq.each(function () { loadData(this, data); }); },
 
        destroy: function (jq) { return jq.each(function () { destroy(this); }); }
    };
 
    $.fn.toolbar.defaults = {
 
        //  表示远程服务器访问地址,用于从远程服务器加载工具栏数据;
        url: null,
 
        //  表示 easyui-toolbar 控件在初始时需要加载的内容数据;
        data: null,
 
        method: "post",
 
        //  表示 easyui-toolbar 控件的宽度,Number 类型数值;默认为 auto;
        width: "auto",
 
        //  表示 easyui-toolbar 控件的高度,Number 类型数值;默认为 auto;
        height: "auto",
 
        //  表示 easyui-toolbar 控件的横向对齐方式,可选的值为 "left"、"center" 或 "right";默认为 "left";
        align: "left",
 
        //  表示 easyui-toolbar 控件的纵向对齐方式,可选的值为 "top"、"middle" 或 "bottom";默认为 "middle";
        valign: "middle",
 
        //  表示 easyui-toolbar 的尺寸大小重置事件;当控件大小被调整后触发;该事件回调函数定义如下参数:
        //      width: 被设置的新的宽度;
        //      height: 被设置的新的告诉。
        //  回调函数中的 this 表示当前 easyui-toolbar 的 DOM 对象。
        onResize: function (width, height) { },
 
        onLoadSuccess: function (data) { },
 
        onLoadError: function () { },
 
        onBeforeLoad: function (param) { },
 
        //  定义 easyui-toolbar 插件能够添加的工具栏项类型;
        //  开发人员可以通过扩展 $.fn.toolbar.defaults.itemTypes 属性来实现其自定义的 easyui-toolbar 工具栏项类型;
        //      就像扩展 $.fn.datagrid.defaults.editors 一样。
        //  已经内置的工具栏项类型有:
        //      separator   :
        //      label       :
        //      button      :
        //      textbox     :
        //      checkbox    :
        //      validatebox :
        //      numberbox   :
        //      datebox     :
        //      combobox    :
        //      combotree   :
        //      combogrid   :
        itemTypes: itemTypes,
 
        loader: loader,
 
        loadFilter: loadFilter,
 
        itemOptions: itemOptions
    };
 
 
 
    $.parser.plugins.push("toolbar");
 
})(jQuery);