diff --git a/apps/files/js/file-upload.js b/apps/files/js/file-upload.js index bc1244a1e6e..e9663353f74 100644 --- a/apps/files/js/file-upload.js +++ b/apps/files/js/file-upload.js @@ -508,11 +508,15 @@ $(document).ready(function() { $(this).children('p').remove(); // add input field - var form=$('
'); - var input=$(''); + var form = $(''); + var input = $(''); + var newName = $(this).attr('data-newname') || ''; + if (newName) { + input.val(newName); + } form.append(input); $(this).append(form); - + var lastPos; var checkInput = function () { var filename = input.val(); if (type === 'web' && filename.length === 0) { @@ -543,6 +547,12 @@ $(document).ready(function() { }); input.focus(); + // pre select name up to the extension + lastPos = newName.lastIndexOf('.'); + if (lastPos === -1) { + lastPos = newName.length; + } + input.selectRange(0, lastPos); form.submit(function(event) { event.stopPropagation(); event.preventDefault(); diff --git a/apps/files/templates/index.php b/apps/files/templates/index.php index 4f8623573cb..99d66ed3f9c 100644 --- a/apps/files/templates/index.php +++ b/apps/files/templates/index.php @@ -5,9 +5,9 @@ t('New'));?>t('Text file'));?>
t('Text file'));?>
t('Folder'));?>
t('Folder'));?>
t('From link'));?>