Fixed merge conflicts
This commit is contained in:
commit
b0a97df0da
|
@ -3,6 +3,10 @@ import PageTracker from 'discourse/lib/page-tracker';
|
||||||
var ad_width = '';
|
var ad_width = '';
|
||||||
var ad_height = '';
|
var ad_height = '';
|
||||||
var ad_code = '';
|
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;
|
var publisher_id = Discourse.SiteSettings.adsense_publisher_code;
|
||||||
var preGoogleVars = null;
|
var preGoogleVars = null;
|
||||||
var postGoogleVars = null;
|
var postGoogleVars = null;
|
||||||
|
@ -20,43 +24,42 @@ function splitHeightInt(value) {
|
||||||
return str.trim();
|
return str.trim();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
PageTracker.current().on('change', function(url) {
|
PageTracker.current().on('change', function(url) {
|
||||||
|
|
||||||
|
|
||||||
var ads = document.getElementById("adsense_loader");
|
var ads = document.getElementById("adsense_loader");
|
||||||
if (ads) {
|
if (ads) {
|
||||||
// clear the old element and its state
|
|
||||||
//ads.remove();
|
|
||||||
ads.parentNode.removeChild(ads);
|
ads.parentNode.removeChild(ads);
|
||||||
for (var i = 0; i < postGoogleVars.length; i++) {
|
for (var key in window) {
|
||||||
var key = postGoogleVars[i];
|
if (key.indexOf("google") !== -1){
|
||||||
window[key] = undefined;
|
window[key] = undefined;
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(preGoogleVars === null) {
|
|
||||||
preGoogleVars = [];
|
|
||||||
for(var key in window) {
|
|
||||||
if(key.indexOf("google") !== -1) {
|
|
||||||
preGoogleVars.push(key);
|
|
||||||
}
|
}
|
||||||
}
|
// for (var i = 0; i < postGoogleVars.length; i++) {
|
||||||
}
|
// var key = postGoogleVars[i];
|
||||||
|
// window[key] = undefined;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// if(preGoogleVars === null) {
|
||||||
|
// preGoogleVars = [];
|
||||||
|
// for(var key in window) {
|
||||||
|
// if(key.indexOf("google") !== -1) {
|
||||||
|
// preGoogleVars.push(key);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true; ga.id="adsense_loader";
|
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true; ga.id="adsense_loader";
|
||||||
ga.src = '//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js';
|
ga.src = '//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js';
|
||||||
ga.addEventListener('load', function(e) {
|
// ga.addEventListener('load', function(e) {
|
||||||
if(postGoogleVars === null) {
|
// if(postGoogleVars === null) {
|
||||||
postGoogleVars = [];
|
// postGoogleVars = [];
|
||||||
|
|
||||||
for(var key in window) {
|
// for(var key in window) {
|
||||||
if(key.indexOf("google") !== -1 && preGoogleVars.indexOf(key) == -1) {
|
// if(key.indexOf("google") !== -1 && preGoogleVars.indexOf(key) == -1) {
|
||||||
postGoogleVars.push(key);
|
// postGoogleVars.push(key);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
});
|
// });
|
||||||
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
|
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
|
||||||
|
|
||||||
});
|
});
|
||||||
|
@ -70,22 +73,27 @@ var data = {
|
||||||
|
|
||||||
|
|
||||||
if (Discourse.SiteSettings.adsense_publisher_code) {
|
if (Discourse.SiteSettings.adsense_publisher_code) {
|
||||||
if (Discourse.SiteSettings.adsense_topic_list_top_code && !Discourse.SiteSettings.adsense_show_topic_list_top) {
|
if (!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;
|
if (!Discourse.Mobile.mobileView && 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_code"] = Discourse.SiteSettings.adsense_topic_list_top_code;
|
||||||
data["topic-list-top"]["ad_height"] = parseInt(splitHeightInt(Discourse.SiteSettings.adsense_topic_list_top_ad_sizes));
|
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) {
|
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_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_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));
|
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) {
|
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_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_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));
|
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) {
|
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_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_width"] = parseInt(splitWidthInt(Discourse.SiteSettings.adsense_post_bottom_ad_sizes));
|
||||||
data["post-bottom"]["ad_height"] = parseInt(splitHeightInt(Discourse.SiteSettings.adsense_post_bottom_ad_sizes));
|
data["post-bottom"]["ad_height"] = parseInt(splitHeightInt(Discourse.SiteSettings.adsense_post_bottom_ad_sizes));
|
||||||
|
@ -100,6 +108,8 @@ export default Ember.Component.extend({
|
||||||
publisher_id: publisher_id,
|
publisher_id: publisher_id,
|
||||||
ad_width: ad_width,
|
ad_width: ad_width,
|
||||||
ad_height: ad_height,
|
ad_height: ad_height,
|
||||||
|
ad_mobile_width: ad_mobile_width,
|
||||||
|
ad_mobile_height: ad_mobile_height,
|
||||||
|
|
||||||
mobile_width: mobile_width,
|
mobile_width: mobile_width,
|
||||||
mobile_height: mobile_height,
|
mobile_height: mobile_height,
|
||||||
|
@ -108,6 +118,7 @@ export default Ember.Component.extend({
|
||||||
this.set('ad_width', data[this.placement]["ad_width"] );
|
this.set('ad_width', data[this.placement]["ad_width"] );
|
||||||
this.set('ad_height', data[this.placement]["ad_height"] );
|
this.set('ad_height', data[this.placement]["ad_height"] );
|
||||||
this.set('ad_code', data[this.placement]["ad_code"] );
|
this.set('ad_code', data[this.placement]["ad_code"] );
|
||||||
|
this.set('ad_mobile_code', data[this.placement]["ad_mobile_code"] );
|
||||||
this._super();
|
this._super();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -120,8 +131,8 @@ export default Ember.Component.extend({
|
||||||
}.property('adWrapperStyle'),
|
}.property('adWrapperStyle'),
|
||||||
|
|
||||||
adWrapperStyleMobile: function() {
|
adWrapperStyleMobile: function() {
|
||||||
return `width: ${this.get('mobile_width')}px; height: ${this.get('mobile_height')}px; margin:0 auto;`.htmlSafe();
|
return `width: ${this.get('ad_mobile_width')}px; height: ${this.get('ad_mobile_height')}px; margin:0 auto;`.htmlSafe();
|
||||||
}.property('mobile_width', 'mobile_height'),
|
}.property('ad_mobile_width', 'ad_mobile_height'),
|
||||||
|
|
||||||
adInsStyleMobile: function() {
|
adInsStyleMobile: function() {
|
||||||
return `display: inline-block; ${this.get('adWrapperStyleMobile')}`.htmlSafe();
|
return `display: inline-block; ${this.get('adWrapperStyleMobile')}`.htmlSafe();
|
||||||
|
|
|
@ -3,6 +3,9 @@ import loadScript from 'discourse/lib/load-script';
|
||||||
|
|
||||||
var const_width = '';
|
var const_width = '';
|
||||||
var const_height = '';
|
var const_height = '';
|
||||||
|
var const_mobile_width = 320;
|
||||||
|
var const_mobile_height = 50;
|
||||||
|
var currentUser = Discourse.User.current();
|
||||||
|
|
||||||
var mobile_width = 320;
|
var mobile_width = 320;
|
||||||
var mobile_height = 50;
|
var mobile_height = 50;
|
||||||
|
@ -19,11 +22,6 @@ function splitHeightInt(value) {
|
||||||
var str = value.substring(4, 7);
|
var str = value.substring(4, 7);
|
||||||
return str.trim();
|
return str.trim();
|
||||||
}
|
}
|
||||||
/*
|
|
||||||
// Coaches Note!
|
|
||||||
// Background: We want to call on google.setTargeting using googletag.bar so that we can can take in inputs from users (key and value) for custom targeting.
|
|
||||||
// Look at 26 - 55 which should call on googletag.setTargeting.
|
|
||||||
// Error is occuring on link 49 which is returning "Uncaught ReferenceError: setTargeting is not defined"
|
|
||||||
|
|
||||||
// This creates an array for the values of the custom targeting key
|
// This creates an array for the values of the custom targeting key
|
||||||
function valueParse(value) {
|
function valueParse(value) {
|
||||||
|
@ -41,41 +39,6 @@ function keyParse(word) {
|
||||||
return key;
|
return key;
|
||||||
}
|
}
|
||||||
|
|
||||||
// This sets the key and value for custom targeting
|
|
||||||
var Foo = function(key, value, googletag) {
|
|
||||||
this.locationKey = key;
|
|
||||||
this.locationValue = value;
|
|
||||||
this.googletag = googletag;
|
|
||||||
}
|
|
||||||
|
|
||||||
// setTargeting is not defined. We want to return as a method - PROBLEM 1
|
|
||||||
Foo.prototype.bar = function() {
|
|
||||||
return this.googletag.setTargeting(this.locationKey, this.locationValue);
|
|
||||||
}
|
|
||||||
|
|
||||||
// This should call googletag.setTargeting(key for that location, value for that location)
|
|
||||||
function custom_targeting(key_array, value_array) {
|
|
||||||
for (var i = 0; i < key_array.length; i++) {
|
|
||||||
var wordValue = valueParse(value_array[i]);
|
|
||||||
var f = new Foo(key_array[i], wordValue, googletag);
|
|
||||||
f.bar();
|
|
||||||
console.log("works!");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// END of Coaches Note
|
|
||||||
|
|
||||||
// splitting values
|
|
||||||
/*var custom_values = [];
|
|
||||||
var word = keyParse(Discourse.SiteSettings.dfp_target_topic_list_top_value_code);
|
|
||||||
var wordValue;
|
|
||||||
for (var i = 0; i < word.length; i++) {
|
|
||||||
wordValue = valueParse(word[i]);
|
|
||||||
custom_values.push(wordValue);
|
|
||||||
}*/
|
|
||||||
|
|
||||||
|
|
||||||
//PageTracker.current().on('change', function(url) {
|
|
||||||
function loadGoogle(settings) {
|
function loadGoogle(settings) {
|
||||||
if (_loaded) {
|
if (_loaded) {
|
||||||
return Ember.RSVP.resolve();
|
return Ember.RSVP.resolve();
|
||||||
|
@ -94,57 +57,72 @@ function loadGoogle(settings) {
|
||||||
}
|
}
|
||||||
|
|
||||||
googletag.cmd.push(function() {
|
googletag.cmd.push(function() {
|
||||||
|
|
||||||
|
var topic_list_top = googletag.defineSlot('/' + settings.dfp_publisher_id + '/' + settings.dfp_topic_list_top_code, [parseInt(splitWidthInt(Discourse.SiteSettings.topic_list_top_ad_sizes)), parseInt(splitHeightInt(Discourse.SiteSettings.topic_list_top_ad_sizes))], 'div-gpt-ad-topic-list-top').addService(googletag.pubads());
|
||||||
|
var topic_above_post_stream = googletag.defineSlot('/' + settings.dfp_publisher_id + '/' + settings.dfp_topic_above_post_stream_code, [parseInt(splitWidthInt(Discourse.SiteSettings.topic_above_post_stream_top_ad_sizes)), parseInt(splitHeightInt(Discourse.SiteSettings.topic_above_post_stream_ad_sizes))], 'div-gpt-ad-topic-above-post-stream').addService(googletag.pubads());
|
||||||
|
var topic_above_suggested = googletag.defineSlot('/' + settings.dfp_publisher_id + '/' + settings.dfp_topic_above_suggested_code, [parseInt(splitWidthInt(Discourse.SiteSettings.topic_above_suggested_ad_sizes)), parseInt(splitHeightInt(Discourse.SiteSettings.topic_above_suggested_ad_sizes))], 'div-gpt-ad-topic-above-suggested').addService(googletag.pubads());
|
||||||
|
var post_bottom = googletag.defineSlot('/' + settings.dfp_publisher_id + '/' + settings.dfp_post_bottom_code, [parseInt(splitWidthInt(Discourse.SiteSettings.post_bottom_ad_sizes)), parseInt(splitHeightInt(Discourse.SiteSettings.post_bottom_ad_sizes))], 'div-gpt-ad-post-bottom').addService(googletag.pubads());
|
||||||
|
|
||||||
|
// This sets the key and value for custom targeting
|
||||||
|
var Foo = function(key, value, googletag) {
|
||||||
|
this.locationKey = key;
|
||||||
|
this.locationValue = value;
|
||||||
|
this.googletag = googletag;
|
||||||
|
}
|
||||||
|
|
||||||
|
// setTargeting is not defined. We want to return as a method - PROBLEM 1
|
||||||
|
Foo.prototype.bar = function() {
|
||||||
|
return this.googletag.setTargeting(this.locationKey, this.locationValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
// This should call googletag.setTargeting(key for that location, value for that location)
|
||||||
|
function custom_targeting(key_array, value_array, location) {
|
||||||
|
var f;
|
||||||
|
for (var i = 0; i < key_array.length; i++) {
|
||||||
|
var wordValue = valueParse(value_array[i]);
|
||||||
|
f = new Foo(key_array[i], wordValue, location);
|
||||||
|
f.bar();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (settings.dfp_topic_list_top_code && !settings.dfp_show_topic_list_top && settings.topic_list_top_ad_sizes) {
|
if (settings.dfp_topic_list_top_code && !settings.dfp_show_topic_list_top && settings.topic_list_top_ad_sizes) {
|
||||||
const_width = parseInt(splitWidthInt(settings.topic_list_top_ad_sizes));
|
const_width = parseInt(splitWidthInt(settings.topic_list_top_ad_sizes));
|
||||||
const_height = parseInt(splitHeightInt(settings.topic_list_top_ad_sizes));
|
const_height = parseInt(splitHeightInt(settings.topic_list_top_ad_sizes));
|
||||||
if (Discourse.Mobile.mobileView) {
|
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_publisher_id + '/' + settings.dfp_topic_list_top_code, [320,50], 'div-gpt-ad-topic-list-top').addService(googletag.pubads());
|
||||||
}
|
}
|
||||||
else {
|
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')
|
custom_targeting((keyParse(Discourse.SiteSettings.dfp_target_topic_list_top_key_code)), (keyParse(Discourse.SiteSettings.dfp_target_topic_list_top_value_code)), topic_list_top)
|
||||||
//custom_targeting((keyParse(Discourse.SiteSettings.dfp_target_topic_list_top_key_code)), (keyParse(Discourse.SiteSettings.dfp_target_topic_list_top_value_code)))
|
|
||||||
.setTargeting('gender', 'female')
|
|
||||||
.addService(googletag.pubads());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (settings.dfp_topic_above_post_stream_code && !settings.dfp_show_topic_above_post_stream && settings.topic_above_post_stream_ad_sizes) {
|
if (settings.dfp_topic_above_post_stream_code && !settings.dfp_show_topic_above_post_stream && settings.topic_above_post_stream_ad_sizes) {
|
||||||
const_width = parseInt(splitWidthInt(settings.topic_above_post_stream_ad_sizes));
|
const_width = parseInt(splitWidthInt(settings.topic_above_post_stream_ad_sizes));
|
||||||
const_height = parseInt(splitHeightInt(settings.topic_above_post_stream_ad_sizes));
|
const_height = parseInt(splitHeightInt(settings.topic_above_post_stream_ad_sizes));
|
||||||
if (Discourse.Mobile.mobileView) {
|
if (Discourse.Mobile.mobileView) {
|
||||||
googletag.defineSlot(settings.dfp_topic_above_post_stream_code, [320,50], 'div-gpt-ad-topic-above-post-stream').addService(googletag.pubads());
|
googletag.defineSlot('/' + settings.dfp_publisher_id + '/' + settings.dfp_topic_above_post_stream_code, [320,50], 'div-gpt-ad-topic-above-post-stream').addService(googletag.pubads());
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
googletag.defineSlot('/' + settings.dfp_publisher_id + '/' + settings.dfp_topic_above_post_stream_code, [parseInt(splitWidthInt(settings.topic_above_post_stream_ad_sizes)), parseInt(splitHeightInt(settings.topic_above_post_stream_ad_sizes))], 'div-gpt-ad-topic-above-post-stream')
|
custom_targeting((keyParse(Discourse.SiteSettings.dfp_target_topic_above_post_stream_key_code)), (keyParse(Discourse.SiteSettings.dfp_target_topic_above_post_stream_value_code)), topic_above_post_stream)
|
||||||
//.setTargeting(settings.dfp_target_topic_above_post_stream_key_code, valueParse(settings.dfp_target_topic_above_post_stream_value_code))
|
|
||||||
// This hardcoded code works: .setTargeting('category', ["clothes", "handbags", "makeup"])
|
|
||||||
.addService(googletag.pubads());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (settings.dfp_topic_above_suggested_code && !settings.dfp_show_topic_above_suggested && settings.topic_above_suggested_ad_sizes) {
|
if (settings.dfp_topic_above_suggested_code && !settings.dfp_show_topic_above_suggested && settings.topic_above_suggested_ad_sizes) {
|
||||||
const_width = parseInt(splitWidthInt(settings.topic_above_suggested_ad_sizes));
|
const_width = parseInt(splitWidthInt(settings.topic_above_suggested_ad_sizes));
|
||||||
const_height = parseInt(splitHeightInt(settings.topic_above_suggested_ad_sizes));
|
const_height = parseInt(splitHeightInt(settings.topic_above_suggested_ad_sizes));
|
||||||
if (Discourse.Mobile.mobileView) {
|
if (Discourse.Mobile.mobileView) {
|
||||||
googletag.defineSlot(settings.dfp_topic_above_suggested_code, [320,50], 'div-gpt-ad-topic-above-suggested').addService(googletag.pubads());
|
googletag.defineSlot('/' + settings.dfp_publisher_id + '/' + settings.dfp_topic_above_suggested_code, [320,50], 'div-gpt-ad-topic-above-suggested').addService(googletag.pubads());
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
googletag.defineSlot('/' + settings.dfp_publisher_id + '/' + settings.dfp_topic_above_suggested_code, [parseInt(splitWidthInt(settings.topic_above_suggested_ad_sizes)), parseInt(splitHeightInt(settings.topic_above_suggested_ad_sizes))], 'div-gpt-ad-topic-above-suggested')
|
custom_targeting((keyParse(Discourse.SiteSettings.dfp_target_topic_above_suggested_key_code)), (keyParse(Discourse.SiteSettings.dfp_target_topic_above_suggested_value_code)), topic_above_suggested)
|
||||||
|
|
||||||
//googletag.setTargeting(settings.dfp_target_topic_above_suggested_key_code, valueParse(settings.dfp_target_topic_above_suggested_value_code))
|
|
||||||
// This hardcoded code works: .setTargeting('category', ["clothes", "handbags", "makeup"])
|
|
||||||
googletag.addService(googletag.pubads());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (settings.dfp_post_bottom_code && !settings.dfp_show_post_bottom && settings.post_bottom_ad_sizes) {
|
if (settings.dfp_post_bottom_code && !settings.dfp_show_post_bottom && settings.post_bottom_ad_sizes) {
|
||||||
const_width = parseInt(splitWidthInt(settings.post_bottom_ad_sizes));
|
const_width = parseInt(splitWidthInt(settings.post_bottom_ad_sizes));
|
||||||
const_height = parseInt(splitHeightInt(settings.post_bottom_ad_sizes));
|
const_height = parseInt(splitHeightInt(settings.post_bottom_ad_sizes));
|
||||||
if (Discourse.Mobile.mobileView) {
|
if (Discourse.Mobile.mobileView) {
|
||||||
googletag.defineSlot(settings.dfp_post_bottom_code, [320,50], 'div-gpt-ad-post-bottom').addService(googletag.pubads());
|
googletag.defineSlot('/' + settings.dfp_publisher_id + '/' + settings.dfp_post_bottom_code, [320,50], 'div-gpt-ad-post-bottom').addService(googletag.pubads());
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
googletag.defineSlot('/' + settings.dfp_publisher_id + '/' + settings.dfp_post_bottom_code, [parseInt(splitWidthInt(settings.post_bottom_ad_sizes)), parseInt(splitHeightInt(settings.post_bottom_ad_sizes))], 'div-gpt-ad-post-bottom')
|
custom_targeting((keyParse(Discourse.SiteSettings.dfp_target_post_bottom_key_code)), (keyParse(Discourse.SiteSettings.dfp_target_post_bottom_value_code)), post_bottom)
|
||||||
//.setTargeting(settings.dfp_target_post_bottom_key_code, valueParse(settings.dfp_target_post_bottom_value_code))
|
|
||||||
// This hardcoded code works: .setTargeting('category', ["clothes", "handbags", "makeup"])
|
|
||||||
.addService(googletag.pubads());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -162,6 +140,8 @@ function loadGoogle(settings) {
|
||||||
export default Ember.Component.extend({
|
export default Ember.Component.extend({
|
||||||
const_width: const_width,
|
const_width: const_width,
|
||||||
const_height: const_height,
|
const_height: const_height,
|
||||||
|
const_mobile_width: const_mobile_width,
|
||||||
|
const_mobile_height: const_mobile_height,
|
||||||
|
|
||||||
classNames: ['google-dfp-ad'],
|
classNames: ['google-dfp-ad'],
|
||||||
loadedGoogletag: false,
|
loadedGoogletag: false,
|
||||||
|
@ -179,8 +159,12 @@ export default Ember.Component.extend({
|
||||||
}.property('const_width', 'const_height'),
|
}.property('const_width', 'const_height'),
|
||||||
|
|
||||||
adWrapperStyleMobile: function() {
|
adWrapperStyleMobile: function() {
|
||||||
return `width: ${this.get('mobile_width')}px; height: ${this.get('mobile_height')}px; margin:0 auto;`.htmlSafe();
|
return `width: ${this.get('const_mobile_width')}px; height: ${this.get('const_mobile_height')}px;`.htmlSafe();
|
||||||
}.property('mobile_width', 'mobile_height'),
|
}.property('const_mobile_width', 'const_mobile_height'),
|
||||||
|
|
||||||
|
checkTrustLevels: function() {
|
||||||
|
return !((currentUser) && (currentUser.get('trust_level') > Discourse.SiteSettings.dfp_through_trust_level));
|
||||||
|
}.property('trust_level'),
|
||||||
|
|
||||||
_initGoogleDFP: function() {
|
_initGoogleDFP: function() {
|
||||||
var self = this;
|
var self = this;
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
<ins class="adsbygoogle"
|
<ins class="adsbygoogle"
|
||||||
style={{adInsStyleMobile}}
|
style={{adInsStyleMobile}}
|
||||||
data-ad-client="ca-pub-{{publisher_id}}"
|
data-ad-client="ca-pub-{{publisher_id}}"
|
||||||
data-ad-slot={{ad_code}}>
|
data-ad-slot={{ad_mobile_code}}>
|
||||||
</ins>
|
</ins>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
@ -12,7 +12,6 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{{else}}
|
{{else}}
|
||||||
<div class="google-adsense-label"><h2>Google Adsense</h2></div>
|
|
||||||
<div style={{adWrapperStyle}}>
|
<div style={{adWrapperStyle}}>
|
||||||
<ins class="adsbygoogle"
|
<ins class="adsbygoogle"
|
||||||
style={{adInsStyle}}
|
style={{adInsStyle}}
|
||||||
|
|
|
@ -1,20 +1,22 @@
|
||||||
<div class="google-dfp-ad-label"><h2>Google Ad Plugin Display</h2></div>
|
|
||||||
|
|
||||||
{{#if site.mobileView}}
|
{{#if site.mobileView}}
|
||||||
{{#if loadedGoogletag}}
|
{{#if loadedGoogletag}}
|
||||||
<div id={{divId}} style={{adWrapperStyleMobile}} class="dfp-ad-unit" align=center>
|
{{#if checkTrustLevels}}
|
||||||
<script type='text/javascript'>
|
<div id={{divId}} style={{adWrapperStyleMobile}} class="dfp-ad-unit" align=center>
|
||||||
googletag.cmd.push(function() { googletag.display('{{divId}}'); });
|
<script type='text/javascript'>
|
||||||
</script>
|
googletag.cmd.push(function() { googletag.display('{{divId}}'); });
|
||||||
</div>
|
</script>
|
||||||
|
</div>
|
||||||
|
{{/if}}
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
||||||
{{else}}
|
{{else}}
|
||||||
{{#if loadedGoogletag}}
|
{{#if loadedGoogletag}}
|
||||||
<div id={{divId}} style={{adWrapperStyle}} class="dfp-ad-unit" align=center>
|
{{#if checkTrustLevels}}
|
||||||
<script type='text/javascript'>
|
<div id={{divId}} style={{adWrapperStyle}} class="dfp-ad-unit" align=center>
|
||||||
googletag.cmd.push(function() { googletag.display('{{divId}}'); });
|
<script type='text/javascript'>
|
||||||
</script>
|
googletag.cmd.push(function() { googletag.display('{{divId}}'); });
|
||||||
</div>
|
</script>
|
||||||
|
</div>
|
||||||
|
{{/if}}
|
||||||
{{/if}}
|
{{/if}}
|
||||||
{{/if}}
|
{{/if}}
|
|
@ -3,5 +3,5 @@ en:
|
||||||
admin:
|
admin:
|
||||||
site_settings:
|
site_settings:
|
||||||
categories:
|
categories:
|
||||||
ad_plugin: 'Ad Plugin'
|
ad_plugin: 'DFP Plugin'
|
||||||
adsense_plugin: 'Adsense Plugin'
|
adsense_plugin: 'Adsense Plugin'
|
|
@ -1,38 +1,48 @@
|
||||||
en:
|
en:
|
||||||
site_settings:
|
site_settings:
|
||||||
dfp_publisher_id: "Put in your publisher id here"
|
dfp_publisher_id: "Put in your publisher id here"
|
||||||
|
dfp_through_trust_level: "Show your ads to users based on trust."
|
||||||
dfp_show_topic_list_top: "Disable topic_list_top ad"
|
dfp_show_topic_list_top: "Disable topic_list_top ad"
|
||||||
dfp_topic_list_top_code: "Show leaderboard ad above topic lists."
|
dfp_topic_list_top_code: "Show leaderboard ad above topic lists."
|
||||||
|
dfp_mobile_topic_list_top_code: "Mobile - Show leaderboard ad above topic lists."
|
||||||
topic_list_top_ad_sizes: "Choose your ad size"
|
topic_list_top_ad_sizes: "Choose your ad size"
|
||||||
dfp_target_topic_list_top_key_code: "Input key values - Inventory Level"
|
dfp_target_topic_list_top_key_code: "Input key values - Inventory Level"
|
||||||
dfp_target_topic_list_top_value_code: "Input key values - Inventory Level"
|
dfp_target_topic_list_top_value_code: "Input key values - Inventory Level"
|
||||||
dfp_show_topic_above_post_stream: "Disable topic_above_post_stream ad"
|
dfp_show_topic_above_post_stream: "Disable topic_above_post_stream ad"
|
||||||
dfp_topic_above_post_stream_code: "Show leaderboard ad above post stream"
|
dfp_topic_above_post_stream_code: "Show leaderboard ad above post stream"
|
||||||
|
dfp_mobile_topic_above_post_stream_code: "Mobile - Show leaderboard ad above post stream"
|
||||||
topic_above_post_stream_ad_sizes: "Choose your ad size"
|
topic_above_post_stream_ad_sizes: "Choose your ad size"
|
||||||
dfp_target_topic_above_post_stream_key_code: "Input key values - Inventory Level"
|
dfp_target_topic_above_post_stream_key_code: "Input key values - Inventory Level"
|
||||||
dfp_target_topic_above_post_stream_value_code: "Input key values - Inventory Level"
|
dfp_target_topic_above_post_stream_value_code: "Input key values - Inventory Level"
|
||||||
dfp_show_topic_above_suggested: "Disable topic_above_suggested ad"
|
dfp_show_topic_above_suggested: "Disable topic_above_suggested ad"
|
||||||
dfp_topic_above_suggested_code: "Show leaderboard ad above suggested topics"
|
dfp_topic_above_suggested_code: "Show leaderboard ad above suggested topics"
|
||||||
|
dfp_mobile_topic_above_suggested_code: "Mobile - Show leaderboard ad above suggested topics"
|
||||||
topic_above_suggested_ad_sizes: "Choose your ad size"
|
topic_above_suggested_ad_sizes: "Choose your ad size"
|
||||||
dfp_target_topic_above_suggested_key_code: "Input key values - Inventory Level"
|
dfp_target_topic_above_suggested_key_code: "Input key values - Inventory Level"
|
||||||
dfp_target_topic_above_suggested_value_code: "Input key values - Inventory Level"
|
dfp_target_topic_above_suggested_value_code: "Input key values - Inventory Level"
|
||||||
dfp_show_post_bottom: "Disable post_bottom ad"
|
dfp_show_post_bottom: "Disable post_bottom ad"
|
||||||
dfp_post_bottom_code: "Show leaderboard ad post_bottom topics"
|
dfp_post_bottom_code: "Show leaderboard ad post_bottom topics"
|
||||||
|
dfp_mobile_post_bottom_code: "Mobile - Show leaderboard ad post_bottom topics"
|
||||||
dfp_nth_post_code: "Choose the Nth position for your ad to show"
|
dfp_nth_post_code: "Choose the Nth position for your ad to show"
|
||||||
post_bottom_ad_sizes: "Choose your ad size"
|
post_bottom_ad_sizes: "Choose your ad size"
|
||||||
dfp_target_post_bottom_key_code: "Input key values - Inventory Level"
|
dfp_target_post_bottom_key_code: "Input key values - Inventory Level"
|
||||||
dfp_target_post_bottom_value_code: "Input key values - Inventory Level"
|
dfp_target_post_bottom_value_code: "Input key values - Inventory Level"
|
||||||
adsense_publisher_code: "Insert your Publisher ID here"
|
adsense_publisher_code: "Insert your Publisher ID here"
|
||||||
|
adsense_through_trust_level: "Show your ads to users based on trust."
|
||||||
adsense_show_topic_list_top: "Disable topic_list_top ad"
|
adsense_show_topic_list_top: "Disable topic_list_top ad"
|
||||||
adsense_topic_list_top_code: "Show leaderboard ad above topic lists."
|
adsense_topic_list_top_code: "Show leaderboard ad above topic lists."
|
||||||
|
adsense_mobile_topic_list_top_code: "Mobile - Show leaderboard ad above topic lists."
|
||||||
adsense_topic_list_top_ad_sizes: "Choose your ad sizes"
|
adsense_topic_list_top_ad_sizes: "Choose your ad sizes"
|
||||||
adsense_show_topic_above_post_stream: "Disable topic_above_post_stream ad"
|
adsense_show_topic_above_post_stream: "Disable topic_above_post_stream ad"
|
||||||
adsense_topic_above_post_stream_code: "Show leaderboard ad above post stream"
|
adsense_topic_above_post_stream_code: "Show leaderboard ad above post stream"
|
||||||
|
adsense_mobile_topic_above_post_stream_code: "Mobile - Show leaderboard ad above post stream"
|
||||||
adsense_topic_above_post_stream_ad_sizes: "Choose your ad sizes"
|
adsense_topic_above_post_stream_ad_sizes: "Choose your ad sizes"
|
||||||
adsense_show_topic_above_suggested: "Disable topic_above_suggested ad"
|
adsense_show_topic_above_suggested: "Disable topic_above_suggested ad"
|
||||||
adsense_topic_above_suggested_code: "Show leaderboard ad above suggested topics"
|
adsense_topic_above_suggested_code: "Show leaderboard ad above suggested topics"
|
||||||
|
adsense_mobile_topic_above_suggested_code: "Mobile - Show leaderboard ad above suggested topics"
|
||||||
adsense_topic_above_suggested_ad_sizes: "Choose your ad sizes"
|
adsense_topic_above_suggested_ad_sizes: "Choose your ad sizes"
|
||||||
adsense_post_bottom_code: "Show leaderboard ad post_bottom topics"
|
adsense_post_bottom_code: "Show leaderboard ad post_bottom topics"
|
||||||
|
adsense_mobile_post_bottom_code: "Mobile - Show leaderboard ad post_bottom topics"
|
||||||
adsense_show_post_bottom: "Disable post_bottom ad"
|
adsense_show_post_bottom: "Disable post_bottom ad"
|
||||||
adsense_post_bottom_ad_sizes: "Choose your ad sizes"
|
adsense_post_bottom_ad_sizes: "Choose your ad sizes"
|
||||||
adsense_nth_post_code: "Choose the Nth position for your ad to show"
|
adsense_nth_post_code: "Choose the Nth position for your ad to show"
|
|
@ -2,9 +2,16 @@ adsense_plugin:
|
||||||
adsense_publisher_code:
|
adsense_publisher_code:
|
||||||
client: true
|
client: true
|
||||||
default: ''
|
default: ''
|
||||||
|
adsense_through_trust_level:
|
||||||
|
client: true
|
||||||
|
default: 2
|
||||||
|
enum: 'TrustLevelSetting'
|
||||||
adsense_topic_list_top_code:
|
adsense_topic_list_top_code:
|
||||||
client: true
|
client: true
|
||||||
default: ''
|
default: ''
|
||||||
|
adsense_mobile_topic_list_top_code:
|
||||||
|
client: true
|
||||||
|
default: ''
|
||||||
adsense_show_topic_list_top:
|
adsense_show_topic_list_top:
|
||||||
client: true
|
client: true
|
||||||
default: false
|
default: false
|
||||||
|
@ -26,6 +33,9 @@ adsense_plugin:
|
||||||
adsense_topic_above_post_stream_code:
|
adsense_topic_above_post_stream_code:
|
||||||
client: true
|
client: true
|
||||||
default: ''
|
default: ''
|
||||||
|
adsense_mobile_topic_above_post_stream_code:
|
||||||
|
client: true
|
||||||
|
default: ''
|
||||||
adsense_show_topic_above_post_stream:
|
adsense_show_topic_above_post_stream:
|
||||||
client: true
|
client: true
|
||||||
default: false
|
default: false
|
||||||
|
@ -47,6 +57,9 @@ adsense_plugin:
|
||||||
adsense_topic_above_suggested_code:
|
adsense_topic_above_suggested_code:
|
||||||
client: true
|
client: true
|
||||||
default: ''
|
default: ''
|
||||||
|
adsense_mobile_topic_above_suggested_code:
|
||||||
|
client: true
|
||||||
|
default: ''
|
||||||
adsense_show_topic_above_suggested:
|
adsense_show_topic_above_suggested:
|
||||||
client: true
|
client: true
|
||||||
default: false
|
default: false
|
||||||
|
@ -68,6 +81,9 @@ adsense_plugin:
|
||||||
adsense_post_bottom_code:
|
adsense_post_bottom_code:
|
||||||
client: true
|
client: true
|
||||||
default: ''
|
default: ''
|
||||||
|
adsense_mobile_post_bottom_code:
|
||||||
|
client: true
|
||||||
|
default: ''
|
||||||
adsense_show_post_bottom:
|
adsense_show_post_bottom:
|
||||||
client: true
|
client: true
|
||||||
default: false
|
default: false
|
||||||
|
@ -94,9 +110,16 @@ ad_plugin:
|
||||||
dfp_publisher_id:
|
dfp_publisher_id:
|
||||||
client: true
|
client: true
|
||||||
default: ''
|
default: ''
|
||||||
|
dfp_through_trust_level:
|
||||||
|
client: true
|
||||||
|
default: 2
|
||||||
|
enum: 'TrustLevelSetting'
|
||||||
dfp_topic_list_top_code:
|
dfp_topic_list_top_code:
|
||||||
client: true
|
client: true
|
||||||
default: ''
|
default: ''
|
||||||
|
dfp_mobile_topic_list_top_code:
|
||||||
|
client: true
|
||||||
|
default: ''
|
||||||
topic_list_top_ad_sizes:
|
topic_list_top_ad_sizes:
|
||||||
client: true
|
client: true
|
||||||
default: '728*90 - leaderboard'
|
default: '728*90 - leaderboard'
|
||||||
|
@ -126,6 +149,9 @@ ad_plugin:
|
||||||
dfp_topic_above_post_stream_code:
|
dfp_topic_above_post_stream_code:
|
||||||
client: true
|
client: true
|
||||||
default: ''
|
default: ''
|
||||||
|
dfp_mobile_topic_above_post_stream_code:
|
||||||
|
client: true
|
||||||
|
default: ''
|
||||||
topic_above_post_stream_ad_sizes:
|
topic_above_post_stream_ad_sizes:
|
||||||
client: true
|
client: true
|
||||||
default: '728*90 - leaderboard'
|
default: '728*90 - leaderboard'
|
||||||
|
@ -155,6 +181,9 @@ ad_plugin:
|
||||||
dfp_topic_above_suggested_code:
|
dfp_topic_above_suggested_code:
|
||||||
client: true
|
client: true
|
||||||
default: ''
|
default: ''
|
||||||
|
dfp_mobile_topic_above_suggested_code:
|
||||||
|
client: true
|
||||||
|
default: ''
|
||||||
topic_above_suggested_ad_sizes:
|
topic_above_suggested_ad_sizes:
|
||||||
client: true
|
client: true
|
||||||
default: '728*90 - leaderboard'
|
default: '728*90 - leaderboard'
|
||||||
|
@ -184,6 +213,9 @@ ad_plugin:
|
||||||
dfp_post_bottom_code:
|
dfp_post_bottom_code:
|
||||||
client: true
|
client: true
|
||||||
default: ''
|
default: ''
|
||||||
|
dfp_mobile_post_bottom_code:
|
||||||
|
client: true
|
||||||
|
default: ''
|
||||||
dfp_nth_post_code:
|
dfp_nth_post_code:
|
||||||
client: true
|
client: true
|
||||||
default: ''
|
default: ''
|
||||||
|
|
Loading…
Reference in New Issue