Container responsive to ad sizes

This commit is contained in:
Sarah Ni 2015-08-10 14:19:51 +10:00
parent 013d6bc363
commit 13fd01e6c2
2 changed files with 35 additions and 27 deletions

View File

@ -1,7 +1,7 @@
import loadScript from 'discourse/lib/load-script';
const const_width = 300;
const const_height = 250;
var const_width = '';
var const_height = '';
var _loaded = false,
_promise = null;
@ -37,15 +37,23 @@ function loadGoogle(settings) {
// Define our ad units - extend for mobile view.
googletag.cmd.push(function() {
if (settings.dfp_topic_list_top_code && !settings.dfp_show_topic_list_top && settings.topic_list_top_ad_sizes) {
const_width = parseInt(splitWidthInt(settings.topic_list_top_ad_sizes));
const_height = parseInt(splitHeightInt(settings.topic_list_top_ad_sizes));
googletag.defineSlot(settings.dfp_topic_list_top_code, [parseInt(splitWidthInt(settings.topic_list_top_ad_sizes)), parseInt(splitHeightInt(settings.topic_list_top_ad_sizes))], 'div-gpt-ad-topic-list-top').addService(googletag.pubads());
}
if (settings.dfp_topic_above_post_stream_code && !settings.dfp_show_topic_above_post_stream && settings.topic_above_post_stream_ad_sizes) {
const_width = parseInt(splitWidthInt(settings.topic_above_post_stream_ad_sizes));
const_height = parseInt(splitHeightInt(settings.topic_above_post_stream_ad_sizes));
googletag.defineSlot(settings.dfp_topic_above_post_stream_code, [parseInt(splitWidthInt(settings.topic_above_post_stream_ad_sizes)), parseInt(splitHeightInt(settings.topic_above_post_stream_ad_sizes))], 'div-gpt-ad-topic-above-post-stream').addService(googletag.pubads());
}
if (settings.dfp_topic_above_suggested_code && !settings.dfp_show_topic_above_suggested && settings.topic_above_suggested_ad_sizes) {
const_width = parseInt(splitWidthInt(settings.topic_above_suggested_ad_sizes));
const_height = parseInt(splitHeightInt(settings.topic_above_suggested_ad_sizes));
googletag.defineSlot(settings.dfp_topic_above_suggested_code, [parseInt(splitWidthInt(settings.topic_above_suggested_ad_sizes)), parseInt(splitHeightInt(settings.topic_above_suggested_ad_sizes))], 'div-gpt-ad-topic-above-suggested').addService(googletag.pubads());
}
if (settings.dfp_post_bottom_code && !settings.dfp_show_post_bottom && settings.post_bottom_ad_sizes) {
const_width = parseInt(splitWidthInt(settings.post_bottom_ad_sizes));
const_height = parseInt(splitHeightInt(settings.post_bottom_ad_sizes));
googletag.defineSlot(settings.dfp_post_bottom_code, [parseInt(splitWidthInt(settings.post_bottom_ad_sizes)), parseInt(splitHeightInt(settings.post_bottom_ad_sizes))], 'div-gpt-ad-post-bottom').addService(googletag.pubads());
}
googletag.pubads().enableSingleRequest();

View File

@ -2,30 +2,6 @@ ad_plugin:
dfp_topic_list_top_code:
client: true
default: ''
dfp_show_topic_list_top:
client: true
default: false
dfp_topic_above_post_stream_code:
client: true
default: ''
dfp_show_topic_above_post_stream:
client: true
default: false
dfp_topic_above_suggested_code:
client: true
default: ''
dfp_show_topic_above_suggested:
client: true
default: false
dfp_post_bottom_code:
client: true
default: ''
dfp_show_post_bottom:
client: true
default: false
dfp_nth_post_code:
client: true
default: ''
topic_list_top_ad_sizes:
client: true
default: '728*90 - leaderboard'
@ -41,6 +17,12 @@ ad_plugin:
- 180*150 - small rectangle
- 200*200 - small square
- 250*250 - square
dfp_show_topic_list_top:
client: true
default: false
dfp_topic_above_post_stream_code:
client: true
default: ''
topic_above_post_stream_ad_sizes:
client: true
default: '728*90 - leaderboard'
@ -56,6 +38,12 @@ ad_plugin:
- 180*150 - small rectangle
- 200*200 - small square
- 250*250 - square
dfp_show_topic_above_post_stream:
client: true
default: false
dfp_topic_above_suggested_code:
client: true
default: ''
topic_above_suggested_ad_sizes:
client: true
default: '728*90 - leaderboard'
@ -71,6 +59,15 @@ ad_plugin:
- 180*150 - small rectangle
- 200*200 - small square
- 250*250 - square
dfp_show_topic_above_suggested:
client: true
default: false
dfp_post_bottom_code:
client: true
default: ''
dfp_nth_post_code:
client: true
default: ''
post_bottom_ad_sizes:
client: true
default: '728*90 - leaderboard'
@ -86,3 +83,6 @@ ad_plugin:
- 180*150 - small rectangle
- 200*200 - small square
- 250*250 - square
dfp_show_post_bottom:
client: true
default: false