From 1dea89befbb54742528abd4f6d01c69c77aaaa25 Mon Sep 17 00:00:00 2001 From: Lars Jung Date: Sat, 27 Oct 2012 03:50:35 +0200 Subject: [PATCH] Semantic changes. --- .../client/css/inc/extended-details.less | 4 +- src/_h5ai/client/css/inc/extended-grid.less | 2 +- src/_h5ai/client/css/inc/extended-icons.less | 2 +- src/_h5ai/client/css/inc/extended-list.less | 4 +- src/_h5ai/client/css/inc/extended.less | 2 +- src/_h5ai/client/css/inc/responsive.less | 4 +- src/_h5ai/client/js/inc/core/location.js | 16 ++-- src/_h5ai/client/js/inc/ext/crumb.js | 33 ++++--- src/_h5ai/client/js/inc/ext/delete.js | 4 +- src/_h5ai/client/js/inc/ext/download.js | 4 +- src/_h5ai/client/js/inc/ext/filter.js | 4 +- src/_h5ai/client/js/inc/ext/l10n.js | 2 +- src/_h5ai/client/js/inc/ext/preview-img.js | 18 ++-- src/_h5ai/client/js/inc/ext/preview-txt.js | 18 ++-- src/_h5ai/client/js/inc/ext/qrcode.js | 16 ++-- src/_h5ai/client/js/inc/ext/select.js | 20 ++-- src/_h5ai/client/js/inc/ext/sort.js | 34 +++---- src/_h5ai/client/js/inc/ext/statusbar.js | 16 ++-- src/_h5ai/client/js/inc/ext/thumbnails.js | 42 +++++---- src/_h5ai/client/js/inc/ext/tree.js | 92 +++++++++---------- .../client/js/inc/model/{entry.js => item.js} | 62 ++++++------- src/_h5ai/client/js/inc/view/items.js | 77 ++++++++-------- src/_h5ai/client/js/inc/view/viewmode.js | 2 +- src/_h5ai/conf/options.json | 2 +- 24 files changed, 243 insertions(+), 237 deletions(-) rename src/_h5ai/client/js/inc/model/{entry.js => item.js} (73%) diff --git a/src/_h5ai/client/css/inc/extended-details.less b/src/_h5ai/client/css/inc/extended-details.less index 74de0518..1641eddf 100644 --- a/src/_h5ai/client/css/inc/extended-details.less +++ b/src/_h5ai/client/css/inc/extended-details.less @@ -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; diff --git a/src/_h5ai/client/css/inc/extended-grid.less b/src/_h5ai/client/css/inc/extended-grid.less index fceadced..3cb979e2 100644 --- a/src/_h5ai/client/css/inc/extended-grid.less +++ b/src/_h5ai/client/css/inc/extended-grid.less @@ -3,7 +3,7 @@ li { - &.entry { + &.item { float: left; a, a:active, a:visited { diff --git a/src/_h5ai/client/css/inc/extended-icons.less b/src/_h5ai/client/css/inc/extended-icons.less index 5581b284..846dd117 100644 --- a/src/_h5ai/client/css/inc/extended-icons.less +++ b/src/_h5ai/client/css/inc/extended-icons.less @@ -4,7 +4,7 @@ li { text-align: center; - &.entry { + &.item { float: left; a, a:active, a:visited { diff --git a/src/_h5ai/client/css/inc/extended-list.less b/src/_h5ai/client/css/inc/extended-list.less index d71492c5..68920925 100644 --- a/src/_h5ai/client/css/inc/extended-list.less +++ b/src/_h5ai/client/css/inc/extended-list.less @@ -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; diff --git a/src/_h5ai/client/css/inc/extended.less b/src/_h5ai/client/css/inc/extended.less index 2bc1edba..5e1e7984 100644 --- a/src/_h5ai/client/css/inc/extended.less +++ b/src/_h5ai/client/css/inc/extended.less @@ -66,7 +66,7 @@ } } - &.entry { + &.item { a, a:active, a:visited { display: block; diff --git a/src/_h5ai/client/css/inc/responsive.less b/src/_h5ai/client/css/inc/responsive.less index 4acb1a7f..fb873a38 100644 --- a/src/_h5ai/client/css/inc/responsive.less +++ b/src/_h5ai/client/css/inc/responsive.less @@ -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; } } diff --git a/src/_h5ai/client/js/inc/core/location.js b/src/_h5ai/client/js/inc/core/location.js index 886354ff..7b80d34f 100644 --- a/src/_h5ai/client/js/inc/core/location.js +++ b/src/_h5ai/client/js/inc/core/location.js @@ -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); } }); }, diff --git a/src/_h5ai/client/js/inc/ext/crumb.js b/src/_h5ai/client/js/inc/ext/crumb.js index 43b906f1..aaabc188 100644 --- a/src/_h5ai/client/js/inc/ext/crumb.js +++ b/src/_h5ai/client/js/inc/ext/crumb.js @@ -14,49 +14,48 @@ modulejs.define('ext/crumb', ['_', '$', 'core/settings', 'core/resource', 'core/ pageHintTemplate = 'has index page', statusHintTemplate = '', - 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; }, diff --git a/src/_h5ai/client/js/inc/ext/delete.js b/src/_h5ai/client/js/inc/ext/delete.js index 5e0d5159..6c805d9c 100644 --- a/src/_h5ai/client/js/inc/ext/delete.js +++ b/src/_h5ai/client/js/inc/ext/delete.js @@ -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 { diff --git a/src/_h5ai/client/js/inc/ext/download.js b/src/_h5ai/client/js/inc/ext/download.js index bd9c43cd..63f3c98f 100644 --- a/src/_h5ai/client/js/inc/ext/download.js +++ b/src/_h5ai/client/js/inc/ext/download.js @@ -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 { diff --git a/src/_h5ai/client/js/inc/ext/filter.js b/src/_h5ai/client/js/inc/ext/filter.js index 3d2ce0f6..5ca92e73 100644 --- a/src/_h5ai/client/js/inc/ext/filter.js +++ b/src/_h5ai/client/js/inc/ext/filter.js @@ -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) { diff --git a/src/_h5ai/client/js/inc/ext/l10n.js b/src/_h5ai/client/js/inc/ext/l10n.js index 8095f872..b27d145d 100644 --- a/src/_h5ai/client/js/inc/ext/l10n.js +++ b/src/_h5ai/client/js/inc/ext/l10n.js @@ -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); diff --git a/src/_h5ai/client/js/inc/ext/preview-img.js b/src/_h5ai/client/js/inc/ext/preview-img.js index 5ab79e02..63b0d212 100644 --- a/src/_h5ai/client/js/inc/ext/preview-img.js +++ b/src/_h5ai/client/js/inc/ext/preview-img.js @@ -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 () { diff --git a/src/_h5ai/client/js/inc/ext/preview-txt.js b/src/_h5ai/client/js/inc/ext/preview-txt.js index 7efc3c96..462db8c4 100644 --- a/src/_h5ai/client/js/inc/ext/preview-txt.js +++ b/src/_h5ai/client/js/inc/ext/preview-txt.js @@ -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 () { diff --git a/src/_h5ai/client/js/inc/ext/qrcode.js b/src/_h5ai/client/js/inc/ext/qrcode.js index 65e807f7..a627cb2b 100644 --- a/src/_h5ai/client/js/inc/ext/qrcode.js +++ b/src/_h5ai/client/js/inc/ext/qrcode.js @@ -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(); diff --git a/src/_h5ai/client/js/inc/ext/select.js b/src/_h5ai/client/js/inc/ext/select.js index 0b2f5c3f..d5a180bd 100644 --- a/src/_h5ai/client/js/inc/ext/select.js +++ b/src/_h5ai/client/js/inc/ext/select.js @@ -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(); } diff --git a/src/_h5ai/client/js/inc/ext/sort.js b/src/_h5ai/client/js/inc/ext/sort.js index 964528d5..485497c3 100644 --- a/src/_h5ai/client/js/inc/ext/sort.js +++ b/src/_h5ai/client/js/inc/ext/sort.js @@ -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 = $('ascending'), $descending = $('descending'), - $header = $('#extended li.header'), + $header = $('#items li.header'), $label = $header.find('a.label'), $date = $header.find('a.date'), $size = $header.find('a.size'); diff --git a/src/_h5ai/client/js/inc/ext/statusbar.js b/src/_h5ai/client/js/inc/ext/statusbar.js index 7956e932..10cc93a7 100644 --- a/src/_h5ai/client/js/inc/ext/statusbar.js +++ b/src/_h5ai/client/js/inc/ext/statusbar.js @@ -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 = $('').append(entry.label); + var $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(); }); diff --git a/src/_h5ai/client/js/inc/ext/thumbnails.js b/src/_h5ai/client/js/inc/ext/thumbnails.js index fd2d8aff..1609a9a4 100644 --- a/src/_h5ai/client/js/inc/ext/thumbnails.js +++ b/src/_h5ai/client/js/inc/ext/thumbnails.js @@ -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 () { diff --git a/src/_h5ai/client/js/inc/ext/tree.js b/src/_h5ai/client/js/inc/ext/tree.js index a42787dc..bdd62b3c 100644 --- a/src/_h5ai/client/js/inc/ext/tree.js +++ b/src/_h5ai/client/js/inc/ext/tree.js @@ -7,7 +7,7 @@ modulejs.define('ext/tree', ['_', '$', 'core/settings', 'core/resource', 'core/e maxSubfolders: 50 }, allsettings.tree), - template = '
' + + template = '
' + '' + '' + '' + @@ -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) { $('
  • … ' + (subfolders.length - settings.maxSubfolders) + ' more subfolders
  • ').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); }, diff --git a/src/_h5ai/client/js/inc/model/entry.js b/src/_h5ai/client/js/inc/model/item.js similarity index 73% rename from src/_h5ai/client/js/inc/model/entry.js rename to src/_h5ai/client/js/inc/model/item.js index fbb6248e..b8be6e84 100644 --- a/src/_h5ai/client/js/inc/model/entry.js +++ b/src/_h5ai/client/js/inc/model/item.js @@ -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 }; }); diff --git a/src/_h5ai/client/js/inc/view/items.js b/src/_h5ai/client/js/inc/view/items.js index 5070538e..5e3a99de 100644 --- a/src/_h5ai/client/js/inc/view/items.js +++ b/src/_h5ai/client/js/inc/view/items.js @@ -6,7 +6,7 @@ modulejs.define('view/items', ['_', '$', 'core/settings', 'core/resource', 'core binaryPrefix: false }, allsettings.view), - template = '
  • ' + + itemTemplate = '
  • ' + '' + '' + '' + @@ -16,7 +16,7 @@ modulejs.define('view/items', ['_', '$', 'core/settings', 'core/resource', 'core '' + '
  • ', hintTemplate = '', - listTemplate = '
      ' + + itemsTemplate = '
        ' + '
      • ' + '' + '' + @@ -27,14 +27,14 @@ modulejs.define('view/items', ['_', '$', 'core/settings', 'core/resource', 'core emptyTemplate = '
        ', contentTemplate = '
        ', - // 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); diff --git a/src/_h5ai/client/js/inc/view/viewmode.js b/src/_h5ai/client/js/inc/view/viewmode.js index 559b773c..f1eeebad 100644 --- a/src/_h5ai/client/js/inc/view/viewmode.js +++ b/src/_h5ai/client/js/inc/view/viewmode.js @@ -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); }, diff --git a/src/_h5ai/conf/options.json b/src/_h5ai/conf/options.json index bbf9498f..3dcea873 100644 --- a/src/_h5ai/conf/options.json +++ b/src/_h5ai/conf/options.json @@ -55,7 +55,7 @@ Options - interval: number, update interval in milliseconds, at least 1000 */ "autorefresh": { - "enabled": true, + "enabled": false, "interval": 5000 },