diff options
author | Jörn Friedrich Dreyer <jfd@butonic.de> | 2012-12-18 16:36:26 +0100 |
---|---|---|
committer | Jörn Friedrich Dreyer <jfd@butonic.de> | 2013-01-02 17:06:33 +0100 |
commit | 474fdef5d4104da40d85d8422c85cc84a0c758be (patch) | |
tree | 53d7d98fac0d955028f9ad5ee7b0d1a8cd602b9a /apps/files/js | |
parent | 42a215513618f179d42dfe7895b353fc7b7693cd (diff) | |
download | nextcloud-server-474fdef5d4104da40d85d8422c85cc84a0c758be.tar.gz nextcloud-server-474fdef5d4104da40d85d8422c85cc84a0c758be.zip |
enable enter in ie by using .submit()+form instead of .change(), use notifications when name is empty
Diffstat (limited to 'apps/files/js')
-rw-r--r-- | apps/files/js/files.js | 43 |
1 files changed, 28 insertions, 15 deletions
diff --git a/apps/files/js/files.js b/apps/files/js/files.js index 9cfdd1462a7..61f6617f092 100644 --- a/apps/files/js/files.js +++ b/apps/files/js/files.js @@ -509,7 +509,7 @@ $(document).ready(function() { $('#new li').each(function(i,element){ if($(element).children('p').length==0){ - $(element).children('input').remove(); + $(element).children('form').remove(); $(element).append('<p>'+$(element).data('text')+'</p>'); } }); @@ -519,19 +519,32 @@ $(document).ready(function() { $(this).data('text',text); $(this).children('p').remove(); var input=$('<input>'); - $(this).append(input); + var form=$('<form></form>'); + form.append(input); + $(this).append(form); input.focus(); - input.change(function(){ - if (type != 'web' && Files.containsInvalidCharacters($(this).val())) { - return; - } else if( type == 'folder' && $('#dir').val() == '/' && $(this).val() == 'Shared') { - $('#notification').text(t('files','Invalid folder name. Usage of "Shared" is reserved by Owncloud')); - $('#notification').fadeIn(); - return; - } - var name = getUniqueName($(this).val()); - if (name != $(this).val()) { - FileList.checkName(name, $(this).val(), true); + form.submit(function(event){ + event.stopPropagation(); + event.preventDefault(); + var newname=input.val(); + if(type != 'web' && Files.containsInvalidCharacters(newname)){ + return false; + } else if (newname.length == 0) { + if(type == 'web') { + $('#notification').text(t('files', "URL cannot be empty.")); + } else { + $('#notification').text(t('files', "Name cannot be empty.")); + } + $('#notification').fadeIn(); + return false; + } else if( type == 'folder' && $('#dir').val() == '/' && newname == 'Shared') { + $('#notification').text(t('files','Invalid folder name. Usage of "Shared" is reserved by Owncloud')); + $('#notification').fadeIn(); + return false; + } + var name = getUniqueName(newname); + if (newname != name) { + FileList.checkName(name, newname, true); var hidden = true; } else { var hidden = false; @@ -614,8 +627,8 @@ $(document).ready(function() { }); break; } - var li=$(this).parent(); - $(this).remove(); + var li=form.parent(); + form.remove(); li.append('<p>'+li.data('text')+'</p>'); $('#new>a').click(); }); |