diff --git a/assets/javascripts/discourse/components/google-adsense.js.es6 b/assets/javascripts/discourse/components/google-adsense.js.es6 index a349ff4..e7047c2 100644 --- a/assets/javascripts/discourse/components/google-adsense.js.es6 +++ b/assets/javascripts/discourse/components/google-adsense.js.es6 @@ -106,7 +106,7 @@ export default Ember.Component.extend({ mobile_width: mobile_width, mobile_height: mobile_height, - init: function() { + init() { 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"] ); @@ -114,6 +114,16 @@ export default Ember.Component.extend({ this._super(); }, + _triggerAds() { + const adsbygoogle = window.adsbygoogle || []; + adsbygoogle.push({}); + }, + + didInsertElement() { + this._super(); + Ember.run.scheduleOnce('afterRender', this, this._triggerAds); + }, + adWrapperStyle: function() { return `width: ${this.get('ad_width')}px; height: ${this.get('ad_height')}px;`.htmlSafe(); }.property('ad_width', 'ad_height'), diff --git a/assets/javascripts/discourse/templates/components/google-adsense.hbs b/assets/javascripts/discourse/templates/components/google-adsense.hbs index 7d81e18..f345c79 100644 --- a/assets/javascripts/discourse/templates/components/google-adsense.hbs +++ b/assets/javascripts/discourse/templates/components/google-adsense.hbs @@ -7,10 +7,6 @@ data-ad-client="ca-pub-{{publisher_id}}" data-ad-slot={{ad_mobile_code}}> - - {{else}}

ADVERTISEMENT

@@ -20,10 +16,6 @@ data-ad-client="ca-pub-{{publisher_id}}" data-ad-slot={{ad_code}}> - - {{/if}} {{/if}}