mirror of
https://github.com/discourse/discourse.git
synced 2024-12-02 14:56:22 +08:00
17c92b4b2a
This commit adds a new option `@modalForMobile` for `<DMenu />` which allows to display a `<DModal />` when expanding a menu on mobile. This commit also adds a `@views` options to toasts which is an array accepting `['mobile', 'desktop']` and will control if the toast is show on desktop and/or mobile. Finally this commit allows to hide the progressBar even if the toast is set to `@autoClose=true`. This is controlled through the `@showProgressBar` option.
28 lines
639 B
JavaScript
28 lines
639 B
JavaScript
import { setOwner } from "@ember/application";
|
|
import { action } from "@ember/object";
|
|
import { service } from "@ember/service";
|
|
import uniqueId from "discourse/helpers/unique-id";
|
|
import { TOAST } from "float-kit/lib/constants";
|
|
|
|
export default class DToastInstance {
|
|
@service site;
|
|
@service toasts;
|
|
|
|
options = null;
|
|
id = uniqueId();
|
|
|
|
constructor(owner, options = {}) {
|
|
setOwner(this, owner);
|
|
this.options = { ...TOAST.options, ...options };
|
|
}
|
|
|
|
@action
|
|
close() {
|
|
this.toasts.close(this);
|
|
}
|
|
|
|
get isValidForView() {
|
|
return this.options.views.includes(this.site.desktopView ? "desktop" : "mobile");
|
|
}
|
|
}
|