Updates to codefund-ad
This commit is contained in:
		
							parent
							
								
									8ef02aa351
								
							
						
					
					
						commit
						63e604d81b
					
				|  | @ -1,11 +1,13 @@ | ||||||
|  | import AdComponent from "discourse/plugins/discourse-adplugin/discourse/components/ad_component"; | ||||||
| import { | import { | ||||||
|   default as computed, |   default as computed, | ||||||
|   observes |   observes | ||||||
| } from "ember-addons/ember-computed-decorators"; | } from "ember-addons/ember-computed-decorators"; | ||||||
| 
 | 
 | ||||||
| var _loaded = false, | let _loaded = false, | ||||||
|   _promise = null, |   _promise = null; | ||||||
|   currentUser = Discourse.User.current(), | 
 | ||||||
|  | const currentUser = Discourse.User.current(), | ||||||
|   propertyId = Discourse.SiteSettings.codefund_property_id; |   propertyId = Discourse.SiteSettings.codefund_property_id; | ||||||
| 
 | 
 | ||||||
| function loadCodeFund() { | function loadCodeFund() { | ||||||
|  | @ -48,12 +50,23 @@ function loadCodeFund() { | ||||||
|   return _promise; |   return _promise; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| export default Ember.Component.extend({ | export default AdComponent.extend({ | ||||||
|   classNameBindings: [":codefund-ad"], |   classNameBindings: [":codefund-ad"], | ||||||
|   propertyId: propertyId, |   propertyId: propertyId, | ||||||
|   adRequested: false, |   adRequested: false, | ||||||
|   adDetails: {}, |   adDetails: {}, | ||||||
| 
 | 
 | ||||||
|  |   displayPostBottom: Ember.computed.equal("placement", "post-bottom"), | ||||||
|  |   displayTopicAbovePostStream: Ember.computed.equal( | ||||||
|  |     "placement", | ||||||
|  |     "topic-above-post-stream" | ||||||
|  |   ), | ||||||
|  |   displayTopicAboveSuggested: Ember.computed.equal( | ||||||
|  |     "placement", | ||||||
|  |     "topic-above-suggested" | ||||||
|  |   ), | ||||||
|  |   displayTopicListTop: Ember.computed.equal("placement", "topic-list-top"), | ||||||
|  | 
 | ||||||
|   _triggerAds() { |   _triggerAds() { | ||||||
|     if (!propertyId) return; |     if (!propertyId) return; | ||||||
| 
 | 
 | ||||||
|  | @ -83,7 +96,7 @@ export default Ember.Component.extend({ | ||||||
|   }, |   }, | ||||||
| 
 | 
 | ||||||
|   @observes("listLoading") |   @observes("listLoading") | ||||||
|   waitForLoad: function() { |   waitForLoad() { | ||||||
|     if (this.get("adRequested")) { |     if (this.get("adRequested")) { | ||||||
|       return; |       return; | ||||||
|     } // already requested that this ad unit be populated |     } // already requested that this ad unit be populated | ||||||
|  | @ -93,7 +106,7 @@ export default Ember.Component.extend({ | ||||||
|   }, |   }, | ||||||
| 
 | 
 | ||||||
|   @computed() |   @computed() | ||||||
|   checkTrustLevels: function() { |   showToTrustLevel() { | ||||||
|     return !( |     return !( | ||||||
|       currentUser && |       currentUser && | ||||||
|       currentUser.get("trust_level") > |       currentUser.get("trust_level") > | ||||||
|  | @ -101,28 +114,12 @@ export default Ember.Component.extend({ | ||||||
|     ); |     ); | ||||||
|   }, |   }, | ||||||
| 
 | 
 | ||||||
|   @computed("checkTrustLevels") |   @computed("showToTrustLevel", "showToGroups") | ||||||
|   showAd: function(checkTrustLevels) { |   showAd(showToTrustLevel, showToGroups) { | ||||||
|     return Discourse.SiteSettings.codefund_property_id && checkTrustLevels; |     return ( | ||||||
|   }, |       Discourse.SiteSettings.codefund_property_id && | ||||||
| 
 |       showToTrustLevel && | ||||||
|   @computed("placement") |       showToGroups | ||||||
|   displayPostBottom: function(placement) { |     ); | ||||||
|     return placement === "post-bottom"; |  | ||||||
|   }, |  | ||||||
| 
 |  | ||||||
|   @computed("placement") |  | ||||||
|   displayTopicAbovePostStream: function() { |  | ||||||
|     return this.get("placement") === "topic-above-post-stream"; |  | ||||||
|   }, |  | ||||||
| 
 |  | ||||||
|   @computed("placement") |  | ||||||
|   displayTopicAboveSuggested: function() { |  | ||||||
|     return this.get("placement") === "topic-above-suggested"; |  | ||||||
|   }, |  | ||||||
| 
 |  | ||||||
|   @computed("placement") |  | ||||||
|   displayTopicListTop: function() { |  | ||||||
|     return this.get("placement") === "topic-list-top"; |  | ||||||
|   } |   } | ||||||
| }); | }); | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue