diff --git a/src/_h5ai/client/js/inc/core/server.js b/src/_h5ai/client/js/inc/core/server.js index 3ca818f6..528c943c 100644 --- a/src/_h5ai/client/js/inc/core/server.js +++ b/src/_h5ai/client/js/inc/core/server.js @@ -23,6 +23,22 @@ modulejs.define('core/server', ['$', '_', 'config', 'core/location'], function ( } else { callback(); } + }, + + formRequest: function (data) { + + var $form = $('
') + .attr('action', location.getAbsHref()); + + _.each(data, function (val, key) { + + $('') + .attr('name', key) + .attr('value', val) + .appendTo($form); + }); + + $form.appendTo('body').submit().remove(); } }); diff --git a/src/_h5ai/client/js/inc/ext/download.js b/src/_h5ai/client/js/inc/ext/download.js index a0f0b2cb..8d5b6881 100644 --- a/src/_h5ai/client/js/inc/ext/download.js +++ b/src/_h5ai/client/js/inc/ext/download.js @@ -1,5 +1,5 @@ -modulejs.define('ext/download', ['_', '$', 'core/settings', 'core/resource', 'core/event', 'core/server', 'core/location'], function (_, $, allsettings, resource, event, server, location) { +modulejs.define('ext/download', ['_', '$', 'core/settings', 'core/resource', 'core/event', 'core/location', 'core/server'], function (_, $, allsettings, resource, event, location, server) { var settings = _.extend({ enabled: false, @@ -7,8 +7,6 @@ modulejs.define('ext/download', ['_', '$', 'core/settings', 'core/resource', 'co packageName: 'package' }, allsettings.download), - // formats = ['tar', 'zip'], - downloadBtnTemplate = '
  • ' + '' + 'download' + @@ -16,25 +14,14 @@ modulejs.define('ext/download', ['_', '$', 'core/settings', 'core/resource', 'co '' + '
  • ', - selectedHrefsStr = '', - $download, $img, - - failed = function () { - - $download.addClass('failed'); - setTimeout(function () { - $download.removeClass('failed'); - }, 1000); - }, + selectedItems = [], onSelection = function (items) { - selectedHrefsStr = ''; - if (items.length) { - selectedHrefsStr = _.map(items, function (item) { + var $download = $('#download'); - return item.absHref; - }).join('|:|'); + selectedItems = items.slice(0); + if (selectedItems.length) { $download.appendTo('#navbar').show(); } else { $download.hide(); @@ -49,31 +36,21 @@ modulejs.define('ext/download', ['_', '$', 'core/settings', 'core/resource', 'co action: 'download', as: (settings.packageName || location.getItem().label) + '.' + extension, type: type, - hrefs: selectedHrefsStr - }, - $form = $(''); + hrefs: _.pluck(selectedItems, 'absHref').join('|:|') + }; - _.each(query, function (val, key) { - - $('') - .attr('name', key) - .attr('value', val) - .appendTo($form); - }); - - $form.appendTo('body').submit().remove(); + server.formRequest(query); }, init = function () { - if (!settings.enabled || !server.api) { + if (!settings.enabled) { return; } - $download = $(downloadBtnTemplate) + $(downloadBtnTemplate) .find('a').on('click', onClick).end() .appendTo('#navbar'); - $img = $download.find('img'); event.sub('selection', onSelection); }; diff --git a/src/_h5ai/conf/options.json b/src/_h5ai/conf/options.json index 61e74abd..4a7911b6 100644 --- a/src/_h5ai/conf/options.json +++ b/src/_h5ai/conf/options.json @@ -92,7 +92,7 @@ Options Allow file deletion. */ "delete": { - "enabled": true + "enabled": false }, /* [EXPERIMENTAL]