summaryrefslogtreecommitdiffstats
path: root/apps/files/js/file-upload.js
diff options
context:
space:
mode:
authorVincent Petry <pvince81@owncloud.com>2013-11-28 10:17:01 +0100
committerVincent Petry <pvince81@owncloud.com>2013-11-28 10:18:31 +0100
commit24a08c686df393e41fca251776ce0a414d75976f (patch)
tree82fb5d0d3ab3b3620519f5b317e54bf545f4e079 /apps/files/js/file-upload.js
parentf23d641b82b0b8f2834983800b3520fcadf6bd71 (diff)
downloadnextcloud-server-24a08c686df393e41fca251776ce0a414d75976f.tar.gz
nextcloud-server-24a08c686df393e41fca251776ce0a414d75976f.zip
New file box now has default file name + extension
Whenever a user creates a file or folder in the web UI, the input field will contain a default file name, pre-selected up to the extension for easier typing. The purpose is mostly to prevent users creating text files without an extension. Fixes #6045
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();