Skip to content

Commit 7fbcec2

Browse files
committed
allow flavor and warning for overlay
1 parent c8cd0dc commit 7fbcec2

File tree

3 files changed

+27
-18
lines changed

3 files changed

+27
-18
lines changed

src/overlay.js

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ export class Overlay extends Events {
1212
constructor(opts) {
1313
super();
1414
this.uid = opts.uid ? opts.uid : uuid4();
15+
this.flavor = opts.flavor ? opts.flavor : '';
1516
this.css = opts.css ? opts.css : '';
1617
this.title = opts.title ? opts.title : ' ';
1718
this.content = opts.content ? opts.content : '';
@@ -28,7 +29,7 @@ export class Overlay extends Events {
2829
compile_template(this, `
2930
<div class="modal-wrapper position-absolute" t-elem="wrapper" style="z-index: ${z_index}">
3031
<div class="modal-backdrop opacity-25" t-elem="backdrop"></div>
31-
<div class="modal ${this.css}" id="${this.uid}" t-elem="elem">
32+
<div class="modal ${this.flavor} ${this.css}" id="${this.uid}" t-elem="elem">
3233
<div class="modal-dialog">
3334
<div class="modal-content">
3435
<div class="modal-header">
@@ -87,7 +88,6 @@ export class Message extends Overlay {
8788

8889
constructor(opts) {
8990
opts.content = opts.message ? opts.message : opts.content;
90-
opts.css = opts.flavor ? opts.flavor : opts.css;
9191
super(opts);
9292
this.compile_actions();
9393
}
@@ -106,7 +106,8 @@ export class Message extends Overlay {
106106
* ts.show_message({
107107
* title: 'Message title',
108108
* message: 'Message text',
109-
* flavor: 'info'
109+
* flavor: 'info',
110+
* css: 'modal-xl
110111
* });
111112
*
112113
* @param {Object} opts - Message options.
@@ -121,6 +122,7 @@ export function show_message(opts) {
121122
title: opts.title,
122123
message: opts.message,
123124
flavor: opts.flavor,
125+
css: opts.css,
124126
on_open: function(inst) {
125127
$('button', inst.elem).first().focus();
126128
}
@@ -134,11 +136,12 @@ export function show_message(opts) {
134136
*
135137
* @param {string} message - Info message to display in overlay content.
136138
*/
137-
export function show_info(message) {
139+
export function show_info(message, css) {
138140
show_message({
139141
title: 'Info',
140142
message: message,
141-
flavor: 'info'
143+
flavor: 'info',
144+
css: css
142145
});
143146
}
144147

@@ -149,11 +152,12 @@ export function show_info(message) {
149152
*
150153
* @param {string} message - Warning message to display in overlay content.
151154
*/
152-
export function show_warning(message) {
155+
export function show_warning(message, css) {
153156
show_message({
154157
title: 'Warning',
155158
message: message,
156-
flavor: 'warning'
159+
flavor: 'warning',
160+
css: css
157161
});
158162
}
159163

@@ -164,11 +168,12 @@ export function show_warning(message) {
164168
*
165169
* @param {string} message - Error message to display in overlay content.
166170
*/
167-
export function show_error(message) {
171+
export function show_error(message, css) {
168172
show_message({
169173
title: 'Error',
170174
message: message,
171-
flavor: 'error'
175+
flavor: 'error',
176+
css: css
172177
});
173178
}
174179

treibstoff/bundle/treibstoff.bundle.js

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -619,6 +619,7 @@ var ts = (function (exports, $) {
619619
constructor(opts) {
620620
super();
621621
this.uid = opts.uid ? opts.uid : uuid4();
622+
this.flavor = opts.flavor ? opts.flavor : '';
622623
this.css = opts.css ? opts.css : '';
623624
this.title = opts.title ? opts.title : '&nbsp;';
624625
this.content = opts.content ? opts.content : '';
@@ -634,7 +635,7 @@ var ts = (function (exports, $) {
634635
compile_template(this, `
635636
<div class="modal-wrapper position-absolute" t-elem="wrapper" style="z-index: ${z_index}">
636637
<div class="modal-backdrop opacity-25" t-elem="backdrop"></div>
637-
<div class="modal ${this.css}" id="${this.uid}" t-elem="elem">
638+
<div class="modal ${this.flavor} ${this.css}" id="${this.uid}" t-elem="elem">
638639
<div class="modal-dialog">
639640
<div class="modal-content">
640641
<div class="modal-header">
@@ -682,7 +683,6 @@ var ts = (function (exports, $) {
682683
class Message extends Overlay {
683684
constructor(opts) {
684685
opts.content = opts.message ? opts.message : opts.content;
685-
opts.css = opts.flavor ? opts.flavor : opts.css;
686686
super(opts);
687687
this.compile_actions();
688688
}
@@ -698,30 +698,34 @@ var ts = (function (exports, $) {
698698
title: opts.title,
699699
message: opts.message,
700700
flavor: opts.flavor,
701+
css: opts.css,
701702
on_open: function(inst) {
702703
$('button', inst.elem).first().focus();
703704
}
704705
}).open();
705706
}
706-
function show_info(message) {
707+
function show_info(message, css) {
707708
show_message({
708709
title: 'Info',
709710
message: message,
710-
flavor: 'info'
711+
flavor: 'info',
712+
css: css
711713
});
712714
}
713-
function show_warning(message) {
715+
function show_warning(message, css) {
714716
show_message({
715717
title: 'Warning',
716718
message: message,
717-
flavor: 'warning'
719+
flavor: 'warning',
720+
css: css
718721
});
719722
}
720-
function show_error(message) {
723+
function show_error(message, css) {
721724
show_message({
722725
title: 'Error',
723726
message: message,
724-
flavor: 'error'
727+
flavor: 'error',
728+
css: css
725729
});
726730
}
727731
class Dialog extends Message {

0 commit comments

Comments
 (0)