1.24.10 • Published 7 years ago

@cnbritain/wc-ads v1.24.10

Weekly downloads
16
License
ISC
Repository
github
Last release
7 years ago

wc-ads

Adverts

Macro settings

KeyOptionalDefaultDescription
ad_unitfalseThe ad unit code
ad_zonefalseThe ad zone code
ad_sizesfalseThe sizes of the ads
ad_sizemaptrueNoneThe sizemapping for the ad
ad_positiontrueNoneThe position of the ad. This is used by GPT
ad_targetstrueNoneThe ad target information
ad_valuestrueNoneKey,value information for GPT
ad_grouptrueNoneThe name of the group the ad belongs to
ad_ordertrueNoneThe order of the ad group
ad_placementtrueNonePosition of the ad but used for the frontend
lazyloadtrueFalseWhether to lazyload the ad
allow_biddingtrueFalseWhether the slot can be bid on
titletrueNoneTitle to include on the ad

JS Documentation

Ad

Kind: global class

new Ad(el, manager, options)

ParamType
elHTMLElement
managerAdManager
optionsObject

ad.el : HTMLElement

The ad element

Kind: instance property of Ad
Access: public

ad.id : String

Unique id of the advert

Kind: instance property of Ad
Access: public

ad.group : AdGroup

The group the ad is part of

Kind: instance property of Ad
Access: public

ad.manager : AdManager

The manager that created the ad

Kind: instance property of Ad
Access: public

ad.renderedSize : Array.<Number>

The rendered size of the advert

Kind: instance property of Ad
Access: public

ad.slot : googletag.Slot

The GPT slot

Kind: instance property of Ad
Access: public

ad.state : Number

Current state of the advert

Kind: instance property of Ad
Access: public

ad.destroy()

Destroys the advert

Kind: instance method of Ad
Access: public

ad.register() ⇒ Promise

Registers the advert with AdManager

Kind: instance method of Ad
Access: public

AdGroup

Kind: global class

new AdGroup(manager, options)

ParamType
managerAdManager
optionsObject

adGroup.id : String

Unique id of the group

Kind: instance property of AdGroup
Access: public

adGroup.lazyload : Boolean

Whether to lazyload the group

Kind: instance property of AdGroup
Access: public

adGroup.manager : AdManager

The manager that created the group

Kind: instance property of AdGroup
Access: public

adGroup.maxSlots : Number

The maximum amount of slots the group can have

Kind: instance property of AdGroup
Access: public

adGroup.size : Number

The amount of slots in the group

Kind: instance property of AdGroup
Access: public

adGroup.slots : Object

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

ParamType
adAd

adGroup.destroy()

Destroys the group

Kind: instance method of AdGroup
Access: public

adGroup.refresh() ⇒ Promise

Refreshes all the slots in the group

Kind: instance method of AdGroup
Access: public

adGroup.register() ⇒ Promise

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

ParamType
adAd

adGroup.render() ⇒ Promise

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

ParamTypeDescription
defaultsObjectDefault 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

ParamType
keyString

adModel.set(key, value)

Sets the property or throws an error if the key doesn't exist

Kind: instance method of AdModel
Access: public

ParamType
keyObject | String
value*

NativeAd

NativeAd~getNativeAdSize(nad) ⇒ Number

Works out what size the native ad is

Kind: inner method of NativeAd

ParamType
nadNativeAd

NativeAd~getNativeAdSizeName(index) ⇒ String

Gets the size name of the native ad

Kind: inner method of NativeAd

ParamType
indexNumber

NativeAd~getNativeAdTemplateUrl(size, json) ⇒ String

Creates a template url

Kind: inner method of NativeAd

ParamType
sizeSize
jsonObject

NativeAd~objectToQueryString(obj) ⇒ String

Converts an object into an encoded string

Kind: inner method of NativeAd

ParamType
objObject

Utils

Utils.buildDFPUrl(attribs) ⇒ String

Creates the DFP url

Kind: static method of Utils

ParamType
attribsObject

Utils.getAdElementAttributes(el) ⇒ Object

Gets the attributes from the Ad element

Kind: static method of Utils

ParamType
elHTMLElement

Utils.getSlot(ad) ⇒ googletag.Slot

Get the slot from the Ad

Kind: static method of Utils

ParamType
adAd

Utils.hasGroup(ad) ⇒ Boolean

Checks if the Ad is part of a group

Kind: static method of Utils

ParamType
adAd

Utils.isAdDestroyed(ad) ⇒ Boolean

Checks if an advert has been destroyed

Kind: static method of Utils

ParamTypeDescription
adAdThe advert to check

Utils.isAdInitialised(ad) ⇒ Boolean

Checks if an advert has been initialised

Kind: static method of Utils

ParamTypeDescription
adAdThe advert to check

Utils.isAdRendered(ad) ⇒ Boolean

Checks if an advert has been rendered

