Semantic changes.

This commit is contained in:
Lars Jung 2012-10-27 03:50:35 +02:00
parent 9163996ac2
commit 1dea89befb
24 changed files with 243 additions and 237 deletions

View file

@ -7,7 +7,7 @@
display: list-item;
}
&.entry {
&.item {
a, a:active, a:visited {
border-top: 1px solid @item-border-col-sep;
@ -24,7 +24,7 @@
}
}
&.entry + .entry {
&.item + .item {
a, a:active, a:visited {
border-top: none;

View file

@ -3,7 +3,7 @@
li {
&.entry {
&.item {
float: left;
a, a:active, a:visited {

View file

@ -4,7 +4,7 @@
li {
text-align: center;
&.entry {
&.item {
float: left;
a, a:active, a:visited {

View file

@ -3,7 +3,7 @@
li {
&.entry {
&.item {
a, a:active, a:visited {
height: 56px;
@ -17,7 +17,7 @@
}
}
&.entry + .entry {
&.item + .item {
a, a:active, a:visited {
border-top: none;

View file

@ -66,7 +66,7 @@
}
}
&.entry {
&.item {
a, a:active, a:visited {
display: block;

View file

@ -15,10 +15,10 @@ body {
}
}
#extended.view-details {
.header .label, .entry .label {
.header .label, .item .label {
margin-right: 110px;
}
.header .date, .entry .date {
.header .date, .item .date {
display: none;
}
}

View file

@ -69,35 +69,35 @@ modulejs.define('core/location', ['_', 'modernizr', 'core/settings', 'core/event
getItem = function () {
return modulejs.require('model/entry').get(absHref);
return modulejs.require('model/item').get(absHref);
},
load = function (callback) {
modulejs.require('core/server').request({action: 'get', entries: true, entriesHref: absHref, entriesWhat: 1}, function (json) {
var Entry = modulejs.require('model/entry'),
entry = Entry.get(absHref);
var Item = modulejs.require('model/item'),
item = Item.get(absHref);
if (json) {
var found = {};
_.each(json.entries, function (jsonEntry) {
_.each(json.entries, function (jsonItem) {
var e = Entry.get(jsonEntry.absHref, jsonEntry.time, jsonEntry.size, jsonEntry.status, jsonEntry.content);
var e = Item.get(jsonItem.absHref, jsonItem.time, jsonItem.size, jsonItem.status, jsonItem.content);
found[e.absHref] = true;
});
_.each(entry.content, function (e) {
_.each(item.content, function (e) {
if (!found[e.absHref]) {
Entry.remove(e.absHref);
Item.remove(e.absHref);
}
});
}
if (_.isFunction(callback)) {
callback(entry);
callback(item);
}
});
},

View file

@ -14,49 +14,48 @@ modulejs.define('ext/crumb', ['_', '$', 'core/settings', 'core/resource', 'core/
pageHintTemplate = '<img class="hint" src="' + resource.image('page') + '" alt="has index page"/>',
statusHintTemplate = '<span class="hint"/>',
update = function (entry, force) {
update = function (item, force) {
if (!force && entry.$crumb && entry.$crumb.data('status') === entry.status) {
return entry.$crumb;
if (!force && item.$crumb) {
return item.$crumb;
}
var $html = $(template),
$a = $html.find('a');
$html
.addClass(entry.isFolder() ? 'folder' : 'file')
.data('item', entry)
.data('status', entry.status);
.addClass(item.isFolder() ? 'folder' : 'file')
.data('item', item);
location.setLink($a, entry);
$a.find('span').text(entry.label).end();
location.setLink($a, item);
$a.find('span').text(item.label).end();
if (entry.isDomain()) {
if (item.isDomain()) {
$html.addClass('domain');
$a.find('img').attr('src', resource.image('home'));
}
if (entry.isRoot()) {
if (item.isRoot()) {
$html.addClass('root');
$a.find('img').attr('src', resource.image('home'));
}
if (entry.isCurrentFolder()) {
if (item.isCurrentFolder()) {
$html.addClass('current');
}
if (_.isNumber(entry.status)) {
if (entry.status === 200) {
if (_.isNumber(item.status)) {
if (item.status === 200) {
$a.append($(pageHintTemplate));
} else {
$a.append($(statusHintTemplate).text('(' + entry.status + ')'));
$a.append($(statusHintTemplate).text('(' + item.status + ')'));
}
}
if (entry.$crumb) {
entry.$crumb.replaceWith($html);
if (item.$crumb) {
item.$crumb.replaceWith($html);
}
entry.$crumb = $html;
item.$crumb = $html;
return $html;
},

View file

@ -45,9 +45,9 @@ modulejs.define('ext/delete', ['_', '$', 'core/settings', 'core/event', 'core/re
selectedHrefsStr = '';
if (entries.length) {
selectedHrefsStr = _.map(entries, function (entry) {
selectedHrefsStr = _.map(entries, function (item) {
return entry.absHref;
return item.absHref;
}).join(':');
$delete.appendTo('#navbar').show();
} else {

View file

@ -60,9 +60,9 @@ modulejs.define('ext/download', ['_', '$', 'core/settings', 'core/resource', 'co
selectedHrefsStr = '';
if (entries.length) {
selectedHrefsStr = _.map(entries, function (entry) {
selectedHrefsStr = _.map(entries, function (item) {
return entry.absHref;
return item.absHref;
}).join(':');
$download.appendTo('#navbar').show();
} else {

View file

@ -22,7 +22,7 @@ modulejs.define('ext/filter', ['_', '$', 'core/settings', 'core/resource'], func
duration = 200;
if (re) {
$('#extended .entry').each(function () {
$('#items .item').each(function () {
var label = $(this).find('.label').text();
@ -33,7 +33,7 @@ modulejs.define('ext/filter', ['_', '$', 'core/settings', 'core/resource'], func
}
});
} else {
match = $('#extended .entry');
match = $('#items .item');
}
if ($(match).length) {

View file

@ -55,7 +55,7 @@ modulejs.define('ext/l10n', ['_', '$', 'core/settings', 'core/langs', 'core/form
format.setDefaultDateFormat(currentLang.dateFormat);
$('#extended .entry .date').each(function () {
$('#items .item .date').each(function () {
var $this = $(this);

View file

@ -201,32 +201,32 @@ modulejs.define('ext/preview-img', ['_', '$', 'core/settings', 'core/resource',
event.stopImmediatePropagation();
},
initEntry = function (entry) {
initItem = function (item) {
if (entry.$extended && _.indexOf(settings.types, entry.type) >= 0) {
entry.$extended.find('a').on('click', function (event) {
if (item.$extended && _.indexOf(settings.types, item.type) >= 0) {
item.$extended.find('a').on('click', function (event) {
event.preventDefault();
var matchedEntries = _.compact(_.map($('#extended .entry'), function (entry) {
var matchedEntries = _.compact(_.map($('#items .item'), function (item) {
entry = $(entry).data('entry');
return _.indexOf(settings.types, entry.type) >= 0 ? entry : null;
item = $(item).data('item');
return _.indexOf(settings.types, item.type) >= 0 ? item : null;
}));
onEnter(matchedEntries, _.indexOf(matchedEntries, entry));
onEnter(matchedEntries, _.indexOf(matchedEntries, item));
});
}
},
onLocationChanged = function (item) {
_.each(item.content, initEntry);
_.each(item.content, initItem);
},
onLocationRefreshed = function (item, added, removed) {
_.each(added, initEntry);
_.each(added, initItem);
},
init = function () {

View file

@ -252,32 +252,32 @@ modulejs.define('ext/preview-txt', ['_', '$', 'core/settings', 'core/resource',
event.stopImmediatePropagation();
},
initEntry = function (entry) {
initItem = function (item) {
if (entry.$extended && _.indexOf(_.keys(settings.types), entry.type) >= 0) {
entry.$extended.find('a').on('click', function (event) {
if (item.$extended && _.indexOf(_.keys(settings.types), item.type) >= 0) {
item.$extended.find('a').on('click', function (event) {
event.preventDefault();
var matchedEntries = _.compact(_.map($('#extended .entry'), function (entry) {
var matchedEntries = _.compact(_.map($('#item .item'), function (item) {
entry = $(entry).data('entry');
return _.indexOf(_.keys(settings.types), entry.type) >= 0 ? entry : null;
item = $(item).data('item');
return _.indexOf(_.keys(settings.types), item.type) >= 0 ? item : null;
}));
onEnter(matchedEntries, _.indexOf(matchedEntries, entry));
onEnter(matchedEntries, _.indexOf(matchedEntries, item));
});
}
},
onLocationChanged = function (item) {
_.each(item.content, initEntry);
_.each(item.content, initItem);
},
onLocationRefreshed = function (item, added, removed) {
_.each(added, initEntry);
_.each(added, initItem);
},
init = function () {

View file

@ -26,7 +26,7 @@ modulejs.define('ext/qrcode', ['_', '$', 'modernizr', 'core/settings', 'core/eve
}
},
update = function (entry) {
update = function (item) {
loadQrCodeExtension(function () {
$qrcode.empty().qrcode({
@ -34,21 +34,21 @@ modulejs.define('ext/qrcode', ['_', '$', 'modernizr', 'core/settings', 'core/eve
width: settings.size,
height: settings.size,
color: '#333',
text: 'http://' + document.domain + entry.absHref
text: 'http://' + document.domain + item.absHref
});
});
},
onMouseenter = function (entry) {
onMouseenter = function (item) {
if (!entry.isFolder()) {
update(entry);
if (!item.isFolder()) {
update(item);
clearTimeout(hideTimeoutId);
$qrcode.stop(true, true).fadeIn(400);
}
},
onMouseleave = function (entry) {
onMouseleave = function (item) {
hideTimeoutId = setTimeout(function () {
@ -64,8 +64,8 @@ modulejs.define('ext/qrcode', ['_', '$', 'modernizr', 'core/settings', 'core/eve
$qrcode = $(template).appendTo('body');
event.sub('entry.mouseenter', onMouseenter);
event.sub('entry.mouseleave', onMouseleave);
event.sub('item.mouseenter', onMouseenter);
event.sub('item.mouseleave', onMouseleave);
};
init();

View file

@ -13,9 +13,9 @@ modulejs.define('ext/select', ['_', '$', 'core/settings', 'core/event'], functio
publish = function () {
var entries = _.map($('#extended .entry.selected'), function (entryElement) {
var entries = _.map($('#items .item.selected'), function (itemElement) {
return $(entryElement).data('entry');
return $(itemElement).data('item');
});
event.pub('selection', entries);
@ -35,13 +35,13 @@ modulejs.define('ext/select', ['_', '$', 'core/settings', 'core/event'], functio
.show();
var selRect = $selectionRect.fracs('rect');
$('#extended .entry').removeClass('selecting').each(function () {
$('#items .item').removeClass('selecting').each(function () {
var $entry = $(this),
rect = $entry.find('a').fracs('rect'),
var $item = $(this),
rect = $item.find('a').fracs('rect'),
inter = selRect.intersection(rect);
if (inter && !$entry.hasClass('folder-parent')) {
$entry.addClass('selecting');
if (inter && !$item.hasClass('folder-parent')) {
$item.addClass('selecting');
}
});
},
@ -50,8 +50,8 @@ modulejs.define('ext/select', ['_', '$', 'core/settings', 'core/event'], functio
event.preventDefault();
$document.off('mousemove', selectionUpdate);
$('#extended .entry.selecting.selected').removeClass('selecting').removeClass('selected');
$('#extended .entry.selecting').removeClass('selecting').addClass('selected');
$('#items .item.selecting.selected').removeClass('selecting').removeClass('selected');
$('#items .item.selecting').removeClass('selecting').addClass('selected');
publish();
$selectionRect
@ -87,7 +87,7 @@ modulejs.define('ext/select', ['_', '$', 'core/settings', 'core/event'], functio
$(':focus').blur();
if (!event.ctrlKey && !event.metaKey) {
$('#extended .entry').removeClass('selected');
$('#items .item').removeClass('selected');
publish();
}

View file

@ -8,13 +8,13 @@ modulejs.define('ext/sort', ['_', '$', 'core/settings', 'core/resource', 'core/e
storekey = 'sort.order',
type = function (entry) {
type = function (item) {
var $entry = $(entry);
var $item = $(item);
if ($entry.hasClass('folder-parent')) {
if ($item.hasClass('folder-parent')) {
return 0;
} else if ($entry.hasClass('folder')) {
} else if ($item.hasClass('folder')) {
return 1;
}
return 2;
@ -22,17 +22,17 @@ modulejs.define('ext/sort', ['_', '$', 'core/settings', 'core/resource', 'core/e
cmpFn = function (rev, getVal) {
return function (entry1, entry2) {
return function (item1, item2) {
var res, val1, val2;
res = type(entry1) - type(entry2);
res = type(item1) - type(item2);
if (res !== 0) {
return res;
}
val1 = getVal(entry1);
val2 = getVal(entry2);
val1 = getVal(item1);
val2 = getVal(item2);
if (val1 < val2) {
return rev ? 1 : -1;
} else if (val1 > val2) {
@ -42,17 +42,17 @@ modulejs.define('ext/sort', ['_', '$', 'core/settings', 'core/resource', 'core/e
};
},
getName = function (entry) {
getName = function (item) {
return $(entry).find('.label').text().toLowerCase();
return $(item).find('.label').text().toLowerCase();
},
getTime = function (entry) {
getTime = function (item) {
return $(entry).find('.date').data('time');
return $(item).find('.date').data('time');
},
getSize = function (entry) {
getSize = function (item) {
return $(entry).find('.size').data('bytes');
return $(item).find('.size').data('bytes');
},
$all, orders,
@ -65,10 +65,10 @@ modulejs.define('ext/sort', ['_', '$', 'core/settings', 'core/resource', 'core/e
$all.removeClass('ascending').removeClass('descending');
order.head.addClass(order.clas);
$('#extended .entry').detach().sort(order.fn).appendTo('#extended > ul');
$('#items .item').detach().sort(order.fn).appendTo('#items');
},
onContentChanged = function (entry) {
onContentChanged = function (item) {
sortBy(store.get(storekey) || settings.order);
},
@ -81,7 +81,7 @@ modulejs.define('ext/sort', ['_', '$', 'core/settings', 'core/resource', 'core/e
var $ascending = $('<img src="' + resource.image('ascending') + '" class="sort ascending" alt="ascending" />'),
$descending = $('<img src="' + resource.image('descending') + '" class="sort descending" alt="descending" />'),
$header = $('#extended li.header'),
$header = $('#items li.header'),
$label = $header.find('a.label'),
$date = $header.find('a.date'),
$size = $header.find('a.size');

View file

@ -54,25 +54,25 @@ modulejs.define('ext/statusbar', ['_', '$', 'core/settings', 'core/format', 'cor
event.sub('location.changed', onLocationChanged);
event.sub('location.refreshed', onLocationChanged);
event.sub('entry.mouseenter', function (entry) {
event.sub('item.mouseenter', function (item) {
if (entry.isCurrentParentFolder()) {
if (item.isCurrentParentFolder()) {
return;
}
var $span = $('<span/>').append(entry.label);
var $span = $('<span/>').append(item.label);
if (_.isNumber(entry.time)) {
$span.append(sepTemplate).append(format.formatDate(entry.time));
if (_.isNumber(item.time)) {
$span.append(sepTemplate).append(format.formatDate(item.time));
}
if (_.isNumber(entry.size)) {
$span.append(sepTemplate).append(format.formatSize(entry.size));
if (_.isNumber(item.size)) {
$span.append(sepTemplate).append(format.formatSize(item.size));
}
update($span);
});
event.sub('entry.mouseleave', function (entry) {
event.sub('item.mouseleave', function (item) {
update();
});

View file

@ -25,31 +25,41 @@ modulejs.define('ext/thumbnails', ['_', 'core/settings', 'core/event', 'core/ser
});
},
checkEntry = function (entry) {
checkItem = function (item) {
var type = null;
if (_.indexOf(settings.img, entry.type) >= 0) {
if (_.indexOf(settings.img, item.type) >= 0) {
type = 'img';
} else if (_.indexOf(settings.mov, entry.type) >= 0) {
} else if (_.indexOf(settings.mov, item.type) >= 0) {
type = 'mov';
} else if (_.indexOf(settings.doc, entry.type) >= 0) {
} else if (_.indexOf(settings.doc, item.type) >= 0) {
type = 'doc';
}
if (type) {
requestThumbSmall(type, entry.absHref, function (src) {
if (item.thumbSmall) {
item.$extended.find('.icon.small img').addClass('thumb').attr('src', item.thumbSmall);
} else {
requestThumbSmall(type, item.absHref, function (src) {
if (src && entry.$extended) {
entry.$extended.find('.icon.small img').addClass('thumb').attr('src', src);
}
});
requestThumbBig(type, entry.absHref, function (src) {
if (src && item.$extended) {
item.thumbSmall = src;
item.$extended.find('.icon.small img').addClass('thumb').attr('src', src);
}
});
}
if (item.thumbBig) {
item.$extended.find('.icon.big img').addClass('thumb').attr('src', item.thumbBig);
} else {
requestThumbBig(type, item.absHref, function (src) {
if (src && entry.$extended) {
entry.$extended.find('.icon.big img').addClass('thumb').attr('src', src);
}
});
if (src && item.$extended) {
item.thumbBig = src;
item.$extended.find('.icon.big img').addClass('thumb').attr('src', src);
}
});
}
}
},
@ -57,13 +67,13 @@ modulejs.define('ext/thumbnails', ['_', 'core/settings', 'core/event', 'core/ser
setTimeout(function () {
_.each(item.content, checkEntry);
_.each(item.content, checkItem);
}, settings.delay);
},
onLocationRefreshed = function (item, added, removed) {
_.each(added, checkEntry);
_.each(added, checkItem);
},
init = function () {

View file

@ -7,7 +7,7 @@ modulejs.define('ext/tree', ['_', '$', 'core/settings', 'core/resource', 'core/e
maxSubfolders: 50
}, allsettings.tree),
template = '<div class="entry">' +
template = '<div class="item">' +
'<span class="indicator none">' +
'<img src="' + resource.image('tree') + '"/>' +
'</span>' +
@ -20,7 +20,7 @@ modulejs.define('ext/tree', ['_', '$', 'core/settings', 'core/resource', 'core/e
magicSequence = '=h5ai=',
update = function (entry) {
update = function (item) {
var $html = $(template),
$indicator = $html.find('.indicator'),
@ -29,26 +29,26 @@ modulejs.define('ext/tree', ['_', '$', 'core/settings', 'core/resource', 'core/e
$label = $html.find('.label');
$html
.addClass(entry.isFolder() ? 'folder' : 'file')
.data('entry', entry)
.data('status', entry.status);
.addClass(item.isFolder() ? 'folder' : 'file')
.data('item', item)
.data('status', item.status);
location.setLink($a, entry);
$img.attr('src', resource.icon(entry.type));
$label.text(entry.label);
location.setLink($a, item);
$img.attr('src', resource.icon(item.type));
$label.text(item.label);
if (entry.isFolder()) {
if (item.isFolder()) {
var subfolders = entry.getSubfolders();
var subfolders = item.getSubfolders();
// indicator
if (!entry.status || (entry.status === magicSequence && !entry.isContentFetched) || subfolders.length) {
if (!item.status || (item.status === magicSequence && !item.isContentFetched) || subfolders.length) {
$indicator.removeClass('none');
if (!entry.status || (entry.status === magicSequence && !entry.isContentFetched)) {
if (!item.status || (item.status === magicSequence && !item.isContentFetched)) {
$indicator.addClass('unknown');
} else if (entry.isContentVisible) {
} else if (item.isContentVisible) {
$indicator.addClass('open');
} else {
$indicator.addClass('close');
@ -56,19 +56,19 @@ modulejs.define('ext/tree', ['_', '$', 'core/settings', 'core/resource', 'core/e
}
// is it the domain?
if (entry.isDomain()) {
if (item.isDomain()) {
$html.addClass('domain');
$img.attr('src', resource.icon('folder-home'));
}
// is it the root?
if (entry.isRoot()) {
if (item.isRoot()) {
$html.addClass('root');
$img.attr('src', resource.icon('folder-home'));
}
// is it the current folder?
if (entry.isCurrentFolder()) {
if (item.isCurrentFolder()) {
$html.addClass('current');
$img.attr('src', resource.icon('folder-open'));
}
@ -86,27 +86,27 @@ modulejs.define('ext/tree', ['_', '$', 'core/settings', 'core/resource', 'core/e
if (subfolders.length > settings.maxSubfolders) {
$('<li class="summary">… ' + (subfolders.length - settings.maxSubfolders) + ' more subfolders</li>').appendTo($ul);
}
if (!entry.isContentVisible) {
if (!item.isContentVisible) {
$ul.hide();
}
}
// reflect folder status
if (_.isNumber(entry.status)) {
if (entry.status === 200) {
if (_.isNumber(item.status)) {
if (item.status === 200) {
$img.attr('src', resource.icon('folder-page'));
} else {
$html.addClass('error');
$a.append($(statusHintTemplate).text(entry.status));
$a.append($(statusHintTemplate).text(item.status));
}
}
}
if (entry.$tree) {
entry.$tree.replaceWith($html);
if (item.$tree) {
item.$tree.replaceWith($html);
}
entry.$tree = $html;
item.$tree = $html;
return $html;
},
@ -114,9 +114,9 @@ modulejs.define('ext/tree', ['_', '$', 'core/settings', 'core/resource', 'core/e
createOnIndicatorClick = function () {
var $tree = $('#tree'),
slide = function (entry, $indicator, $content, down) {
slide = function (item, $indicator, $content, down) {
entry.isContentVisible = down;
item.isContentVisible = down;
$indicator.removeClass('open close').addClass(down ? 'open' : 'close');
$tree.scrollpanel('update', true);
$content[down ? 'slideDown' : 'slideUp'](function () {
@ -128,32 +128,32 @@ modulejs.define('ext/tree', ['_', '$', 'core/settings', 'core/resource', 'core/e
return function () {
var $indicator = $(this),
$entry = $indicator.closest('.entry'),
entry = $entry.data('entry'),
$content = $entry.find('> ul.content');
$item = $indicator.closest('.item'),
item = $item.data('item'),
$content = $item.find('> ul.content');
if ($indicator.hasClass('unknown')) {
entry.fetchContent(function (entry) {
item.fetchContent(function (item) {
entry.isContentVisible = false;
item.isContentVisible = false;
var $entry = update(entry),
$indicator = $entry.find('> .indicator'),
$content = $entry.find('> ul.content');
var $item = update(item),
$indicator = $item.find('> .indicator'),
$content = $item.find('> ul.content');
if (!$indicator.hasClass('none')) {
slide(entry, $indicator, $content, true);
slide(item, $indicator, $content, true);
}
});
} else if ($indicator.hasClass('open')) {
slide(entry, $indicator, $content, false);
slide(item, $indicator, $content, false);
} else if ($indicator.hasClass('close')) {
slide(entry, $indicator, $content, true);
slide(item, $indicator, $content, true);
}
};
},
@ -171,15 +171,15 @@ modulejs.define('ext/tree', ['_', '$', 'core/settings', 'core/resource', 'core/e
}
},
fetchTree = function (entry, callback) {
fetchTree = function (item, callback) {
entry.isContentVisible = true;
entry.fetchContent(function (entry) {
item.isContentVisible = true;
item.fetchContent(function (item) {
if (entry.parent) {
fetchTree(entry.parent, callback);
if (item.parent) {
fetchTree(item.parent, callback);
} else {
callback(entry);
callback(item);
}
});
},
@ -199,13 +199,13 @@ modulejs.define('ext/tree', ['_', '$', 'core/settings', 'core/resource', 'core/e
$tree.scrollpanel('update');
},
onContentChanged = function (entry) {
onContentChanged = function (item) {
while (entry.parent) {
entry = entry.parent;
while (item.parent) {
item = item.parent;
}
update(entry);
update(item);
adjustSpacing();
shiftTree(false, true);
},

View file

@ -1,5 +1,5 @@
modulejs.define('model/entry', ['_', 'core/types', 'core/event', 'core/settings', 'core/server', 'core/location'], function (_, types, event, settings, server, location) {
modulejs.define('model/item', ['_', 'core/types', 'core/event', 'core/settings', 'core/server', 'core/location'], function (_, types, event, settings, server, location) {
var reEndsWithSlash = /\/$/,
@ -39,11 +39,9 @@ modulejs.define('model/entry', ['_', 'core/types', 'core/event', 'core/settings'
// Cache
cache = {},
getEntry = function (absHref, time, size, status, isContentFetched) {
getItem = function (absHref, time, size, status, isContentFetched) {
absHref = location.forceEncoding(absHref);
@ -51,7 +49,7 @@ modulejs.define('model/entry', ['_', 'core/types', 'core/event', 'core/settings'
return null;
}
var self = cache[absHref] || new Entry(absHref);
var self = cache[absHref] || new Item(absHref);
if (_.isNumber(time)) {
self.time = time;
@ -69,7 +67,7 @@ modulejs.define('model/entry', ['_', 'core/types', 'core/event', 'core/settings'
return self;
},
removeEntry = function (absHref) {
removeItem = function (absHref) {
absHref = location.forceEncoding(absHref);
@ -80,16 +78,16 @@ modulejs.define('model/entry', ['_', 'core/types', 'core/event', 'core/settings'
if (self.parent) {
delete self.parent.content[self.absHref];
}
_.each(self.content, function (entry) {
_.each(self.content, function (item) {
removeEntry(entry.absHref);
removeItem(item.absHref);
});
}
},
fetchContent = function (absHref, callback) {
var self = getEntry(absHref);
var self = getItem(absHref);
if (!_.isFunction(callback)) {
callback = function () {};
@ -101,8 +99,8 @@ modulejs.define('model/entry', ['_', 'core/types', 'core/event', 'core/settings'
server.request({action: 'get', entries: true, entriesHref: self.absHref, entriesWhat: 1}, function (response) {
if (response.entries) {
_.each(response.entries, function (entry) {
getEntry(entry.absHref, entry.time, entry.size, entry.status, entry.content);
_.each(response.entries, function (item) {
getItem(item.absHref, item.time, item.size, item.status, item.content);
});
}
@ -113,9 +111,7 @@ modulejs.define('model/entry', ['_', 'core/types', 'core/event', 'core/settings'
// Entry
var Entry = function (absHref) {
var Item = function (absHref) {
var split = splitPath(absHref);
@ -131,7 +127,7 @@ modulejs.define('model/entry', ['_', 'core/types', 'core/event', 'core/settings'
this.content = {};
if (split.parent) {
this.parent = getEntry(split.parent);
this.parent = getItem(split.parent);
this.parent.content[this.absHref] = this;
if (_.keys(this.parent.content).length > 1) {
this.parent.isContentFetched = true;
@ -139,7 +135,7 @@ modulejs.define('model/entry', ['_', 'core/types', 'core/event', 'core/settings'
}
};
_.extend(Entry.prototype, {
_.extend(Item.prototype, {
isFolder: function () {
@ -158,7 +154,7 @@ modulejs.define('model/entry', ['_', 'core/types', 'core/event', 'core/settings'
isCurrentParentFolder: function () {
return this === getEntry(location.getAbsHref()).parent;
return this === getItem(location.getAbsHref()).parent;
},
isDomain: function () {
@ -188,12 +184,12 @@ modulejs.define('model/entry', ['_', 'core/types', 'core/event', 'core/settings'
getCrumb: function () {
var entry = this,
crumb = [entry];
var item = this,
crumb = [item];
while (entry.parent) {
entry = entry.parent;
crumb.unshift(entry);
while (item.parent) {
item = item.parent;
crumb.unshift(item);
}
return crumb;
@ -201,12 +197,12 @@ modulejs.define('model/entry', ['_', 'core/types', 'core/event', 'core/settings'
getSubfolders: function () {
return _.sortBy(_.filter(this.content, function (entry) {
return _.sortBy(_.filter(this.content, function (item) {
return entry.isFolder();
}), function (entry) {
return item.isFolder();
}), function (item) {
return entry.label.toLowerCase();
return item.label.toLowerCase();
});
},
@ -215,9 +211,9 @@ modulejs.define('model/entry', ['_', 'core/types', 'core/event', 'core/settings'
var folders = 0,
files = 0;
_.each(this.content, function (entry) {
_.each(this.content, function (item) {
if (entry.isFolder()) {
if (item.isFolder()) {
folders += 1;
} else {
files += 1;
@ -225,11 +221,11 @@ modulejs.define('model/entry', ['_', 'core/types', 'core/event', 'core/settings'
});
var depth = 0,
entry = this;
item = this;
while (entry.parent) {
while (item.parent) {
depth += 1;
entry = entry.parent;
item = item.parent;
}
return {
@ -241,7 +237,7 @@ modulejs.define('model/entry', ['_', 'core/types', 'core/event', 'core/settings'
});
return {
get: getEntry,
remove: removeEntry
get: getItem,
remove: removeItem
};
});

View file

@ -6,7 +6,7 @@ modulejs.define('view/items', ['_', '$', 'core/settings', 'core/resource', 'core
binaryPrefix: false
}, allsettings.view),
template = '<li class="entry">' +
itemTemplate = '<li class="item">' +
'<a>' +
'<span class="icon small"><img/></span>' +
'<span class="icon big"><img/></span>' +
@ -16,7 +16,7 @@ modulejs.define('view/items', ['_', '$', 'core/settings', 'core/resource', 'core
'</a>' +
'</li>',
hintTemplate = '<span class="hint"/>',
listTemplate = '<ul>' +
itemsTemplate = '<ul id="items">' +
'<li class="header">' +
'<a class="icon"/>' +
'<a class="label" href="#"><span class="l10n-name"/></a>' +
@ -27,14 +27,14 @@ modulejs.define('view/items', ['_', '$', 'core/settings', 'core/resource', 'core
emptyTemplate = '<div class="empty l10n-empty"/>',
contentTemplate = '<div id="content"><div id="extended" class="clearfix"/></div>',
// updates this single entry
update = function (entry, force) {
// updates this single item
update = function (item, force) {
if (!force && entry.$extended && entry.status && entry.$extended.data('status') === entry.status) {
return entry.$extended;
if (!force && item.$extended) {
return item.$extended;
}
var $html = $(template),
var $html = $(itemTemplate),
$a = $html.find('a'),
$imgSmall = $html.find('.icon.small img'),
$imgBig = $html.find('.icon.big img'),
@ -43,30 +43,29 @@ modulejs.define('view/items', ['_', '$', 'core/settings', 'core/resource', 'core
$size = $html.find('.size');
$html
.addClass(entry.isFolder() ? 'folder' : 'file')
.data('entry', entry)
.data('status', entry.status);
.addClass(item.isFolder() ? 'folder' : 'file')
.data('item', item);
location.setLink($a, entry);
location.setLink($a, item);
$imgSmall.attr('src', resource.icon(entry.type)).attr('alt', entry.type);
$imgBig.attr('src', resource.icon(entry.type, true)).attr('alt', entry.type);
$label.text(entry.label);
$date.data('time', entry.time).text(format.formatDate(entry.time));
$size.data('bytes', entry.size).text(format.formatSize(entry.size));
$imgSmall.attr('src', resource.icon(item.type)).attr('alt', item.type);
$imgBig.attr('src', resource.icon(item.type, true)).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 (entry.isFolder() && _.isNumber(entry.status)) {
if (entry.status === 200) {
if (item.isFolder() && _.isNumber(item.status)) {
if (item.status === 200) {
$html.addClass('page');
$imgSmall.attr('src', resource.icon('folder-page'));
$imgBig.attr('src', resource.icon('folder-page', true));
} else {
$html.addClass('error');
$label.append($(hintTemplate).text(' ' + entry.status + ' '));
$label.append($(hintTemplate).text(' ' + item.status + ' '));
}
}
if (entry.isCurrentParentFolder()) {
if (item.isCurrentParentFolder()) {
$imgSmall.attr('src', resource.icon('folder-parent'));
$imgBig.attr('src', resource.icon('folder-parent', true));
if (!settings.setParentFolderLabels) {
@ -75,41 +74,41 @@ modulejs.define('view/items', ['_', '$', 'core/settings', 'core/resource', 'core
$html.addClass('folder-parent');
}
if (entry.$extended) {
entry.$extended.replaceWith($html);
if (item.$extended) {
item.$extended.replaceWith($html);
}
entry.$extended = $html;
item.$extended = $html;
return $html;
},
onMouseenter = function () {
var entry = $(this).closest('.entry').data('entry');
event.pub('entry.mouseenter', entry);
var item = $(this).closest('.item').data('item');
event.pub('item.mouseenter', item);
},
onMouseleave = function () {
var entry = $(this).closest('.entry').data('entry');
event.pub('entry.mouseleave', entry);
var item = $(this).closest('.item').data('item');
event.pub('item.mouseleave', item);
},
onLocationChanged = function (item) {
var $extended = $('#extended'),
$ul = $extended.find('ul'),
$items = $('#items'),
$empty = $extended.find('.empty');
$ul.find('.entry').remove();
$items.find('.item').remove();
if (item.parent) {
$ul.append(update(item.parent));
$items.append(update(item.parent, true));
}
_.each(item.content, function (e) {
$ul.append(update(e));
$items.append(update(e, true));
});
if (item.isEmpty()) {
@ -122,12 +121,12 @@ modulejs.define('view/items', ['_', '$', 'core/settings', 'core/resource', 'core
onLocationRefreshed = function (item, added, removed) {
var $extended = $('#extended'),
$ul = $extended.find('ul'),
$items = $('#items'),
$empty = $extended.find('.empty');
_.each(added, function (item) {
update(item, true).hide().appendTo($ul).fadeIn(400);
update(item, true).hide().appendTo($items).fadeIn(400);
});
_.each(removed, function (item) {
@ -148,16 +147,18 @@ modulejs.define('view/items', ['_', '$', 'core/settings', 'core/resource', 'core
var $content = $(contentTemplate),
$extended = $content.find('#extended'),
$ul = $(listTemplate),
$items = $(itemsTemplate),
$emtpy = $(emptyTemplate).hide();
format.setDefaultMetric(settings.binaryPrefix);
$extended
.append($ul)
.append($emtpy)
.on('mouseenter', '.entry a', onMouseenter)
.on('mouseleave', '.entry a', onMouseleave);
.append($items)
.append($emtpy);
$items
.on('mouseenter', '.item a', onMouseenter)
.on('mouseleave', '.item a', onMouseleave);
event.sub('location.changed', onLocationChanged);
event.sub('location.refreshed', onLocationRefreshed);

View file

@ -20,7 +20,7 @@ modulejs.define('view/viewmode', ['_', '$', 'core/settings', 'core/resource', 'c
var contentWidth = $('#content').width(),
$extended = $('#extended'),
itemWidth = ($extended.hasClass('view-icons') || $extended.hasClass('view-grid')) ? ($extended.find('.entry').eq(0).width() || 1) : 1;
itemWidth = ($extended.hasClass('view-icons') || $extended.hasClass('view-grid')) ? ($extended.find('.item').eq(0).width() || 1) : 1;
$extended.width(Math.floor(contentWidth / itemWidth) * itemWidth);
},

View file

@ -55,7 +55,7 @@ Options
- interval: number, update interval in milliseconds, at least 1000
*/
"autorefresh": {
"enabled": true,
"enabled": false,
"interval": 5000
},