<commit_before>import moment from 'moment/moment';

import { Meteor } from 'meteor/meteor';
import { ReactiveVar } from 'meteor/reactive-var';
import { FlowRouter } from 'meteor/kadira:flow-router';

import { Minutes } from '/imports/minutes';
import { MeetingSeries } from '/imports/meetingseries';
import { UserRoles } from '/imports/userroles';
import { User, userSettings } from '/imports/users';

import { TopicListConfig } from '../topic/topicsList';
import { GlobalSettings } from '/imports/GlobalSettings';
import { FlashMessage } from '../../helpers/flashMessage';

var _minutesID; // the ID of these minutes

/**
 *
 * @type {FlashMessage}
 */
var orphanFlashMessage = null;

/**
 * togglePrintView
 * Prepares the DOM view for printing - on and off
 * @param switchOn - optional (if missing, function toggles on <=> off)
 */
var togglePrintView = function (switchOn) {
    if (switchOn === undefined) {   // toggle on <=> off
        Session.set("minutesedit.PrintViewActive", ! Session.get("minutesedit.PrintViewActive"));
    } else {
        Session.set("minutesedit.PrintViewActive", switchOn);
    }

    if (Session.get("minutesedit.PrintViewActive")) {
        // expand all topics, but save current state before!
        Session.set("minutesedit.collapsetopics-save4print."+_minutesID, Session.get("minutesedit.collapsetopics."+_minutesID));
        Session.set("minutesedit.collapsetopics."+_minutesID, undefined);

        Session.set("participants.expand", false);
        $(".help").hide();
        Meteor.setTimeout(function(){$(".collapse").addClass("in");}, 100);

        // give collapsibles some time for animation
        Meteor.setTimeout(function(){$(".expand-collapse-triangle").hide();}, 350);
        // as material checkboxes do not print correctly...
        // change material checkbox to normal checkbox for printing
        Meteor.setTimeout(function(){$("div.checkbox").toggleClass('checkbox print-checkbox');}, 360);
        Meteor.setTimeout(function(){openPrintDialog();}, 500);
    } else {
        // change back normal checkboxes to material checkboxes after printing
        $("div.print-checkbox").toggleClass('checkbox print-checkbox');
        $(".expand-collapse-triangle").show();
        $(".collapse").removeClass("in");
        // restore old topic collapsible state
        Session.set("minutesedit.collapsetopics."+_minutesID, Session.get("minutesedit.collapsetopics-save4print."+_minutesID));
    }
};



// Automatically restore view after printing
(function() {
    var afterPrint = function() {
        togglePrintView(false);
    };

    if (window.matchMedia) {
        var mediaQueryList = window.matchMedia('print');
        mediaQueryList.addListener(function(mql) {
            if (! mql.matches) {
                afterPrint();
            }
        });
    }

    window.onafterprint = afterPrint;
}());


// Global keyboard shortcut handler for this template
// In Meteor global key events can only be bound to the template on <INPUT> elements
// If we want to have these key events really global, we have to register them with
// the document. For details see SO:
// http://stackoverflow.com/questions/27972873/meteor-keydown-keyup-events-outside-input
let handleTemplatesGlobalKeyboardShortcuts = function(switchOn) {
    if (switchOn) {
        $(document).keypress( function(evt) {
            if ($('.modal.in').length > 0) {    // any modal dialog open?
                return;
            }
            console.log(evt);
            // check if focus is in input-text or input-textarea
            // let el = document.activeElement;
            // if (el && (el.tagName.toLowerCase() == 'input' && el.type == 'text' ||
            //     el.tagName.toLowerCase() == 'textarea')) {
            //     return;
            // }

            // Listen for "Ctrl+Alt+T" for "Add Topic"
            // accesskey attribute is not an option, as it needs browser specific modifieres
            // (see www.w3schools.com/tags/att_global_accesskey.asp) and
            // accessKeyLabel is not implemented in all browsers
            if (evt.ctrlKey && evt.altKey && !evt.shiftKey &&
                (evt.which === 20 || evt.originalEvent.code === 'KeyT')) {
                $('#dlgAddTopic').modal('show');
                evt.preventDefault();
            }
        });
    } else {
        $(document).off('keypress');
    }
};

Template.minutesedit.onCreated(function () {
    this.minutesReady = new ReactiveVar();

    this.autorun(() => {
        _minutesID = FlowRouter.getParam('_id');
        let subscriptionHandle = this.subscribe('minutes', _minutesID);

        this.minutesReady.set(subscriptionHandle.ready());
    });

    Session.set('minutesedit.checkParent', false);
    handleTemplatesGlobalKeyboardShortcuts(true);
});

