<commit_before>'use strict';

/**
 * Open and close button for aside-menu
 */
$('show-aside-button').addEvent('click', function (event) {
    // Get the aside current margin-left as integer
    var asideMargin = parseInt($('aside-menu').getStyle('margin-left'));

    /**
     * Change aside margin to show or hide it
     */
    $('aside-menu').setStyle(
        'margin-left',
        asideMargin === 0 ? '-18rem' : '0rem'
    );

    /**
     * Change content width do adjust to fit on the side of aside
     */
    $('content').setStyle(
        'width',
        asideMargin === 0 ? '100%' : 'calc(100% - 17rem)'
    );
});<commit_msg>Refactor and other ways to close the aside<commit_after>'use strict';



/**
 * Change aside margin to show it
 * Change content width do adjust to fit on the side of aside
 */
var showAside = (function() {
    $('aside-menu').setStyle('margin-left', '0rem');
    $('content').setStyle('width', 'calc(100% - 17rem)');
});



/**
 * Change aside margin to hide it
 * Change content width do adjust to fit on the side of aside
 */
var hideAside = (function() {
    $('aside-menu').setStyle('margin-left', '-18rem');
    $('content').setStyle('width', '100%');
});



/**
 * Open and close button for aside-menu
 */
$('show-aside-button').addEvent('click', function (event) {
    // Get the aside current margin-left as integer
    var asideMargin = parseInt($('aside-menu').getStyle('margin-left'));

    if (0 === asideMargin) {
        hideAside();

        return true;
    }

    showAside();
});



/**
 * Catch all clicks on the content element, then check if we should close the
 * aside or not.
 */
$('content').addEvent('click', function (event) {
    var asideButtonVisible = $('show-aside-button').getStyle('display') === 'inline-block';
    var asideVisible = parseInt($('aside-menu').getStyle('margin-left')) === 0;

    if (false === asideButtonVisible && false === asideVisible) {
        showAside();
    }

    if (true === asideButtonVisible && true === asideVisible) {
        hideAside();
    }
});
{'fraction_non_alphanumeric': 0.1781021897810219, 'fraction_numerical': 0.012652068126520682, 'mean_word_length': 3.0, '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': '747825', 'n_tokens_mistral': 649, 'n_tokens_neox': 613, 'n_words': 180}