<commit_before>import { Class } from '../../core/Core';
import '../../foundation/ObservableProps';  // For Function#observes
import View from '../View';

/**
    Class: O.LabelView

    Extends: O.View

    A LabelView simply displays a string of text, and optionally has a tooltip.
    Its DOM structure is:

        <span title="${view.tooltip}">${view.value}</span>

    Although you may often want to change the layer tag (e.g. to an `h1` etc.)
*/
const LabelView = Class({

    Extends: View,

    /**
        Property: O.LabelView#layerTag
        Type: String
        Default: 'span'

        Overrides default in <O.View#layerTag>.
    */
    layerTag: 'span',

    /**
        Property: O.LabelView.value
        Type: String
        Default: ''

        The text to display in the view.
    */
    value: '',

    /**
        Property: O.LabelView#tooltip
        Type: String
        Default: ''

        The tooltip for the view.
    */
    tooltip: '',

    /**
        Method: O.LabelView#draw

        Overridden to draw view. See <O.View#draw>.
    */
    draw ( layer/*, Element, el*/ ) {
        layer.title = this.get( 'tooltip' );
        layer.textContent = this.get( 'value' );
    },

    /**
        Method: O.LabelView#labelNeedsRedraw

        Calls <O.View#propertyNeedsRedraw> for extra properties requiring
        redraw.
    */
    labelNeedsRedraw: function ( self, property, oldValue ) {
        return this.propertyNeedsRedraw( self, property, oldValue );
    }.observes( 'tooltip', 'value' ),

    /**
        Method: O.LabelView#redrawTooltip

        Parameters:
            layer - {Element} The DOM layer for the view.

        Updates the title attribute on the DOM layer to match the tooltip
        property of the view.
    */
    redrawTooltip ( layer ) {
        layer.title = this.get( 'tooltip' );
    },

    /**<commit_msg>LabelView: omit title attribute when no tooltip<commit_after>import { Class } from '../../core/Core';
import '../../foundation/ObservableProps';  // For Function#observes
import View from '../View';

/**
    Class: O.LabelView

    Extends: O.View

    A LabelView simply displays a string of text, and optionally has a tooltip.
    Its DOM structure is:

        <span title="${view.tooltip}">${view.value}</span>

    Although you may often want to change the layer tag (e.g. to an `h1` etc.)
*/
const LabelView = Class({

    Extends: View,

    /**
        Property: O.LabelView#layerTag
        Type: String
        Default: 'span'

        Overrides default in <O.View#layerTag>.
    */
    layerTag: 'span',

    /**
        Property: O.LabelView.value
        Type: String
        Default: ''

        The text to display in the view.
    */
    value: '',

    /**
        Property: O.LabelView#tooltip
        Type: String
        Default: ''

        The tooltip for the view.
    */
    tooltip: '',

    /**
        Method: O.LabelView#draw

        Overridden to draw view. See <O.View#draw>.
    */
    draw ( layer/*, Element, el*/ ) {
        const tooltip = this.get( 'tooltip' );
        if ( tooltip ) {
            layer.title = tooltip;
        }
        layer.textContent = this.get( 'value' );
    },

    /**
        Method: O.LabelView#labelNeedsRedraw

        Calls <O.View#propertyNeedsRedraw> for extra properties requiring
        redraw.
    */
    labelNeedsRedraw: function ( self, property, oldValue ) {
        return this.propertyNeedsRedraw( self, property, oldValue );
    }.observes( 'tooltip', 'value' ),

    /**
        Method: O.LabelView#redrawTooltip

        Parameters:
            layer - {Element} The DOM layer for the view.

        Updates the title attribute on the DOM layer to match the tooltip
        property of the view.
    */
    redrawTooltip ( layer ) {
        const tooltip = this.get( 'tooltip' );
        if ( tooltip ) {
            layer.title = tooltip;
        } else {
            layer.removeAttribute( 'title' );
        }
    },

    /**
{'fraction_non_alphanumeric': 0.12321204516938519, 'fraction_numerical': 0.0005018820577164366, 'mean_word_length': 1.9094890510948905, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, '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': '801410', 'n_tokens_mistral': 1185, 'n_tokens_neox': 1149, 'n_words': 345}