Skip to content

Commit

Permalink
Fix VPAID methods not found and removeEventListeners
Browse files Browse the repository at this point in the history
* Fix vpaid-methods not being compiled into babel by using `.js` instead of `.json`
* `removeEventListener` is previously not working due to incorrect bindings.
  • Loading branch information
kahwee committed Oct 28, 2016
1 parent 0565d2a commit 78309ae
Show file tree
Hide file tree
Showing 12 changed files with 73 additions and 75 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# 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.

# v2.1.2 -- 2016-09-26

* Cleanup & refactor
Expand Down
46 changes: 15 additions & 31 deletions dist/vpaid-ad.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ function _possibleConstructorReturn(self, call) { if (!self) { throw new Referen
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }

var TinyEmitter = require('tiny-emitter');
var vpaidMethods = require('./vpaid-methods.json');
var vpaidMethods = require('./vpaid-methods');
var VideoTracker = require('./video-tracker');
var isSupported = require('./util/is-supported');

Expand All @@ -102,7 +102,7 @@ var Linear = function (_TinyEmitter) {
_inherits(Linear, _TinyEmitter);

function Linear() {
var opts = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0];
var opts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};

_classCallCheck(this, Linear);

Expand Down Expand Up @@ -600,7 +600,7 @@ var Linear = function (_TinyEmitter) {
Linear.prototype.setSize = require('./util/set-size');
module.exports = Linear;

},{"./util/is-supported":4,"./util/set-size":5,"./video-tracker":6,"./vpaid-methods.json":8,"tiny-emitter":1}],4:[function(require,module,exports){
},{"./util/is-supported":4,"./util/set-size":5,"./video-tracker":6,"./vpaid-methods":8,"tiny-emitter":1}],4:[function(require,module,exports){
'use strict';

var el = void 0;
Expand Down Expand Up @@ -669,7 +669,7 @@ var VideoTracker = function () {
* @return {[type]} [description]
*/
function VideoTracker(el, emitter) {
var prefix = arguments.length <= 2 || arguments[2] === undefined ? 'AdVideo' : arguments[2];
var prefix = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'AdVideo';

_classCallCheck(this, VideoTracker);

Expand All @@ -693,14 +693,18 @@ var VideoTracker = function () {
}, {
key: 'addEventListeners',
value: function addEventListeners() {
this.el.addEventListener('timeupdate', handleTimeupdate.bind(this));
this.el.addEventListener('ended', handleEnded.bind(this));
this.events = {
handleTimeupdate: handleTimeupdate.bind(this),
handleEnded: handleEnded.bind(this)
};
this.el.addEventListener('timeupdate', this.events.handleTimeupdate);
this.el.addEventListener('ended', this.events.handleEnded);
}
}, {
key: 'removeEventListeners',
value: function removeEventListeners() {
this.el.removeEventListener('timeupdate', handleTimeupdate);
this.el.removeEventListener('ended', handleEnded);
this.el.removeEventListener('timeupdate', this.events.handleTimeupdate);
this.el.removeEventListener('ended', this.events.handleEnded);
}
}]);

Expand All @@ -715,28 +719,8 @@ module.exports = VideoTracker;
module.exports = ['Start', 'FirstQuartile', 'Midpoint', 'ThirdQuartile', 'Complete'];

},{}],8:[function(require,module,exports){
module.exports=[
"handshakeVersion",
"initAd",
"startAd",
"stopAd",
"skipAd",
"resizeAd",
"pauseAd",
"resumeAd",
"expandAd",
"collapseAd",
"getAdLinear",
"getAdWidth",
"getAdHeight",
"getAdExpanded",
"getAdadSkippableState",
"getAdRemainingTime",
"getAdDuration",
"getAdVolume",
"getAdCompanions",
"getAdIcons",
"setAdVolume"
]
'use strict';

module.exports = ['handshakeVersion', 'initAd', 'startAd', 'stopAd', 'skipAd', 'resizeAd', 'pauseAd', 'resumeAd', 'expandAd', 'collapseAd', 'getAdLinear', 'getAdWidth', 'getAdHeight', 'getAdExpanded', 'getAdadSkippableState', 'getAdRemainingTime', 'getAdDuration', 'getAdVolume', 'getAdCompanions', 'getAdIcons', 'setAdVolume'];

},{}]},{},[2]);
4 changes: 2 additions & 2 deletions lib/linear.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ function _possibleConstructorReturn(self, call) { if (!self) { throw new Referen
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }

var TinyEmitter = require('tiny-emitter');
var vpaidMethods = require('./vpaid-methods.json');
var vpaidMethods = require('./vpaid-methods');
var VideoTracker = require('./video-tracker');
var isSupported = require('./util/is-supported');

Expand All @@ -24,7 +24,7 @@ var Linear = function (_TinyEmitter) {
_inherits(Linear, _TinyEmitter);

function Linear() {
var opts = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0];
var opts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};

_classCallCheck(this, Linear);

Expand Down
14 changes: 9 additions & 5 deletions lib/video-tracker.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ var VideoTracker = function () {
* @return {[type]} [description]
*/
function VideoTracker(el, emitter) {
var prefix = arguments.length <= 2 || arguments[2] === undefined ? 'AdVideo' : arguments[2];
var prefix = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'AdVideo';

_classCallCheck(this, VideoTracker);

Expand All @@ -65,14 +65,18 @@ var VideoTracker = function () {
}, {
key: 'addEventListeners',
value: function addEventListeners() {
this.el.addEventListener('timeupdate', handleTimeupdate.bind(this));
this.el.addEventListener('ended', handleEnded.bind(this));
this.events = {
handleTimeupdate: handleTimeupdate.bind(this),
handleEnded: handleEnded.bind(this)
};
this.el.addEventListener('timeupdate', this.events.handleTimeupdate);
this.el.addEventListener('ended', this.events.handleEnded);
}
}, {
key: 'removeEventListeners',
value: function removeEventListeners() {
this.el.removeEventListener('timeupdate', handleTimeupdate);
this.el.removeEventListener('ended', handleEnded);
this.el.removeEventListener('timeupdate', this.events.handleTimeupdate);
this.el.removeEventListener('ended', this.events.handleEnded);
}
}]);

Expand Down
3 changes: 3 additions & 0 deletions lib/vpaid-methods.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "vpaid-ad",
"version": "2.1.2",
"version": "2.1.3",
"description": "VPAID ad class for extending purposes.",
"main": "lib/index.js",
"scripts": {
Expand All @@ -24,13 +24,13 @@
},
"homepage": "https://github.com/kahwee/vpaid-ad#readme",
"devDependencies": {
"babel-cli": "^6.16.0",
"babel-core": "^6.17.0",
"babel-cli": "^6.18.0",
"babel-core": "^6.18.0",
"babel-istanbul": "^0.11.0",
"babel-polyfill": "^6.16.0",
"babel-preset-es2015": "^6.16.0",
"babel-preset-es2015": "^6.18.0",
"babelify": "^7.3.0",
"browserify": "^13.1.0",
"browserify": "^13.1.1",
"browserify-istanbul": "^2.0.0",
"chai": "^3.5.0",
"codecov": "^1.0.1",
Expand All @@ -43,7 +43,7 @@
"karma-mocha": "^1.2.0",
"karma-mocha-reporter": "^2.2.0",
"mocha": "^3.1.2",
"standard": "^8.4.0",
"standard": "^8.5.0",
"watchify": "^3.7.0"
},
"browserify": {
Expand Down
2 changes: 1 addition & 1 deletion src/linear.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const TinyEmitter = require('tiny-emitter')
const vpaidMethods = require('./vpaid-methods.json')
const vpaidMethods = require('./vpaid-methods')
const VideoTracker = require('./video-tracker')
const isSupported = require('./util/is-supported')

Expand Down
12 changes: 8 additions & 4 deletions src/video-tracker.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,17 @@ class VideoTracker {
}

addEventListeners () {
this.el.addEventListener('timeupdate', handleTimeupdate.bind(this))
this.el.addEventListener('ended', handleEnded.bind(this))
this.events = {
handleTimeupdate: handleTimeupdate.bind(this),
handleEnded: handleEnded.bind(this)
}
this.el.addEventListener('timeupdate', this.events.handleTimeupdate)
this.el.addEventListener('ended', this.events.handleEnded)
}

removeEventListeners () {
this.el.removeEventListener('timeupdate', handleTimeupdate)
this.el.removeEventListener('ended', handleEnded)
this.el.removeEventListener('timeupdate', this.events.handleTimeupdate)
this.el.removeEventListener('ended', this.events.handleEnded)
}

}
Expand Down
23 changes: 23 additions & 0 deletions src/vpaid-methods.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
module.exports = [
'handshakeVersion',
'initAd',
'startAd',
'stopAd',
'skipAd',
'resizeAd',
'pauseAd',
'resumeAd',
'expandAd',
'collapseAd',
'getAdLinear',
'getAdWidth',
'getAdHeight',
'getAdExpanded',
'getAdadSkippableState',
'getAdRemainingTime',
'getAdDuration',
'getAdVolume',
'getAdCompanions',
'getAdIcons',
'setAdVolume'
]
23 changes: 0 additions & 23 deletions src/vpaid-methods.json

This file was deleted.

1 change: 0 additions & 1 deletion tests/linear-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,6 @@ describe('Linear', function () {
it('should emit getAdWidth() when it is called', function (done) {
let handler = function () {
linear.unsubscribe(handler, 'Hello')
console.log('hi')
done()
}
linear.subscribe(handler, 'Hello')
Expand Down
4 changes: 2 additions & 2 deletions tests/video-tracker-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,14 @@ describe('VideoTracker', function () {

describe('life cycle #2 (for staggering)', function () {
it('should emit "AdVideoFirstQuartile"', function (done) {
emitter2.on('AdVideoFirstQuartile', function () {
emitter2.once('AdVideoFirstQuartile', function () {
done()
})
videoSlot2.play()
})

it('should emit "AdVideoThirdQuartile"', function (done) {
emitter2.on('AdVideoThirdQuartile', function () {
emitter2.once('AdVideoThirdQuartile', function () {
done()
})
})
Expand Down

0 comments on commit 78309ae

Please sign in to comment.