From 820c037b4b85257ad217260bd119c24e99fe724d Mon Sep 17 00:00:00 2001 From: leeight Date: Thu, 18 Jun 2015 16:38:54 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=9B=BE=E6=A0=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/browser/demo/index.css | 3 ++- test/browser/demo/src/config.js | 13 +++++++++++++ test/browser/demo/src/tpl/filters.js | 16 ++++++++++++++++ test/browser/demo/src/tpl/list-buckets.tpl | 4 ++-- test/browser/demo/src/tpl/list-objects.tpl | 4 ++-- 5 files changed, 35 insertions(+), 5 deletions(-) diff --git a/test/browser/demo/index.css b/test/browser/demo/index.css index 3a97edc..458fcb9 100644 --- a/test/browser/demo/index.css +++ b/test/browser/demo/index.css @@ -100,12 +100,13 @@ legend { padding: 8px 15px; text-align: left; } +/* .file-list tr .fa { display: none; } .file-list tr:hover .fa { display: inline-block; -} +}*/ .file-list td { padding: 8px 15px; border-top: 1px solid #eaeff0; diff --git a/test/browser/demo/src/config.js b/test/browser/demo/src/config.js index c8b7245..ccee211 100644 --- a/test/browser/demo/src/config.js +++ b/test/browser/demo/src/config.js @@ -35,6 +35,19 @@ define(function (require) { 'group-6': '六号工作组' }; + // file-${type}-o + exports.kType2Exts = { + excel: ['xls', 'xlsx'], + word: ['doc', 'docx'], + powerpoint: ['ppt', 'pptx'], + image: ['jpg', 'jpeg', 'gif', 'png'], + audio: ['wav', 'aac'], + archive: ['zip', 'tgz', 'tar', 'rar', 'tar.gz', 'gz', '7z'], + video: ['rm', 'rmvb', 'mp4', 'avi', 'flv', 'mpg', 'webm'], + pdf: ['pdf'], + code: ['js', 'css', 'html', 'htm', 'h', 'cpp', 'java', 'txt', 'cs', 'ts'] + }; + /** * @return {{bucket:string, prefix:string}} */ diff --git a/test/browser/demo/src/tpl/filters.js b/test/browser/demo/src/tpl/filters.js index d1dbfc2..e02860d 100644 --- a/test/browser/demo/src/tpl/filters.js +++ b/test/browser/demo/src/tpl/filters.js @@ -20,7 +20,16 @@ define(function (require) { var exports = {}; + var kExts2Type = {}; + exports.init = function () { + for (var type in config.kType2Exts) { + var exts = config.kType2Exts[type]; + for (var i = 0; i < exts.length; i ++) { + kExts2Type[exts[i]] = type; + } + } + etpl.addFilter('relativeTime', function (source) { var timestamp = moment(source).unix(); return humanize.relativeTime(timestamp); @@ -31,6 +40,13 @@ define(function (require) { etpl.addFilter('i18n', function (value) { return config.kWorkGroupMap[value] || value; }); + etpl.addFilter('fa_icon', function (value) { + var match = /\.([a-z0-9]+)$/i.exec(value); + if (match && match[1]) { + return ('fa-file-' + kExts2Type[match[1].toLowerCase()] + '-o') || 'fa-file'; + } + return 'fa-file'; + }); }; return exports; diff --git a/test/browser/demo/src/tpl/list-buckets.tpl b/test/browser/demo/src/tpl/list-buckets.tpl index 675cbbc..a6eba73 100644 --- a/test/browser/demo/src/tpl/list-buckets.tpl +++ b/test/browser/demo/src/tpl/list-buckets.tpl @@ -2,9 +2,9 @@ - ${row.name|i18n}/ + ${row.name|i18n}/ - ${row.name} + ${row.name}   文件夹 diff --git a/test/browser/demo/src/tpl/list-objects.tpl b/test/browser/demo/src/tpl/list-objects.tpl index f320ba0..3e56e24 100644 --- a/test/browser/demo/src/tpl/list-objects.tpl +++ b/test/browser/demo/src/tpl/list-objects.tpl @@ -5,7 +5,7 @@ - ${row.key} + ${row.key} @@ -18,7 +18,7 @@ - ${row.prefix} + ${row.prefix}   文件夹 -