Skip to content
Snippets Groups Projects
edit.php 1.64 KiB
Newer Older
<div id="file_edit_window">
    <?= $aside_template->render() ?>
    <div id="file_management_forms">
        <form method="post" data-dialog class="default"
              action="<?= PluginEngine::getURL(NextcloudPlugin::class, [], 'file/edit/' . $file->getId()) ?>">
            <?= CSRFProtection::tokenTag() ?>
            <fieldset>
                <legend><?= dgettext('NextcloudPlugin', 'Datei bearbeiten') ?></legend>
                    <?= dgettext('NextcloudPlugin', 'Name') ?>
                    <input id="edit_file_name" type="text" name="name"
                           value="<?= htmlReady($name) ?>">
                </label>
            </fieldset>
            <footer data-dialog-button>
                <?= Studip\Button::createAccept(dgettext('NextcloudPlugin', 'Speichern'), 'save') ?>
                <?= Studip\LinkButton::createCancel(
                    dgettext('NextcloudPlugin', 'Abbrechen'),
                    $controller->url_for((in_array($folder->range_type, ['course', 'institute']) ? $folder->range_type . '/' : '') . 'files/index/' . $folder->id)
                ) ?>
            </footer>
        </form>
    </div>
</div>

<script>
    //On focus on the edit file name input field, the whole file name but the
    //extension shall be selected. This can't be done with jQuery directly!

    jQuery('#edit_file_name').focus(function() {
        //select the whole file name, but the file extension
        var text = $(this).val(),
            //get start position of extension:
            extension_start_pos = text.lastIndexOf('.');

        $(this).setSelection(0, extension_start_pos);
    });

</script>