importUsersDialog: function()

in enginframe/hydrogen.manage-users.js [585:627]


    importUsersDialog: function (dialogTitle, dialogDescription, buttonLabel, checkEmpty, actionfunc) {
        var dialog, form, entryTextArea, entryFile, button, dialogButtons;

        dialog = jQuery(".hy-import-users-dialog");
        if (dialog.length === 0) {
            dialog = jQuery('<div class="hy-import-users-dialog"/>').appendTo(jQuery('body'));
            jQuery('<div style="display:block">' + dialogDescription + '</div>').appendTo(dialog);
            form = jQuery('<form id="import-users-form"/>').appendTo(dialog);
            jQuery('<input type="file" name="fileCSV" id="file-csv" />').appendTo(form);
            jQuery('<div style="display:block"><p></p></div>').appendTo(form);
            jQuery('<textarea name="usersCSV" id="users-csv" class="ef-ugm-dialog-input-area" rows="10" cols="50"/>').appendTo(form);
        }

        dialogButtons = {
            Cancel: function () {
                jQuery(this).dialog("close");
            }
        };
        dialogButtons[buttonLabel] = function () {
            var entryFile = jQuery("#file-csv").val();
            var entryTextArea = jQuery("#users-csv").val();

            if (checkEmpty === true) {
                if (entryFile.length === 0 && entryTextArea.length === 0) {
                    return false;
                }
            }
            jQuery(this).dialog("close");

            actionfunc("import-users-form");
        };

        dialog.dialog({
            title: dialogTitle,
            resizable: false,
            buttons: dialogButtons,
            modal: true,
            width: "550px"
        });

        button = jQuery('button:contains(' + buttonLabel + ')', dialog.parent('div.ui-dialog'));
        button.addClass('ui-priority-primary');
    }