Skip to content

Commit

Permalink
添加图标
Browse files Browse the repository at this point in the history
  • Loading branch information
leeight committed Jun 18, 2015
1 parent 0a0db2a commit 820c037
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 5 deletions.
3 changes: 2 additions & 1 deletion test/browser/demo/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
13 changes: 13 additions & 0 deletions test/browser/demo/src/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}}
*/
Expand Down
16 changes: 16 additions & 0 deletions test/browser/demo/src/tpl/filters.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions test/browser/demo/src/tpl/list-buckets.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
<!-- for: ${rows} as ${row} -->
<tr>
<!-- if: ${row.is_dir} -->
<td><a href="#/${row.name}">${row.name|i18n}/</a></td>
<td><i class="fa fa-folder-o"></i> <a href="#/${row.name}">${row.name|i18n}/</a></td>
<!-- else -->
<td>${row.name}</td>
<td><i class="fa ${row.name|fa_icon}"></i> ${row.name}</td>
<!-- /if -->
<td>&nbsp;</td>
<td>文件夹</td>
Expand Down
4 changes: 2 additions & 2 deletions test/browser/demo/src/tpl/list-objects.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<!-- for: ${contents} as ${row} -->
<!-- if: ${row.key} -->
<tr>
<td><a target="_blank" href="/v1/${name}/${prefix|raw}${row.key}">${row.key}</a></td>
<td><i class="fa ${row.key|fa_icon}"></i> <a target="_blank" href="/v1/${name}/${prefix|raw}${row.key}">${row.key}</a></td>
<td>
<i class="fa fa-trash-o" title="删除" data-bucket="${name}" data-key="${prefix|raw}${row.key}"></i>
<a class="fa" href="/v1/${name}/${prefix|raw}${row.key}?responseContentDisposition=attachment"><i class="fa fa-download" title="下载"></i></a>
Expand All @@ -18,7 +18,7 @@
<!-- /for -->
<!-- for: ${commonPrefixes} as ${row} -->
<tr>
<td><a href="#/${name}/${prefix|raw}${row.prefix}">${row.prefix}</a></td>
<td><i class="fa fa-folder-o"></i> <a href="#/${name}/${prefix|raw}${row.prefix}">${row.prefix}</a></td>
<td>&nbsp;</td>
<td>文件夹</td>
<td>-</td>
Expand Down

0 comments on commit 820c037

Please sign in to comment.