|
@@ -31,6 +31,15 @@ const FOCUSABLE_ELEMENTS = [
|
|
const TAB_KEY = 9
|
|
const TAB_KEY = 9
|
|
const ESC_KEY = 27
|
|
const ESC_KEY = 27
|
|
|
|
|
|
|
|
+function createPromise () {
|
|
|
|
+ const o = {}
|
|
|
|
+ o.promise = new Promise((resolve, reject) => {
|
|
|
|
+ o.resolve = resolve
|
|
|
|
+ o.reject = reject
|
|
|
|
+ })
|
|
|
|
+ return o
|
|
|
|
+}
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* Dashboard UI with previews, metadata editing, tabs for various services and more
|
|
* Dashboard UI with previews, metadata editing, tabs for various services and more
|
|
*/
|
|
*/
|
|
@@ -298,6 +307,7 @@ module.exports = class Dashboard extends Plugin {
|
|
}
|
|
}
|
|
|
|
|
|
openModal () {
|
|
openModal () {
|
|
|
|
+ const { promise, resolve } = createPromise()
|
|
// save scroll position
|
|
// save scroll position
|
|
this.savedScrollPosition = window.scrollY
|
|
this.savedScrollPosition = window.scrollY
|
|
// save active element, so we can restore focus when modal is closed
|
|
// save active element, so we can restore focus when modal is closed
|
|
@@ -313,12 +323,14 @@ module.exports = class Dashboard extends Plugin {
|
|
isHidden: false
|
|
isHidden: false
|
|
})
|
|
})
|
|
this.el.removeEventListener('animationend', handler, false)
|
|
this.el.removeEventListener('animationend', handler, false)
|
|
|
|
+ resolve()
|
|
}
|
|
}
|
|
this.el.addEventListener('animationend', handler, false)
|
|
this.el.addEventListener('animationend', handler, false)
|
|
} else {
|
|
} else {
|
|
this.setPluginState({
|
|
this.setPluginState({
|
|
isHidden: false
|
|
isHidden: false
|
|
})
|
|
})
|
|
|
|
+ resolve()
|
|
}
|
|
}
|
|
|
|
|
|
if (this.opts.browserBackButtonClose) {
|
|
if (this.opts.browserBackButtonClose) {
|
|
@@ -330,6 +342,8 @@ module.exports = class Dashboard extends Plugin {
|
|
|
|
|
|
// this.rerender(this.uppy.getState())
|
|
// this.rerender(this.uppy.getState())
|
|
this.setFocusToBrowse()
|
|
this.setFocusToBrowse()
|
|
|
|
+
|
|
|
|
+ return promise
|
|
}
|
|
}
|
|
|
|
|
|
closeModal (opts = {}) {
|
|
closeModal (opts = {}) {
|
|
@@ -337,6 +351,8 @@ module.exports = class Dashboard extends Plugin {
|
|
manualClose = true // Whether the modal is being closed by the user (`true`) or by other means (e.g. browser back button)
|
|
manualClose = true // Whether the modal is being closed by the user (`true`) or by other means (e.g. browser back button)
|
|
} = opts
|
|
} = opts
|
|
|
|
|
|
|
|
+ const { promise, resolve } = createPromise()
|
|
|
|
+
|
|
if (this.opts.disablePageScrollWhenModalOpen) {
|
|
if (this.opts.disablePageScrollWhenModalOpen) {
|
|
document.body.classList.remove('uppy-Dashboard-isFixed')
|
|
document.body.classList.remove('uppy-Dashboard-isFixed')
|
|
}
|
|
}
|
|
@@ -351,12 +367,14 @@ module.exports = class Dashboard extends Plugin {
|
|
isClosing: false
|
|
isClosing: false
|
|
})
|
|
})
|
|
this.el.removeEventListener('animationend', handler, false)
|
|
this.el.removeEventListener('animationend', handler, false)
|
|
|
|
+ resolve()
|
|
}
|
|
}
|
|
this.el.addEventListener('animationend', handler, false)
|
|
this.el.addEventListener('animationend', handler, false)
|
|
} else {
|
|
} else {
|
|
this.setPluginState({
|
|
this.setPluginState({
|
|
isHidden: true
|
|
isHidden: true
|
|
})
|
|
})
|
|
|
|
+ resolve()
|
|
}
|
|
}
|
|
|
|
|
|
// handle ESC and TAB keys in modal dialog
|
|
// handle ESC and TAB keys in modal dialog
|
|
@@ -373,6 +391,8 @@ module.exports = class Dashboard extends Plugin {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ return promise
|
|
}
|
|
}
|
|
|
|
|
|
isModalOpen () {
|
|
isModalOpen () {
|