mirror of
https://github.com/lrsjng/h5ai.git
synced 2025-05-25 04:24:45 -04:00
Reorganize file structure.
This commit is contained in:
parent
74745a8603
commit
c8eff2d313
206 changed files with 70 additions and 69 deletions
|
@ -1,76 +0,0 @@
|
|||
modulejs.define('ext/download', ['_', '$', 'core/event', 'core/location', 'core/resource', 'core/server', 'core/settings'], function (_, $, event, location, resource, server, allsettings) {
|
||||
|
||||
var settings = _.extend({
|
||||
enabled: false,
|
||||
type: 'php-tar',
|
||||
packageName: 'package',
|
||||
alwaysVisible: false
|
||||
}, allsettings.download);
|
||||
var template =
|
||||
'<div id="download" class="tool">' +
|
||||
'<img src="' + resource.image('download') + '" alt="download"/>' +
|
||||
'</div>';
|
||||
var selectedItems = [];
|
||||
var $download;
|
||||
|
||||
|
||||
function onSelection(items) {
|
||||
|
||||
selectedItems = items.slice(0);
|
||||
if (selectedItems.length) {
|
||||
$download.show();
|
||||
} else if (!settings.alwaysVisible) {
|
||||
$download.hide();
|
||||
}
|
||||
}
|
||||
|
||||
function onClick() {
|
||||
|
||||
var type = settings.type;
|
||||
var name = settings.packageName;
|
||||
var extension = (type === 'shell-zip') ? 'zip' : 'tar';
|
||||
|
||||
if (!name) {
|
||||
if (selectedItems.length === 1) {
|
||||
name = selectedItems[0].label;
|
||||
} else {
|
||||
name = location.getItem().label;
|
||||
}
|
||||
}
|
||||
|
||||
var query = {
|
||||
action: 'download',
|
||||
as: name + '.' + extension,
|
||||
type: type,
|
||||
baseHref: location.getAbsHref()
|
||||
};
|
||||
|
||||
_.each(selectedItems, function (item, idx) {
|
||||
|
||||
query['hrefs[' + idx + ']'] = item.absHref;
|
||||
});
|
||||
|
||||
server.formRequest(query);
|
||||
}
|
||||
|
||||
function init() {
|
||||
|
||||
if (!settings.enabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
$download = $(template)
|
||||
.hide()
|
||||
.appendTo('#toolbar')
|
||||
.on('click', onClick);
|
||||
|
||||
if (settings.alwaysVisible) {
|
||||
$download.show();
|
||||
}
|
||||
|
||||
event.sub('selection', onSelection);
|
||||
}
|
||||
|
||||
|
||||
init();
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue