basic amazon product link inputs added and works
This commit is contained in:
parent
082f4e336d
commit
2d752d8b2f
|
@ -0,0 +1,56 @@
|
|||
var amazon_code = '';
|
||||
var amazon_width = '';
|
||||
var amazon_height = '';
|
||||
var amazon_mobile_width = 320;
|
||||
var amazon_mobile_height = 50;
|
||||
var user_input = Discourse.SiteSettings.amazon_topic_list_top_code;
|
||||
var currentUser = Discourse.User.current();
|
||||
|
||||
function splitWidthInt(value) {
|
||||
var str = value.substring(0, 3);
|
||||
return str.trim();
|
||||
}
|
||||
|
||||
function splitHeightInt(value) {
|
||||
var str = value.substring(4, 7);
|
||||
return str.trim();
|
||||
}
|
||||
|
||||
if (Discourse.SiteSettings.amazon_topic_list_top_code) {
|
||||
if (!((currentUser) && (currentUser.get('trust_level') > Discourse.SiteSettings.amazon_through_trust_level))) {
|
||||
user_input = Discourse.SiteSettings.amazon_topic_list_top_code;
|
||||
amazon_width = parseInt(splitWidthInt(Discourse.SiteSettings.amazon_topic_list_top_ad_sizes));
|
||||
amazon_height = parseInt(splitHeightInt(Discourse.SiteSettings.amazon_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;
|
||||
//}
|
||||
}
|
||||
|
||||
// Ember component - the class is the adblock and css
|
||||
export default Ember.Component.extend({
|
||||
amazon_width: amazon_width,
|
||||
amazon_height: amazon_height,
|
||||
amazon_mobile_width: amazon_mobile_width,
|
||||
amazon_mobile_height: amazon_mobile_height,
|
||||
user_input: user_input,
|
||||
|
||||
classNames: ['amazon-product-links'],
|
||||
|
||||
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('amazon_mobile_width')}px; height: ${this.get('amazon_mobile_height')}px;`.htmlSafe();
|
||||
}.property('amazon_mobile_width', 'amazon_mobile_height'),
|
||||
|
||||
userInput: function() {
|
||||
return `${this.get('user_input')}`.htmlSafe();
|
||||
}.property('user_input'),
|
||||
|
||||
checkTrustLevels: function() {
|
||||
return !((currentUser) && (currentUser.get('trust_level') > Discourse.SiteSettings.amazon_through_trust_level));
|
||||
}.property('trust_level'),
|
||||
|
||||
});
|
|
@ -0,0 +1,12 @@
|
|||
{{#if site.mobileView}}
|
||||
{{#if checkTrustLevels}}
|
||||
<iframe style={{adWrapperStyleMobile}} marginwidth="0" marginheight="0" scrolling="no" frameborder="0" src={{userInput}}>
|
||||
</iframe>
|
||||
{{/if}}
|
||||
|
||||
{{else}}
|
||||
{{#if checkTrustLevels}}
|
||||
<iframe style={{adWrapperStyle}} marginwidth="0" marginheight="0" scrolling="no" frameborder="0" src={{userInput}}>
|
||||
</iframe>
|
||||
{{/if}}
|
||||
{{/if}}
|
|
@ -4,3 +4,6 @@
|
|||
{{#if siteSettings.dfp_topic_list_top_code}}
|
||||
{{google-dfp-ad placement="topic-list-top"}}
|
||||
{{/if}}
|
||||
{{#if siteSettings.amazon_topic_list_top_code}}
|
||||
{{amazon-product-links placement="topic-list-top"}}
|
||||
{{/if}}
|
|
@ -11,6 +11,10 @@ export default {
|
|||
postSpecificCountAdsense: function() {
|
||||
return this.get('post_number') === parseInt(Discourse.SiteSettings.adsense_nth_post_code);
|
||||
}.property('post_number'),
|
||||
|
||||
postSpecificCountAmazon: function() {
|
||||
return this.get('post_number') === parseInt(Discourse.SiteSettings.amazon_nth_post_code);
|
||||
}.property('post_number'),
|
||||
});
|
||||
}
|
||||
};
|
||||
|
|
|
@ -19,3 +19,13 @@
|
|||
margin: 0 auto;
|
||||
}
|
||||
|
||||
.amazon-product-links {
|
||||
padding: 3px;
|
||||
margin-bottom: 10px;
|
||||
clear: both;
|
||||
}
|
||||
|
||||
.amazon-product-links .amazon-unit {
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
|
@ -5,3 +5,4 @@ en:
|
|||
categories:
|
||||
dfp_plugin: 'DFP Plugin'
|
||||
adsense_plugin: 'Adsense Plugin'
|
||||
amazon_plugin: 'Amazon Plugin'
|
|
@ -46,3 +46,6 @@ en:
|
|||
adsense_show_post_bottom: "Disable post_bottom ad"
|
||||
adsense_post_bottom_ad_sizes: "Choose your ad sizes"
|
||||
adsense_nth_post_code: "Choose the Nth position for your ad to show"
|
||||
amazon_topic_list_top_code: "Insert your src code here"
|
||||
amazon_topic_list_top_ad_sizes: "Choose your ad sizes"
|
||||
amazon_nth_post_code: "Choose the Nth position for your ad to show"
|
|
@ -242,6 +242,12 @@ amazon_plugin:
|
|||
amazon_topic_list_top_code:
|
||||
client: true
|
||||
default: ''
|
||||
amazon_through_trust_level:
|
||||
client: true
|
||||
default: 2
|
||||
amazon_nth_post_code:
|
||||
client: true
|
||||
default: ''
|
||||
amazon_topic_list_top_ad_sizes:
|
||||
client: true
|
||||
default: '728*90 - leaderboard'
|
||||
|
|
Loading…
Reference in New Issue