<commit_before>
//TODO: REFACTOR
schnipp.dynforms.fields.dropdownselect = function(field_descriptor, field_data) {
    var self = schnipp.dynforms.abstractselect(field_descriptor, field_data)
    
    self.templates.dropdown = '\
        <div  class="schnippforms-dropdownselect-select">\
            <div class="schnippforms-dropdownselect-input">\
                <div class="schnippforms-dropdownselect-display"></div>\
                <div class="schnippforms-dropdownselect-toggler"></div>\
            </div>\
            <div class="schnippforms-dropdownselect-options"></div>\
        </div>\
    '
    self.templates.option = _.template('<div><%=label%></div>')

    self.initialize = function() {
        self.events.bind('change', function(args) {
            self.dom.display.html(self.selected_option.label)
        })
        // TODO: mark fd.default_value as mandatory
        self.dom.display.html(self.selected_option.label)
    }    
    
    self.render_input = function() {
        self.dom.dropdown = $(self.templates.dropdown)
        self.dom.display = self.dom.dropdown.find('.schnippforms-dropdownselect-display')
        self.dom.toggler = self.dom.dropdown.find('.schnippforms-dropdownselect-toggler')
        self.dom.options = self.dom.dropdown.find('.schnippforms-dropdownselect-options')
        
        // add toggle handler
        self.dom.display.add(self.dom.toggler).click(function() {
            if(self.dom.options.css('display') === 'none') {
                self.dom.main.addClass('active')
            } else {
                self.dom.main.removeClass('active')
            }
        })
        
        // render options
        $.each(field_descriptor.options, function(key, opt) {
            var item = $(self.templates.option({label:opt.label}))  
            self.dom.options.append(item)  
            item.click(function() {
                self.set_data(opt.value)
                self.dom.main.removeClass('active')
                return false
            })   
        })
        <commit_msg>prevent error when option are empty<commit_after>
//TODO: REFACTOR
schnipp.dynforms.fields.dropdownselect = function(field_descriptor, field_data) {
    var self = schnipp.dynforms.abstractselect(field_descriptor, field_data)
    
    self.templates.dropdown = '\
        <div  class="schnippforms-dropdownselect-select">\
            <div class="schnippforms-dropdownselect-input">\
                <div class="schnippforms-dropdownselect-display"></div>\
                <div class="schnippforms-dropdownselect-toggler"></div>\
            </div>\
            <div class="schnippforms-dropdownselect-options"></div>\
        </div>\
    '
    self.templates.option = _.template('<div><%=label%></div>')

    self.initialize = function() {
        self.events.bind('change', function(args) {
            self.dom.display.html(self.selected_option.label)
        })
        if (self.selected_option) {
            // TODO: mark fd.default_value as mandatory
            self.dom.display.html(self.selected_option.label)
        }
    }    
    
    self.render_input = function() {
        self.dom.dropdown = $(self.templates.dropdown)
        self.dom.display = self.dom.dropdown.find('.schnippforms-dropdownselect-display')
        self.dom.toggler = self.dom.dropdown.find('.schnippforms-dropdownselect-toggler')
        self.dom.options = self.dom.dropdown.find('.schnippforms-dropdownselect-options')
        
        // add toggle handler
        self.dom.display.add(self.dom.toggler).click(function() {
            if(self.dom.options.css('display') === 'none') {
                self.dom.main.addClass('active')
            } else {
                self.dom.main.removeClass('active')
            }
        })
        
        // render options
        $.each(field_descriptor.options, function(key, opt) {
            var item = $(self.templates.option({label:opt.label}))  
            self.dom.options.append(item)  
            item.click(function() {
                self.set_data(opt.value)
                self.dom.main.removeClass('active')
                return false
            })   
        })
        
{'fraction_non_alphanumeric': 0.13727839003354098, 'fraction_numerical': 0.0, 'mean_word_length': 2.0586080586080584, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 29, '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': '3304867', 'n_tokens_mistral': 1190, 'n_tokens_neox': 1175, 'n_words': 145}