<commit_before>/*
 * Copyright 2011 Adobe Systems Incorporated. All Rights Reserved.
 */

// TODO: break out the definition of brackets into a separate module from the application controller logic

// Define core brackets namespace
brackets = window.brackets || {};

brackets.inBrowser = !brackets.hasOwnProperty("fs");

brackets.DIALOG_BTN_CANCEL = "cancel";
brackets.DIALOG_BTN_OK = "ok";
brackets.DIALOG_BTN_DONTSAVE = "dontsave";

brackets.DIALOG_ID_ERROR = "error-dialog";
brackets.DIALOG_ID_SAVE_CLOSE = "save-close-dialog";

/**
 * General purpose modal dialog. Assumes that the HTML for the dialog contains elements with "title"
 * and "message" classes, as well as a number of elements with "dialog-button" class, each of which has
 * a "data-button-id".
 *
 * @param {string} id The ID of the dialog node in the HTML.
 * @param {string} title The title of the error dialog. Can contain HTML markup.
 * @param {string} message The message to display in the error dialog. Can contain HTML markup.
 * @return {Deferred} a $.Deferred() that will be resolved with the ID of the clicked button when the dialog
 *     is dismissed.
 */
brackets.showModalDialog = function(id, title, message, callback) {
    var result = $.Deferred();
    var dlg = $("#" + id);
    
    // Set title and message
    $(".dialog-title", dlg).html(title);
    $(".dialog-message", dlg).html(message);
    
    // Click handler for buttons
    dlg.on("click", ".dialog-button", function(e) {
        result.resolve($(this).attr("data-button-id"));
        dlg.modal(true).hide();
    });
    
    // Run the dialog
    dlg.modal(<commit_msg>Enter/Return key closes modal dialog.<commit_after>/*
 * Copyright 2011 Adobe Systems Incorporated. All Rights Reserved.
 */

// TODO: break out the definition of brackets into a separate module from the application controller logic

// Define core brackets namespace
brackets = window.brackets || {};

brackets.inBrowser = !brackets.hasOwnProperty("fs");

brackets.DIALOG_BTN_CANCEL = "cancel";
brackets.DIALOG_BTN_OK = "ok";
brackets.DIALOG_BTN_DONTSAVE = "dontsave";

brackets.DIALOG_ID_ERROR = "error-dialog";
brackets.DIALOG_ID_SAVE_CLOSE = "save-close-dialog";

/**
 * General purpose modal dialog. Assumes that the HTML for the dialog contains elements with "title"
 * and "message" classes, as well as a number of elements with "dialog-button" class, each of which has
 * a "data-button-id".
 *
 * @param {string} id The ID of the dialog node in the HTML.
 * @param {string} title The title of the error dialog. Can contain HTML markup.
 * @param {string} message The message to display in the error dialog. Can contain HTML markup.
 * @return {Deferred} a $.Deferred() that will be resolved with the ID of the clicked button when the dialog
 *     is dismissed.
 */
brackets.showModalDialog = function(id, title, message, callback) {
    var result = $.Deferred();
    var dlg = $("#" + id);
    
    // Set title and message
    $(".dialog-title", dlg).html(title);
    $(".dialog-message", dlg).html(message);
    
    // Click handler for buttons
    dlg.on("click", ".dialog-button", function(e) {
        result.resolve($(this).attr("data-button-id"));
        dlg.modal(true).hide();
    });
    
    // Enter/Return handler for the primary button
    $(document).on("keyup.modal", function(e) {
        if (e.keyCode === 13) {
            var primaryBtn = dlg.find(".primary");
            if (primaryBtn) {
                result.resolve(primaryBtn.attr("data-button-id"));
                dlg.modal(true).hide();
            }
        }
    });
    
    // Run the dialog
    dlg.modal(
{'fraction_non_alphanumeric': 0.12734288864388094, 'fraction_numerical': 0.0027563395810363835, 'mean_word_length': 3.2444444444444445, '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': '3987190', 'n_tokens_mistral': 1128, 'n_tokens_neox': 1077, 'n_words': 359}