mirror of
https://github.com/discourse/discourse-adplugin.git
synced 2025-07-07 13:52:12 +00:00
Add support for adsense fluid format for in-feed (#89)
This commit is contained in:
parent
501ad7878e
commit
50788a876e
@ -11,6 +11,9 @@ function parseAdWidth(value) {
|
|||||||
if (value === "responsive") {
|
if (value === "responsive") {
|
||||||
return "auto";
|
return "auto";
|
||||||
}
|
}
|
||||||
|
if (value.startsWith("fluid")) {
|
||||||
|
return "fluid";
|
||||||
|
}
|
||||||
const w = parseInt(value.substring(0, 3).trim(), 10);
|
const w = parseInt(value.substring(0, 3).trim(), 10);
|
||||||
if (isNaN(w)) {
|
if (isNaN(w)) {
|
||||||
return "auto";
|
return "auto";
|
||||||
@ -23,6 +26,9 @@ function parseAdHeight(value) {
|
|||||||
if (value === "responsive") {
|
if (value === "responsive") {
|
||||||
return "auto";
|
return "auto";
|
||||||
}
|
}
|
||||||
|
if (value.startsWith("fluid")) {
|
||||||
|
return "fluid";
|
||||||
|
}
|
||||||
const h = parseInt(value.substring(4, 7).trim(), 10);
|
const h = parseInt(value.substring(4, 7).trim(), 10);
|
||||||
if (isNaN(h)) {
|
if (isNaN(h)) {
|
||||||
return "auto";
|
return "auto";
|
||||||
@ -172,7 +178,12 @@ export default AdComponent.extend({
|
|||||||
|
|
||||||
@discourseComputed("ad_width")
|
@discourseComputed("ad_width")
|
||||||
isResponsive(adWidth) {
|
isResponsive(adWidth) {
|
||||||
return adWidth === "auto";
|
return ["auto", "fluid"].includes(adWidth);
|
||||||
|
},
|
||||||
|
|
||||||
|
@discourseComputed("ad_width")
|
||||||
|
isFluid(adWidth) {
|
||||||
|
return adWidth === "fluid";
|
||||||
},
|
},
|
||||||
|
|
||||||
@discourseComputed("placement", "showAd")
|
@discourseComputed("placement", "showAd")
|
||||||
@ -182,7 +193,7 @@ export default AdComponent.extend({
|
|||||||
|
|
||||||
@discourseComputed("isResponsive")
|
@discourseComputed("isResponsive")
|
||||||
autoAdFormat(isResponsive) {
|
autoAdFormat(isResponsive) {
|
||||||
return isResponsive ? "auto".htmlSafe() : false;
|
return isResponsive ? (isFluid ? "fluid".htmlSafe() : "auto".htmlSafe()) : false;
|
||||||
},
|
},
|
||||||
|
|
||||||
@discourseComputed("ad_width", "ad_height", "isResponsive")
|
@discourseComputed("ad_width", "ad_height", "isResponsive")
|
||||||
|
@ -55,6 +55,7 @@ adsense_plugin:
|
|||||||
type: list
|
type: list
|
||||||
choices: &adsense_choices
|
choices: &adsense_choices
|
||||||
- responsive
|
- responsive
|
||||||
|
- fluid - for in-feed ad units
|
||||||
- 728*90 - leaderboard
|
- 728*90 - leaderboard
|
||||||
- 336*280 - large rectangle
|
- 336*280 - large rectangle
|
||||||
- 300*250 - medium rectangle
|
- 300*250 - medium rectangle
|
||||||
|
Loading…
x
Reference in New Issue
Block a user