From 6d93faf871d224d33431d1c77966094f9745f15b Mon Sep 17 00:00:00 2001 From: Sarah Ni Date: Fri, 28 Aug 2015 15:34:14 +1000 Subject: [PATCH] Successful mobile slots - default to 320*50 --- .../discourse/components/google-adsense.js.es6 | 9 +++++++-- .../discourse/components/google-dfp-ad.js.es6 | 10 ++++++++-- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/assets/javascripts/discourse/components/google-adsense.js.es6 b/assets/javascripts/discourse/components/google-adsense.js.es6 index dad8958..99c66a4 100644 --- a/assets/javascripts/discourse/components/google-adsense.js.es6 +++ b/assets/javascripts/discourse/components/google-adsense.js.es6 @@ -8,6 +8,8 @@ var ad_code = ''; var publisher_id = Discourse.SiteSettings.adsense_publisher_code; var preGoogleVars = null; var postGoogleVars = null; +var mobile_width = 320; +var mobile_height = 50; function splitWidthInt(value) { @@ -101,6 +103,9 @@ export default Ember.Component.extend({ ad_width: ad_width, ad_height: ad_height, + mobile_width: mobile_width, + mobile_height: mobile_height, + init: function() { this.set('ad_width', data[this.placement]["ad_width"] ); this.set('ad_height', data[this.placement]["ad_height"] ); @@ -117,8 +122,8 @@ export default Ember.Component.extend({ }.property('adWrapperStyle'), adWrapperStyleMobile: function() { - return `width: 320px; height: 50px; margin:0 auto;`.htmlSafe(); - }, + return `width: ${this.get('mobile_width')}px; height: ${this.get('mobile_height')}px; margin:0 auto;`.htmlSafe(); + }.property('mobile_width', 'mobile_height'), adInsStyleMobile: function() { return `display: inline-block; ${this.get('adWrapperStyleMobile')}`.htmlSafe(); diff --git a/assets/javascripts/discourse/components/google-dfp-ad.js.es6 b/assets/javascripts/discourse/components/google-dfp-ad.js.es6 index f4e0be3..5bedaba 100755 --- a/assets/javascripts/discourse/components/google-dfp-ad.js.es6 +++ b/assets/javascripts/discourse/components/google-dfp-ad.js.es6 @@ -4,6 +4,9 @@ import loadScript from 'discourse/lib/load-script'; var const_width = ''; var const_height = ''; +var mobile_width = 320; +var mobile_height = 50; + var _loaded = false, _promise = null; @@ -115,6 +118,9 @@ export default Ember.Component.extend({ classNames: ['google-dfp-ad'], loadedGoogletag: false, + mobile_width: mobile_width, + mobile_height: mobile_height, + // Part of the divID of the div part of the GPT divId: function() { return "div-gpt-ad-" + this.get('placement'); @@ -125,8 +131,8 @@ export default Ember.Component.extend({ }.property('const_width', 'const_height'), adWrapperStyleMobile: function() { - return `width: 320px; height: 50px;`.htmlSafe(); - }, + return `width: ${this.get('mobile_width')}px; height: ${this.get('mobile_height')}px; margin:0 auto;`.htmlSafe(); + }.property('mobile_width', 'mobile_height'), _initGoogleDFP: function() { var self = this;