<commit_before>//@flow
import template from '../../templates/selectionCell.hbs';

const config = {
    TRANSITION_DELAY: 400
};

const selectionTypes = {
    all: 'all',
    single: 'single'
};

const classes = {
    checked: 'editor_checked',
    checked_some: 'editor_checked_some',
    selected: 'selected',
    dragover: 'dragover',
    hover: 'hover',
    hover__transition: 'hover__transition',
    rowChecked: 'row-checked'
};

export default Marionette.View.extend({
    initialize(options) {
        if (options.selectionType === selectionTypes.all) {
            this.collection = options.collection;
            this.selectAllCell = true;
        } else {
            this.collection = options.model.collection;
            this.model.currentIndex = this.model.collection.indexOf(this.model) + 1;
        }
    },

    template: Handlebars.compile(template),

    attributes() {
        return {
            draggable: this.getOption('draggable'),
            showCheckbox: this.getOption('showCheckbox')
        };
    },

    templateContext() {
        let index = '';
        if (this.getOption('showRowIndex') && this.model) {
            index = this.model.collection.indexOf(this.model) + 1;
        }
        return {
            draggable: this.getOption('draggable'),
            index,
            showCheckbox: this.getOption('showCheckbox')
        };
    },

    className() {
        return `${this.getOption('draggable') ? 'js-dots cell_draggable' : ''} ${this.options.showRowIndex ? 'cell_selection-index' : 'cell_selection'} ${
            this.options.checkboxColumnClass
        }`;
    },

    ui: {
        checkbox: '.js-checkbox',
        dots: '.js-dots',
        index: '.js-index'
    },

    events: {
        'click @ui.checkbox': '__handleCheckboxClick',
        dragstart: '__handleDragStart',
        dragend: '__handleDragEnd',
        click: '__handleClick',
        dblclick: '__handleDblClick',
        dragover: '__handleDragOver',
        dragenter: '__handleDragEnter',
        dragleave: '__handleDragLeave',
        drop: '__handleDrop',
        mouseenter: '__handleMouseEnter',
        mouseleave: '__handleMouseLeave',
        contextmenu: '__handleContextMenu'
    },

    modelEvents: {
        'update:model': '__updateIndex',
        selected: '__handleSelection',
        deselected: '__handleDeselection',
        dragover: '__handleModelDragOver',
        dragleave: '__handleModelDragLeave',
        drop: '__handleModelDrop',
        mouseenter: '__handleModelMouseEnter',
        mouseleave: '__handleModelMouseLeave',
        blink: '__blink',
        checked: '__addCheckedClass',
        unchecked: '__removeCheckedClass'
    },

    onRender() {
        this.__updateState();

        if (this.getOption('selectionType') === selectionTypes.all) {
            this.listenTo(this.collection, 'check:all check:none check:some', this.__updateState);
            this.listenTo(this.collection, 'dragover:head', this.__handleModelDragOver);
            this.listenTo(this.collection, 'dragleave:head', this.__handleModelDragLeave);
            this.listenTo(this.collection, 'drop:head', this.__handleModelDrop);
        } else {
            this.listenTo(this.model, 'checked unchecked checked:some', this.__updateState);
            if (this.model.selected) {
                this.__handleSelection();
            }
        }
    },

    __handleClick(event) {
        if (!this.selectAllCell) {
            this.model.trigger('click', event);
        }
    },

    __handleDblClick(event) {
        if (!this.selectAllCell) {
            this.model.trigger('dblclick', event);
        }
    },

    __handleCheckboxClick() {
        if (this.selectAllCell) {
            this.collection.toggleCheckAll();
        } else {
            this.model.toggleChecked();
            if (this.getOption('bindSelection')) {
                this.model.collection.updateTreeNodesCheck(this.model);
            }
        }
    },

    __handleDragStart(event) {
        this.collection.draggingModel = this.model;
        event.originalEvent.dataTransfer.setData('Text', this.cid); // fix for FireFox
    },

    __handleDragEnd() {
        delete this.collection.draggingModel;
        delete this.collection.dragoverModel;
    },

    __handleDragOver(event) {
        event.preventDefault();
    },

    __handleDragEnter(event) {
        this.collection.dragoverModel = this.model;
        this.__triggerIfAllow('dragover', event);<commit_msg>[#454572]fix expand scope event for checkbox<commit_after>//@flow
import template from '../../templates/selectionCell.hbs';

const config = {
    TRANSITION_DELAY: 400
};

const selectionTypes = {
    all: 'all',
    single: 'single'
};

const classes = {
    checked: 'editor_checked',
    checked_some: 'editor_checked_some',
    selected: 'selected',
    dragover: 'dragover',
    hover: 'hover',
    hover__transition: 'hover__transition',
    rowChecked: 'row-checked'
};

export default Marionette.View.extend({
    initialize(options) {
        if (options.selectionType === selectionTypes.all) {
            this.collection = options.collection;
            this.selectAllCell = true;
        } else {
            this.collection = options.model.collection;
            this.model.currentIndex = this.model.collection.indexOf(this.model) + 1;
        }
    },

    template: Handlebars.compile(template),

    attributes() {
        return {
            draggable: this.getOption('draggable'),
            showCheckbox: this.getOption('showCheckbox')
        };
    },

    templateContext() {
        let index = '';
        if (this.getOption('showRowIndex') && this.model) {
            index = this.model.collection.indexOf(this.model) + 1;
        }
        return {
            draggable: this.getOption('draggable'),
            index,
            showCheckbox: this.getOption('showCheckbox')
        };
    },

    className() {
        return `${this.getOption('draggable') ? 'js-dots cell_draggable' : ''} ${this.options.showRowIndex ? 'cell_selection-index' : 'cell_selection'} ${
            this.options.checkboxColumnClass
        }`;
    },

    ui: {
        checkbox: '.js-checkbox',
        dots: '.js-dots',
        index: '.js-index'
    },

    events: {
        dragstart: '__handleDragStart',
        dragend: '__handleDragEnd',
        click: '__handleClick',
        dblclick: '__handleDblClick',
        dragover: '__handleDragOver',
        dragenter: '__handleDragEnter',
        dragleave: '__handleDragLeave',
        drop: '__handleDrop',
        mouseenter: '__handleMouseEnter',
        mouseleave: '__handleMouseLeave',
        contextmenu: '__handleContextMenu'
    },

    modelEvents: {
        'update:model': '__updateIndex',
        selected: '__handleSelection',
        deselected: '__handleDeselection',
        dragover: '__handleModelDragOver',
        dragleave: '__handleModelDragLeave',
        drop: '__handleModelDrop',
        mouseenter: '__handleModelMouseEnter',
        mouseleave: '__handleModelMouseLeave',
        blink: '__blink',
        checked: '__addCheckedClass',
        unchecked: '__removeCheckedClass'
    },

    onRender() {
        this.__updateState();

        if (this.getOption('selectionType') === selectionTypes.all) {
            this.listenTo(this.collection, 'check:all check:none check:some', this.__updateState);
            this.listenTo(this.collection, 'dragover:head', this.__handleModelDragOver);
            this.listenTo(this.collection, 'dragleave:head', this.__handleModelDragLeave);
            this.listenTo(this.collection, 'drop:head', this.__handleModelDrop);
        } else {
            this.listenTo(this.model, 'checked unchecked checked:some', this.__updateState);
            if (this.model.selected) {
                this.__handleSelection();
            }
        }
    },

    __handleDblClick(event) {
        if (!this.selectAllCell) {
            this.model.trigger('dblclick', event);
        }
    },

    __handleClick(event) {
        if (!this.selectAllCell) {
            this.model.trigger('click', event);
        }
        if (this.selectAllCell) {
            this.collection.toggleCheckAll();
        } else {
            this.model.toggleChecked();
            if (this.getOption('bindSelection')) {
                this.model.collection.updateTreeNodesCheck(this.model);
            }
        }
    },

    __handleDragStart(event) {
        this.collection.draggingModel = this.model;
        event.originalEvent.dataTransfer.setData('Text', this.cid); // fix for FireFox
    },

    __handleDragEnd() {
        delete this.collection.draggingModel;
        delete this.collection.dragoverModel;
    },

    __handleDragOver(event) {
        event.preventDefault();
    },

    __handleDragEnter(event) {
        this.collection.dragoverModel = this.model;
        this.__triggerIfAllow('dragover', event);
{'fraction_non_alphanumeric': 0.12667860340196957, 'fraction_numerical': 0.0017905102954341987, 'mean_word_length': 2.3497001499250376, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '7241140', 'n_tokens_mistral': 2565, 'n_tokens_neox': 2518, 'n_words': 406}