diff options
author | Vincent Petry <pvince81@owncloud.com> | 2013-11-28 03:38:58 -0800 |
---|---|---|
committer | Vincent Petry <pvince81@owncloud.com> | 2013-11-28 03:38:58 -0800 |
commit | 30b2ed588b76544142fade70f9b849043d54e05a (patch) | |
tree | e90fa1dbc1e6f972b77163aeb7c8b7f3b06825cd | |
parent | 6c16d45dc75317f6714afe48de8c56c70b8d2665 (diff) | |
parent | 69a3327f47843da8f070b2da653f6d956cfde6c1 (diff) | |
download | nextcloud-server-30b2ed588b76544142fade70f9b849043d54e05a.tar.gz nextcloud-server-30b2ed588b76544142fade70f9b849043d54e05a.zip |
Merge pull request #6096 from owncloud/files-txtextfornewfiles
New file box now has default file name + extension
-rw-r--r-- | apps/files/js/file-upload.js | 16 | ||||
-rw-r--r-- | apps/files/templates/index.php | 4 |
2 files changed, 15 insertions, 5 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(); 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 @@ <a><?php p($l->t('New'));?></a> <ul> <li style="background-image:url('<?php p(OCP\mimetype_icon('text/plain')) ?>')" - data-type='file'><p><?php p($l->t('Text file'));?></p></li> + data-type='file' data-newname='<?php p($l->t('New text file')) ?>.txt'><p><?php p($l->t('Text file'));?></p></li> <li style="background-image:url('<?php p(OCP\mimetype_icon('dir')) ?>')" - data-type='folder'><p><?php p($l->t('Folder'));?></p></li> + data-type='folder' data-newname='<?php p($l->t('New folder')) ?>'><p><?php p($l->t('Folder'));?></p></li> <li style="background-image:url('<?php p(OCP\image_path('core', 'places/link.svg')) ?>')" data-type='web'><p><?php p($l->t('From link'));?></p></li> </ul> |