<commit_before>/*globals window:false */
define(['jquery','events'], function($,events) {
    "use strict";

    var vertical = false;
    var currentGeometry = {};

    function changeLayout(vert) {
        if (vert) {
            vertical = true;
            $('#facsimile-container').attr('class','horizontal span12');
            $('#editor').attr('class','horizontal span12');


        } else {
            vertical = false;
            $('#facsimile-container').attr('class','vertical span6');
            $('#editor').attr('class','vertical span6');
        }
        resizeHandler ();
    }

    function newViewportRequest(data) {
        changeLayout(data.vertical);
    }

    function resizeHandler () {
        var topHeight = $('#toolbar').outerHeight();
        var bottomHeight = $('#bottom-geometry').outerHeight();
        var wHeight = $(window).innerHeight();
        var availableH = wHeight - topHeight - bottomHeight;
        if (vertical) {
            availableH /= 2;
        } else {

        }

        availableH -= 30; // TODO: what is 30!

        var facsimileWidth = $('#facsimile-container').innerWidth();
        var facsimileHeight = availableH;
        var data = {
            width: facsimileWidth,
            height: facsimileHeight,
            vertical: vertical
        };

        if (
            (data.vertical != currentGeometry.vertical) ||
            (data.width != currentGeometry.facsimileWidth) ||
            (data.height != currentGeometry.facsimileHeight)
            ) {
            $('#editor').height(availableH);
            $('.CodeMirror').height(availableH);
            $('#facsimile-container').height(availableH);
            $('#document').css('max-height',availableH);
            $('#spinner').height(availableH);
            currentGeometry = data;
            events.trigger('setGeometry',data);
        }
    }

    // keep element sizes ok, when window size changes
    $(window).resize(resizeHandler);

    events.on('changePageDone',resizeHandler);
    events.on('changePageError',resizeHandler);
    events.on('keyboardLayoutChanged',resizeHandler);
    events.on('newViewportRequest',newViewportRequest);
    events.on('changeLayout',changeLayout);

    return {
        resizeHandler: resizeHandler
    };
});
<commit_msg>Fix preservation of page dirty class across page changes<commit_after>/*globals window:false */
define(['jquery','events'], function($,events) {
    "use strict";

    var vertical = false;
    var currentGeometry = {};

    function changeLayout(vert) {
        var $els = $('#facsimile-container,#editor');

        if (vert) {

            vertical = true;
            $els.removeClass('vertical');
            $els.removeClass('span6');
            $els.addClass('horizontal');
            $els.addClass('span12');

        } else {

            vertical = false;
            $els.addClass('vertical');
            $els.addClass('span6');
            $els.removeClass('horizontal');
            $els.removeClass('span12');

        }
        resizeHandler ();
    }

    function newViewportRequest(data) {
        changeLayout(data.vertical);
    }

    function resizeHandler () {
        var topHeight = $('#toolbar').outerHeight();
        var bottomHeight = $('#bottom-geometry').outerHeight();
        var wHeight = $(window).innerHeight();
        var availableH = wHeight - topHeight - bottomHeight;
        if (vertical) {
            availableH /= 2;
        } else {

        }

        availableH -= 30; // TODO: what is 30!

        var facsimileWidth = $('#facsimile-container').innerWidth();
        var facsimileHeight = availableH;
        var data = {
            width: facsimileWidth,
            height: facsimileHeight,
            vertical: vertical
        };

        if (
            (data.vertical != currentGeometry.vertical) ||
            (data.width != currentGeometry.facsimileWidth) ||
            (data.height != currentGeometry.facsimileHeight)
            ) {
            $('#editor').height(availableH);
            $('.CodeMirror').height(availableH);
            $('#facsimile-container').height(availableH);
            $('#document').css('max-height',availableH);
            $('#spinner').height(availableH);
            currentGeometry = data;
            events.trigger('setGeometry',data);
        }
    }

    // keep element sizes ok, when window size changes
    $(window).resize(resizeHandler);

    events.on('changePageDone',resizeHandler);
    events.on('changePageError',resizeHandler);
    events.on('keyboardLayoutChanged',resizeHandler);
    events.on('newViewportRequest',newViewportRequest);
    events.on('changeLayout',changeLayout);

    return {
        resizeHandler: resizeHandler
    };
});

{'fraction_non_alphanumeric': 0.14321713565728686, 'fraction_numerical': 0.004619907601847963, 'mean_word_length': 2.242341729067393, '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': '4282977', 'n_tokens_mistral': 1249, 'n_tokens_neox': 1209, 'n_words': 221}