<commit_before>define( [
            'dojo/_base/declare',
            'dojo/_base/lang',
            'dojo/_base/array',
            'dojo/dom-geometry',
            'dojo/on',
            'dojo/aspect',
            'dijit/Menu',
            'dijit/Dialog',
            'dijit/PopupMenuItem',
            'dijit/MenuItem',
            'JBrowse/View/Track/BlockBased',
            'JBrowse/View/Track/YScaleMixin',
            'JBrowse/Util',
            'JBrowse/View/GranularRectLayout'
        ],
      function( declare,
                lang,
                array,
                domGeom,
                on,
                aspect,
                dijitMenu,
                dijitDialog,
                dijitPopupMenuItem,
                dijitMenuItem,
                BlockBased,
                YScaleMixin,
                Util,
                Layout
              ) {

var HTMLFeatures = declare( BlockBased,

 /**
  * @lends JBrowse.View.Track.HTMLFeatures.prototype
  */
{
    /**
     * A track that draws discrete features using `div` elements.
     * @constructs
     * @extends JBrowse.View.Track.BlockBased
     * @param args.config {Object} track configuration. Must include key, label
     * @param args.refSeq {Object} reference sequence object with name, start,
     *   and end members.
     * @param args.changeCallback {Function} optional callback for
     *   when the track's data is loaded and ready
     * @param args.trackPadding {Number} distance in px between tracks
     */
    constructor: function( args ) {
        this.fields = {};
        this.refSeq = args.refSeq;

        //number of histogram bins per block
        this.numBins = 25;
        this.histLabel = false;
        this.padding = 5;
        this.trackPadding = args.trackPadding;

        this.config = args.config;

        // this featureStore object should eventually be
        // instantiated by Browser and passed into this constructor, not
        // constructed here.
        this.featureStore = args.store;

        // connect the store and track loadSuccess and loadFailed events
        // to eachother
        dojo.connect( this.featureStore, 'loadSuccess', this, 'loadSuccess' );
        dojo.connect( this.featureStore, 'loadFail',    this, 'loadFail' );

        // initialize a bunch of config stuff
        var defaultConfig = {
            description: true,
            style: {
                className: "feature2",
                histScale: 4,
                labelScale: 30,
                subfeatureScale: 80,
                maxDescriptionLength: 70,
                descriptionScale: 170
            },
            hooks: {
                create: function(track, feat ) {
                    return document.createElement('div');
                }
            },
            events: {
                click: this.config.style.linkTemplate
                    ? { action: "newWindow", url: this.config.style.linkTemplate }
                    : { action: "contentDialog", content: dojo.hitch( this, 'defaultFeatureDetail' ) }
            },
            menuTemplate: [
                { label: 'View details',
                  action: 'contentDialog',
                  iconClass: 'dijitIconTask',
                  content: dojo.hitch( this, 'defaultFeatureDetail' )
                }
            ]
        };
        Util.deepUpdate(defaultConfig, this.config);
        this.config = defaultConfig;

        this.eventHandlers = (function() {
            var handlers = dojo.clone( this.config.events || {} );
            // find conf vars that set events, like `onClick`
            for( var key in this.config ) {
                var handlerName = key.replace(/^on(?=[A-Z])/, '');
                if( handlerName != key )
                    handlers[ handlerName.toLowerCase() ] = this.config[key];
            }
            // interpret handlers that are just strings to be URLs that should be opened
            for( key in handlers ) {
                if( typeof handlers[key] == 'string' )
                    handlers[key] = { url: handlers[key] };
            }
            return handlers;
        }).call(this);
        this.eventHandlers.click = this._makeClickHandler( this.eventHandlers.click );
    },

    /**
     * Request that the track load its data.  The track will call its own
     * loadSuccess() function when it is loaded.
     */
    load: function() {
        this.featureStore.load();
    },

    loadSuccess: function() {
        this.inherited(arguments);
        this.labelScale = this.featureStore.density * this.config.style.labelScale;
        this.subfeatureScale = this.featureStore.density * this.config.style.subfeatureScale;
        this.descriptionScale = this.featureStore.density * this.config.style.descriptionScale;;
    },

    /**
     * Make a default feature detail page for the given feature.
     * @returns {HTMLElement} feature detail page HTML
     */
    defaultFeatureDetail: function( /** JBrowse.Track */ track, /** Object */ f, /** HTMLElement */ div ) {
        var fmt = dojo.hitch( this, '_fmtFeatureDetailField' );
        var container = dojo.create('div', { className: 'feature-detail feature-detail-'+track.name, innerHTML: '' } );
        container.innerHTML += fmt( 'Name', f.get('name') );<commit_msg>fix bug with HTMLFeatures loadSuccess rendering features before this.*Scale values are calculated<commit_after>define( [
            'dojo/_base/declare',
            'dojo/_base/lang',
            'dojo/_base/array',
            'dojo/dom-geometry',
            'dojo/on',
            'dojo/aspect',
            'dijit/Menu',
            'dijit/Dialog',
            'dijit/PopupMenuItem',
            'dijit/MenuItem',
            'JBrowse/View/Track/BlockBased',
            'JBrowse/View/Track/YScaleMixin',
            'JBrowse/Util',
            'JBrowse/View/GranularRectLayout'
        ],
      function( declare,
                lang,
                array,
                domGeom,
                on,
                aspect,
                dijitMenu,
                dijitDialog,
                dijitPopupMenuItem,
                dijitMenuItem,
                BlockBased,
                YScaleMixin,
                Util,
                Layout
              ) {

var HTMLFeatures = declare( BlockBased,

 /**
  * @lends JBrowse.View.Track.HTMLFeatures.prototype
  */
{
    /**
     * A track that draws discrete features using `div` elements.
     * @constructs
     * @extends JBrowse.View.Track.BlockBased
     * @param args.config {Object} track configuration. Must include key, label
     * @param args.refSeq {Object} reference sequence object with name, start,
     *   and end members.
     * @param args.changeCallback {Function} optional callback for
     *   when the track's data is loaded and ready
     * @param args.trackPadding {Number} distance in px between tracks
     */
    constructor: function( args ) {
        this.fields = {};
        this.refSeq = args.refSeq;

        //number of histogram bins per block
        this.numBins = 25;
        this.histLabel = false;
        this.padding = 5;
        this.trackPadding = args.trackPadding;

        this.config = args.config;

        // this featureStore object should eventually be
        // instantiated by Browser and passed into this constructor, not
        // constructed here.
        this.featureStore = args.store;

        // connect the store and track loadSuccess and loadFailed events
        // to eachother
        dojo.connect( this.featureStore, 'loadSuccess', this, 'loadSuccess' );
        dojo.connect( this.featureStore, 'loadFail',    this, 'loadFail' );

        // initialize a bunch of config stuff
        var defaultConfig = {
            description: true,
            style: {
                className: "feature2",
                histScale: 4,
                labelScale: 30,
                subfeatureScale: 80,
                maxDescriptionLength: 70,
                descriptionScale: 170
            },
            hooks: {
                create: function(track, feat ) {
                    return document.createElement('div');
                }
            },
            events: {
                click: this.config.style.linkTemplate
                    ? { action: "newWindow", url: this.config.style.linkTemplate }
                    : { action: "contentDialog", content: dojo.hitch( this, 'defaultFeatureDetail' ) }
            },
            menuTemplate: [
                { label: 'View details',
                  action: 'contentDialog',
                  iconClass: 'dijitIconTask',
                  content: dojo.hitch( this, 'defaultFeatureDetail' )
                }
            ]
        };
        Util.deepUpdate(defaultConfig, this.config);
        this.config = defaultConfig;

        this.eventHandlers = (function() {
            var handlers = dojo.clone( this.config.events || {} );
            // find conf vars that set events, like `onClick`
            for( var key in this.config ) {
                var handlerName = key.replace(/^on(?=[A-Z])/, '');
                if( handlerName != key )
                    handlers[ handlerName.toLowerCase() ] = this.config[key];
            }
            // interpret handlers that are just strings to be URLs that should be opened
            for( key in handlers ) {
                if( typeof handlers[key] == 'string' )
                    handlers[key] = { url: handlers[key] };
            }
            return handlers;
        }).call(this);
        this.eventHandlers.click = this._makeClickHandler( this.eventHandlers.click );
    },

    /**
     * Request that the track load its data.  The track will call its own
     * loadSuccess() function when it is loaded.
     */
    load: function() {
        this.featureStore.load();
    },

    loadSuccess: function() {
        this.labelScale = this.featureStore.density * this.config.style.labelScale;
        this.subfeatureScale = this.featureStore.density * this.config.style.subfeatureScale;
        this.descriptionScale = this.featureStore.density * this.config.style.descriptionScale;;
        this.inherited(arguments);
    },

    /**
     * Make a default feature detail page for the given feature.
     * @returns {HTMLElement} feature detail page HTML
     */
    defaultFeatureDetail: function( /** JBrowse.Track */ track, /** Object */ f, /** HTMLElement */ div ) {
        var fmt = dojo.hitch( this, '_fmtFeatureDetailField' );
        var container = dojo.create('div', { className: 'feature-detail feature-detail-'+track.name, innerHTML: '' } );
        container.innerHTML += fmt( 'Name', f.get('name') );
{'fraction_non_alphanumeric': 0.10527299925205684, 'fraction_numerical': 0.002617801047120419, 'mean_word_length': 1.6616073650161731, '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': '510936', 'n_tokens_mistral': 2878, 'n_tokens_neox': 2737, 'n_words': 697}