diff --git a/ajax/documentController.php b/ajax/documentController.php index 4468b500..45fa69ab 100644 --- a/ajax/documentController.php +++ b/ajax/documentController.php @@ -38,7 +38,8 @@ class DocumentController extends Controller{ $documents = Storage::getDocuments(); $fileIds = array(); - foreach ($documents as $document) { + foreach ($documents as $key=>$document) { + $documents[$key]['icon'] = preg_replace('/\.png$/', '.svg', \OC_Helper::mimetypeIcon($document['mimetype'])); $fileIds[] = $document['fileid']; } diff --git a/ajax/mimeicon.php b/ajax/mimeicon.php deleted file mode 100644 index 8a354746..00000000 --- a/ajax/mimeicon.php +++ /dev/null @@ -1,3 +0,0 @@ - OC_Helper::mimetypeIcon($_GET['mime']))); diff --git a/js/documents.js b/js/documents.js index c42a855f..af5be88a 100644 --- a/js/documents.js +++ b/js/documents.js @@ -218,10 +218,8 @@ var documentsMain = { var a = docElem.find('a'); a.attr('href', OC.Router.generate('download',{file:document.path})); a.find('label').text(document.name); + a.css('background-image', 'url("'+document.icon+'")'); - getMimeIcon(document.mimetype).then(function(path){ - a.css('background-image', 'url("'+path+'")'); - }); $('.documentslist').append(docElem); docElem.show(); }); @@ -241,30 +239,6 @@ var documentsMain = { }; -/** - * TODO copy from files, move from files to core? load files.js? - * @param {type} mime - * @returns {getMimeIcon} - */ -function getMimeIcon(mime){ - var def = new $.Deferred(); - if(getMimeIcon.cache[mime]){ - def.resolve(getMimeIcon.cache[mime]); - }else{ - jQuery.getJSON( OC.filePath('documents','ajax','mimeicon.php'), {mime: mime}) - .done(function(data){ - getMimeIcon.cache[mime]=data.path; - def.resolve(getMimeIcon.cache[mime]); - }) - .error(function(jqXHR, textStatus, errorThrown){ - console.log(textStatus + ': ' + errorThrown); - console.log(jqXHR); - }); - } - return def; -} -getMimeIcon.cache={}; - $(document).ready(function() { "use strict"; @@ -330,4 +304,4 @@ $(document).ready(function() { //TODO when ending a session as the last user close session? OC.addScript('documents', 'webodf_bootstrap', documentsMain.onStartup); -}); \ No newline at end of file +});