"use strict";

//
// Description: plays cinemagraph videos on mouseenter or focus
// Author: Kim Christiansen
//
//
(function ($, window) {
  'use strict';

  var $window,
      $document,
      $scope,
      windowWidth,
      minActiveWidth = 576,
      setup = function setup() {
    $document.on('mouseenter focus', '.js-topicworldteaser-link', function (e) {
      var $teaser = $(this).closest('.js-topicworldteaser');

      if ($teaser.length) {
        $teaser.find('video').get(0).play();
      }
    });
    $document.on('mouseleave focusout', '.js-topicworldteaser-link', function (e) {
      var $teaser = $(this).closest('.js-topicworldteaser');

      if ($teaser.length) {
        $teaser.find('video').get(0).pause();
      }
    });
  },
      init = function init() {
    $window = $(window);
    $document = $(document);
    $scope = $('.js-topicworldteaser');

    if ($scope.length) {
      setup();
    }
  };

  init();
})(jQuery, window);