mirror of
https://github.com/lrsjng/h5ai.git
synced 2025-05-25 12:34:47 -04:00
Add alwaysVisible option to download button.
This commit is contained in:
parent
506c93340a
commit
3e617ae005
4 changed files with 24 additions and 11 deletions
|
@ -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
|
||||||
|
|
|
@ -4,15 +4,17 @@ 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 =
|
||||||
'<a href="#">' +
|
'<li id="download">' +
|
||||||
'<img src="' + resource.image('download') + '" alt="download"/>' +
|
'<a href="#">' +
|
||||||
'<span class="l10n-download"/>' +
|
'<img src="' + resource.image('download') + '" alt="download"/>' +
|
||||||
'</a>' +
|
'<span class="l10n-download"/>' +
|
||||||
'</li>',
|
'</a>' +
|
||||||
|
'</li>',
|
||||||
|
|
||||||
selectedItems = [],
|
selectedItems = [],
|
||||||
|
|
||||||
|
@ -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);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -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
|
||||||
},
|
},
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -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);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue