mirror of
https://github.com/lrsjng/h5ai.git
synced 2025-05-29 22:45:14 -04:00
Semantic changes.
This commit is contained in:
parent
9163996ac2
commit
1dea89befb
24 changed files with 243 additions and 237 deletions
|
@ -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);
|
||||
},
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue