Skip to content

Instantly share code, notes, and snippets.

@marcveens
Created March 22, 2017 15:09
Show Gist options
  • Select an option

  • Save marcveens/6542318e1882df92e9cce653c23ed591 to your computer and use it in GitHub Desktop.

Select an option

Save marcveens/6542318e1882df92e9cce653c23ed591 to your computer and use it in GitHub Desktop.
Default JS plugin
<!DOCTYPE>
<html>
<head>
<script src="lodash.min.js"></script>
</head>
<body>
<div class="js-player"></div>
<script>
;(function () {
'use strict';
var DEFAULTS = {
autoplay: true
};
var VideoPlayer = function(root, options) {
this.root = document.querySelector(arguments[0]);
this.options = _.merge({}, DEFAULTS, _.isObject(arguments[1]) && arguments[1]);
}
VideoPlayer.prototype.play = function() {
console.log('play', this);
};
VideoPlayer.prototype.pause = function() {
console.log('pause');
};
window.VideoPlayer = VideoPlayer;
})();
var video = new VideoPlayer('.js-player');
video.play('video');
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment