<commit_before>// auto-suggest docs:
// http://code.drewwilson.com/entry/autosuggest-jquery-plugin
define([
    'require',
    '../logging',
    '../../lib/jquery.autoSuggest'
], function(require) {
    var log = require('../logging').getLogger('autosuggest');

    var init = function($el, opts) {
        // fetch words for auto-suggestion
        var $cfg = $el.parents('[data-auto-suggest-config]:first');

        // XXX: do this properly
        var words = (($cfg.data('auto-suggest-config') || '')
                     .split(':')[1] || '').split(/\s*,\s*/);
        var data = words.map(function(word) {
            return {value: word, name: word};
        });
        var $prefillcfg = $el.parents('[data-auto-suggest-prefill]:first');
        var prefill = $prefillcfg.data('auto-suggest-prefill') || '';

        var $asHtmlIDcfg = $el.parents('[data-auto-suggest-ashtmlid]:first');
        var asHtmlID = $asHtmlIDcfg.data('auto-suggest-ashtmlid') || false;

        // are we autosubmit?
        var autosubmit = $el.is('.auto-submit') ||
                ($el.parents('.auto-submit').length > 0);
        log.debug('auto-submit', autosubmit, $el);

        var cfg = {
            asHtmlID: asHtmlID,
            preFill: prefill,
            selectedValueProp: "name",
            searchObjProp: "name",
            startText: "Enter name here"
        };
        var $form;
        if (autosubmit) {
            $form = $el.parents('form');
            cfg.selectionAdded = function($el) {
                log.debug('submit because selection was added', $el);
                // trigger the form
                $form.submit();
            };
            cfg.selectionRemoved = function($el) {
                log.debug('submit because selection was removed', $el);
                // trigger the form
                $el.remove();<commit_msg>autosuggest honors readonly inputs<commit_after>// auto-suggest docs:
// http://code.drewwilson.com/entry/autosuggest-jquery-plugin
define([
    'require',
    '../logging',
    '../../lib/jquery.autoSuggest'
], function(require) {
    var log = require('../logging').getLogger('autosuggest');

    var init = function($el, opts) {
        // fetch words for auto-suggestion
        var $cfg = $el.parents('[data-auto-suggest-config]:first');

        // XXX: do this properly
        var words = (($cfg.data('auto-suggest-config') || '')
                     .split(':')[1] || '').split(/\s*,\s*/);
        var data = words.map(function(word) {
            return {value: word, name: word};
        });
        var $prefillcfg = $el.parents('[data-auto-suggest-prefill]:first');
        var prefill = $prefillcfg.data('auto-suggest-prefill') || '';

        var $asHtmlIDcfg = $el.parents('[data-auto-suggest-ashtmlid]:first');
        var asHtmlID = $asHtmlIDcfg.data('auto-suggest-ashtmlid') || false;

        // are we autosubmit?
        var autosubmit = $el.is('.auto-submit') ||
                ($el.parents('.auto-submit').length > 0);
        log.debug('auto-submit', autosubmit, $el);

        var cfg = {
            asHtmlID: asHtmlID,
            preFill: prefill,
            selectedValueProp: "name",
            searchObjProp: "name",
            startText: $el.attr('readonly') ? "" : "Enter name here"
        };
        var $form;
        if (autosubmit) {
            $form = $el.parents('form');
            cfg.selectionAdded = function($item) {
                log.debug('submit because selection was added', $item);
                // trigger the form
                $form.submit();
            };
            cfg.selectionRemoved = function($item) {
                // ignore removal request if readonly
                if ($el.attr('readonly')) return;
                log.debug('submit because selection was removed', $item);
                // trigger the form
                $item.remove();
{'fraction_non_alphanumeric': 0.16507854751480813, 'fraction_numerical': 0.0010301313417460727, 'mean_word_length': 1.90067214339059, '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': '2200269', 'n_tokens_mistral': 1157, 'n_tokens_neox': 1107, 'n_words': 227}