From dbb7d1a7848bfbe2e6cf3253cc3a52955f71a915 Mon Sep 17 00:00:00 2001 From: Sarah Ni Date: Wed, 2 Sep 2015 13:50:47 +1000 Subject: [PATCH] Refactored trust levels --- .../discourse/components/google-dfp-ad.js.es6 | 10 +++++--- .../templates/components/google-dfp-ad.hbs | 24 +++++++++++-------- config/locales/client.en.yml | 2 +- 3 files changed, 22 insertions(+), 14 deletions(-) diff --git a/assets/javascripts/discourse/components/google-dfp-ad.js.es6 b/assets/javascripts/discourse/components/google-dfp-ad.js.es6 index a969855..350b053 100755 --- a/assets/javascripts/discourse/components/google-dfp-ad.js.es6 +++ b/assets/javascripts/discourse/components/google-dfp-ad.js.es6 @@ -89,7 +89,7 @@ function loadGoogle(settings) { 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) } } - if (settings.dfp_topic_above_post_stream_code && !settings.dfp_show_topic_above_post_stream && settings.topic_above_post_stream_ad_sizes && !((currentUser) && (currentUser.get('trust_level') > Discourse.SiteSettings.dfp_through_trust_level))) { + 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_height = parseInt(splitHeightInt(settings.topic_above_post_stream_ad_sizes)); if (Discourse.Mobile.mobileView) { @@ -99,7 +99,7 @@ function loadGoogle(settings) { 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) } } - if (settings.dfp_topic_above_suggested_code && !settings.dfp_show_topic_above_suggested && settings.topic_above_suggested_ad_sizes && !((currentUser) && (currentUser.get('trust_level') > Discourse.SiteSettings.dfp_through_trust_level))) { + 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_height = parseInt(splitHeightInt(settings.topic_above_suggested_ad_sizes)); if (Discourse.Mobile.mobileView) { @@ -109,7 +109,7 @@ function loadGoogle(settings) { 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) } } - if (settings.dfp_post_bottom_code && !settings.dfp_show_post_bottom && settings.post_bottom_ad_sizes && !((currentUser) && (currentUser.get('trust_level') > Discourse.SiteSettings.dfp_through_trust_level))) { + 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_height = parseInt(splitHeightInt(settings.post_bottom_ad_sizes)); if (Discourse.Mobile.mobileView) { @@ -153,6 +153,10 @@ export default Ember.Component.extend({ return `width: ${this.get('const_mobile_width')}px; height: ${this.get('const_mobile_height')}px;`.htmlSafe(); }.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() { var self = this; loadGoogle(this.siteSettings).then(function() { diff --git a/assets/javascripts/discourse/templates/components/google-dfp-ad.hbs b/assets/javascripts/discourse/templates/components/google-dfp-ad.hbs index ca96b4c..256bf73 100755 --- a/assets/javascripts/discourse/templates/components/google-dfp-ad.hbs +++ b/assets/javascripts/discourse/templates/components/google-dfp-ad.hbs @@ -1,18 +1,22 @@ {{#if site.mobileView}} {{#if loadedGoogletag}} -
- -
+ {{#if checkTrustLevels}} +
+ +
+ {{/if}} {{/if}} {{else}} {{#if loadedGoogletag}} -
- -
+ {{#if checkTrustLevels}} +
+ +
+ {{/if}} {{/if}} {{/if}} \ No newline at end of file diff --git a/config/locales/client.en.yml b/config/locales/client.en.yml index e437608..2d6f20f 100755 --- a/config/locales/client.en.yml +++ b/config/locales/client.en.yml @@ -3,5 +3,5 @@ en: admin: site_settings: categories: - ad_plugin: 'Ad Plugin' + ad_plugin: 'DFP Plugin' adsense_plugin: 'Adsense Plugin' \ No newline at end of file