<commit_before>// --
// Core.UI.Resizable.js - Resizable
// Copyright (C) 2001-2010 OTRS AG, http://otrs.org/\n";
// --
// $Id: Core.UI.Resizable.js,v 1.7 2010-09-22 09:54:41 mg Exp $
// --
// This software comes with ABSOLUTELY NO WARRANTY. For details, see
// the enclosed file COPYING for license information (AGPL). If you
// did not receive this file, see http://www.gnu.org/licenses/agpl.txt.
// --

"use strict";

var Core = Core || {};
Core.UI = Core.UI || {};

/**
 * @namespace
 * @exports TargetNS as Core.UI.Resizable
 * @description
 *      Contains the code for resizable elements.
 */
Core.UI.Resizable = (function (TargetNS) {

    var ScrollerMinHeight = 84,
        HandleHeight = 9,
        TableHeaderHeight = 28;
    /**
     * @function
     * @description
     *      This function initializes the resizability of the given element
     * @param {jQueryObject} $Element jQuery object of the element, which should be resizable
     * @param {jQueryObject} ScrollerHeight The default height of the resizable object
     * @param {jQueryObject} Callback The callback if resizable has changed
     * @return nothing
     */
    TargetNS.Init = function ($Element, ScrollerHeight, Callback) {
        // also catch NaN or undefined values for ScrollerHeight, but pass 0
        //      to Math.max in these cases, otherwise it may cause an exception
        ScrollerHeight = Math.max(ScrollerHeight || 0, ScrollerMinHeight);

        if (isJQueryObject($Element) && $Element.length) {
            if (($Element.find('table').height() + HandleHeight) < ScrollerHeight) {
                $Element.find('.Scroller').height($Element.find('table').height());
            }
            else {
                $Element.find('.Scroller').height(ScrollerHeight);
            }

            $Element.resizable({
                handles: {
                    s: $Element.find('.Handle a')
                },
                minHeight: ScrollerMinHeight + HandleHeight + TableHeaderHeight,
                maxHeight: $Element.find('table').height() + HandleHeight + TableHeaderHeight,
                resize: function (Event, UI) {
                    var Height, Width;
                    Height = UI.size.height - TableHeaderHeight - HandleHeight;
                    Width = UI.size.width;
                    $Element.find('div.Scroller').height(Height + 'px').width(Width + 'px');

                    if ($.isFunction(Callback)) {
                        Callback(Event, UI, Height, Width);
                    }
                }
            });
        }
    };

    return TargetNS;
}(Core.UI.Resizable || {}));
<commit_msg>Refactored. Avoid unneccessary DOM operations.<commit_after>// --
// Core.UI.Resizable.js - Resizable
// Copyright (C) 2001-2010 OTRS AG, http://otrs.org/\n";
// --
// $Id: Core.UI.Resizable.js,v 1.8 2010-10-01 14:25:58 mg Exp $
// --
// This software comes with ABSOLUTELY NO WARRANTY. For details, see
// the enclosed file COPYING for license information (AGPL). If you
// did not receive this file, see http://www.gnu.org/licenses/agpl.txt.
// --

"use strict";

var Core = Core || {};
Core.UI = Core.UI || {};

/**
 * @namespace
 * @exports TargetNS as Core.UI.Resizable
 * @description
 *      Contains the code for resizable elements.
 */
Core.UI.Resizable = (function (TargetNS) {

    var ScrollerMinHeight = 84,
        HandleHeight = 9,
        TableHeaderHeight = 28;
    /**
     * @function
     * @description
     *      This function initializes the resizability of the given element
     * @param {jQueryObject} $Element jQuery object of the element, which should be resizable
     * @param {jQueryObject} ScrollerHeight The default height of the resizable object
     * @param {jQueryObject} Callback The callback if resizable has changed
     * @return nothing
     */
    TargetNS.Init = function ($Element, ScrollerHeight, Callback) {
        var CurrentTableHeight;

        // also catch NaN or undefined values for ScrollerHeight, but pass 0
        //      to Math.max in these cases, otherwise it may cause an exception
        ScrollerHeight = Math.max(ScrollerHeight || 0, ScrollerMinHeight);

        if (isJQueryObject($Element) && $Element.length) {
            CurrentTableHeight = $Element.find('table').height();
            if ((CurrentTableHeight + HandleHeight) < ScrollerHeight) {
                $Element.find('.Scroller').height(CurrentTableHeight);
            }
            else {
                $Element.find('.Scroller').height(ScrollerHeight);
            }

            $Element.resizable({
                handles: {
                    s: $Element.find('.Handle a')
                },
                minHeight: ScrollerMinHeight + HandleHeight + TableHeaderHeight,
                maxHeight: $Element.find('table').height() + HandleHeight + TableHeaderHeight,
                resize: function (Event, UI) {
                    var Height, Width;
                    Height = UI.size.height - TableHeaderHeight - HandleHeight;
                    Width = UI.size.width;
                    $Element.find('div.Scroller').height(Height + 'px').width(Width + 'px');

                    if ($.isFunction(Callback)) {
                        Callback(Event, UI, Height, Width);
                    }
                }
            });
        }
    };

    return TargetNS;
}(Core.UI.Resizable || {}));

{'fraction_non_alphanumeric': 0.12212323682256868, 'fraction_numerical': 0.011507052709725315, 'mean_word_length': 2.00893355667225, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, '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': '5887713', 'n_tokens_mistral': 1538, 'n_tokens_neox': 1420, 'n_words': 398}