Template.minutesedit.onDestroyed(function() {
    if (orphanFlashMessage !== null) {
        orphanFlashMessage.hideMe();
    }<commit_msg>Fix: Shortcut Ctrl+Alt+T did not work on Chrome for Windows.<commit_after>import moment from 'moment/moment';

import { Meteor } from 'meteor/meteor';
import { ReactiveVar } from 'meteor/reactive-var';
import { FlowRouter } from 'meteor/kadira:flow-router';

import { Minutes } from '/imports/minutes';
import { MeetingSeries } from '/imports/meetingseries';
import { UserRoles } from '/imports/userroles';
import { User, userSettings } from '/imports/users';

import { TopicListConfig } from '../topic/topicsList';
import { GlobalSettings } from '/imports/GlobalSettings';
import { FlashMessage } from '../../helpers/flashMessage';

var _minutesID; // the ID of these minutes

/**
 *
 * @type {FlashMessage}
 */
var orphanFlashMessage = null;

/**
 * togglePrintView
 * Prepares the DOM view for printing - on and off
 * @param switchOn - optional (if missing, function toggles on <=> off)
 */
var togglePrintView = function (switchOn) {
    if (switchOn === undefined) {   // toggle on <=> off
        Session.set("minutesedit.PrintViewActive", ! Session.get("minutesedit.PrintViewActive"));
    } else {
        Session.set("minutesedit.PrintViewActive", switchOn);
    }

    if (Session.get("minutesedit.PrintViewActive")) {
        // expand all topics, but save current state before!
        Session.set("minutesedit.collapsetopics-save4print."+_minutesID, Session.get("minutesedit.collapsetopics."+_minutesID));
        Session.set("minutesedit.collapsetopics."+_minutesID, undefined);

        Session.set("participants.expand", false);
        $(".help").hide();
        Meteor.setTimeout(function(){$(".collapse").addClass("in");}, 100);

        // give collapsibles some time for animation
        Meteor.setTimeout(function(){$(".expand-collapse-triangle").hide();}, 350);
        // as material checkboxes do not print correctly...
        // change material checkbox to normal checkbox for printing
        Meteor.setTimeout(function(){$("div.checkbox").toggleClass('checkbox print-checkbox');}, 360);
        Meteor.setTimeout(function(){openPrintDialog();}, 500);
    } else {
        // change back normal checkboxes to material checkboxes after printing
        $("div.print-checkbox").toggleClass('checkbox print-checkbox');
        $(".expand-collapse-triangle").show();
        $(".collapse").removeClass("in");
        // restore old topic collapsible state
        Session.set("minutesedit.collapsetopics."+_minutesID, Session.get("minutesedit.collapsetopics-save4print."+_minutesID));
    }
};



// Automatically restore view after printing
(function() {
    var afterPrint = function() {
        togglePrintView(false);
    };

    if (window.matchMedia) {
        var mediaQueryList = window.matchMedia('print');
        mediaQueryList.addListener(function(mql) {
            if (! mql.matches) {
                afterPrint();
            }
        });
    }

    window.onafterprint = afterPrint;
}());


// Global keyboard shortcut handler for this template
// In Meteor global key events can only be bound to the template on <INPUT> elements
// If we want to have these key events really global, we have to register them with
// the document. For details see SO:
// http://stackoverflow.com/questions/27972873/meteor-keydown-keyup-events-outside-input
let handleTemplatesGlobalKeyboardShortcuts = function(switchOn) {
    if (switchOn) {
        $(document).keydown( function(evt) {
            if ($('.modal.in').length > 0) {    // any modal dialog open?
                return;
            }
            // console.log("keydown", evt);
            // check if focus is in input-text or input-textarea
            // let el = document.activeElement;
            // if (el && (el.tagName.toLowerCase() == 'input' && el.type == 'text' ||
            //     el.tagName.toLowerCase() == 'textarea')) {
            //     return;
            // }

            // Listen for "Ctrl+Alt+T" for "Add Topic"
            // accesskey attribute is not an option, as it needs browser specific modifieres
            // (see www.w3schools.com/tags/att_global_accesskey.asp) and
            // accessKeyLabel is not implemented in all browsers
            if (evt.ctrlKey && evt.altKey && !evt.shiftKey &&
                evt.keyCode === 84) {
                $('#dlgAddTopic').modal('show');
                evt.preventDefault();
            }
        });
    } else {
        $(document).off('keydown');
    }
};

Template.minutesedit.onCreated(function () {
    this.minutesReady = new ReactiveVar();

    this.autorun(() => {
        _minutesID = FlowRouter.getParam('_id');
        let subscriptionHandle = this.subscribe('minutes', _minutesID);

        this.minutesReady.set(subscriptionHandle.ready());
    });

    Session.set('minutesedit.checkParent', false);
    handleTemplatesGlobalKeyboardShortcuts(true);
});

Template.minutesedit.onDestroyed(function() {
    if (orphanFlashMessage !== null) {
        orphanFlashMessage.hideMe();
    }
{'fraction_non_alphanumeric': 0.13968957871396895, 'fraction_numerical': 0.005240878855069542, 'mean_word_length': 2.7975507079984694, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '6187507', 'n_tokens_mistral': 2874, 'n_tokens_neox': 2732, 'n_words': 650}