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

View file

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

View file

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

View file

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