/* jshint ignore:start */ (function(){ "use strict"; angular .module('whow') .directive('exitBanner', ['$timeout', 'Helper', 'LocalizationService', function($timeout, Helper, Localization) { return { restrict: 'E', replace: true, scope: { rewardSlug: '@', timeSpan: '@', imageUrl: '@' }, template: '
', link: function($scope, $element) { var $banner = $element.children('.banner'); var $mouseAreas = $element.children('.mouse-areas').children(); Localization.loadCatalog("landingpages"); var STATES = { initial: 'INITIAL', content: 'CONTENT', pending: 'PENDING' }; var getCurrentTimeStamp = function () { return Math.floor(Date.now() / 1000); }; var lastClosedTimeStamp = getCurrentTimeStamp(); var currentState = STATES.initial; var isTimeoutPending = false; var showBanner = function () { if (isTimeoutPending) { return; } var timeout = Math.max(0, ($scope.timeSpan - Math.max(0, getCurrentTimeStamp() - lastClosedTimeStamp))) * 1000; isTimeoutPending = true; $timeout(function () { isTimeoutPending = false; if (STATES.pending !== currentState) { return; } currentState = STATES.initial; $banner.addClass('visible'); }, timeout); }; var hideBanner = function () { $banner.removeClass('visible'); $.get('/rewards/l/' + $scope.rewardSlug); Helper.message('success', [{ message: Localization.catalog.getString('Sign up and