FIX: when dfp/adsense publisher id is missing, don't render blank ad units
This commit is contained in:
parent
910b0d0e4c
commit
da1d4e0063
|
@ -125,6 +125,8 @@ export default Ember.Component.extend({
|
|||
didInsertElement() {
|
||||
this._super();
|
||||
|
||||
if (!this.get('showAd')) { return; }
|
||||
|
||||
Ember.run.scheduleOnce('afterRender', this, this._triggerAds);
|
||||
},
|
||||
|
||||
|
@ -151,4 +153,8 @@ export default Ember.Component.extend({
|
|||
checkTrustLevels: function() {
|
||||
return !((currentUser) && (currentUser.get('trust_level') > Discourse.SiteSettings.adsense_through_trust_level));
|
||||
}.property('trust_level'),
|
||||
|
||||
showAd: function() {
|
||||
return Discourse.SiteSettings.adsense_publisher_code && this.get('checkTrustLevels');
|
||||
}.property('checkTrustLevels')
|
||||
});
|
||||
|
|
|
@ -56,6 +56,11 @@ function custom_targeting(key_array, value_array, location) {
|
|||
}
|
||||
|
||||
function defineSlot(divId, placement, settings, isMobile) {
|
||||
|
||||
if (!settings.dfp_publisher_id) {
|
||||
return;
|
||||
}
|
||||
|
||||
var ad, width, height;
|
||||
|
||||
if (ads[divId]) {
|
||||
|
@ -185,6 +190,10 @@ export default Ember.Component.extend({
|
|||
return `width: ${this.get('width')}px;`.htmlSafe();
|
||||
}.property('width'),
|
||||
|
||||
showAd: function() {
|
||||
return Discourse.SiteSettings.dfp_publisher_id && this.get('checkTrustLevels');
|
||||
}.property('checkTrustLevels'),
|
||||
|
||||
checkTrustLevels: function() {
|
||||
return !((currentUser) && (currentUser.get('trust_level') > Discourse.SiteSettings.dfp_through_trust_level));
|
||||
}.property('trust_level'),
|
||||
|
@ -205,6 +214,8 @@ export default Ember.Component.extend({
|
|||
}.observes('refreshOnChange'),
|
||||
|
||||
_initGoogleDFP: function() {
|
||||
if (!this.get('showAd')) { return; }
|
||||
|
||||
var self = this;
|
||||
loadGoogle(this.siteSettings).then(function() {
|
||||
self.set('loadedGoogletag', true);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
{{#if checkTrustLevels}}
|
||||
{{#if showAd}}
|
||||
{{#if site.mobileView}}
|
||||
<div class="google-adsense-label" style={{adTitleStyleMobile}}><h2>ADVERTISEMENT</h2></div>
|
||||
<div class="google-adsense-content" style={{adWrapperStyleMobile}}>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
{{#if checkTrustLevels}}
|
||||
{{#if showAd}}
|
||||
{{#if site.mobileView}}
|
||||
<div class="google-dfp-ad-label" style={{adTitleStyleMobile}}><h2>ADVERTISEMENT</h2></div>
|
||||
<div id={{divId}} style={{adWrapperStyle}} class="dfp-ad-unit" align=center></div>
|
||||
|
|
Loading…
Reference in New Issue