<commit_before>import { Session } from 'meteor/session';
import { $ } from 'meteor/jquery';
import { OHIF } from 'meteor/ohif:core';
import { getInstanceClassDefaultViewport } from '../instanceClassSpecificViewport';

// Manage resizing viewports triggered by window resize
export class ResizeViewportManager {
    constructor() {
        this._resizeHandler = null;
        OHIF.log.info('ResizeViewportManager');
    }

    // Reposition Study Series Quick Switch based whether side bars are opened or not
    repositionStudySeriesQuickSwitch() {
        OHIF.log.info('ResizeViewportManager repositionStudySeriesQuickSwitch');

        // Stop here if viewer is not displayed
        const isViewer = Session.get('ViewerOpened');
        if (!isViewer) return;

        // Stop here if there is no one or only one viewport
        const nViewports = OHIF.viewerbase.layoutManager.viewportData.length;
        if (!nViewports || nViewports <= 1) return;

        const $viewer = $('#viewer');
        const leftSidebar = $viewer.find('.sidebar-left.sidebar-open');
        const rightSidebar = $viewer.find('.sidebar-right.sidebar-open');

        const $leftQuickSwitch = $('.quickSwitchWrapper.left');
        const $rightQuickSwitch = $('.quickSwitchWrapper.right');

        const hasLeftSidebar = leftSidebar.length > 0;
        const hasRightSidebar = rightSidebar.length > 0;

        $rightQuickSwitch.removeClass('left-sidebar-only');
        $leftQuickSwitch.removeClass('right-sidebar-only');

        let leftOffset = 0;

        if (hasLeftSidebar) {
            leftOffset = (leftSidebar.width() / $(window).width()) * 100;

            if (!hasRightSidebar) {
                $rightQuickSwitch.addClass('left-sidebar-only');
            }
        }

        if (hasRightSidebar && !hasLeftSidebar) {
            $leftQuickSwitch.addClass('right-sidebar-only');
        }

        const leftPosition = (($('#imageViewerViewports').width() / nViewports) / $(window).width()) * 100 + leftOffset;
        const rightPosition = 100 - leftPosition;

        $leftQuickSwitch.css('right', rightPosition + '%');
        $rightQuickSwitch.css('left', leftPosition + '%');
    }

    // Relocate dialogs positions
    relocateDialogs(){
        OHIF.log.info('ResizeViewportManager relocateDialogs');

        const $bottomRightDialogs = $('#cineDialog, #annotationDialog, #textMarkerOptionsDialog');
        $bottomRightDialogs.css({
            top: '', // This removes the CSS property completely
            left: '',
            bottom: 0,
            right: 0
        });

        const centerDialogs = $('.draggableDialog').not($bottomRightDialogs);

        centerDialogs.css({
            top: 0,
            left: 0,
            bottom: 0,
            right: 0
        });
    }

    // Resize viewport scrollbars
    resizeScrollbars(element) {
        OHIF.log.info('ResizeViewportManager resizeScrollbars');

        const currentOverlay = $(element).siblings('.imageViewerViewportOverlay');
        currentOverlay.find('.imageControls').height($(element).height());

        // Set it's width to its parent's height<commit_msg>OHIF-61 (ASCD): Resizing of window causes controls to overlay on the image<commit_after>import { Session } from 'meteor/session';
import { $ } from 'meteor/jquery';
import { OHIF } from 'meteor/ohif:core';
import { getInstanceClassDefaultViewport } from '../instanceClassSpecificViewport';

// Manage resizing viewports triggered by window resize
export class ResizeViewportManager {
    constructor() {
        this._resizeHandler = null;
        OHIF.log.info('ResizeViewportManager');
    }

    // Reposition Study Series Quick Switch based whether side bars are opened or not
    repositionStudySeriesQuickSwitch() {
        OHIF.log.info('ResizeViewportManager repositionStudySeriesQuickSwitch');

        // Stop here if viewer is not displayed
        const isViewer = Session.get('ViewerOpened');
        if (!isViewer) return;

        // Stop here if there is no one or only one viewport
        const nViewports = OHIF.viewerbase.layoutManager.viewportData.length;
        if (!nViewports || nViewports <= 1) return;

        const $viewer = $('#viewer');
        const leftSidebar = $viewer.find('.sidebar-left.sidebar-open');
        const rightSidebar = $viewer.find('.sidebar-right.sidebar-open');

        const $leftQuickSwitch = $('.quickSwitchWrapper.left');
        const $rightQuickSwitch = $('.quickSwitchWrapper.right');

        const hasLeftSidebar = leftSidebar.length > 0;
        const hasRightSidebar = rightSidebar.length > 0;

        $rightQuickSwitch.removeClass('left-sidebar-only');
        $leftQuickSwitch.removeClass('right-sidebar-only');

        let leftOffset = 0;

        if (hasLeftSidebar) {
            leftOffset = (leftSidebar.width() / $(window).width()) * 100;

            if (!hasRightSidebar) {
                $rightQuickSwitch.addClass('left-sidebar-only');
            }
        }

        if (hasRightSidebar && !hasLeftSidebar) {
            $leftQuickSwitch.addClass('right-sidebar-only');
        }

        const leftPosition = (($('#imageViewerViewports').width() / nViewports) / $(window).width()) * 100 + leftOffset;
        const rightPosition = 100 - leftPosition;

        $leftQuickSwitch.css('right', rightPosition + '%');
        $rightQuickSwitch.css('left', leftPosition + '%');
    }

    // Relocate dialogs positions
    relocateDialogs(){
        OHIF.log.info('ResizeViewportManager relocateDialogs');

        const $bottomRightDialogs = $('#annotationDialog, #textMarkerOptionsDialog');
        $bottomRightDialogs.css({
            top: '', // This removes the CSS property completely
            left: '',
            bottom: 0,
            right: 0
        });

        const centerDialogs = $('.draggableDialog').not($bottomRightDialogs);

        centerDialogs.css({
            top: 0,
            left: 0,
            bottom: 0,
            right: 0
        });
    }

    // Resize viewport scrollbars
    resizeScrollbars(element) {
        OHIF.log.info('ResizeViewportManager resizeScrollbars');

        const currentOverlay = $(element).siblings('.imageViewerViewportOverlay');
        currentOverlay.find('.imageControls').height($(element).height());

        // Set it's width to its parent's height
{'fraction_non_alphanumeric': 0.12200504413619168, 'fraction_numerical': 0.006305170239596469, 'mean_word_length': 2.6591695501730106, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, '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': '3835639', 'n_tokens_mistral': 1789, 'n_tokens_neox': 1676, 'n_words': 381}