Skip to content

Commit

Permalink
Add clickThru
Browse files Browse the repository at this point in the history
  • Loading branch information
kahwee committed Oct 8, 2017
1 parent 10a4016 commit 283221b
Show file tree
Hide file tree
Showing 8 changed files with 512 additions and 441 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
# v2.3.0 -- 2017-10-08

* Added clickThru function. See Usage in README.

# v2.1.4 -- 2016-10-28

* Fix setSize on videoSlot

# v2.1.3 -- 2016-10-28

* Fix vpaid-methods not being compiled into babel by using `.js` instead of `.json`
* `removeEventListener` is previously not working due to incorrect bindings.

Expand Down
39 changes: 39 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,45 @@ window.getVPAIDAd = function () {
return new VpaidAd()
}
```

Your player can then call:

```js
vpaid = window.getVPAIDAd()
vpaid.subscribe(...)
```

### clickThru

There's a special clickThru method that you can use:

```js
vpaid.clickThru({
url: 'https://example.com',
id: 'my-id',
playerHandles: true
})
```

The above function emits the parameters as both an object and as an array.

As an array:

```json
["https://example.com", "my-id", true]
```

As an object:

```json
{
"url": "https://example.com",
"id": "my-id",
"playerHandles": true
}
```


## Resources

* [MailOnline's VPAIDHTML5Client](https://github.com/MailOnline/VPAIDHTML5Client)
41 changes: 34 additions & 7 deletions dist/vpaid-ad.js
Original file line number Diff line number Diff line change
Expand Up @@ -186,15 +186,15 @@ var Linear = function (_TinyEmitter) {
* @param {number} width indicates the available ad display area width in pixels
* @param {number} height indicates the available ad display area height in pixels
* @param {string} viewMode indicates either “normal”, “thumbnail”, or “fullscreen” as the view mode
for the video player as defined by the publisher. Default is “normal”.
* for the video player as defined by the publisher. Default is “normal”.
* @param {number} desiredBitrate indicates the desired bitrate as number for kilobits per second
(kbps). The ad unit may use this information to select appropriate bitrate for any
streaming content.
* (kbps). The ad unit may use this information to select appropriate bitrate for any
* streaming content.
* @param {object} creativeData (optional) used for additional initialization data. In a VAST context,
the ad unit should pass the value for either the Linear or Nonlinear AdParameter
element specified in the VAST document.
* the ad unit should pass the value for either the Linear or Nonlinear AdParameter
* element specified in the VAST document.
* @param {object} environmentVars (optional) used for passing implementation-specific runtime
variables. Refer to the language specific API description for more details.
* variables. Refer to the language specific API description for more details.
*/

}, {
Expand Down Expand Up @@ -370,6 +370,33 @@ var Linear = function (_TinyEmitter) {
this.emit('AdPaused');
}

/**
* The AdClickThru event is sent by the ad unit when a clickthrough occurs. Three parameters can be included to give the video player the option for handling the event.
* Three parameters are available for the event:
* • String url: enables the ad unit to specify the clickthrough url
* • String Id: used for tracking purposes
* • Boolean playerHandles: indicates whether the video player or the ad unit handles
* the event. Set to true, the video player opens the new browser window to the URL provided. Set to false, the ad unit handles the event.
* The AdClickThru event is included under the same name in Digital Video In-Stream Ad Metrics Definitions and must be implemented to be IAB compliant.
*
* This function does some compatibility to ensure clickThrus can be delivered as either and array or an object.
*
* @param {Object} opts [description]
* @return {[type]} [description]
*/

}, {
key: 'clickThru',
value: function clickThru() {
var opts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};

var params = [opts.url, opts.id, opts.playerHandles];
params.url = opts.url;
params.id = opts.id;
params.playerHandles = opts.playerHandles;
this.emit('AdClickThru', params);
}

/**
* resumeAd
*
Expand Down Expand Up @@ -413,7 +440,7 @@ var Linear = function (_TinyEmitter) {
* @param {Function} fn fn is a reference to the function that needs to be called when the specified event occurs
* @param {string} event event is the name of the event that the video player is subscribing to
* @param {[type]} listenerScope [optional] listenerScope is a reference to the object in which the function is
defined
* defined
*/

}, {
Expand Down
41 changes: 34 additions & 7 deletions lib/linear.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,15 +103,15 @@ var Linear = function (_TinyEmitter) {
* @param {number} width indicates the available ad display area width in pixels
* @param {number} height indicates the available ad display area height in pixels
* @param {string} viewMode indicates either “normal”, “thumbnail”, or “fullscreen” as the view mode
for the video player as defined by the publisher. Default is “normal”.
* for the video player as defined by the publisher. Default is “normal”.
* @param {number} desiredBitrate indicates the desired bitrate as number for kilobits per second
(kbps). The ad unit may use this information to select appropriate bitrate for any
streaming content.
* (kbps). The ad unit may use this information to select appropriate bitrate for any
* streaming content.
* @param {object} creativeData (optional) used for additional initialization data. In a VAST context,
the ad unit should pass the value for either the Linear or Nonlinear AdParameter
element specified in the VAST document.
* the ad unit should pass the value for either the Linear or Nonlinear AdParameter
* element specified in the VAST document.
* @param {object} environmentVars (optional) used for passing implementation-specific runtime
variables. Refer to the language specific API description for more details.
* variables. Refer to the language specific API description for more details.
*/

}, {
Expand Down Expand Up @@ -287,6 +287,33 @@ var Linear = function (_TinyEmitter) {
this.emit('AdPaused');
}

/**
* The AdClickThru event is sent by the ad unit when a clickthrough occurs. Three parameters can be included to give the video player the option for handling the event.
* Three parameters are available for the event:
* • String url: enables the ad unit to specify the clickthrough url
* • String Id: used for tracking purposes
* • Boolean playerHandles: indicates whether the video player or the ad unit handles
* the event. Set to true, the video player opens the new browser window to the URL provided. Set to false, the ad unit handles the event.
* The AdClickThru event is included under the same name in Digital Video In-Stream Ad Metrics Definitions and must be implemented to be IAB compliant.
*
* This function does some compatibility to ensure clickThrus can be delivered as either and array or an object.
*
* @param {Object} opts [description]
* @return {[type]} [description]
*/

}, {
key: 'clickThru',
value: function clickThru() {
var opts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};

var params = [opts.url, opts.id, opts.playerHandles];
params.url = opts.url;
params.id = opts.id;
params.playerHandles = opts.playerHandles;
this.emit('AdClickThru', params);
}

/**
* resumeAd
*
Expand Down Expand Up @@ -330,7 +357,7 @@ var Linear = function (_TinyEmitter) {
* @param {Function} fn fn is a reference to the function that needs to be called when the specified event occurs
* @param {string} event event is the name of the event that the video player is subscribing to
* @param {[type]} listenerScope [optional] listenerScope is a reference to the object in which the function is
defined
* defined
*/

}, {
Expand Down
Loading

0 comments on commit 283221b

Please sign in to comment.