discourse/app/assets/javascripts/wizard/components/image-preview-favicon-url.js.es6

33 lines
747 B
Plaintext
Raw Normal View History

2018-06-15 23:03:24 +08:00
import { observes } from "ember-addons/ember-computed-decorators";
2016-09-17 05:02:45 +08:00
2018-06-15 23:03:24 +08:00
import { createPreviewComponent } from "wizard/lib/preview";
2016-09-17 05:02:45 +08:00
export default createPreviewComponent(371, 124, {
tab: null,
image: null,
2018-06-15 23:03:24 +08:00
@observes("field.value")
2016-09-17 05:02:45 +08:00
imageChanged() {
this.reload();
},
images() {
2018-06-15 23:03:24 +08:00
return { tab: "/images/wizard/tab.png", image: this.get("field.value") };
2016-09-17 05:02:45 +08:00
},
paint(ctx, colors, width, height) {
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'`;
2018-06-15 23:03:24 +08:00
ctx.fillStyle = "#000";
2016-09-17 05:02:45 +08:00
2018-06-15 23:03:24 +08:00
let title = this.get("wizard").getTitle();
2016-09-17 05:02:45 +08:00
if (title.length > 20) {
title = title.substring(0, 20) + "...";
}
ctx.fillText(title, 80, 48);
}
});