diff --git a/assets/javascripts/discourse/components/amazon-product-links.js.es6 b/assets/javascripts/discourse/components/amazon-product-links.js.es6 new file mode 100644 index 0000000..240cb76 --- /dev/null +++ b/assets/javascripts/discourse/components/amazon-product-links.js.es6 @@ -0,0 +1,116 @@ +var amazon_width = ''; +var amazon_height = ''; +var mobile_amazon_width = ''; +var mobile_amazon_height = ''; +var user_input = ''; +var user_input_mobile = ''; +var currentUser = Discourse.User.current(); + +function splitWidthInt(value) { + var str = value.substring(0, 3); + return str.trim(); +} + +function splitHeightInt(value) { + var str = value.substring(0, 3); + return str.trim(); +} + +var data = { + "topic-list-top" : {}, + "topic-above-post-stream" : {}, + "topic-above-suggested" : {}, + "post-bottom" : {} +} + + +if (!Discourse.Mobile.mobileView && Discourse.SiteSettings.amazon_topic_list_top_src_code) { + data["topic-list-top"]["user_input"] = Discourse.SiteSettings.amazon_topic_list_top_src_code; + data["topic-list-top"]["amazon_width"] = parseInt(Discourse.SiteSettings.amazon_topic_list_top_ad_width_code); + data["topic-list-top"]["amazon_height"] = parseInt(Discourse.SiteSettings.amazon_topic_list_top_ad_height_code); +} + +if (Discourse.Mobile.mobileView && Discourse.SiteSettings.amazon_mobile_topic_list_top_src_code) { + data["topic-list-top"]["user_input_mobile"] = Discourse.SiteSettings.amazon_mobile_topic_list_top_src_code; + data["topic-list-top"]["mobile_amazon_width"] = parseInt(Discourse.SiteSettings.amazon_mobile_topic_list_top_ad_width_code); + data["topic-list-top"]["mobile_amazon_height"] = parseInt(Discourse.SiteSettings.amazon_mobile_topic_list_top_ad_height_code); +} + +if (!Discourse.Mobile.mobileView && Discourse.SiteSettings.amazon_topic_above_post_stream_src_code) { + data["topic-above-post-stream"]["user_input"] = Discourse.SiteSettings.amazon_topic_above_post_stream_src_code; + data["topic-above-post-stream"]["amazon_width"] = parseInt(Discourse.SiteSettings.amazon_topic_above_post_stream_ad_width_code); + data["topic-above-post-stream"]["amazon_height"] = parseInt(Discourse.SiteSettings.amazon_topic_above_post_stream_ad_height_code); +} + +if (Discourse.Mobile.mobileView && Discourse.SiteSettings.amazon_mobile_topic_above_post_stream_src_code) { + data["topic-above-post-stream"]["user_input_mobile"] = Discourse.SiteSettings.amazon_mobile_topic_above_post_stream_src_code; + data["topic-above-post-stream"]["mobile_amazon_width"] = parseInt(Discourse.SiteSettings.amazon_mobile_topic_above_post_stream_ad_width_code); + data["topic-above-post-stream"]["mobile_amazon_height"] = parseInt(Discourse.SiteSettings.amazon_mobile_topic_above_post_stream_ad_height_code); +} + +if (!Discourse.Mobile.mobileView && Discourse.SiteSettings.amazon_topic_above_suggested_src_code) { + data["topic-above-suggested"]["user_input"] = Discourse.SiteSettings.amazon_topic_above_suggested_src_code; + data["topic-above-suggested"]["amazon_width"] = parseInt(Discourse.SiteSettings.amazon_topic_above_suggested_ad_width_code); + data["topic-above-suggested"]["amazon_height"] = parseInt(Discourse.SiteSettings.amazon_topic_above_suggested_ad_height_code); +} + +if (Discourse.Mobile.mobileView && Discourse.SiteSettings.amazon_mobile_topic_above_sugggested_src_code) { + data["topic-above-suggested"]["user_input_mobile"] = Discourse.SiteSettings.amazon_mobile_topic_above_suggested_src_code; + data["topic-above-suggested"]["mobile_amazon_width"] = parseInt(Discourse.SiteSettings.amazon_mobile_topic_above_suggested_ad_width_code); + data["topic-above-suggested"]["mobile_amazon_height"] = parseInt(Discourse.SiteSettings.amazon_mobile_topic_above_suggested_ad_height_code); +} + +if (!Discourse.Mobile.mobileView && Discourse.SiteSettings.amazon_post_bottom_src_code) { + data["post-bottom"]["user_input"] = Discourse.SiteSettings.amazon_post_bottom_src_code; + data["post-bottom"]["amazon_width"] = parseInt(Discourse.SiteSettings.amazon_post_bottom_ad_width_code); + data["post-bottom"]["amazon_height"] = parseInt(Discourse.SiteSettings.amazon_post_bottom_ad_height_code); +} + +if (Discourse.Mobile.mobileView && Discourse.SiteSettings.amazon_mobile_post_bottom_src_code) { + data["post-bottom"]["user_input_mobile"] = Discourse.SiteSettings.amazon_mobile_post_bottom_src_code; + data["post-bottom"]["mobile_amazon_width"] = parseInt(Discourse.SiteSettings.amazon_mobile_post_bottom_ad_width_code); + data["post-bottom"]["mobile_amazon_height"] = parseInt(Discourse.SiteSettings.amazon_mobile_post_bottom_ad_height_code); +} + + +export default Ember.Component.extend({ + amazon_width: amazon_width, + amazon_height: amazon_height, + mobile_amazon_width: mobile_amazon_width, + mobile_amazon_height: mobile_amazon_height, + user_input: user_input, + user_input_mobile: user_input_mobile, + + classNames: ['amazon-product-links'], + + init: function() { + this.set('user_input', data[this.placement]["user_input"] ); + this.set('amazon_width', data[this.placement]["amazon_width"] ); + this.set('amazon_height', data[this.placement]["amazon_height"] ); + this.set('user_input_mobile', data[this.placement]["user_input_mobile"] ); + this.set('mobile_amazon_height', data[this.placement]["mobile_amazon_height"] ); + this.set('mobile_amazon_width', data[this.placement]["mobile_amazon_width"] ); + this._super(); + }, + + adWrapperStyle: function() { + return `width: ${this.get('amazon_width')}px; height: ${this.get('amazon_height')}px;`.htmlSafe(); + }.property('amazon_width', 'amazon_height'), + + adWrapperStyleMobile: function() { + return `width: ${this.get('mobile_amazon_width')}px; height: ${this.get('mobile_amazon_height')}px;`.htmlSafe(); + }.property('mobile_amazon_width', 'mobile_amazon_height'), + + userInput: function() { + return `${this.get('user_input')}`.htmlSafe(); + }.property('user_input'), + + userInputMobile: function() { + return `${this.get('user_input_mobile')}`.htmlSafe(); + }.property('user_input_mobile'), + + checkTrustLevels: function() { + return !((currentUser) && (currentUser.get('trust_level') > Discourse.SiteSettings.amazon_through_trust_level)); + }.property('trust_level'), + +}); \ No newline at end of file diff --git a/assets/javascripts/discourse/components/google-adsense.js.es6 b/assets/javascripts/discourse/components/google-adsense.js.es6 index f368071..b1626ce 100644 --- a/assets/javascripts/discourse/components/google-adsense.js.es6 +++ b/assets/javascripts/discourse/components/google-adsense.js.es6 @@ -52,7 +52,7 @@ 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.SiteSettings.adsense_show_topic_list_top) { 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)); @@ -62,7 +62,7 @@ if (Discourse.SiteSettings.adsense_publisher_code) { data["topic-list-top"]["ad_mobile_code"] = Discourse.SiteSettings.adsense_mobile_topic_list_top_code; } } - if (!Discourse.SiteSettings.adsense_show_topic_above_post_stream && !((currentUser) && (currentUser.get('trust_level') > Discourse.SiteSettings.adsense_through_trust_level))) { + if (!Discourse.SiteSettings.adsense_show_topic_above_post_stream) { if (!Discourse.Mobile.mobileView && 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)); @@ -72,7 +72,7 @@ if (Discourse.SiteSettings.adsense_publisher_code) { data["topic-above-post-stream"]["ad_mobile_code"] = Discourse.SiteSettings.adsense_mobile_topic_above_post_stream_code; } } - if (!Discourse.SiteSettings.adsense_show_topic_above_suggested && !((currentUser) && (currentUser.get('trust_level') > Discourse.SiteSettings.adsense_through_trust_level))) { + if (!Discourse.SiteSettings.adsense_show_topic_above_suggested) { if (!Discourse.Mobile.mobileView && 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)); @@ -82,7 +82,7 @@ if (Discourse.SiteSettings.adsense_publisher_code) { data["topic-above-suggested"]["ad_mobile_code"] = Discourse.SiteSettings.adsense_mobile_topic_above_suggested_code; } } - if (!Discourse.SiteSettings.adsense_show_post_bottom && !((currentUser) && (currentUser.get('trust_level') > Discourse.SiteSettings.adsense_through_trust_level))) { + if (!Discourse.SiteSettings.adsense_show_post_bottom) { if (!Discourse.Mobile.mobileView && 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)); @@ -131,4 +131,8 @@ export default Ember.Component.extend({ adInsStyleMobile: function() { return `display: inline-block; ${this.get('adWrapperStyleMobile')}`.htmlSafe(); }.property('adWrapperStyleMobile'), + + checkTrustLevels: function() { + return !((currentUser) && (currentUser.get('trust_level') > Discourse.SiteSettings.adsense_through_trust_level)); + }.property('trust_level'), }); \ No newline at end of file diff --git a/assets/javascripts/discourse/templates/components/amazon-product-links.hbs b/assets/javascripts/discourse/templates/components/amazon-product-links.hbs new file mode 100644 index 0000000..5ddf9b5 --- /dev/null +++ b/assets/javascripts/discourse/templates/components/amazon-product-links.hbs @@ -0,0 +1,11 @@ +{{#if checkTrustLevels}} + {{#if site.mobileView}} + + {{else}} +
+ +
+ {{/if}} +{{/if}} \ No newline at end of file diff --git a/assets/javascripts/discourse/templates/components/google-adsense.hbs b/assets/javascripts/discourse/templates/components/google-adsense.hbs index 1401e5d..53c645d 100644 --- a/assets/javascripts/discourse/templates/components/google-adsense.hbs +++ b/assets/javascripts/discourse/templates/components/google-adsense.hbs @@ -1,27 +1,29 @@ -{{#if site.mobileView}} -
- - - - -
-{{else}} -
- - +{{#if checkTrustLevels}} + {{#if site.mobileView}} +
+ + + + +
+ {{else}} +
+ + - -
+ +
+ {{/if}} {{/if}} diff --git a/assets/javascripts/discourse/templates/components/google-dfp-ad.hbs b/assets/javascripts/discourse/templates/components/google-dfp-ad.hbs index 256bf73..480e1cf 100755 --- a/assets/javascripts/discourse/templates/components/google-dfp-ad.hbs +++ b/assets/javascripts/discourse/templates/components/google-dfp-ad.hbs @@ -1,17 +1,12 @@ -{{#if site.mobileView}} +{{#if checkTrustLevels}} {{#if loadedGoogletag}} - {{#if checkTrustLevels}} + {{#if site.mobileView}}
- {{/if}} - {{/if}} - -{{else}} - {{#if loadedGoogletag}} - {{#if checkTrustLevels}} + {{else}}