<commit_before>;
(function ($) {
    window.xTree = function (options) {
        return new tree(options);
    };

    var defOpt = {
        dom: '', //jqueryDom
        position: 'absolute',
        is_trigger: false, //是否需要触发? 否则直接显示
        has_search: false,
        searchType: 'all', //'all'全部，'node'节点，'leaf'叶子
        only_child: false, //是否结果只要 child
        node_merge: false, //结果只显示最上层  比如   中国被选中  四川,成都则不会显示  否则 每个被勾选的节点都显示
        zIndex: 99,
        is_multi: true, //是否多选
        expand: false, //是否展开，false、true、num, (0、false,都展开ROOT级。true,完全展开。num>=1时，展开到对应级）
        width: null,
        maxHeight: 300,
        data: [], //{id:1,name:'xx',nodeId:'0',is_node:true,is_check:false},
        sel_ids: '',
        onInit: function () {},
        onBeforeOpen: function () {},
        onOpen: function () {},
        onCheck: function () {},
        onCancel: function () {},
        onChange: function () {},
        onClose: function () {},
    };
    var defState = {
        _is_open: false, //是否open
        _originId: {
            nodeId: [],
            id: []
        }, //上次打开时候选中了哪一些id
        _searchTimer: '' //搜索框的定时器
    };

    var tree = function (opt) {
        this._init(opt);
        return this;
    };

    tree.prototype = {
        _init: function (opt) {
            var res = this._validateOpt(opt);
            if (!res) {
                return false;
            }

            this.opt = $.extend(true, {}, defOpt, opt);
            this.state = $.extend({}, defState);
            this.data = this.opt.data;
            this.tree = this._arrayToTree(this.data);
            this.$tree = this._makeTree(this.tree);

            this.dom = this.opt.dom;
            if (this.opt.position === 'fixed') {
                $('body').append(this.$tree);
            } else {
                this.dom.css({
                    'position': 'relative'
                });
                this.dom.append(this.$tree);
            }

            if (this.opt.sel_ids) {
                if (this.opt.is_multi) {
                    this._checkTreeByIds(this.tree, this.opt.sel_ids);
                } else {
                    this._checkDataRadio(this.data, this.opt.sel_ids);
                }
            }

            this.opt.onInit.apply(this);

            var that = this;
            if (this.opt.is_trigger) {
                this.dom.off('click.xTree');
                this.dom.on('click.xTree', function (e) {
                    if (that.state._is_open && !that.$tree.is(e.target) && that.$tree.has(e.target).length === 0 ) {
                        that.hide();
                    } else {
                        that.show();
                    }
                });
                $(document).on('click.xTree', function (e) {
                    var a = that.dom;
                    var b = that.$tree;
                    if (!a.is(e.target) && a.has(e.target).length === 0 && !b.is(e.target) && b.has(e.target).length === 0) {
                        that.hide();
                    }
                });
            } else {
                that.show();
            }
        },

        /**
         *      方法
         *
         */
        show: function () {
            this.opt.onBeforeOpen.apply(this);
            this._showTree();
            this.state._is_open = true;
            this.opt.onOpen.apply(this);
            return this;
        },
        hide: function () {
            if (this.state._is_open) {<commit_msg>format<commit_after>;
(function ($) {
    window.xTree = function (options) {
        return new tree(options);
    };

    var defOpt = {
        dom: '', //jqueryDom
        position: 'absolute',
        is_trigger: false, //是否需要触发? 否则直接显示
        has_search: false,
        searchType: 'all', //'all'全部，'node'节点，'leaf'叶子
        only_child: false, //是否结果只要 child
        node_merge: false, //结果只显示最上层  比如   中国被选中  四川,成都则不会显示  否则 每个被勾选的节点都显示
        zIndex: 99,
        is_multi: true, //是否多选
        expand: false, //是否展开，false、true、num, (0、false,都展开ROOT级。true,完全展开。num>=1时，展开到对应级）
        width: null,
        maxHeight: 300,
        data: [], //{id:1,name:'xx',nodeId:'0',is_node:true,is_check:false},
        sel_ids: '',
        onInit: function () {},
        onBeforeOpen: function () {},
        onOpen: function () {},
        onCheck: function () {},
        onCancel: function () {},
        onChange: function () {},
        onClose: function () {},
    };
    var defState = {
        _is_open: false, //是否open
        _originId: {
            nodeId: [],
            id: []
        }, //上次打开时候选中了哪一些id
        _searchTimer: '' //搜索框的定时器
    };

    var tree = function (opt) {
        this._init(opt);
        return this;
    };

    tree.prototype = {
        _init: function (opt) {
            var res = this._validateOpt(opt);
            if (!res) {
                return false;
            }

            this.opt = $.extend(true, {}, defOpt, opt);
            this.state = $.extend({}, defState);
            this.data = this.opt.data;
            this.tree = this._arrayToTree(this.data);
            this.$tree = this._makeTree(this.tree);

            this.dom = this.opt.dom;
            if (this.opt.position === 'fixed') {
                $('body').append(this.$tree);
            } else {
                this.dom.css({
                    'position': 'relative'
                });
                this.dom.append(this.$tree);
            }

            if (this.opt.sel_ids) {
                if (this.opt.is_multi) {
                    this._checkTreeByIds(this.tree, this.opt.sel_ids);
                } else {
                    this._checkDataRadio(this.data, this.opt.sel_ids);
                }
            }

            this.opt.onInit.apply(this);

            var that = this;
            if (this.opt.is_trigger) {
                this.dom.off('click.xTree');
                this.dom.on('click.xTree', function (e) {
                    if (that.state._is_open && !that.$tree.is(e.target) && that.$tree.has(e.target).length === 0) {
                        that.hide();
                    } else {
                        that.show();
                    }
                });
                $(document).on('click.xTree', function (e) {
                    var a = that.dom;
                    var b = that.$tree;
                    if (!a.is(e.target) && a.has(e.target).length === 0 && !b.is(e.target) && b.has(e.target).length === 0) {
                        that.hide();
                    }
                });
            } else {
                that.show();
            }
        },

        /**
         *      方法
         *
         */
        show: function () {
            this.opt.onBeforeOpen.apply(this);
            this._showTree();
            this.state._is_open = true;
            this.opt.onOpen.apply(this);
            return this;
        },
        hide: function () {
            if (this.state._is_open) {
{'fraction_non_alphanumeric': 0.1486254295532646, 'fraction_numerical': 0.003436426116838488, 'mean_word_length': 1.2330562659846547, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '474660', 'n_tokens_mistral': 2229, 'n_tokens_neox': 2206, 'n_words': 356}