<commit_before>var width;
var clicked;

var first = {
    index: function() {
        return 1;
    },
    visible: function() {
        var position = $('.columns-holder [index=' + this.index() + ']').position().left;
        return position > 0 && position < $('.columns-holder').width();
    },
    animate: function() {
        reset();
    }
};

var second = {
    index: function() {
        return 2;
    },
    visible: function() {
        var position = $('.columns-holder [index=' + this.index() + ']').position().left;
        return position > 0 && position < $('.columns-holder').width();
    },
    animate: function() {
        reset();
    }
};

var third = {
    index: function() {
        return 3;
    },
    visible: function() {
        var position = $('.columns-holder [index=' + this.index() + ']').position().left;
        return position > 0 && position < $('.columns-holder').width();
    },
    animate: function() {
        reset();
        next.animate();
    }
};

var next = {
    index: function() {
        return clicked + 1;
    },
    visible: function() {
        var position = $('.columns-holder [index=' + this.index() + ']').position().left;
        return position > 0 && position < $('.columns-holder').width();
    },
    animate: function() {
        var columns = $('.columns-holder .column');
        width = columns.first().width();

        columns.each(function() {
            $(this).animate({
                left: '-=' + width
            });
        });        
    }
};

var prev = {
    index: function() {
        return clicked - 1;
    },
    visible: function() {       
        var position = $('.columns-holder [index=' + this.index() + ']').position().left;
        return position > 0 && position < $('.columns-holder').width();
    },
    animate: function() {
        var columns = $('.columns-holder .column');
        width = columns.first().width();

        columns.each(function() {
            $(this).animate({
                left: '+=' + width
            });
        });
    }
};

/**
 * Registers a click on an AJAX link so that the source column is known to the renderer.
 *
 * @param element source element
 */
function register(element) {
    clicked = parseInt($(element).parents('.column').first().attr('index'));
}

/**
 * Renders the AJAX return value in the target column (next or prev). If the target
 * column is not visible the view will be changed to show the target column.
 *
 * The target column is given as a simple object that can calculate the next column
 * position and animate the transition to show the column (if necessary). Currently
 * supported targets are next and prev.
 *
 * E.g.,
 *      render(data, next);
 *      render(data, prev);
 *
 * @param data data to render in target column
 * @param target column function. next or prev.
 */
function render(data, target) {
    $('.columns-holder [index= ' + target.index() + '] .column-hold').html(data);
    if (!target.visible()) target.animate();
}

/**
 * Closes the panel containing the passed element and shifts the view back
 * to the previous position.
 * 
 * @param element element contained in the panel to close. usually the ajax link or form element.
 */
function closePanel(element) {
    register(element);
    prev.animate();
    $('.columns-holder [index=' + clicked + '] .column-hold').html('');
}

/**
 * Resets the view back it's original position.
 */
function reset() {
    $('.columns-holder .column').css('left','');
    width = null;
}

/**
 * Returns the first selected element ID residing in the same column as the given element.
 *
 * E.g., getSelectedElementId(this);  #=>  "user-123"
 *
 * @param element in the same column as the selected row
 */
function getSelectedElementId(element) {
    var column = $(element).is('.column-hold') ? element : $(element).parents('.column-hold')[0];
    return $(column).find('.table-box .active').attr('id');<commit_msg>Fixed js 'closePanel' call for views where no animation is necessary<commit_after>var width;
var clicked;

var first = {
    index: function() {
        return 1;
    },
    visible: function() {
        var position = $('.columns-holder [index=' + this.index() + ']').position().left;
        return position > 0 && position < $('.columns-holder').width();
    },
    animate: function() {
        reset();
    }
};

var second = {
    index: function() {
        return 2;
    },
    visible: function() {
        var position = $('.columns-holder [index=' + this.index() + ']').position().left;
        return position > 0 && position < $('.columns-holder').width();
    },
    animate: function() {
        reset();
    }
};

var third = {
    index: function() {
        return 3;
    },
    visible: function() {
        var position = $('.columns-holder [index=' + this.index() + ']').position().left;
        return position > 0 && position < $('.columns-holder').width();
    },
    animate: function() {
        reset();
        next.animate();
    }
};

var next = {
    index: function() {
        return clicked + 1;
    },
    visible: function() {
        var position = $('.columns-holder [index=' + this.index() + ']').position().left;
        return position > 0 && position < $('.columns-holder').width();
    },
    animate: function() {
        var columns = $('.columns-holder .column');
        width = columns.first().width();

        columns.each(function() {
            $(this).animate({
                left: '-=' + width
            });
        });        
    }
};

var prev = {
    index: function() {
        return clicked - 1;
    },
    visible: function() {       
        var position = $('.columns-holder [index=' + this.index() + ']').position().left;
        return position > 0 && position < $('.columns-holder').width();
    },
    animate: function() {
        var columns = $('.columns-holder .column');
        width = columns.first().width();

        columns.each(function() {
            $(this).animate({
                left: '+=' + width
            });
        });
    }
};

/**
 * Registers a click on an AJAX link so that the source column is known to the renderer.
 *
 * @param element source element
 */
function register(element) {
    clicked = parseInt($(element).parents('.column').first().attr('index'));
}

/**
 * Renders the AJAX return value in the target column (next or prev). If the target
 * column is not visible the view will be changed to show the target column.
 *
 * The target column is given as a simple object that can calculate the next column
 * position and animate the transition to show the column (if necessary). Currently
 * supported targets are next and prev.
 *
 * E.g.,
 *      render(data, next);
 *      render(data, prev);
 *
 * @param data data to render in target column
 * @param target column function. next or prev.
 */
function render(data, target) {
    $('.columns-holder [index= ' + target.index() + '] .column-hold').html(data);
    if (!target.visible()) target.animate();
}

/**
 * Closes the panel containing the passed element and shifts the view back
 * to the previous position.
 * 
 * @param element element contained in the panel to close. usually the ajax link or form element.
 */
function closePanel(element) {
    register(element);
    if (!first.visible()) prev.animate(); // animate only if not in the default position.
    $('.columns-holder [index=' + clicked + '] .column-hold').html('');
}

/**
 * Resets the view back it's original position.
 */
function reset() {
    $('.columns-holder .column').css('left','');
    width = null;
}

/**
 * Returns the first selected element ID residing in the same column as the given element.
 *
 * E.g., getSelectedElementId(this);  #=>  "user-123"
 *
 * @param element in the same column as the selected row
 */
function getSelectedElementId(element) {
    var column = $(element).is('.column-hold') ? element : $(element).parents('.column-hold')[0];
    return $(column).find('.table-box .active').attr('id');
{'fraction_non_alphanumeric': 0.16681222707423582, 'fraction_numerical': 0.0034934497816593887, 'mean_word_length': 2.491289198606272, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 15, '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': '770174', 'n_tokens_mistral': 2275, 'n_tokens_neox': 2185, 'n_words': 705}