diff --git a/assets/javascripts/discourse/components/google-adsense.js.es6 b/assets/javascripts/discourse/components/google-adsense.js.es6 index dd53e38..16a0c91 100644 --- a/assets/javascripts/discourse/components/google-adsense.js.es6 +++ b/assets/javascripts/discourse/components/google-adsense.js.es6 @@ -3,6 +3,7 @@ import PageTracker from 'discourse/lib/page-tracker'; var ad_width = ''; var ad_height = ''; var ad_code = ''; +var ad_mobile_code = ''; var currentUser = Discourse.User.current(); var publisher_id = Discourse.SiteSettings.adsense_publisher_code; var preGoogleVars = null; @@ -66,12 +67,17 @@ var data = { "post-bottom" : {} } + if (Discourse.SiteSettings.adsense_publisher_code) { - // if ((currentUser) && (currentUser.get('trust_level') > Discourse.SiteSettings.adsense_through_trust_level)) { - if (Discourse.SiteSettings.adsense_topic_list_top_code && !Discourse.SiteSettings.adsense_show_topic_list_top && !((currentUser) && (currentUser.get('trust_level') > Discourse.SiteSettings.adsense_through_trust_level))) { - data["topic-list-top"]["ad_code"] = Discourse.SiteSettings.adsense_topic_list_top_code; - data["topic-list-top"]["ad_width"] = parseInt(splitWidthInt(Discourse.SiteSettings.adsense_topic_list_top_ad_sizes)); - data["topic-list-top"]["ad_height"] = parseInt(splitHeightInt(Discourse.SiteSettings.adsense_topic_list_top_ad_sizes)); + if (!Discourse.SiteSettings.adsense_show_topic_list_top && !((currentUser) && (currentUser.get('trust_level') > Discourse.SiteSettings.adsense_through_trust_level))) { + if (!Discourse.Mobile.mobileView && Discourse.SiteSettings.adsense_topic_list_top_code) { + data["topic-list-top"]["ad_code"] = Discourse.SiteSettings.adsense_topic_list_top_code; + data["topic-list-top"]["ad_width"] = parseInt(splitWidthInt(Discourse.SiteSettings.adsense_topic_list_top_ad_sizes)); + data["topic-list-top"]["ad_height"] = parseInt(splitHeightInt(Discourse.SiteSettings.adsense_topic_list_top_ad_sizes)); + } + if (Discourse.Mobile.mobileView && Discourse.SiteSettings.adsense_mobile_topic_list_top_code) { + data["topic-list-top"]["ad_mobile_code"] = Discourse.SiteSettings.adsense_mobile_topic_list_top_code; + } } if (Discourse.SiteSettings.adsense_topic_above_post_stream_code && !Discourse.SiteSettings.adsense_show_topic_above_post_stream && !((currentUser) && (currentUser.get('trust_level') > Discourse.SiteSettings.adsense_through_trust_level))) { data["topic-above-post-stream"]["ad_code"] = Discourse.SiteSettings.adsense_topic_above_post_stream_code; @@ -104,6 +110,7 @@ export default Ember.Component.extend({ this.set('ad_width', data[this.placement]["ad_width"] ); this.set('ad_height', data[this.placement]["ad_height"] ); this.set('ad_code', data[this.placement]["ad_code"] ); + this.set('ad_mobile_code', data[this.placement]["ad_mobile_code"] ); this._super(); }, diff --git a/assets/javascripts/discourse/components/google-dfp-ad.js.es6 b/assets/javascripts/discourse/components/google-dfp-ad.js.es6 index a4f5f5f..f6ede75 100755 --- a/assets/javascripts/discourse/components/google-dfp-ad.js.es6 +++ b/assets/javascripts/discourse/components/google-dfp-ad.js.es6 @@ -96,7 +96,7 @@ function loadGoogle(settings) { const_width = parseInt(splitWidthInt(settings.topic_list_top_ad_sizes)); const_height = parseInt(splitHeightInt(settings.topic_list_top_ad_sizes)); if (Discourse.Mobile.mobileView) { - googletag.defineSlot(settings.dfp_topic_list_top_code, [320,50], 'div-gpt-ad-topic-list-top').addService(googletag.pubads()); + googletag.defineSlot(settings.dfp_mobile_topic_list_top_code, [320,50], 'div-gpt-ad-topic-list-top').addService(googletag.pubads()); } else { googletag.defineSlot('/' + settings.dfp_publisher_id + '/' + 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') diff --git a/assets/javascripts/discourse/templates/components/google-adsense.hbs b/assets/javascripts/discourse/templates/components/google-adsense.hbs index f98d0d7..280fdcd 100644 --- a/assets/javascripts/discourse/templates/components/google-adsense.hbs +++ b/assets/javascripts/discourse/templates/components/google-adsense.hbs @@ -3,7 +3,7 @@ + data-ad-slot={{ad_mobile_code}}>