Kind: static method of Utils

ParamTypeDescription
adAdThe advert to check

Utils.isElInitialised(el) ⇒ Boolean

Checks if an advert element has been initialised

Kind: static method of Utils

ParamType
elHTMLElement

Utils.loadGPTLibrary() ⇒ Promise

Loads the GPT library

Kind: static method of Utils

Utils.parseAdKeyValues(value) ⇒ Object

Parses the ad key value pairs. These need to be unescaped as jinja super encodes the json

Kind: static method of Utils

ParamType
valueString

Utils.parseAdAttributes(el) ⇒ Object

Parses the attributes for the ads

Kind: static method of Utils

ParamType
elHTMLElement

Utils.mapAdElementAttributes(attribs) ⇒ Object

Maps the ad attributes

Kind: static method of Utils

ParamType
attribsObject

Utils.pushToGoogleTag(callback) ⇒ Promise

Adds a callback to GPT's cmd queue

Kind: static method of Utils

ParamType
callbackfunction

Utils.setAdStateToDestroyed(ad) ⇒ Ad

Sets the state of the Ad to destroyed

Kind: static method of Utils

ParamType
adAd

Utils.setAdStateToRendered(ad) ⇒ Ad

Sets the state of the Ad to rendered

Kind: static method of Utils

ParamType
adAd

Utils.setAdStateToStopped(ad) ⇒ Ad

Sets the state of the Ad to stopped

Kind: static method of Utils

ParamType
adAd

Utils~AD_STATES : enum

Different states for the advert

Kind: inner enum property of Utils
Read only: true
Properties

NameTypeDefault
UNINITIALISEDNumber0
INITIALISEDNumber1
RENDEREDNumber2
STOPPEDNumber3
DESTROYEDNumber4

Utils~DEFAULT_AD_ELEMENT_ATTRIBUTES : Object

Default properties for the Ad element

Kind: inner property of Utils
Read only: true

Utils~AD_ATTRIBUTE_MAP : Object

Parser for Ad element attributes

Kind: inner property of Utils
Read only: true

Utils~GPT_URL : String

GPT Script url

Kind: inner constant of Utils
Read only: true

Themes

Prerequisites:

  • Node.jsbrew install node
  • Grunt - npm install -g grunt-cli
  • Other prereqs? Python? Virtualenv?

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
1.24.10

7 years ago

1.24.9

7 years ago

1.24.8

7 years ago

1.24.7

7 years ago

1.24.6

7 years ago

1.24.5

7 years ago

1.24.4

7 years ago

1.24.3

7 years ago

1.24.2

7 years ago

1.24.1

7 years ago

1.24.0

7 years ago

1.23.2

8 years ago

1.23.1

8 years ago

1.23.0

8 years ago

1.22.15

8 years ago

1.22.14

8 years ago

1.22.13

8 years ago

1.22.12

8 years ago

1.22.11

8 years ago

1.22.10

8 years ago

1.22.9

8 years ago

1.22.8

8 years ago

1.22.7

8 years ago

1.22.6

8 years ago

1.22.5

8 years ago

1.22.4

8 years ago

1.22.3

8 years ago

1.22.2

8 years ago

1.22.1

8 years ago

1.22.0

8 years ago

1.21.4

8 years ago

1.21.3

8 years ago

1.21.2

8 years ago

1.21.1

8 years ago

1.21.0

8 years ago

1.20.5

8 years ago

1.20.4

8 years ago

1.20.3

8 years ago

1.20.2

8 years ago

1.20.1

8 years ago

1.20.0

8 years ago

1.19.2

8 years ago

1.19.1

8 years ago

1.19.0

8 years ago

1.18.2

8 years ago

1.18.1

8 years ago

1.18.0

8 years ago

1.17.1

8 years ago

1.17.0

8 years ago

1.16.3

8 years ago

1.16.2

8 years ago

1.16.1

8 years ago

1.16.0

8 years ago

1.15.2

8 years ago

1.15.1

8 years ago

1.15.0

8 years ago

1.14.3

8 years ago

1.14.2

8 years ago

1.14.1

8 years ago

1.14.0

8 years ago

1.13.0

8 years ago

1.12.4

8 years ago

1.12.3

8 years ago

1.12.2

8 years ago

1.12.1

8 years ago

1.11.0

8 years ago

1.10.4

8 years ago

1.10.3

8 years ago

1.10.2

8 years ago

1.10.1

8 years ago

1.10.0

8 years ago

1.9.0

8 years ago

1.8.0

8 years ago

1.7.2

8 years ago

1.7.1

8 years ago

1.7.0

8 years ago

1.6.0

8 years ago

1.4.0

8 years ago

1.3.0

8 years ago

1.2.0

8 years ago

1.1.2

8 years ago

1.1.1

8 years ago

1.1.0

8 years ago

1.0.0

8 years ago