<commit_before>﻿/*
 * SPEasyForms ResizeModalDialog - if the current page is a document, containing
 * a form on which SPEasyForms is configured, resize the dialog box to accomodate
 * the SPEasyForms controls.
 *
 * @version 2015.00.05
 * @requires SPEasyForms v2014.01 
 * @copyright 2014-2015 <NAME>
 * @license under the MIT license:
 *    http://www.opensource.org/licenses/mit-license.php
 */

/* global spefjQuery, ExecuteOrDelayUntilScriptLoaded, _spPageContextInfo, SP */
(function ($, undefined) {
    // return without doing anything if SPEasyForms has not been loaded
    if (!$.spEasyForms) return;

    // get the version number from the default options (not defined in 2014.01)
    var spEasyFormsVersion = ($.spEasyForms.defaults.version ? $.spEasyForms.defaults.version : "2014.01");

    // this patch only needs to be applied to v2014.01
    if (spEasyFormsVersion !== "2014.01") return;

    // save a reference to the original SPEasyForms init method
    $.spEasyForms.ResizeModalDialog_originalInit = $.spEasyForms.init;

    // replace the original SPEasyForms init method
    $.spEasyForms.init = function (options) {
        // call the original SPEasyForms init method
        $.spEasyForms.ResizeModalDialog_originalInit(options);

        ExecuteOrDelayUntilScriptLoaded(function () {
            var dlg = SP.UI.ModalDialog.get_childDialog();
            if (dlg !== null) {
                setTimeout(function () {
                    if ($("#spEasyFormsContainersPre").length > 0) {
                        $.spEasyForms.utilities.autoSizeDialog();
                    }
                }, 3000);
            }
        }, "sp.ui.dialog.js");
    };

    $.spEasyForms.utilities.autoSizeDialog = function () {
        $(".ms-webpartzone-cell").css("margin", "auto");

        var dlgHeight = $.spEasyForms.utilities.getFormHeight();
        var dlgWidth = $.spEasyForms.utilities.getFormWidth();

        if (_spPageContextInfo.webUIVersion === 4) {
            $(".ms-dlgContent", window.parent.document).height(dlgHeight);
            $(".ms-dlgBorder", window.parent.document).height(dlgHeight);
            $(".ms-dlgFrame", window.parent.document).height(dlgHeight - 32);

            $(".ms-dlgContent", window.parent.document).width(dlgWidth);
            $(".ms-dlgBorder", window.parent.document).width(dlgWidth - 2);
            $(".ms-dlgFrame", window.parent.document).width(dlgWidth - 2);

            $("#s4-workspace").css("overflow-x", "hidden");<commit_msg>modified resize dialog so it works on forms that are hidden on dialog load ala 'Why is my Form So Jumpy'<commit_after>﻿/*
 * SPEasyForms ResizeModalDialog - if the current page is a document, containing
 * a form on which SPEasyForms is configured, resize the dialog box to accomodate
 * the SPEasyForms controls.
 *
 * @version 2015.00.05
 * @requires SPEasyForms v2014.01 
 * @copyright 2014-2015 <NAME>
 * @license under the MIT license:
 *    http://www.opensource.org/licenses/mit-license.php
 */

/* global spefjQuery, ExecuteOrDelayUntilScriptLoaded, _spPageContextInfo, SP */
(function ($, undefined) {
    // return without doing anything if SPEasyForms has not been loaded
    if (!$.spEasyForms) return;

    // get the version number from the default options (not defined in 2014.01)
    var spEasyFormsVersion = ($.spEasyForms.defaults.version ? $.spEasyForms.defaults.version : "2014.01");

    // this patch only needs to be applied to v2014.01
    if (spEasyFormsVersion !== "2014.01") return;

    // save a reference to the original SPEasyForms init method
    $.spEasyForms.ResizeModalDialog_originalInit = $.spEasyForms.init;

    // replace the original SPEasyForms init method
    $.spEasyForms.init = function (options) {
        // call the original SPEasyForms init method
        $.spEasyForms.ResizeModalDialog_originalInit(options);

        var formHidden = $(".ms-formtable").css("display") === "none";

        ExecuteOrDelayUntilScriptLoaded(function () {
            var dlg = SP.UI.ModalDialog.get_childDialog();
            if (dlg !== null) {
                setTimeout(function () {
                    if (formHidden || $("#spEasyFormsContainersPre").length > 0) {
                        $.spEasyForms.utilities.autoSizeDialog();
                    }
                }, 3000);
            }
        }, "sp.ui.dialog.js");
    };

    $.spEasyForms.utilities.autoSizeDialog = function () {
        $(".ms-webpartzone-cell").css("margin", "auto");

        var dlgHeight = $.spEasyForms.utilities.getFormHeight();
        var dlgWidth = $.spEasyForms.utilities.getFormWidth();

        if (_spPageContextInfo.webUIVersion === 4) {
            $(".ms-dlgContent", window.parent.document).height(dlgHeight);
            $(".ms-dlgBorder", window.parent.document).height(dlgHeight);
            $(".ms-dlgFrame", window.parent.document).height(dlgHeight - 32);

            $(".ms-dlgContent", window.parent.document).width(dlgWidth);
            $(".ms-dlgBorder", window.parent.document).width(dlgWidth - 2);
            $(".ms-dlgFrame", window.parent.document).width(dlgWidth - 2);

            $("#s4-workspace").css("overflow-x", "hidden");
{'fraction_non_alphanumeric': 0.13211186113789777, 'fraction_numerical': 0.021986499517839923, 'mean_word_length': 2.728253055355859, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, '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': '4222243', 'n_tokens_mistral': 1597, 'n_tokens_neox': 1450, 'n_words': 348}