2016-09-22 04:09:18 +08:00
|
|
|
import { createPreviewComponent } from "wizard/lib/preview";
|
2019-11-08 05:38:28 +08:00
|
|
|
import { observes } from "discourse-common/utils/decorators";
|
2016-09-17 05:02:45 +08:00
|
|
|
|
|
|
|
export default createPreviewComponent(371, 124, {
|
|
|
|
tab: null,
|
|
|
|
image: null,
|
|
|
|
|
|
|
|
@observes("field.value")
|
|
|
|
imageChanged() {
|
|
|
|
this.reload();
|
|
|
|
},
|
|
|
|
|
2016-09-22 04:09:18 +08:00
|
|
|
images() {
|
|
|
|
return { tab: "/images/wizard/tab.png", image: this.get("field.value") };
|
2016-09-17 05:02:45 +08:00
|
|
|
},
|
|
|
|
|
2020-10-06 01:40:41 +08:00
|
|
|
paint(options) {
|
|
|
|
const { ctx, width, height } = options;
|
2016-09-22 04:48:48 +08:00
|
|
|
this.scaleImage(this.tab, 0, 0, width, height);
|
|
|
|
this.scaleImage(this.image, 40, 25, 30, 30);
|
2016-09-17 05:02:45 +08:00
|
|
|
|
|
|
|
ctx.font = `20px 'Arial'`;
|
|
|
|
ctx.fillStyle = "#000";
|
|
|
|
|
2019-05-27 16:15:39 +08:00
|
|
|
let title = this.wizard.getTitle();
|
2016-09-17 05:02:45 +08:00
|
|
|
if (title.length > 20) {
|
|
|
|
title = title.substring(0, 20) + "...";
|
|
|
|
}
|
|
|
|
|
|
|
|
ctx.fillText(title, 80, 48);
|
|
|
|
},
|
|
|
|
});
|