Add alwaysVisible option to download button.

This commit is contained in:
Lars Jung 2014-06-16 02:31:50 +02:00
parent 506c93340a
commit 3e617ae005
4 changed files with 24 additions and 11 deletions

View File

@ -15,6 +15,7 @@
* adds markdown support for custom header and footer files
* adds video and audio preview via HTML5 elements (no fallback, works best in Chrome)
* adds filter reset on location change
* adds option to make download button always visible
* adds Google UA support
* extends selectable icon sizes (adds 128px, 192px, 256px, 384px)
* improves preview GUI

View File

@ -4,15 +4,17 @@ modulejs.define('ext/download', ['_', '$', 'core/settings', 'core/resource', 'co
var settings = _.extend({
enabled: false,
type: 'php-tar',
packageName: 'package'
packageName: 'package',
alwaysVisible: false
}, allsettings.download),
downloadBtnTemplate = '<li id="download">' +
'<a href="#">' +
'<img src="' + resource.image('download') + '" alt="download"/>' +
'<span class="l10n-download"/>' +
'</a>' +
'</li>',
downloadBtnTemplate =
'<li id="download">' +
'<a href="#">' +
'<img src="' + resource.image('download') + '" alt="download"/>' +
'<span class="l10n-download"/>' +
'</a>' +
'</li>',
selectedItems = [],
@ -22,8 +24,8 @@ modulejs.define('ext/download', ['_', '$', 'core/settings', 'core/resource', 'co
selectedItems = items.slice(0);
if (selectedItems.length) {
$download.appendTo('#navbar').show();
} else {
$download.show();
} else if (!settings.alwaysVisible) {
$download.hide();
}
},
@ -52,6 +54,10 @@ modulejs.define('ext/download', ['_', '$', 'core/settings', 'core/resource', 'co
.find('a').on('click', onClick).end()
.appendTo('#navbar');
if (settings.alwaysVisible) {
$('#download').show();
}
event.sub('selection', onSelection);
};

View File

@ -98,11 +98,13 @@ Options
- type: "php-tar", "shell-tar" or "shell-zip"
- packageName: basename of the download package, null for current foldername
- alwaysVisible: always show download button (defaults to download the current folder)
*/
"download": {
"enabled": true,
"type": "php-tar",
"packageName": null
"packageName": null,
"alwaysVisible": false
},
/*

View File

@ -23,7 +23,7 @@ class Archive {
$this->add_hrefs($urls);
if (count($this->dirs) === 0 && count($this->files) === 0) {
return 500;
$this->add_dir(CURRENT_PATH, "/");
}
if ($type === "php-tar") {
@ -145,6 +145,10 @@ class Archive {
foreach ($urls as $href) {
if (trim($href) === "") {
continue;
}
$d = normalize_path(dirname($href), true);
$n = basename($href);