Begin to move all src javascript to es6. Add search/filter ignore case option.

This commit is contained in:
Lars Jung 2016-06-02 23:16:23 +02:00
parent f37e8e7b89
commit 7ec2bdf16a
58 changed files with 3546 additions and 3420 deletions

View file

@ -1,71 +1,76 @@
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;
const {jQuery: jq, _: lo} = require('../win');
const event = require('../core/event');
const location = require('../core/location');
const resource = require('../core/resource');
const server = require('../core/server');
const allsettings = require('../core/settings');
const settings = lo.extend({
enabled: false,
type: 'php-tar',
packageName: 'package',
alwaysVisible: false
}, allsettings.download);
const template =
`<div id="download" class="tool">
<img src="${resource.image('download')}" alt="download"/>
</div>`;
let selectedItems = [];
let $download;
function onSelection(items) {
selectedItems = items.slice(0);
if (selectedItems.length) {
$download.show();
} else if (!settings.alwaysVisible) {
$download.hide();
function onSelection(items) {
selectedItems = items.slice(0);
if (selectedItems.length) {
$download.show();
} else if (!settings.alwaysVisible) {
$download.hide();
}
}
function onClick() {
const type = settings.type;
let name = settings.packageName;
const extension = type === 'shell-zip' ? 'zip' : 'tar';
if (!name) {
if (selectedItems.length === 1) {
name = selectedItems[0].label;
} else {
name = location.getItem().label;
}
}
function onClick() {
var type = settings.type;
var name = settings.packageName;
var extension = type === 'shell-zip' ? 'zip' : 'tar';
const query = {
action: 'download',
as: name + '.' + extension,
type,
baseHref: location.getAbsHref()
};
if (!name) {
if (selectedItems.length === 1) {
name = selectedItems[0].label;
} else {
name = location.getItem().label;
}
}
lo.each(selectedItems, (item, idx) => {
query['hrefs[' + idx + ']'] = item.absHref;
});
var query = {
action: 'download',
as: name + '.' + extension,
type: type,
baseHref: location.getAbsHref()
};
server.formRequest(query);
}
_.each(selectedItems, function (item, idx) {
query['hrefs[' + idx + ']'] = item.absHref;
});
server.formRequest(query);
function init() {
if (!settings.enabled) {
return;
}
function init() {
if (!settings.enabled) {
return;
}
$download = jq(template)
.hide()
.appendTo('#toolbar')
.on('click', onClick);
$download = $(template)
.hide()
.appendTo('#toolbar')
.on('click', onClick);
if (settings.alwaysVisible) {
$download.show();
}
event.sub('selection', onSelection);
if (settings.alwaysVisible) {
$download.show();
}
event.sub('selection', onSelection);
}
init();
});
init();