file: remember last visited directory per widget
This commit is contained in:
parent
dfe45cac01
commit
51e33c0230
3 changed files with 11 additions and 2 deletions
|
|
@ -1,5 +1,10 @@
|
|||
# Changelog
|
||||
|
||||
## 1.30.3
|
||||
|
||||
-widgets
|
||||
- file: remember last visited directy per widget if `directory` property is not set
|
||||
|
||||
## 1.30.2
|
||||
|
||||
- bug fixes
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ import UiModal from './ui-modal.mjs'
|
|||
import {DOM} from '../globals.mjs'
|
||||
|
||||
|
||||
export default function UiFilebrowser(options, callback) {
|
||||
export default function UiFilebrowser(options, callback, closeCallback) {
|
||||
|
||||
var save = options.save,
|
||||
saveInputFocus = undefined,
|
||||
|
|
@ -199,6 +199,7 @@ export default function UiFilebrowser(options, callback) {
|
|||
document.removeEventListener('keydown', keyDownHandler)
|
||||
document.removeEventListener('keyup', keyUpHandler)
|
||||
keyboardJS.setContext(previousKbContext)
|
||||
if (closeCallback) closeCallback(path)
|
||||
})
|
||||
|
||||
browser.appendChild(ariane)
|
||||
|
|
|
|||
|
|
@ -45,6 +45,7 @@ export default class File extends Widget {
|
|||
if (this.getProp('hidePath')) this.widget.classList.add('hide-path')
|
||||
|
||||
this.text = DOM.get(this.widget, '.text')[0]
|
||||
this.lastDir = null
|
||||
|
||||
var ext = this.getProp('extension')
|
||||
if (Array.isArray(ext)) {
|
||||
|
|
@ -57,7 +58,7 @@ export default class File extends Widget {
|
|||
|
||||
uiFilebrowser({
|
||||
extension: ext.replace(/^\.?(.*)$/, '$1'),
|
||||
directory: this.getProp('directory') === 'auto' ? undefined : this.getProp('directory'),
|
||||
directory: this.getProp('directory') === 'auto' ? this.lastDir : this.getProp('directory'),
|
||||
loadDir: this.getProp('allowDir'),
|
||||
save: this.getProp('mode') === 'save'
|
||||
}, (path, root)=>{
|
||||
|
|
@ -71,6 +72,8 @@ export default class File extends Widget {
|
|||
send: true
|
||||
})
|
||||
|
||||
}, (path)=>{
|
||||
this.lastDir = path
|
||||
})
|
||||
}, {element: this.widget})
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue