README
wc-ads
Adverts
Macro settings
Key | Optional | Default | Description |
---|---|---|---|
ad_unit | false | The ad unit code | |
ad_zone | false | The ad zone code | |
ad_sizes | false | The sizes of the ads | |
ad_sizemap | true | None | The sizemapping for the ad |
ad_position | true | None | The position of the ad. This is used by GPT |
ad_targets | true | None | The ad target information |
ad_values | true | None | Key,value information for GPT |
ad_group | true | None | The name of the group the ad belongs to |
ad_order | true | None | The order of the ad group |
ad_placement | true | None | Position of the ad but used for the frontend |
lazyload | true | False | Whether to lazyload the ad |
allow_bidding | true | False | Whether the slot can be bid on |
title | true | None | Title to include on the ad |
JS Documentation
Ad
Kind: global class
- Ad
- new Ad(el, manager, options)
- .el :
HTMLElement
- .id :
String
- .group :
AdGroup
- .manager :
AdManager
- .renderedSize :
Array.<Number>
- .slot :
googletag.Slot
- .state :
Number
- .destroy()
- .register() ⇒
Promise
new Ad(el, manager, options)
Param | Type |
---|---|
el | HTMLElement |
manager | AdManager |
options | Object |
HTMLElement
ad.el : The ad element
Kind: instance property of Ad
Access: public
String
ad.id : Unique id of the advert
Kind: instance property of Ad
Access: public
AdGroup
ad.group : The group the ad is part of
Kind: instance property of Ad
Access: public
AdManager
ad.manager : The manager that created the ad
Kind: instance property of Ad
Access: public
Array.<Number>
ad.renderedSize : The rendered size of the advert
Kind: instance property of Ad
Access: public
googletag.Slot
ad.slot : The GPT slot
Kind: instance property of Ad
Access: public
Number
ad.state : Current state of the advert
Kind: instance property of Ad
Access: public
ad.destroy()
Destroys the advert
Kind: instance method of Ad
Access: public
Promise
ad.register() ⇒ Registers the advert with AdManager
Kind: instance method of Ad
Access: public
AdGroup
Kind: global class
- AdGroup
- new AdGroup(manager, options)
- .id :
String
- .lazyload :
Boolean
- .manager :
AdManager
- .maxSlots :
Number
- .size :
Number
- .slots :
Object
- .add(ad)
- .destroy()
- .refresh() ⇒
Promise
- .register() ⇒
Promise
- .release()
- .remove(ad)
- .render() ⇒
Promise
- .resize()
new AdGroup(manager, options)
Param | Type |
---|---|
manager | AdManager |
options | Object |
String
adGroup.id : Unique id of the group
Kind: instance property of AdGroup
Access: public
Boolean
adGroup.lazyload : Whether to lazyload the group
Kind: instance property of AdGroup
Access: public
AdManager
adGroup.manager : The manager that created the group
Kind: instance property of AdGroup
Access: public
Number
adGroup.maxSlots : The maximum amount of slots the group can have
Kind: instance property of AdGroup
Access: public
Number
adGroup.size : The amount of slots in the group
Kind: instance property of AdGroup
Access: public
Object
adGroup.slots : The ad slots
Kind: instance property of AdGroup
Access: public
adGroup.add(ad)
Add an Ad to the group
Kind: instance method of AdGroup
Access: public
Param | Type |
---|---|
ad | Ad |
adGroup.destroy()
Destroys the group
Kind: instance method of AdGroup
Access: public
Promise
adGroup.refresh() ⇒ Refreshes all the slots in the group
Kind: instance method of AdGroup
Access: public
Promise
adGroup.register() ⇒ Registers all the slots in the group
Kind: instance method of AdGroup
Access: public
adGroup.release()
Release all the slots from the group
Kind: instance method of AdGroup
Access: public
adGroup.remove(ad)
Removes an Ad from the group
Kind: instance method of AdGroup
Access: public
Param | Type |
---|---|
ad | Ad |
Promise
adGroup.render() ⇒ Renders all the slots in the group
Kind: instance method of AdGroup
Access: public
adGroup.resize()
Recalculates the top and bottom bounds of the group
Kind: instance method of AdGroup
Access: public
AdModel
Kind: global class
new AdModel(defaults)
Creates an AdModel
Param | Type | Description |
---|---|---|
defaults | Object |
Default values that will be set |
adModel.clear()
Clears all the properties
Kind: instance method of AdModel
Access: public
*
adModel.get(key) ⇒ Gets the property or throws an error if the key doesn't exist
Kind: instance method of AdModel
Access: public
Param | Type |
---|---|
key | String |
adModel.set(key, value)
Sets the property or throws an error if the key doesn't exist
Kind: instance method of AdModel
Access: public
Param | Type |
---|---|
key | Object | String |
value | * |
NativeAd
- NativeAd
- ~getNativeAdSize(nad) ⇒
Number
- ~getNativeAdSizeName(index) ⇒
String
- ~getNativeAdTemplateUrl(size, json) ⇒
String
- ~objectToQueryString(obj) ⇒
String
- ~getNativeAdSize(nad) ⇒
Number
NativeAd~getNativeAdSize(nad) ⇒ Works out what size the native ad is
Kind: inner method of NativeAd
Param | Type |
---|---|
nad | NativeAd |
String
NativeAd~getNativeAdSizeName(index) ⇒ Gets the size name of the native ad
Kind: inner method of NativeAd
Param | Type |
---|---|
index | Number |
String
NativeAd~getNativeAdTemplateUrl(size, json) ⇒ Creates a template url
Kind: inner method of NativeAd
Param | Type |
---|---|
size | Size |
json | Object |
String
NativeAd~objectToQueryString(obj) ⇒ Converts an object into an encoded string
Kind: inner method of NativeAd
Param | Type |
---|---|
obj | Object |
Utils
- Utils
- static
- .buildDFPUrl(attribs) ⇒
String
- .getAdElementAttributes(el) ⇒
Object
- .getSlot(ad) ⇒
googletag.Slot
- .hasGroup(ad) ⇒
Boolean
- .isAdDestroyed(ad) ⇒
Boolean
- .isAdInitialised(ad) ⇒
Boolean
- .isAdRendered(ad) ⇒
Boolean
- .isElInitialised(el) ⇒
Boolean
- .loadGPTLibrary() ⇒
Promise
- .parseAdKeyValues(value) ⇒
Object
- .parseAdAttributes(el) ⇒
Object
- .mapAdElementAttributes(attribs) ⇒
Object
- .pushToGoogleTag(callback) ⇒
Promise
- .setAdStateToDestroyed(ad) ⇒
Ad
- .setAdStateToRendered(ad) ⇒
Ad
- .setAdStateToStopped(ad) ⇒
Ad
- .buildDFPUrl(attribs) ⇒
- inner
- ~AD_STATES :
enum
- ~DEFAULT_AD_ELEMENT_ATTRIBUTES :
Object
- ~AD_ATTRIBUTE_MAP :
Object
- ~GPT_URL :
String
- ~AD_STATES :
- static
String
Utils.buildDFPUrl(attribs) ⇒ Creates the DFP url
Kind: static method of Utils
Param | Type |
---|---|
attribs | Object |
Object
Utils.getAdElementAttributes(el) ⇒ Gets the attributes from the Ad element
Kind: static method of Utils
Param | Type |
---|---|
el | HTMLElement |
googletag.Slot
Utils.getSlot(ad) ⇒ Get the slot from the Ad
Kind: static method of Utils
Param | Type |
---|---|
ad | Ad |
Boolean
Utils.hasGroup(ad) ⇒ Checks if the Ad is part of a group
Kind: static method of Utils
Param | Type |
---|---|
ad | Ad |
Boolean
Utils.isAdDestroyed(ad) ⇒ Checks if an advert has been destroyed
Kind: static method of Utils
Param | Type | Description |
---|---|---|
ad | Ad |
The advert to check |
Boolean
Utils.isAdInitialised(ad) ⇒ Checks if an advert has been initialised
Kind: static method of Utils
Param | Type | Description |
---|---|---|
ad | Ad |
The advert to check |
Boolean
Utils.isAdRendered(ad) ⇒ Checks if an advert has been rendered
Kind: static method of Utils
Param | Type | Description |
---|---|---|
ad | Ad |
The advert to check |
Boolean
Utils.isElInitialised(el) ⇒ Checks if an advert element has been initialised
Kind: static method of Utils
Param | Type |
---|---|
el | HTMLElement |
Promise
Utils.loadGPTLibrary() ⇒ Loads the GPT library
Kind: static method of Utils
Object
Utils.parseAdKeyValues(value) ⇒ Parses the ad key value pairs. These need to be unescaped as jinja super encodes the json
Kind: static method of Utils
Param | Type |
---|---|
value | String |
Object
Utils.parseAdAttributes(el) ⇒ Parses the attributes for the ads
Kind: static method of Utils
Param | Type |
---|---|
el | HTMLElement |
Object
Utils.mapAdElementAttributes(attribs) ⇒ Maps the ad attributes
Kind: static method of Utils
Param | Type |
---|---|
attribs | Object |
Promise
Utils.pushToGoogleTag(callback) ⇒ Adds a callback to GPT's cmd queue
Kind: static method of Utils
Param | Type |
---|---|
callback | function |
Ad
Utils.setAdStateToDestroyed(ad) ⇒ Sets the state of the Ad to destroyed
Kind: static method of Utils
Param | Type |
---|---|
ad | Ad |
Ad
Utils.setAdStateToRendered(ad) ⇒ Sets the state of the Ad to rendered
Kind: static method of Utils
Param | Type |
---|---|
ad | Ad |
Ad
Utils.setAdStateToStopped(ad) ⇒ Sets the state of the Ad to stopped
Kind: static method of Utils
Param | Type |
---|---|
ad | Ad |
enum
Utils~AD_STATES : Different states for the advert
Kind: inner enum property of Utils
Read only: true
Properties
Name | Type | Default |
---|---|---|
UNINITIALISED | Number |
0 |
INITIALISED | Number |
1 |
RENDERED | Number |
2 |
STOPPED | Number |
3 |
DESTROYED | Number |
4 |
Object
Utils~DEFAULT_AD_ELEMENT_ATTRIBUTES : Default properties for the Ad element
Kind: inner property of Utils
Read only: true
Object
Utils~AD_ATTRIBUTE_MAP : Parser for Ad element attributes
Kind: inner property of Utils
Read only: true
String
Utils~GPT_URL : GPT Script url
Kind: inner constant of Utils
Read only: true
Themes
Prerequisites:
Demo:
Install dependencies:
npm install
Build the things:
npm run sass
npm run js
npm run docs
Hint your JS
npm run jshint
Python the pythons:
npm run demo-install
Start the demo server:
python demo.py