summaryrefslogtreecommitdiffhomepage
path: root/modules/luci-base/htdocs/luci-static
diff options
context:
space:
mode:
authorJo-Philipp Wich <jo@mein.io>2020-01-20 19:38:17 +0100
committerJo-Philipp Wich <jo@mein.io>2020-01-20 19:40:46 +0100
commit136b965b255c3d37a21e8cf2fc835f83c2f0d3be (patch)
tree42fe1cf90caed60b26afeb45d8fa2213f7e50211 /modules/luci-base/htdocs/luci-static
parent9fd7e9fc23647fe7adfe84d1bc3b406ab52186e7 (diff)
luci-base: ui.js: UIFileUpload fixes
- Introduce a new option `initial_directory` which describes the initial directory to display when nothing is selected, default to the root directory - Prevent stray legacy cbi reloads when deselecting files - Fix within-root-directory-check for initial rendering Signed-off-by: Jo-Philipp Wich <jo@mein.io>
Diffstat (limited to 'modules/luci-base/htdocs/luci-static')
-rw-r--r--modules/luci-base/htdocs/luci-static/resources/ui.js6
1 files changed, 4 insertions, 2 deletions
diff --git a/modules/luci-base/htdocs/luci-static/resources/ui.js b/modules/luci-base/htdocs/luci-static/resources/ui.js
index 08edaa1475..7cf4f4102f 100644
--- a/modules/luci-base/htdocs/luci-static/resources/ui.js
+++ b/modules/luci-base/htdocs/luci-static/resources/ui.js
@@ -1919,6 +1919,8 @@ var UIFileUpload = UIElement.extend({
button.style.display = '';
this.node.dispatchEvent(new CustomEvent('cbi-fileupload-cancel', {}));
+
+ ev.preventDefault();
},
handleReset: function(ev) {
@@ -1962,9 +1964,9 @@ var UIFileUpload = UIElement.extend({
handleFileBrowser: function(ev) {
var button = ev.target,
browser = button.nextElementSibling,
- path = this.stat ? this.stat.path.replace(/\/[^\/]+$/, '') : this.options.root_directory;
+ path = this.stat ? this.stat.path.replace(/\/[^\/]+$/, '') : (this.options.initial_directory || this.options.root_directory);
- if (this.options.root_directory.indexOf(path) != 0)
+ if (path.indexOf(this.options.root_directory) != 0)
path = this.options.root_directory;
ev.preventDefault();