Tue May 15 2018
Copied to clipboard! Copy reply
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
  • 82
  • 83
  • 84
  • 85
  • 86
  • 87
  • 88
  • 89
  • 90
  • 91
  • 92
  • 93
  • 94
  • 95
  • 96
  • 97
  • 98
  • 99
  • 100
  • 101
  • 102
  • 103
  • 104
  • 105
  • 106
  • 107
  • 108
  • 109
  • 110
  • 111
  • 112
  • 113
  • 114
  • 115
  • 116
  • 117
  • 118
  • 119
  • 120
  • 121
  • 122
  • 123
  • 124
  • 125
  • 126
  • 127
  • 128
  • 129
  • 130
  • 131
  • 132
  • 133
  • 134
  • 135
  • 136
  • 137
  • 138
  • 139
  • 140
  • 141
  • 142
  • 143
  • 144
  • 145
  • 146
  • 147
  • 148
  • 149
  • 150
  • 151
  • 152
  • 153
  • 154
  • 155
  • 156
  • 157
  • 158
  • 159
  • 160
  • 161
  • 162
  • 163
  • 164
  • 165
  • 166
  • 167
<!-- OneTrust Cookies Consent Notice (Production CDN, rosettastone.com, en-GB) start -->

<script type="text/javascript">

(function(){

	// max wait time for API to return country code
	var max_wait_for_country_code = (window.gdpr && window.gdpr.max_wait_for_country_code || 500);


	// initialize onetrust popup (with url given in onetrust dashboard)
	var onetrust_popup_url = 'https://cdn.cookielaw.org/consent/c4ba6041-9063-4f3f-9cea-eca312d6194b.js';
	initialize_onetrust_popup(onetrust_popup_url);


	// determine what to do with popup after country code wait
	setTimeout(function(){


		// unblock cookie consent popup if user is NOT from US
		if( !(window.gdpr && window.gdpr.country_code==='US') ){
			unblockOneTrust();
		}


		// this runs on page load and every time user updates cookie preferences
		window.OptanonWrapper = function(){
			if(window.OptanonActiveGroups){
				
				var all_cookies_accepted = (/,4,/).test(window.OptanonActiveGroups);
				var analytics_cookies_accepted = (/,(2|3),/).test(window.OptanonActiveGroups);
				var no_cookies_accepted = window.OptanonActiveGroups===',1,';

				if(all_cookies_accepted){
					window.gdpr && window.gdpr.trigger('gdpr_accept_all_cookies');
				}
				else if(analytics_cookies_accepted){
					window.gdpr && window.gdpr.trigger('gdpr_accept_analytics_only');
				}
				else if(no_cookies_accepted){
					window.gdpr && window.gdpr.trigger('gdpr_revoke_cookie_consent');
				}
			}
		}



		// Rosetta Stone's custom fixes ensure OneTrust's dark overlay appears and disappears when it should
		perform_onetrust_fixes();



	}, max_wait_for_country_code);










	// ******************************************************
	// Utility functions
	// ******************************************************


	function initialize_onetrust_popup(onetrust_url){
		var onetrust = document.createElement('script');
		onetrust.setAttribute('src', onetrust_url);
		onetrust.setAttribute('type', 'text/javascript');
		onetrust.setAttribute('charset', 'UTF-8');
		document.head.appendChild(onetrust);

		// make sure onetrust popup starts temporarily hidden while code decides whether to show it
		blockOneTrust();
	}

	function blockOneTrust(){
		var one_trust_hider = document.createElement('style');
		one_trust_hider.setAttribute('id','__gdpr_onetrust_hider');
		var one_trust_hider_css = ''
			+'#optanon, .optanon-alert-box-wrapper{'
				+'display: none !important;'
			+'}'
			+'';
		one_trust_hider.innerHTML = one_trust_hider_css;
		document.querySelector('head').appendChild(one_trust_hider);
	}

	function unblockOneTrust(){
		var one_trust_hider = document.getElementById('__gdpr_onetrust_hider');
		document.querySelector('head').removeChild(one_trust_hider);
	}


	function perform_onetrust_fixes(){

		function fadeOut(selector, duration, callback){
			duration = duration || 400;

			var elems = Array.prototype.slice.call(document.querySelectorAll(selector));
			elems.forEach(function(elem){
				elem.style.transition = 'opacity '+duration+'ms';
			});
			setTimeout(function(){
				elems.forEach(function(elem){
					elem.style.opacity = 0;
				});
			},0);
			setTimeout(function(){
				elems.forEach(function(elem){
					elem.style.display = 'none';
				});

				callback && callback();
			},duration);

		}

		function fadeIn(selector, duration, callback){
			duration = duration || 400;

			var elems = Array.prototype.slice.call(document.querySelectorAll(selector));
			elems.forEach(function(elem){
				elem.style.transition = 'opacity '+duration+'ms';
				elem.style.display = 'block';
			});
			setTimeout(function(){
				elems.forEach(function(elem){
					elem.style.opacity = 1;
				});
			},0);

			setTimeout(function(){
				callback && callback();
			},duration);
		}

		function getElems(selector){
			return Array.prototype.slice.call(document.querySelectorAll(selector));
		}

		// Rosetta Stone's custom fixes ensure OneTrust's dark overlay appears and disappears when it should
		setTimeout(function(){
			getElems('.optanon-alert-box-close').forEach(function(elem){
				elem.addEventListener('click', function(){
					fadeOut('#optanon-popup-bg', 400, blockOneTrust);
				});
			});
			getElems('.optanon-close-link').forEach(function(elem){
				elem.addEventListener('click', function(){
					setTimeout(function(){
						fadeIn('#optanon-popup-bg', 400);
					}, 500);
				});
			});
		}, 1000);
	}

})();


</script>

<!-- OneTrust Cookies Consent Notice (Production CDN, rosettastone.com, en-GB) end -->