<commit_before>define(["jquery", "t5/core/events", "t5/core/dom", "bootstrap/modal"], function($) {
    
    return function(spec) {
        var clientId = spec.clientId;
        var title    = spec.title;
        var message  = spec.message;
        var confirm  = spec.confirm;
        var cancel   = spec.cancel;
    
        var modalDialogId   = "bootstrap_confirmation_modal_" + spec.messagehash;
        var confirmButtonId = "bootstrap_confirmation_button_" + spec.messagehash;
        
        if (!$('#' + modalDialogId).length)
            $(document.body).append (
                '<div class="modal fade" role="dialog" id="' + modalDialogId + '">' +
                    '<div class="modal-dialog">' +
                        '<div class="modal-content">' +
                            '<div class="modal-header">' +
                                '<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>' +
                                '<h3 class="modal-title">' + title + '</h3>' +
                            '</div>' +
                            '<div class="modal-body">' +
                                '<p>' + message + '</p>' +
                            '</div>' +
                            '<div class="modal-footer">' +
                                '<button class="btn ' + spec.confirmClass + '" id="' + confirmButtonId + '">' + confirm + '</button>' +
                                '<button class="btn" data-dismiss="modal">' + cancel + '</button>' + 
                            '</div>' +
                        '</div>' +
                    '</div>' +
                '</div>'                
            );

        $('#' + clientId).data('confirmationPassed', false);
        $('#' + clientId).bind('click', function(event){
            if ($('#' + clientId).data('confirmationPassed')) {
                $('#' + clientId).data('confirmationPassed', false);
                console.log('action on ' + clientId + ' confirmed');
                return true;
            } else {
                event.preventDefault();
                event.stopImmediatePropagation();
                console.log('confirmation on ' + clientId + ' requested');

                $('#' + modalDialogId).modal({keyboard:true});
                $('#' + confirmButtonId).bind('click', function(confirmEvent){
                    $('#' + clientId).data('confirmationPassed', true);
                    $('#' + modalDialogId).modal('hide');
                    $('#' + clientId).click();
                });
                return false;
            }
        });<commit_msg>fix confirmation dialog stale events<commit_after>define(["jquery", "t5/core/events", "t5/core/dom", "bootstrap/modal"], function($) {
    
    return function(spec) {
        var clientId = spec.clientId;
        var title    = spec.title;
        var message  = spec.message;
        var confirm  = spec.confirm;
        var cancel   = spec.cancel;
    
        var modalDialogId   = "bootstrap_confirmation_modal_" + spec.messagehash;
        var confirmButtonId = "bootstrap_confirmation_button_" + spec.messagehash;
        
        $('#' + clientId).data('confirmationPassed', false);
        $('#' + clientId).bind('click', function(event){
            if ($('#' + clientId).data('confirmationPassed')) {
                $('#' + clientId).data('confirmationPassed', false);
                console.log('action on ' + clientId + ' confirmed');
                return true;
            } else {
                event.preventDefault();
                event.stopImmediatePropagation();
                console.log('confirmation on ' + clientId + ' requested');

                if (!$('#' + modalDialogId).length)
                    $(document.body).append (
                        '<div class="modal fade" role="dialog" id="' + modalDialogId + '">' +
                            '<div class="modal-dialog">' +
                                '<div class="modal-content">' +
                                    '<div class="modal-header">' +
                                        '<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>' +
                                        '<h3 class="modal-title">' + title + '</h3>' +
                                    '</div>' +
                                    '<div class="modal-body">' +
                                        '<p>' + message + '</p>' +
                                    '</div>' +
                                    '<div class="modal-footer">' +
                                        '<button class="btn ' + spec.confirmClass + '" id="' + confirmButtonId + '">' + confirm + '</button>' +
                                        '<button class="btn" data-dismiss="modal">' + cancel + '</button>' + 
                                    '</div>' +
                                '</div>' +
                            '</div>' +
                        '</div>'                
                    );
                
                $('#' + modalDialogId).modal({keyboard:true});
                $('#' + modalDialogId).on('hidden.bs.modal', function(){ $('#' + modalDialogId).remove() });
                $('#' + confirmButtonId).bind('click', function(confirmEvent){
                    $('#' + clientId).data('confirmationPassed', true);
                    $('#' + modalDialogId).modal('hide');
                    $('#' + clientId).click();
                });
                return false;
            }
        });
{'fraction_non_alphanumeric': 0.1618808327351041, 'fraction_numerical': 0.0014357501794687725, 'mean_word_length': 1.3038445638693674, 'pattern_counts': {'":': 0, '<': 47, '<?xml version=': 0, '>': 47, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 12, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5215632', 'n_tokens_mistral': 1363, 'n_tokens_neox': 1345, 'n_words': 225}