2016-02-01 16:31:29 +01:00
|
|
|
var HeroVideo = (function(w, d, $) {
|
2016-02-01 14:56:46 +01:00
|
|
|
|
2016-02-01 16:31:29 +01:00
|
|
|
'use strict'
|
2016-02-01 14:56:46 +01:00
|
|
|
|
2016-02-01 16:31:29 +01:00
|
|
|
var app, _private, _config
|
2016-02-01 14:56:46 +01:00
|
|
|
|
2016-02-01 16:31:29 +01:00
|
|
|
_config = {
|
|
|
|
heroVideo: $('.hero-video__video').get(0),
|
|
|
|
minWidth: 720 // $screen-md
|
2016-02-01 14:56:46 +01:00
|
|
|
}
|
|
|
|
|
2016-02-01 16:31:29 +01:00
|
|
|
_private = {
|
|
|
|
play: function() {
|
|
|
|
if ( _config.heroVideo.paused ) {
|
|
|
|
if ( _config.heroVideo.readyState < 4 ) {
|
|
|
|
_config.heroVideo.load();
|
|
|
|
}
|
|
|
|
_config.heroVideo.play();
|
|
|
|
$(_config.heroVideo).addClass('enabled').removeClass('hide');
|
|
|
|
}
|
|
|
|
},
|
|
|
|
pause: function() {
|
|
|
|
_config.heroVideo.pause();
|
|
|
|
$(_config.heroVideo).addClass('hide').removeClass('enabled');
|
|
|
|
},
|
|
|
|
isWide: function() {
|
|
|
|
return $(window).width() >= _config.minWidth;
|
|
|
|
},
|
2016-02-01 14:56:46 +01:00
|
|
|
}
|
|
|
|
|
2016-02-01 16:31:29 +01:00
|
|
|
app = {
|
|
|
|
init: function() {
|
|
|
|
$(window).on('load resize', function() {
|
|
|
|
if (_private.isWide()) {
|
|
|
|
_private.play()
|
|
|
|
} else {
|
|
|
|
_private.pause()
|
|
|
|
}
|
|
|
|
})
|
2016-02-01 14:56:46 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-02-01 16:31:29 +01:00
|
|
|
return app
|
2016-02-01 14:56:46 +01:00
|
|
|
|
2016-02-01 16:31:29 +01:00
|
|
|
})(window, document, jQuery)
|