<commit_before>$(document).ready(function(){
    
    /// BEHAVIOUR
    /// DELETED ITEMS will be moved to the end of the group.
    /// In case of an Error, deleted stay at this position.
    /// EXTRA ITEMS stay at their position, if they are not empty.
    /// In case of an Error, empty extra items are moved to the end of
    /// the list (just before predeleted items).
    
    /// BUTTONS (STACKED INLINE)
    $('div[name="inlinegroup"] a.closehandler').bind("click", function(){
        $(this).parent().parent().parent().find('div[name="inlinerelated"]').addClass('collapsed');
    });
    $('div[name="inlinegroup"] a.openhandler').bind("click", function(){
        $(this).parent().parent().parent().removeClass('collapsed');
        $(this).parent().parent().parent().find('div[name="inlinerelated"]').removeClass('collapsed');
    });
    
    /// ADDHANDLER
    $('div.inline-group a.addhandler').bind("click", function(){
        var new_item = $(this).parent().parent().parent().find('div.items div.inline-related:last').clone(true).appendTo($(this).parent().parent().parent().children('.items'));
        var items = $(this).parent().parent().parent().find('div.inline-related').length;
        /// change header
        new_item.find('h3:first').html("<b>" + new_item.find('h3:first').text().split("#")[0] + "#" + parseInt(items) + "</b>");
        /// replace IDs, NAMEs, HREFs & FORs ...
        var new_html = new_item.html().replace(/-\d+-/g, "-" + parseInt(items - 1) + "-");
        new_item.html(new_html);
        /// set TOTAL_FORMS to number of items
        new_item.parent().parent().find('input[id*="TOTAL_FORMS"]').val(parseInt(items));
        /// remove error-lists and error-classes
        new_item.find('ul.errorlist').remove();
        new_item.find('div[class*="errors"]').removeClass("errors");
        /// remove delete-button and button view on site
        new_item.find('a.deletelink').remove();
        new_item.find('a.viewsitelink').remove();
        /// add collapse-functionality
        new_item.find('h3.collapse-toggle').bind("click", function(e){
            $(this).parent().toggleClass('collapsed');
        });
    });
    
    /// DELETELINK
    $('div.inline-group input[name*="DELETE"]').hide();
    $('div.inline-related a.deletelink').bind("click", function() {
        $(this).prev('input').attr('checked', !$(this).prev('input').attr('checked'));
        var delete_item = $(this).parent().parent().parent();
        if (delete_item.parent().hasClass('predelete-items')) {
            var new_item = delete_item.clone(true).appendTo(delete_item.parent().prev());
        } else {
            var new_item = delete_item.clone(true).appendTo(delete_item.parent().next());
        }
        delete_item.remove();
    });
    
    /// REORDER
    $('div.sortable').each(function(i) {
        var items = new Array();<commit_msg>solved tinymce-issue with inlines, tickt #21<commit_after>$(document).ready(function(){
    
    /// BEHAVIOUR
    /// DELETED ITEMS will be moved to the end of the group.
    /// In case of an Error, deleted stay at this position.
    /// EXTRA ITEMS stay at their position, if they are not empty.
    /// In case of an Error, empty extra items are moved to the end of
    /// the list (just before predeleted items).
    
    /// BUTTONS (STACKED INLINE)
    $('div[name="inlinegroup"] a.closehandler').bind("click", function(){
        $(this).parent().parent().parent().find('div[name="inlinerelated"]').addClass('collapsed');
    });
    $('div[name="inlinegroup"] a.openhandler').bind("click", function(){
        $(this).parent().parent().parent().removeClass('collapsed');
        $(this).parent().parent().parent().find('div[name="inlinerelated"]').removeClass('collapsed');
    });
    
    /// ADDHANDLER
    $('div.inline-group a.addhandler').bind("click", function(){
        var new_item = $(this).parent().parent().parent().find('div.items div.inline-related:last').clone(true).appendTo($(this).parent().parent().parent().children('.items'));
        var items = $(this).parent().parent().parent().find('div.inline-related').length;
        /// change header
        new_item.find('h3:first').html("<b>" + new_item.find('h3:first').text().split("#")[0] + "#" + parseInt(items) + "</b>");
        /// replace IDs, NAMEs, HREFs & FORs ...
        var new_html = new_item.html().replace(/-\d+-/g, "-" + parseInt(items - 1) + "-");
        new_item.html(new_html);
        /// set TOTAL_FORMS to number of items
        new_item.parent().parent().find('input[id*="TOTAL_FORMS"]').val(parseInt(items));
        /// remove error-lists and error-classes
        new_item.find('ul.errorlist').remove();
        new_item.find('div[class*="errors"]').removeClass("errors");
        /// remove delete-button and button view on site
        new_item.find('a.deletelink').remove();
        new_item.find('a.viewsitelink').remove();
        /// tinymce
        new_item.find('span.mceEditor').each(function(e) {
            var id = this.id.split('_parent')[0];
            $(this).remove();
            new_item.find('#' + id).css('display', '');
            tinyMCE.execCommand("mceAddControl", true, id);
        });
        /// add collapse-functionality
        new_item.find('h3.collapse-toggle').bind("click", function(e){
            $(this).parent().toggleClass('collapsed');
        });
    });
    
    /// DELETELINK
    $('div.inline-group input[name*="DELETE"]').hide();
    $('div.inline-related a.deletelink').bind("click", function() {
        $(this).prev('input').attr('checked', !$(this).prev('input').attr('checked'));
        var delete_item = $(this).parent().parent().parent();
        if (delete_item.parent().hasClass('predelete-items')) {
            var new_item = delete_item.clone(true).appendTo(delete_item.parent().prev());
        } else {
            var new_item = delete_item.clone(true).appendTo(delete_item.parent().next());
        }
        delete_item.remove();
    });
    
    /// REORDER
    $('div.sortable').each(function(i) {
        var items = new Array();
{'fraction_non_alphanumeric': 0.2075812274368231, 'fraction_numerical': 0.002133245815556285, 'mean_word_length': 2.902048655569782, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '3677435', 'n_tokens_mistral': 1842, 'n_tokens_neox': 1838, 'n_words': 311}