Permalink
Browse files

Refactors.

  • Loading branch information...
1 parent 7b3daeb commit 4d4e41a637e08f923bd5b1180e42e7c9f84281b7 @lrsjng committed Aug 27, 2013
@@ -1,12 +1,12 @@
modulejs.define('core/resource', ['core/settings'], function (settings) {
- var image = function (id, customExt) {
+ var image = function (id) {
- return settings.h5aiAbsHref + 'client/images/' + id + (customExt ? '' : '.svg');
+ return settings.h5aiAbsHref + 'client/images/' + id + '.svg';
},
- icon = function (id, big) {
+ icon = function (id) {
return settings.h5aiAbsHref + 'client/icons/96/' + id + '.png';
};
@@ -37,7 +37,7 @@ modulejs.define('ext/delete', ['_', '$', 'core/settings', 'core/event', 'core/re
requestDeletion = function (hrefsStr) {
$delete.addClass('current');
- $img.attr('src', resource.image('loading.gif', true));
+ $img.attr('src', resource.image('loading'));
server.request({action: 'delete', hrefs: hrefsStr}, handleResponse);
},
@@ -29,11 +29,11 @@ modulejs.define('ext/thumbnails', ['_', 'core/settings', 'core/event', 'core/ser
var type = null;
- if (_.indexOf(settings.img, item.type) >= 0) {
+ if (_.contains(settings.img, item.type)) {
type = 'img';
- } else if (_.indexOf(settings.mov, item.type) >= 0) {
+ } else if (_.contains(settings.mov, item.type)) {
type = 'mov';
- } else if (_.indexOf(settings.doc, item.type) >= 0) {
+ } else if (_.contains(settings.doc, item.type)) {
type = 'doc';
}
@@ -34,7 +34,6 @@ modulejs.define('ext/tree', ['_', '$', 'core/settings', 'core/resource', 'core/e
.data('status', item.status);
location.setLink($a, item);
- // $img.attr('src', resource.icon(item.type));
$img.attr('src', resource.image('folder'));
$label.text(item.label);
@@ -95,7 +94,6 @@ modulejs.define('ext/tree', ['_', '$', 'core/settings', 'core/resource', 'core/e
// reflect folder status
if (_.isNumber(item.status)) {
if (item.status === 200) {
- // $img.attr('src', resource.icon('folder-page'));
$img.attr('src', resource.image('folder-page'));
} else {
$html.addClass('error');
@@ -39,8 +39,7 @@ modulejs.define('view/items', ['_', '$', 'core/settings', 'core/resource', 'core
var $html = $(itemTemplate),
$a = $html.find('a'),
- $imgSquare = $html.find('.icon.square img'),
- $imgRational = $html.find('.icon.rational img'),
+ $iconImg = $html.find('.icon img'),
$label = $html.find('.label'),
$date = $html.find('.date'),
$size = $html.find('.size');
@@ -51,26 +50,23 @@ modulejs.define('view/items', ['_', '$', 'core/settings', 'core/resource', 'core
location.setLink($a, item);
- $imgSquare.attr('src', resource.icon(item.type)).attr('alt', item.type);
- $imgRational.attr('src', resource.icon(item.type)).attr('alt', item.type);
+ $iconImg.attr('src', resource.icon(item.type)).attr('alt', item.type);
$label.text(item.label);
$date.data('time', item.time).text(format.formatDate(item.time));
$size.data('bytes', item.size).text(format.formatSize(item.size));
if (item.isFolder() && _.isNumber(item.status)) {
if (item.status === 200) {
$html.addClass('page');
- $imgSquare.attr('src', resource.icon('folder-page'));
- $imgRational.attr('src', resource.icon('folder-page'));
+ $iconImg.attr('src', resource.icon('folder-page'));
} else {
$html.addClass('error');
$label.append($(hintTemplate).text(' ' + item.status + ' '));
}
}
if (item.isCurrentParentFolder()) {
- $imgSquare.attr('src', resource.icon('folder-parent'));
- $imgRational.attr('src', resource.icon('folder-parent'));
+ $iconImg.attr('src', resource.icon('folder-parent'));
if (!settings.setParentFolderLabels) {
$label.addClass('l10n-parentDirectory');
}

0 comments on commit 4d4e41a

Please sign in to comment.