<commit_before>function closeHandler(dialog) {
    // Hide the dialog
    $(dialog).css('display', 'none');

    // Remove the backdrop
    $('.removableBackdrop').remove();
}

/**
 * This function is used inside the Worklist package to define a right click callback
 *
 * @param e
 */
openStudyContextMenu = function(e) {
    Worklist.functions['exportSelectedStudies'] = exportSelectedStudies;

    Template.studyContextMenu.study = $(e.currentTarget);

    var dialog = $('#studyContextMenu');

    // Show the nonTargetLesion dialog above
    var dialogProperty = {
        display: 'block'
    };

    // Device is touch device or not
    // If device is touch device, set position center of screen vertically and horizontally// jscs:ignore
    if (isTouchDevice()) {
        // add dialogMobile class to provide a black, transparent background
        dialog.addClass('dialogMobile');
        dialogProperty.top = 0;
        dialogProperty.left = 0;
        dialogProperty.right = 0;
        dialogProperty.bottom = 0;
    } else {
        dialogProperty.top = e.pageY;
        dialogProperty.left = e.pageX;

        var pageHeight = $(document.body).height();
        dialogProperty.top = Math.max(dialogProperty.top, 0);
        dialogProperty.top = Math.min(dialogProperty.top, pageHeight - dialog.outerHeight());

        var pageWidth = $(document.body).width();
        dialogProperty.left = Math.max(dialogProperty.left, 0);
        dialogProperty.left = Math.min(dialogProperty.left, pageWidth - dialog.outerWidth());
    }

    dialog.css(dialogProperty);
    dialog.focus();

    // Show the backdrop
    UI.render(Template.removableBackdrop, document.body);

    // Make sure the context menu is closed when the user clicks away
    $('.removableBackdrop').one('mousedown touchstart', function() {
        closeHandler(dialog);
    });
};

/**
 * Exports all selected studies on the worklist
 */
function exportSelectedStudies() {
    var selectedStudies = WorklistSelectedStudies.find({}, {<commit_msg>Fix worklist context menu position (LT-193)<commit_after>function closeHandler(dialog) {
    // Hide the dialog
    $(dialog).css('display', 'none');

    // Remove the backdrop
    $('.removableBackdrop').remove();
}

/**
 * This function is used inside the Worklist package to define a right click callback
 *
 * @param e
 */
openStudyContextMenu = function(e) {
    Worklist.functions['exportSelectedStudies'] = exportSelectedStudies;

    Template.studyContextMenu.study = $(e.currentTarget);

    var dialog = $('#studyContextMenu');

    // Show the nonTargetLesion dialog above
    var dialogProperty = {
        display: 'block'
    };

    var pageHeight = $(document).height();
    dialogProperty.top = Math.max(e.pageY, 0);
    dialogProperty.top = Math.min(dialogProperty.top, pageHeight - dialog.outerHeight());

    var pageWidth = $(document).width();
    dialogProperty.left = Math.max(e.pageX, 0);
    dialogProperty.left = Math.min(dialogProperty.left, pageWidth - dialog.outerWidth());

    // Device is touch device or not
    // If device is touch device, set position center of screen vertically and horizontally
    if (isTouchDevice()) {
        // add dialogMobile class to provide a black, transparent background
        dialog.addClass('dialogMobile');
        dialogProperty.top = 0;
        dialogProperty.left = 0;
        dialogProperty.right = 0;
        dialogProperty.bottom = 0;
        dialogProperty.margin = 'auto';
    }

    dialog.css(dialogProperty);
    dialog.focus();

    // Show the backdrop
    UI.render(Template.removableBackdrop, document.body);

    // Make sure the context menu is closed when the user clicks away
    $('.removableBackdrop').one('mousedown touchstart', function() {
        closeHandler(dialog);
    });
};

/**
 * Exports all selected studies on the worklist
 */
function exportSelectedStudies() {
    var selectedStudies = WorklistSelectedStudies.find({}, {
{'fraction_non_alphanumeric': 0.11870412553783852, 'fraction_numerical': 0.0037965072133637054, 'mean_word_length': 3.1469045120671564, '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': '6542711', 'n_tokens_mistral': 1110, 'n_tokens_neox': 1040, 'n_words': 291}