mirror of
https://github.com/lrsjng/h5ai.git
synced 2025-03-22 13:30:05 +01:00
More changes to enable smart browsing.
This commit is contained in:
parent
499013f4fb
commit
e956a49680
@ -1,5 +0,0 @@
|
||||
|
||||
modulejs.define('core/entry', ['core/location'], function (location) {
|
||||
|
||||
return location.getItem();
|
||||
});
|
@ -76,7 +76,7 @@ modulejs.define('core/location', ['_', 'modernizr', 'core/settings', 'core/event
|
||||
newAbsHref = encodedHref(newAbsHref);
|
||||
if (absHref !== newAbsHref) {
|
||||
absHref = newAbsHref;
|
||||
event.pub('location.changed', absHref);
|
||||
event.pub('location.changed', getItem());
|
||||
|
||||
notify.set('loading...');
|
||||
modulejs.require('core/refresh')(function () { notify.set(); });
|
||||
|
@ -105,12 +105,7 @@ modulejs.define('ext/crumb', ['_', '$', 'core/settings', 'core/resource', 'core/
|
||||
// event.sub('entry.removed', onContentChanged);
|
||||
event.sub('entry.changed', onContentChanged);
|
||||
|
||||
event.sub('location.changed', function () {
|
||||
|
||||
onLocationChanged(location.getItem());
|
||||
});
|
||||
|
||||
onLocationChanged(location.getItem());
|
||||
event.sub('location.changed', onLocationChanged);
|
||||
};
|
||||
|
||||
init();
|
||||
|
@ -34,8 +34,6 @@ modulejs.define('ext/custom', ['_', '$', 'core/settings', 'core/server', 'core/e
|
||||
$('<div id="content-footer"/>').hide().appendTo('#content');
|
||||
|
||||
event.sub('location.changed', onLocationChanged);
|
||||
|
||||
onLocationChanged();
|
||||
};
|
||||
|
||||
init();
|
||||
|
@ -1,5 +1,5 @@
|
||||
|
||||
modulejs.define('ext/download', ['_', '$', 'core/settings', 'core/resource', 'core/event', 'core/server', 'core/entry'], function (_, $, allsettings, resource, event, server, entry) {
|
||||
modulejs.define('ext/download', ['_', '$', 'core/settings', 'core/resource', 'core/event', 'core/server', 'core/location'], function (_, $, allsettings, resource, event, server, location) {
|
||||
|
||||
var settings = _.extend({
|
||||
enabled: false,
|
||||
@ -36,7 +36,7 @@ modulejs.define('ext/download', ['_', '$', 'core/settings', 'core/resource', 'co
|
||||
if (json && json.code === 0) {
|
||||
setTimeout(function () { // wait here so the img above can be updated in time
|
||||
|
||||
window.location = '?action=getArchive&id=' + json.id + '&as=' + (settings.packageName || entry.label) + '.' + settings.format;
|
||||
window.location = '?action=getArchive&id=' + json.id + '&as=' + (settings.packageName || location.getItem().label) + '.' + settings.format;
|
||||
}, 200);
|
||||
} else {
|
||||
failed();
|
||||
|
@ -1,5 +1,5 @@
|
||||
|
||||
modulejs.define('ext/dropbox', ['_', '$', 'core/settings', 'core/entry', 'core/refresh', 'core/server'], function (_, $, allsettings, entry, refresh, server) {
|
||||
modulejs.define('ext/dropbox', ['_', '$', 'core/settings', 'core/location', 'core/refresh', 'core/server'], function (_, $, allsettings, location, refresh, server) {
|
||||
|
||||
var settings = _.extend({
|
||||
enabled: false,
|
||||
@ -50,7 +50,7 @@ modulejs.define('ext/dropbox', ['_', '$', 'core/settings', 'core/entry', 'core/r
|
||||
url: server.api,
|
||||
data: {
|
||||
action: 'upload',
|
||||
href: entry.absHref
|
||||
href: location.getAbsHref()
|
||||
},
|
||||
|
||||
docEnter: function () {
|
||||
|
@ -1,5 +1,5 @@
|
||||
|
||||
modulejs.define('ext/preview-img', ['_', '$', 'core/settings', 'core/resource', 'core/store', 'core/event', 'core/entry'], function (_, $, allsettings, resource, store, event, entry) {
|
||||
modulejs.define('ext/preview-img', ['_', '$', 'core/settings', 'core/resource', 'core/store', 'core/event', 'core/location'], function (_, $, allsettings, resource, store, event, location) {
|
||||
|
||||
var settings = _.extend({
|
||||
enabled: false,
|
||||
@ -219,14 +219,17 @@ modulejs.define('ext/preview-img', ['_', '$', 'core/settings', 'core/resource',
|
||||
}
|
||||
},
|
||||
|
||||
init = function (entry) {
|
||||
onLocationChanged = function (item) {
|
||||
|
||||
_.each(item.content, initEntry);
|
||||
},
|
||||
|
||||
init = function () {
|
||||
|
||||
if (!settings.enabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
_.each(entry.content, initEntry);
|
||||
|
||||
$(template).appendTo('body');
|
||||
$('#pv-img-bar-prev, #pv-img-prev').on('click', onPrevious);
|
||||
$('#pv-img-bar-next, #pv-img-next').on('click', onNext);
|
||||
@ -276,10 +279,11 @@ modulejs.define('ext/preview-img', ['_', '$', 'core/settings', 'core/resource',
|
||||
event.stopImmediatePropagation();
|
||||
});
|
||||
|
||||
event.sub('location.changed', onLocationChanged);
|
||||
event.sub('entry.created', initEntry);
|
||||
|
||||
$(window).on('resize load', adjustSize);
|
||||
};
|
||||
|
||||
init(entry);
|
||||
init();
|
||||
});
|
||||
|
@ -1,5 +1,5 @@
|
||||
|
||||
modulejs.define('ext/preview-txt', ['_', '$', 'core/settings', 'core/resource', 'core/store', 'core/event', 'core/entry'], function (_, $, allsettings, resource, store, event, entry) {
|
||||
modulejs.define('ext/preview-txt', ['_', '$', 'core/settings', 'core/resource', 'core/store', 'core/event', 'core/location'], function (_, $, allsettings, resource, store, event, location) {
|
||||
|
||||
var settings = _.extend({
|
||||
enabled: false,
|
||||
@ -224,14 +224,17 @@ modulejs.define('ext/preview-txt', ['_', '$', 'core/settings', 'core/resource',
|
||||
}
|
||||
},
|
||||
|
||||
init = function (entry) {
|
||||
onLocationChanged = function (item) {
|
||||
|
||||
_.each(item.content, initEntry);
|
||||
},
|
||||
|
||||
init = function () {
|
||||
|
||||
if (!settings.enabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
_.each(entry.content, initEntry);
|
||||
|
||||
$(template).appendTo('body');
|
||||
$('#pv-txt-bar-prev').on('click', onPrevious);
|
||||
$('#pv-txt-bar-next').on('click', onNext);
|
||||
@ -253,10 +256,11 @@ modulejs.define('ext/preview-txt', ['_', '$', 'core/settings', 'core/resource',
|
||||
event.stopImmediatePropagation();
|
||||
});
|
||||
|
||||
event.sub('location.changed', onLocationChanged);
|
||||
event.sub('entry.created', initEntry);
|
||||
|
||||
$(window).on('resize load', adjustSize);
|
||||
};
|
||||
|
||||
init(entry);
|
||||
init();
|
||||
});
|
||||
|
@ -1,5 +1,5 @@
|
||||
|
||||
modulejs.define('ext/statusbar', ['_', '$', 'core/settings', 'core/format', 'core/event', 'core/entry'], function (_, $, allsettings, format, event, entry) {
|
||||
modulejs.define('ext/statusbar', ['_', '$', 'core/settings', 'core/format', 'core/event', 'core/location'], function (_, $, allsettings, format, event, location) {
|
||||
|
||||
var settings = _.extend({
|
||||
enabled: false
|
||||
@ -29,7 +29,7 @@ modulejs.define('ext/statusbar', ['_', '$', 'core/settings', 'core/format', 'cor
|
||||
}
|
||||
},
|
||||
|
||||
init = function (entry) {
|
||||
init = function () {
|
||||
|
||||
if (!settings.enabled) {
|
||||
return;
|
||||
@ -42,25 +42,28 @@ modulejs.define('ext/statusbar', ['_', '$', 'core/settings', 'core/format', 'cor
|
||||
$statusDefault = $statusbar.find('.status.default');
|
||||
$statusDynamic = $statusbar.find('.status.dynamic');
|
||||
|
||||
var stats = entry.getStats();
|
||||
$folderTotal.text(stats.folders);
|
||||
$fileTotal.text(stats.files);
|
||||
event.sub('location.changed', function (item) {
|
||||
|
||||
update();
|
||||
var stats = item.getStats();
|
||||
$folderTotal.text(stats.folders);
|
||||
$fileTotal.text(stats.files);
|
||||
|
||||
update();
|
||||
});
|
||||
|
||||
event.sub('statusbar', update);
|
||||
$('#bottombar > .center').append($statusbar);
|
||||
|
||||
event.sub('entry.created', function () {
|
||||
|
||||
var stats = entry.getStats();
|
||||
var stats = location.getItem().getStats();
|
||||
$folderTotal.text(stats.folders);
|
||||
$fileTotal.text(stats.files);
|
||||
});
|
||||
|
||||
event.sub('entry.removed', function () {
|
||||
|
||||
var stats = entry.getStats();
|
||||
var stats = location.getItem().getStats();
|
||||
$folderTotal.text(stats.folders);
|
||||
$fileTotal.text(stats.files);
|
||||
});
|
||||
@ -89,5 +92,5 @@ modulejs.define('ext/statusbar', ['_', '$', 'core/settings', 'core/format', 'cor
|
||||
});
|
||||
};
|
||||
|
||||
init(entry);
|
||||
init();
|
||||
});
|
||||
|
@ -1,5 +1,5 @@
|
||||
|
||||
modulejs.define('ext/thumbnails', ['_', 'core/settings', 'core/entry', 'core/event', 'core/server'], function (_, allsettings, entry, event, server) {
|
||||
modulejs.define('ext/thumbnails', ['_', 'core/settings', 'core/event', 'core/server'], function (_, allsettings, event, server) {
|
||||
|
||||
var settings = _.extend({
|
||||
enabled: false,
|
||||
@ -56,22 +56,26 @@ modulejs.define('ext/thumbnails', ['_', 'core/settings', 'core/entry', 'core/eve
|
||||
}
|
||||
},
|
||||
|
||||
init = function (entry) {
|
||||
onLocationChanged = function (item) {
|
||||
|
||||
setTimeout(function () {
|
||||
|
||||
_.each(item.content, checkEntry);
|
||||
}, settings.delay);
|
||||
},
|
||||
|
||||
init = function () {
|
||||
|
||||
if (!settings.enabled || !server.api) {
|
||||
return;
|
||||
}
|
||||
|
||||
setTimeout(function () {
|
||||
|
||||
_.each(entry.content, checkEntry);
|
||||
}, settings.delay);
|
||||
|
||||
event.sub('location.changed', onLocationChanged);
|
||||
event.sub('entry.created', function (entry) {
|
||||
|
||||
checkEntry(entry);
|
||||
});
|
||||
};
|
||||
|
||||
init(entry);
|
||||
init();
|
||||
});
|
||||
|
@ -1,17 +1,13 @@
|
||||
|
||||
modulejs.define('ext/title', ['_', 'core/settings', 'core/entry'], function (_, allsettings, entry) {
|
||||
modulejs.define('ext/title', ['_', 'core/settings', 'core/event'], function (_, allsettings, event) {
|
||||
|
||||
var settings = _.extend({
|
||||
enabled: false
|
||||
}, allsettings.title),
|
||||
|
||||
init = function (entry) {
|
||||
onLocationChanged = function (item) {
|
||||
|
||||
if (!settings.enabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
var labels = _.pluck(entry.getCrumb(), 'label'),
|
||||
var labels = _.pluck(item.getCrumb(), 'label'),
|
||||
title = labels.join(' > ');
|
||||
|
||||
if (labels.length > 1) {
|
||||
@ -19,7 +15,16 @@ modulejs.define('ext/title', ['_', 'core/settings', 'core/entry'], function (_,
|
||||
}
|
||||
|
||||
document.title = title;
|
||||
},
|
||||
|
||||
init = function () {
|
||||
|
||||
if (!settings.enabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
event.sub('location.changed', onLocationChanged);
|
||||
};
|
||||
|
||||
init(entry);
|
||||
init();
|
||||
});
|
||||
|
@ -1,5 +1,5 @@
|
||||
|
||||
modulejs.define('ext/tree', ['_', '$', 'core/settings', 'core/resource', 'core/event', 'core/entry'], function (_, $, allsettings, resource, event, entry) {
|
||||
modulejs.define('ext/tree', ['_', '$', 'core/settings', 'core/resource', 'core/event', 'core/location'], function (_, $, allsettings, resource, event, location) {
|
||||
|
||||
var settings = _.extend({
|
||||
enabled: false,
|
||||
@ -34,7 +34,7 @@ modulejs.define('ext/tree', ['_', '$', 'core/settings', 'core/resource', 'core/e
|
||||
.data('entry', entry)
|
||||
.data('status', entry.status);
|
||||
|
||||
$a.attr('href', entry.absHref);
|
||||
location.setLink($a, entry);
|
||||
$img.attr('src', resource.icon(entry.type));
|
||||
$label.text(entry.label);
|
||||
|
||||
@ -207,10 +207,24 @@ modulejs.define('ext/tree', ['_', '$', 'core/settings', 'core/resource', 'core/e
|
||||
}
|
||||
|
||||
update(entry);
|
||||
adjustSpacing();
|
||||
shiftTree(false, true);
|
||||
},
|
||||
|
||||
onLocationChanged = function (item) {
|
||||
|
||||
fetchTree(item, function (root) {
|
||||
|
||||
$('#tree')
|
||||
.find('.sp-container').append(update(root)).end()
|
||||
.show();
|
||||
adjustSpacing();
|
||||
shiftTree(false, true);
|
||||
});
|
||||
},
|
||||
|
||||
// creates the complete tree from entry down to the root
|
||||
init = function (entry) {
|
||||
init = function () {
|
||||
|
||||
if (!settings.enabled) {
|
||||
return;
|
||||
@ -229,23 +243,15 @@ modulejs.define('ext/tree', ['_', '$', 'core/settings', 'core/resource', 'core/e
|
||||
shiftTree();
|
||||
});
|
||||
|
||||
fetchTree(entry, function (root) {
|
||||
|
||||
$tree
|
||||
.find('.sp-container').append(update(root)).end()
|
||||
.show();
|
||||
|
||||
adjustSpacing();
|
||||
shiftTree(false, true);
|
||||
});
|
||||
|
||||
event.sub('ready', adjustSpacing);
|
||||
event.sub('location.changed', onLocationChanged);
|
||||
|
||||
// strong negative performance impact in aai mode
|
||||
// event.sub('entry.changed', onContentChanged);
|
||||
// event.sub('entry.created', onContentChanged);
|
||||
// event.sub('entry.removed', onContentChanged);
|
||||
|
||||
event.sub('ready', adjustSpacing);
|
||||
|
||||
$(window).on('resize', function () {
|
||||
|
||||
adjustSpacing();
|
||||
@ -253,5 +259,5 @@ modulejs.define('ext/tree', ['_', '$', 'core/settings', 'core/resource', 'core/e
|
||||
});
|
||||
};
|
||||
|
||||
init(entry);
|
||||
init();
|
||||
});
|
||||
|
@ -7,8 +7,6 @@ modulejs.define('main', ['_', 'core/event'], function (_, event) {
|
||||
modulejs.require('view/spacing');
|
||||
modulejs.require('view/viewmode');
|
||||
|
||||
modulejs.require('core/location').setLocation(document.location.href, true);
|
||||
|
||||
event.pub('beforeExt');
|
||||
|
||||
_.each(modulejs.state(), function (state, id) {
|
||||
@ -18,5 +16,7 @@ modulejs.define('main', ['_', 'core/event'], function (_, event) {
|
||||
}
|
||||
});
|
||||
|
||||
modulejs.require('core/location').setLocation(document.location.href, true);
|
||||
|
||||
event.pub('ready');
|
||||
});
|
||||
|
@ -163,10 +163,7 @@ modulejs.define('view/items', ['_', '$', 'core/settings', 'core/resource', 'core
|
||||
}
|
||||
});
|
||||
|
||||
event.sub('location.changed', function () {
|
||||
|
||||
onLocationChanged(location.getItem());
|
||||
});
|
||||
event.sub('location.changed', onLocationChanged);
|
||||
|
||||
$content.appendTo('body');
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user