mimetype icon improvements

This commit is contained in:
Robin Appelman 2011-10-08 21:18:47 +02:00
parent bbd96fdd39
commit 949494ccfd
6 changed files with 31 additions and 10 deletions

View File

Before

Width:  |  Height:  |  Size: 859 B

After

Width:  |  Height:  |  Size: 859 B

View File

Before

Width:  |  Height:  |  Size: 538 B

After

Width:  |  Height:  |  Size: 538 B

8
files/ajax/mimeicon.php Normal file
View File

@ -0,0 +1,8 @@
<?php
// Init owncloud
require_once('../../lib/base.php');
print OC_Helper::mimetypeIcon($_GET['mime']);
?>

View File

@ -101,10 +101,14 @@ FileList={
$('.file_upload_filename').removeClass('highlight'); $('.file_upload_filename').removeClass('highlight');
}, },
loadingDone:function(name){ loadingDone:function(name){
$('tr[data-file="'+name+'"]').data('loading',false); var tr=$('tr[data-file="'+name+'"]');
var mime=$('tr[data-file="'+name+'"]').data('mime'); tr.data('loading',false);
$('tr[data-file="'+name+'"] td.filename').attr('style','background-image:url('+getMimeIcon(mime)+')'); var mime=tr.data('mime');
$('tr[data-file="'+name+'"] td.filename').draggable(dragOptions); tr.attr('data-mime',mime);
getMimeIcon(mime,function(path){
tr.find('td.filename').attr('style','background-image:url('+path+')');
});
tr.find('td.filename').draggable(dragOptions);
}, },
isLoading:function(name){ isLoading:function(name){
return $('tr[data-file="'+name+'"]').data('loading'); return $('tr[data-file="'+name+'"]').data('loading');

View File

@ -473,11 +473,14 @@ function relative_modified_date(timestamp) {
else { return diffyears+' '+t('files','years ago'); } else { return diffyears+' '+t('files','years ago'); }
} }
function getMimeIcon(mime){ function getMimeIcon(mime, ready){
mime=mime.substr(0,mime.indexOf('/')); if(getMimeIcon.cache[mime]){
var knownMimes=['image','audio']; ready(getMimeIcon.cache[mime]);
if(knownMimes.indexOf(mime)==-1){ }else{
mime='file'; $.get( OC.filePath('files','ajax','mimeicon.php')+'?mime='+mime, function(path){
getMimeIcon.cache[mime]=path;
ready(getMimeIcon.cache[mime]);
});
} }
return OC.imagePath('core','filetypes/'+mime);
} }
getMimeIcon.cache={};

View File

@ -96,6 +96,12 @@ class OC_Helper {
* Returns the path to the image of this file type. * Returns the path to the image of this file type.
*/ */
public static function mimetypeIcon( $mimetype ){ public static function mimetypeIcon( $mimetype ){
$alias=array('application/xml'=>'code/xml');
// echo $mimetype;
if(isset($alias[$mimetype])){
$mimetype=$alias[$mimetype];
// echo $mimetype;
}
// Replace slash with a minus // Replace slash with a minus
$mimetype = str_replace( "/", "-", $mimetype ); $mimetype = str_replace( "/", "-", $mimetype );