Fixed up properties in ad mobile sizes for dfp and adsense
This commit is contained in:
parent
67141dd884
commit
5eecf0d731
|
@ -3,6 +3,8 @@ import PageTracker from 'discourse/lib/page-tracker';
|
|||
var ad_width = '';
|
||||
var ad_height = '';
|
||||
var ad_code = '';
|
||||
var ad_mobile_width = 320;
|
||||
var ad_mobile_height = 50;
|
||||
var ad_mobile_code = '';
|
||||
var currentUser = Discourse.User.current();
|
||||
var publisher_id = Discourse.SiteSettings.adsense_publisher_code;
|
||||
|
@ -28,9 +30,9 @@ PageTracker.current().on('change', function(url) {
|
|||
if (key.indexOf("google") !== -1){
|
||||
window[key] = undefined;
|
||||
}
|
||||
// for (var i = 0; i < postGoogleVars.length; i++) {
|
||||
// var key = postGoogleVars[i];
|
||||
// window[key] = undefined;
|
||||
// for (var i = 0; i < postGoogleVars.length; i++) {
|
||||
// var key = postGoogleVars[i];
|
||||
// window[key] = undefined;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -69,32 +71,31 @@ var data = {
|
|||
|
||||
|
||||
if (Discourse.SiteSettings.adsense_publisher_code) {
|
||||
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;
|
||||
data["topic-above-post-stream"]["ad_width"] = parseInt(splitWidthInt(Discourse.SiteSettings.adsense_topic_above_post_stream_ad_sizes));
|
||||
data["topic-above-post-stream"]["ad_height"] = parseInt(splitHeightInt(Discourse.SiteSettings.adsense_topic_above_post_stream_ad_sizes));
|
||||
}
|
||||
if (Discourse.SiteSettings.adsense_topic_above_suggested_code && !Discourse.SiteSettings.adsense_show_topic_above_suggested && !((currentUser) && (currentUser.get('trust_level') > Discourse.SiteSettings.adsense_through_trust_level))) {
|
||||
data["topic-above-suggested"]["ad_code"] = Discourse.SiteSettings.adsense_topic_above_suggested_code;
|
||||
data["topic-above-suggested"]["ad_width"] = parseInt(splitWidthInt(Discourse.SiteSettings.adsense_topic_above_suggested_ad_sizes));
|
||||
data["topic-above-suggested"]["ad_height"] = parseInt(splitHeightInt(Discourse.SiteSettings.adsense_topic_above_suggested_ad_sizes));
|
||||
}
|
||||
if (Discourse.SiteSettings.adsense_post_bottom_code && !Discourse.SiteSettings.adsense_show_post_bottom && !((currentUser) && (currentUser.get('trust_level') > Discourse.SiteSettings.adsense_through_trust_level))) {
|
||||
data["post-bottom"]["ad_code"] = Discourse.SiteSettings.adsense_post_bottom_code;
|
||||
data["post-bottom"]["ad_width"] = parseInt(splitWidthInt(Discourse.SiteSettings.adsense_post_bottom_ad_sizes));
|
||||
data["post-bottom"]["ad_height"] = parseInt(splitHeightInt(Discourse.SiteSettings.adsense_post_bottom_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;
|
||||
data["topic-above-post-stream"]["ad_width"] = parseInt(splitWidthInt(Discourse.SiteSettings.adsense_topic_above_post_stream_ad_sizes));
|
||||
data["topic-above-post-stream"]["ad_height"] = parseInt(splitHeightInt(Discourse.SiteSettings.adsense_topic_above_post_stream_ad_sizes));
|
||||
}
|
||||
if (Discourse.SiteSettings.adsense_topic_above_suggested_code && !Discourse.SiteSettings.adsense_show_topic_above_suggested && !((currentUser) && (currentUser.get('trust_level') > Discourse.SiteSettings.adsense_through_trust_level))) {
|
||||
data["topic-above-suggested"]["ad_code"] = Discourse.SiteSettings.adsense_topic_above_suggested_code;
|
||||
data["topic-above-suggested"]["ad_width"] = parseInt(splitWidthInt(Discourse.SiteSettings.adsense_topic_above_suggested_ad_sizes));
|
||||
data["topic-above-suggested"]["ad_height"] = parseInt(splitHeightInt(Discourse.SiteSettings.adsense_topic_above_suggested_ad_sizes));
|
||||
}
|
||||
if (Discourse.SiteSettings.adsense_post_bottom_code && !Discourse.SiteSettings.adsense_show_post_bottom && !((currentUser) && (currentUser.get('trust_level') > Discourse.SiteSettings.adsense_through_trust_level))) {
|
||||
data["post-bottom"]["ad_code"] = Discourse.SiteSettings.adsense_post_bottom_code;
|
||||
data["post-bottom"]["ad_width"] = parseInt(splitWidthInt(Discourse.SiteSettings.adsense_post_bottom_ad_sizes));
|
||||
data["post-bottom"]["ad_height"] = parseInt(splitHeightInt(Discourse.SiteSettings.adsense_post_bottom_ad_sizes));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -105,6 +106,8 @@ export default Ember.Component.extend({
|
|||
publisher_id: publisher_id,
|
||||
ad_width: ad_width,
|
||||
ad_height: ad_height,
|
||||
ad_mobile_width: ad_mobile_width,
|
||||
ad_mobile_height: ad_mobile_height,
|
||||
|
||||
init: function() {
|
||||
this.set('ad_width', data[this.placement]["ad_width"] );
|
||||
|
@ -123,8 +126,8 @@ export default Ember.Component.extend({
|
|||
}.property('adWrapperStyle'),
|
||||
|
||||
adWrapperStyleMobile: function() {
|
||||
return `width: 320px; height: 50px; margin:0 auto;`.htmlSafe();
|
||||
},
|
||||
return `width: ${this.get('ad_mobile_width')}px; height: ${this.get('ad_mobile_height')}px; margin:0 auto;`.htmlSafe();
|
||||
}.property('ad_mobile_width', 'ad_mobile_height'),
|
||||
|
||||
adInsStyleMobile: function() {
|
||||
return `display: inline-block; ${this.get('adWrapperStyleMobile')}`.htmlSafe();
|
||||
|
|
|
@ -3,6 +3,8 @@ import loadScript from 'discourse/lib/load-script';
|
|||
|
||||
var const_width = '';
|
||||
var const_height = '';
|
||||
var const_mobile_width = 320;
|
||||
var const_mobile_height = 50;
|
||||
var currentUser = Discourse.User.current();
|
||||
|
||||
var _loaded = false,
|
||||
|
@ -160,6 +162,8 @@ function loadGoogle(settings) {
|
|||
export default Ember.Component.extend({
|
||||
const_width: const_width,
|
||||
const_height: const_height,
|
||||
const_mobile_width: const_mobile_width,
|
||||
const_mobile_height: const_mobile_height,
|
||||
|
||||
classNames: ['google-dfp-ad'],
|
||||
loadedGoogletag: false,
|
||||
|
@ -174,8 +178,8 @@ export default Ember.Component.extend({
|
|||
}.property('const_width', 'const_height'),
|
||||
|
||||
adWrapperStyleMobile: function() {
|
||||
return `width: 320px; height: 50px;`.htmlSafe();
|
||||
},
|
||||
return `width: ${this.get('const_mobile_width')}px; height: ${this.get('const_mobile_height')}px;`.htmlSafe();
|
||||
}.property('const_mobile_width', 'const_mobile_height'),
|
||||
|
||||
_initGoogleDFP: function() {
|
||||
var self = this;
|
||||
|
|
Loading…
Reference in New Issue