<commit_before>'use strict';

var $panel = $bundle.filter('.lowerthird');
var $take = $panel.find('button[command="take"]');
var $show = $panel.find('button[command="show"]');
var $hide = $panel.find('button[command="hide"]');
var $pulse = $panel.find('button[command="pulse"]');
var $preview = $panel.find('.js-preview');
var $program = $panel.find('.js-program');

var texts = nodecg.Replicant('texts')
    .on('change', function(oldVal, newVal) {
        $program.find('.js-title').val(newVal.title);
        $program.find('.js-body').val(newVal.body);

        var evt = document.createEvent('Event');
        var el = $program.find('.js-body')[0];
        evt.initEvent('autosize:update', true, false);
        el.dispatchEvent(evt);
        simulateClick(el);
    });

var isShowing = nodecg.Replicant('isShowing')
    .on('change', function(oldVal, newVal) {
        $show.prop('disabled', newVal);
        $pulse.prop('disabled', newVal);
        $hide.prop('disabled', !newVal);
    });

nodecg.Replicant('isPulsing')
    .on('change', function(oldVal, newVal) {
        $hide.prop('disabled', !isShowing.value ? true : newVal);
    });

$take.click(function () {
    texts.value = {
        title: $preview.find('.js-title').val(),
        body: $preview.find('.js-body').val()
    };
});

$show.click(function () {
    isShowing.value = true;
});

$hide.click(function () {
    isShowing.value = false;
});

$pulse.click(function () {
    nodecg.sendMessage('pulse', $(this).data('duration'));
});

/*
 * Make the "Body" textareas automatically size themselves
 */
autosize($panel[0].querySelectorAll('textarea'));
$preview.find('.js-body').on('autosize:resized', function(){
    simulateClick(this);
});

// Simulates a "click" event, which triggers Masonry to re-position the panels if necessary.
function simulateClick(el) {
    var event = new MouseEvent('click', {
        'view': window,
        'bubbles': true,
        'cancelable': true
    });
    el.dispatchEvent(event);
}
<commit_msg>[lowerthird] Disable "take" button for one second after showing or hiding.<commit_after>'use strict';

var $panel = $bundle.filter('.lowerthird');
var $take = $panel.find('button[command="take"]');
var $show = $panel.find('button[command="show"]');
var $hide = $panel.find('button[command="hide"]');
var $pulse = $panel.find('button[command="pulse"]');
var $preview = $panel.find('.js-preview');
var $program = $panel.find('.js-program');

var texts = nodecg.Replicant('texts')
    .on('change', function(oldVal, newVal) {
        $program.find('.js-title').val(newVal.title);
        $program.find('.js-body').val(newVal.body);

        var evt = document.createEvent('Event');
        var el = $program.find('.js-body')[0];
        evt.initEvent('autosize:update', true, false);
        el.dispatchEvent(evt);
        simulateClick(el);
    });

var isShowing = nodecg.Replicant('isShowing')
    .on('change', function(oldVal, newVal) {
        $show.prop('disabled', newVal);
        $pulse.prop('disabled', newVal);
        $hide.prop('disabled', !newVal);

        // When this changes, disable the "take" button for a bit
        if ($take.data('cooldownTimer')) {
            clearTimeout($take.data('cooldownTimer'));
        }

        $take.prop('disabled', true);
        $take.data('cooldownTimer', setTimeout(function() {
            $take.prop('disabled', false);
        }, 1000));
    });

nodecg.Replicant('isPulsing')
    .on('change', function(oldVal, newVal) {
        $hide.prop('disabled', !isShowing.value ? true : newVal);
    });

$take.click(function () {
    texts.value = {
        title: $preview.find('.js-title').val(),
        body: $preview.find('.js-body').val()
    };
});

$show.click(function () {
    isShowing.value = true;
});

$hide.click(function () {
    isShowing.value = false;
});

$pulse.click(function () {
    nodecg.sendMessage('pulse', $(this).data('duration'));
});

/*
 * Make the "Body" textareas automatically size themselves
 */
autosize($panel[0].querySelectorAll('textarea'));
$preview.find('.js-body').on('autosize:resized', function(){
    simulateClick(this);
});

// Simulates a "click" event, which triggers Masonry to re-position the panels if necessary.
function simulateClick(el) {
    var event = new MouseEvent('click', {
        'view': window,
        'bubbles': true,
        'cancelable': true
    });
    el.dispatchEvent(event);
}

{'fraction_non_alphanumeric': 0.19850441876274644, 'fraction_numerical': 0.0018128257421255382, 'mean_word_length': 3.5225409836065573, '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': '3271400', 'n_tokens_mistral': 1436, 'n_tokens_neox': 1421, 'n_words': 258}