diff options
author | Robin Appelman <icewind1991@gmail.com> | 2011-11-04 03:00:03 +0100 |
---|---|---|
committer | Robin Appelman <icewind1991@gmail.com> | 2011-11-04 03:00:03 +0100 |
commit | 2c68aab1983c912e52af6c0f62bc04850178894b (patch) | |
tree | 0cbf68f3be22624f2dbb8e1b752ad99e1679b625 /files | |
parent | 0c890a501cc7c24fb7eb5a4e4bff35dd2bb56b6d (diff) | |
parent | ce2b39b398b1bf2143e1b16523de5325a766d24d (diff) | |
download | nextcloud-server-2c68aab1983c912e52af6c0f62bc04850178894b.tar.gz nextcloud-server-2c68aab1983c912e52af6c0f62bc04850178894b.zip |
Merge branch 'master' into newbutton
Diffstat (limited to 'files')
-rw-r--r-- | files/js/fileactions.js | 2 | ||||
-rw-r--r-- | files/js/filelist.js | 54 | ||||
-rw-r--r-- | files/js/files.js | 14 | ||||
-rw-r--r-- | files/templates/part.list.php | 2 |
4 files changed, 43 insertions, 29 deletions
diff --git a/files/js/fileactions.js b/files/js/fileactions.js index f95c5e84dc1..9e2688e82c1 100644 --- a/files/js/fileactions.js +++ b/files/js/fileactions.js @@ -56,7 +56,7 @@ FileActions={ $('#fileList .action').remove(); var actions=FileActions.get(FileActions.getCurrentMimeType(),FileActions.getCurrentType()); var file=FileActions.getCurrentFile(); - if($('tr[data-file="'+file+'"]').data('renaming')){ + if($('tr').filterAttr('data-file',file).data('renaming')){ return; } var defaultAction=FileActions.getDefault(FileActions.getCurrentMimeType(),FileActions.getCurrentType()); diff --git a/files/js/filelist.js b/files/js/filelist.js index 863a3385d15..5740ece9716 100644 --- a/files/js/filelist.js +++ b/files/js/filelist.js @@ -4,7 +4,7 @@ FileList={ }, addFile:function(name,size,lastModified,loading){ var img=(loading)?OC.imagePath('core', 'loading.gif'):OC.imagePath('core', 'filetypes/file.png'); - var html='<tr data-file="'+name+'" data-type="file" data-size="'+size+'">'; + var html='<tr data-type="file" data-size="'+size+'">'; if(name.indexOf('.')!=-1){ var basename=name.substr(0,name.lastIndexOf('.')); var extention=name.substr(name.lastIndexOf('.')); @@ -29,16 +29,21 @@ FileList={ html+='<td class="filesize" title="'+humanFileSize(size)+'" style="color:rgb('+sizeColor+','+sizeColor+','+sizeColor+')">'+simpleSize+'</td>'; html+='<td class="date"><span class="modified" title="'+formatDate(lastModified)+'" style="color:rgb('+modifiedColor+','+modifiedColor+','+modifiedColor+')">'+relative_modified_date(lastModified.getTime() / 1000)+'</span></td>'; html+='</tr>'; - FileList.insertElement(name,'file',$(html)); + FileList.insertElement(name,'file',$(html).attr('data-file',name)); if(loading){ - $('tr[data-file="'+name+'"]').data('loading',true); + $('tr').filterAttr('data-file',name).data('loading',true); }else{ - $('tr[data-file="'+name+'"] td.filename').draggable(dragOptions); + $('tr').filterAttr('data-file',name).find('td.filename').draggable(dragOptions); } }, addDir:function(name,size,lastModified){ - var html='<tr data-file="'+name+'" data-type="dir" data-size="'+size+'">'; - html+='<td class="filename" style="background-image:url('+OC.imagePath('core', 'filetypes/folder.png')+')"><input type="checkbox" /><a class="name" href="index.php?dir='+$('#dir').val()+'/'+name+'">'+name+'</a></td>'; + html = $('<tr></tr>').attr({ "data-type": "dir", "data-size": size, "data-file": name}); + td = $('<td></td>').attr({"class": "filename", "style": 'background-image:url('+OC.imagePath('core', 'filetypes/folder.png')+')' }); + td.append('<input type="checkbox" />'); + var link_elem = $('<a></a>').attr({ "class": "name", "href": "index.php?dir="+ encodeURIComponent($('#dir').val()+'/'+name) }); + link_elem.append($('<span></span>').addClass('nametext').text(name)); + td.append(link_elem); + html.append(td); if(size!='Pending'){ simpleSize=simpleFileSize(size); }else{ @@ -47,13 +52,15 @@ FileList={ sizeColor = Math.round(200-Math.pow((size/(1024*1024)),2)); lastModifiedTime=Math.round(lastModified.getTime() / 1000); modifiedColor=Math.round((Math.round((new Date()).getTime() / 1000)-lastModifiedTime)/60/60/24*5); - html+='<td class="filesize" title="'+humanFileSize(size)+'" style="color:rgb('+sizeColor+','+sizeColor+','+sizeColor+')">'+simpleSize+'</td>'; - html+='<td class="date"><span class="modified" title="'+formatDate(lastModified)+'" style="color:rgb('+modifiedColor+','+modifiedColor+','+modifiedColor+')">'+relative_modified_date(lastModified.getTime() / 1000)+'</span></td>'; - html+='</tr>'; + td = $('<td></td>').attr({ "class": "filesize", "title": humanFileSize(size), "style": 'color:rgb('+sizeColor+','+sizeColor+','+sizeColor+')'}).text(simpleSize); + html.append(td); - FileList.insertElement(name,'dir',$(html)); - $('tr[data-file="'+name+'"] td.filename').draggable(dragOptions); - $('tr[data-file="'+name+'"] td.filename').droppable(folderDropOptions); + td = $('<td></td>').attr({ "class": "date" }); + td.append($('<span></span>').attr({ "class": "modified", "title": formatDate(lastModified), "style": 'color:rgb('+modifiedColor+','+modifiedColor+','+modifiedColor+')' }).text( relative_modified_date(lastModified.getTime() / 1000) )); + html.append(td); + FileList.insertElement(name,'dir',html); + $('tr').filterAttr('data-file',name).find('td.filename').draggable(dragOptions); + $('tr').filterAttr('data-file',name).find('td.filename').droppable(folderDropOptions); }, refresh:function(data) { result = jQuery.parseJSON(data.responseText); @@ -64,8 +71,8 @@ FileList={ resetFileActionPanel(); }, remove:function(name){ - $('tr[data-file="'+name+'"] td.filename').draggable('destroy'); - $('tr[data-file="'+name+'"]').remove(); + $('tr').filterAttr('data-file',name).find('td.filename').draggable('destroy'); + $('tr').filterAttr('data-file',name).remove(); if($('tr[data-file]').length==0){ $('#emptyfolder').show(); $('.file_upload_filename').addClass('highlight'); @@ -101,7 +108,7 @@ FileList={ $('.file_upload_filename').removeClass('highlight'); }, loadingDone:function(name){ - var tr=$('tr[data-file="'+name+'"]'); + var tr=$('tr').filterAttr('data-file',name); tr.data('loading',false); var mime=tr.data('mime'); tr.attr('data-mime',mime); @@ -111,13 +118,13 @@ FileList={ tr.find('td.filename').draggable(dragOptions); }, isLoading:function(name){ - return $('tr[data-file="'+name+'"]').data('loading'); + return $('tr').filterAttr('data-file',name).data('loading'); }, rename:function(name){ - var tr=$('tr[data-file="'+name+'"]'); + var tr=$('tr').filterAttr('data-file',name); tr.data('renaming',true); var td=tr.children('td.filename'); - var input=$('<input value="'+name+'" class="filename"></input>'); + var input=$('<input class="filename"></input>').val(name); var form=$('<form action="#"></form>') form.append(input); td.children('a.name').text(''); @@ -143,7 +150,7 @@ FileList={ } $.ajax({ url: 'ajax/rename.php', - data: "dir="+$('#dir').val()+"&newname="+encodeURIComponent(newname)+"&file="+encodeURIComponent(name) + data: { dir : $('#dir').val(), newname: newname, file: name } }); }); form.click(function(event){ @@ -165,9 +172,10 @@ FileList={ files=[files]; } $.each(files,function(index,file){ - $('tr[data-file="'+file+'"]').hide(); - $('tr[data-file="'+file+'"]').find('input[type="checkbox"]').removeAttr('checked'); - $('tr[data-file="'+file+'"]').removeClass('selected'); + var files = $('tr').filterAttr('data-file',file); + files.hide(); + files.find('input[type="checkbox"]').removeAttr('checked'); + files.removeClass('selected'); }); procesSelection(); FileList.deleteCanceled=false; @@ -208,7 +216,7 @@ $(document).ready(function(){ if($('#notification').data('deletefile')) { $.each(FileList.deleteFiles,function(index,file){ - $('tr[data-file="'+file+'"]').show(); + $('tr').filterAttr('data-file',file).show(); // alert(file); }); FileList.deleteCanceled=true; diff --git a/files/js/files.js b/files/js/files.js index db3f3135b9f..4f9cde49aa9 100644 --- a/files/js/files.js +++ b/files/js/files.js @@ -1,4 +1,10 @@ $(document).ready(function() { + $('#fileList tr').each(function(){ + //little hack to set unescape filenames in attribute + $(this).attr('data-file',unescape($(this).data('file'))); + $(this).data('file',unescape($(this).data('file'))); + }); + if($('tr[data-file]').length==0){ $('.file_upload_filename').addClass('highlight'); } @@ -64,7 +70,7 @@ $(document).ready(function() { } procesSelection(); } else { - var filename=$(this).parent().parent().data('file'); + var filename=$(this).parent().parent().attr('data-file'); if(!FileList.isLoading(filename)){ var mime=$(this).parent().parent().data('mime'); var type=$(this).parent().parent().data('type'); @@ -185,9 +191,9 @@ $(document).ready(function() { if(response[0] != undefined && response[0].status == 'success'){ for(var i=0;i<response.length;i++){ var file=response[i]; - $('tr[data-file="'+file.name+'"]').data('mime',file.mime); + $('tr').filterAttr('data-file',file.name).data('mime',file.mime); if(size=='Pending'){ - $('tr[data-file='+file.name+'] td.filesize').text(file.size); + $('tr').filterAttr('data-file',file.name).find('td.filesize').text(file.size); } FileList.loadingDone(file.name); } @@ -388,7 +394,7 @@ var folderDropOptions={ url: 'ajax/move.php', data: "dir="+dir+"&file="+file+'&target='+dir+'/'+target, complete: function(data){boolOperationFinished(data, function(){ - var el=$('#fileList tr[data-file="'+file+'"] td.filename'); + var el = $('#fileList tr').filterAttr('data-file',file).find('td.filename'); el.draggable('destroy'); FileList.remove(file); });} diff --git a/files/templates/part.list.php b/files/templates/part.list.php index 6bf5efe2fb2..46830ba3a37 100644 --- a/files/templates/part.list.php +++ b/files/templates/part.list.php @@ -5,7 +5,7 @@ $relative_modified_date = relative_modified_date($file['mtime']); $relative_date_color = round((time()-$file['mtime'])/60/60/24*14); // the older the file, the brighter the shade of grey; days*14 if($relative_date_color>200) $relative_date_color = 200; ?> - <tr data-file="<?php echo $file['name'];?>" data-type="<?php echo ($file['type'] == 'dir')?'dir':'file'?>" data-mime="<?php echo $file['mime']?>" data-size='<?php echo $file['size'];?>'> + <tr data-file="<?php echo str_replace('+','%20',urlencode($file['name']));?>" data-type="<?php echo ($file['type'] == 'dir')?'dir':'file'?>" data-mime="<?php echo $file['mime']?>" data-size='<?php echo $file['size'];?>'> <td class="filename svg" style="background-image:url(<?php if($file['type'] == 'dir') echo mimetype_icon('dir'); else echo mimetype_icon($file['mime']); ?>)"> <?php if(!isset($_['readonly']) || !$_['readonly']) { ?><input type="checkbox" /><?php } ?> <a class="name" href="<?php if($file['type'] == 'dir') echo $_['baseURL'].$file['directory'].'/'.$file['name']; else echo $_['downloadURL'].urlencode($file['directory']).'/'.urlencode($file['name']); ?>" title=""> |