Skip to content

Commit

Permalink
Solve elninotech#288: Add a settings option to choose where to render…
Browse files Browse the repository at this point in the history
… the Uppload modal.
  • Loading branch information
phlegx committed Aug 12, 2021
1 parent 7aa46cf commit ca87b1f
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/uppload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ class UploadingService extends UpploadService {
*/
export class Uppload implements IUppload {
id: string = `${+new Date()}`;
wrapper?: string;
services: UpploadService[] = [new DefaultService(), new UploadingService()];
effects: UpploadEffect[] = [];
isOpen = false;
Expand Down Expand Up @@ -66,9 +67,9 @@ export class Uppload implements IUppload {
this.container.setAttribute("id", `uppload-${this.id}`);
this.renderContainer();
this.container.classList.add("uppload-container");
const body = document.body;
if (body) {
body.appendChild(this.container);
const wrapper = this.wrapper ? document.querySelector(this.wrapper) : document.body;
if (wrapper) {
wrapper.appendChild(this.container);
}
this.focusTrap = createFocusTrap(this.container, {
initialFocus: () => this.container.querySelector("button"),
Expand Down Expand Up @@ -101,6 +102,7 @@ export class Uppload implements IUppload {
this.settings = { ...this.settings, ...settings };
this.emitter.emit("settingsUpdated", settings);
if (settings.id) this.id = settings.id;
if (settings.wrapper) this.wrapper = settings.wrapper;
if (settings.lang) setI18N(settings.lang);
if (settings.defaultService) this.activeService = settings.defaultService;
if (settings.lang) this.lang = settings.lang;
Expand Down

0 comments on commit ca87b1f

Please sign in to comment.