aboutsummaryrefslogtreecommitdiffstats
path: root/apps/files/js/file-upload.js
diff options
context:
space:
mode:
Diffstat (limited to 'apps/files/js/file-upload.js')
-rw-r--r--apps/files/js/file-upload.js16
1 files changed, 13 insertions, 3 deletions
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=$('<form></form>');
- var input=$('<input type="text">');
+ var form = $('<form></form>');
+ var input = $('<input type="text">');
+ 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();