<commit_before>/**
骨骼数面板的view
@module
**/
define([
    'underscore',
    'view.panel.abstractSkeleton', 'view.abstractBone',
    'tmpl!html/panel.boneTree.bone.html'
], function(
    _,
    AbstractSkeleton, AbstractBone,
    boneTmpl
){
    var BoneTreePanel, Bone;

    /**
    @class BoneTreePanel
    @extends AbstractSkeleton
    **/
    BoneTreePanelView = PanelView.extend({
        el: '#js-boneTreePanel',

        initialize: function(){
            // 复用父类的`initialize`方法
            BoneTreePanel.__super__.initialize.apply(this, arguments);

            // 此面板中所有骨骼view构成的hash，用骨骼的id索引
            this._boneHash = {};
        },

        render: function(bonesData){
            this.$el
                .html( this.panelTmpl({
                    type: 'boneTree',
                    title: '骨骼树'
                }) );

            // 如果有传入骨骼数据，渲染出骨骼view
            if(bonesData){
                bonesData.forEach(function(boneData){
                    this.addBone(boneData);
                }, this);
            }

            // 缓存DOM元素
            this.$bd = this.$('>.bd');

            return this;
        }
    });

    /**
    @class Bone
    @extends AbstractBone
    **/
    Bone = AbstractBone.extend({
        attributes: {
            'class': 'js-bone'
        },

        /**
        @param {Object} [options]
        **/
        initialize: function(options){
            // TODO:
            // 拖拽调整骨骼位置，
            // 抛出事件move，带上自身id，目标父骨骼的id
        },

        /**
        @param {Object} boneData 骨骼的数据<commit_msg>Improve render of bone-tree panel<commit_after>/**
骨骼数面板的view
@module
**/
define([
    'underscore',
    'view.panel.abstractSkeleton', 'view.abstractBone',
    'tmpl!html/panel.boneTree.html', 'tmpl!html/panel.boneTree.bone.html'
], function(
    _,
    AbstractSkeleton, AbstractBone,
    boneTreeTmpl, boneTmpl
){
    var BoneTreePanel, Bone;

    /**
    @class BoneTreePanel
    @extends AbstractSkeleton
    **/
    BoneTreePanelView = PanelView.extend({
        el: '#js-boneTreePanel',

        initialize: function(){
            // 复用父类的`initialize`方法
            BoneTreePanel.__super__.initialize.apply(this, arguments);

            // 此面板中所有骨骼view构成的hash，用骨骼的id索引
            this._boneHash = {};
        },

        render: function(bonesData){
            // 渲染空面板
            this.$el.html( boneTreeTmpl() );

            // 如果有传入骨骼数据，渲染出骨骼view
            if(bonesData && bonesData.length){
                bonesData.forEach(function(boneData){
                    this.addBone(boneData);
                }, this);
            }

            // 缓存DOM元素
            this._$bd = this.$el.children('.bd');

            return this;
        }
    });

    /**
    @class Bone
    @extends AbstractBone
    **/
    Bone = AbstractBone.extend({
        attributes: {
            'class': 'js-bone'
        },

        /**
        @param {Object} [options]
        **/
        initialize: function(options){
            // TODO:
            // 拖拽调整骨骼位置，
            // 抛出事件move，带上自身id，目标父骨骼的id
        },

        /**
        @param {Object} boneData 骨骼的数据
{'fraction_non_alphanumeric': 0.1293213828425096, 'fraction_numerical': 0.0, 'mean_word_length': 1.5120578778135048, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, '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': '2474785', 'n_tokens_mistral': 1090, 'n_tokens_neox': 1063, 'n_words': 142}