Mon Mar 19 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
  • 168
  • 169
  • 170
  • 171
  • 172
  • 173
  • 174
  • 175
  • 176
  • 177
  • 178
  • 179
  • 180
  • 181
  • 182
  • 183
  • 184
  • 185
  • 186
  • 187
  • 188
  • 189
  • 190
  • 191
  • 192
  • 193
  • 194
  • 195
  • 196
  • 197
  • 198
  • 199
  • 200
  • 201
  • 202
  • 203
  • 204
  • 205
  • 206
  • 207
  • 208
  • 209
  • 210
  • 211
  • 212
  • 213
  • 214
  • 215
  • 216
  • 217
  • 218
  • 219
  • 220
  • 221
  • 222
  • 223
  • 224
  • 225
  • 226
  • 227
  • 228
  • 229
  • 230
  • 231
  • 232
  • 233
  • 234
  • 235
  • 236
  • 237
  • 238
  • 239
  • 240
  • 241
  • 242
  • 243
  • 244
  • 245
  • 246
  • 247
  • 248
  • 249
  • 250
  • 251
  • 252
  • 253
  • 254
  • 255
  • 256
  • 257
  • 258
  • 259
  • 260
  • 261
  • 262
  • 263
  • 264
  • 265
  • 266
  • 267
  • 268
  • 269
  • 270
  • 271
  • 272
  • 273
  • 274
  • 275
  • 276
  • 277
  • 278
  • 279
  • 280
  • 281
  • 282
  • 283
  • 284
  • 285
  • 286
  • 287
  • 288
  • 289
  • 290
  • 291
  • 292
  • 293
  • 294
  • 295
  • 296
  • 297
  • 298
  • 299
  • 300
  • 301
  • 302
  • 303
  • 304
  • 305
  • 306
  • 307
  • 308
  • 309
  • 310
  • 311
  • 312
$(function(){

	setTimeout(function(){

		// ********************************************************
		// OVERALL TEST SETTINGS - WS-2579 meclabs product combos
		// ********************************************************

		var current_experience = 'a';

		var experience_data = {
			a: {
				lvl_to_hide: '06',
				lvls_to_combine: ['12', '24'],
				group_name: 'Annual',
				savings_message: 'Pay annually and save'
			},
			b: {
				lvl_to_hide: '24',
				lvls_to_combine: ['06', '12'],
				group_name: 'Extended Value',
				savings_message: 'Pay semi-annually and save'
			}
		}

		var exp = experience_data[current_experience];








		// ************************************************
		// DESKTOP
		// ************************************************

		function $desktop_product_for_lvl(lvl){
			var cache = $desktop_product_for_lvl;
			var cached_lvl = 'cache_' + lvl;

			cache[cached_lvl] = cache[cached_lvl] || $('.oct_2016_addtocart_square[data-lvl='+lvl+']').closest('.oct_2016_product_square');

			return cache[cached_lvl];
		}
		$desktop_product_for_lvl(exp.lvl_to_hide).hide();
		$('.oct_2016_best_value').hide();



		$('.oct_2016_product_square').css({
			'margin': '0px'
		});







		$desktop_product_for_lvl('03').before(''
			+'<div class="product_group_desktop">'
				+'<div class="product_group_title_desktop">'
					+'<div class="product_group_title_desktop_primary">Quarterly</div>'
					+'<div class="product_group_title_desktop_secondary">Subscription</div>'
				+'</div>'
			+'</div>'
		+'');

		$('.product_group_desktop:eq(0)').append(
			$desktop_product_for_lvl('03')
		);




		function combine_desktop_products(left_product_lvl, right_product_lvl){

			$desktop_product_for_lvl(left_product_lvl).css({
				'border-right': '1px solid #bba'
			});

			$desktop_product_for_lvl(left_product_lvl).before(''
				+'<div class="product_group_desktop">'
					+'<div class="product_group_top_callout">'
						+exp.savings_message
					+'</div>'
					+'<div class="product_group_title_desktop">'
						+'<div class="product_group_title_desktop_primary">'+exp.group_name+'</div>'
						+'<div class="product_group_title_desktop_secondary">Subscriptions</div>'
					+'</div>'
				+'</div>'
			+'');

			$('.product_group_desktop:eq(1)').append(
				$desktop_product_for_lvl(left_product_lvl),
				$desktop_product_for_lvl(right_product_lvl)
			);

		}
		combine_desktop_products(exp.lvls_to_combine[0], exp.lvls_to_combine[1]);




		$('body').append(''
			+'<style>'
				+'.product_group_top_callout{'
					+'font-size: 16px;'
					+'text-transform: uppercase;'
					+'font-style: italic;'
					+'color: #dce0e3;'
					+'margin-bottom: 9px;'
					+'text-align: left;'
					+'font-family: gothammedium, sans-serif;'
				+'}'
				+'.product_group_desktop{'
					+'margin: 9px 27px;'
					+'vertical-align: bottom;'
					+'display: inline-block;'
					+'border-bottom-left-radius: 8px;'
					+'border-bottom-right-radius: 8px;'
					+'overflow: hidden;'
				+'}'
				+'@media(max-width:800px){'
					+'.product_group_desktop{'
						+'margin: 9px;'
					+'}'
				+'}'
			+'</style>'
		+'');



		$('.product_group_title_desktop').css({
			'font-size': '18px',
			'text-transform': 'uppercase',
			'padding': '18px 9px',
			'background-color': '#f1f1f1',
			'color': '#330',
			'letter-spacing': '0.01em',
			'border-top-left-radius': '8px',
			'border-top-right-radius': '8px'
		});

		$('.product_group_title_desktop_primary').css({
			'font-size': '22px',
			'font-family': 'gothambold, sans-serif',
			'margin-bottom': '0.1em'
		});
		$('.product_group_title_desktop_secondary').css({
			'color': '#553',
			'font-size': '17px'
		});





		$('.oct_2016_addtocart_square').css({
			'margin': 'auto'
		});

		$('.oct_2016_product_square').css({
			'vertical-align': 'bottom',
			'border-radius': '0px'
		});


		$('.oct_2016_product_square_header').css({
			'background-color': '#ecc200',
			'padding': '9px',
			'border-radius': '0px',
			'font-size': '15px'
		});

		$('.oct_2016_product_square_subhead').css({
			'margin-left': '0.5em',
			'display': 'inline-block',
			'font-size': '15px'
		});












		// ************************************************
		// MOBILE
		// ************************************************






		function $mobile_product_for_lvl(lvl){
			var cache = $mobile_product_for_lvl;
			var cached_lvl = 'cache_' + lvl;

			cache[cached_lvl] = cache[cached_lvl] || $('.js_radio_lvl_mobile[data-lvl='+lvl+']').closest('.mobile_product_label');

			return cache[cached_lvl];
		}

		function hide_mobile_product(lvl){
			$mobile_product_for_lvl(lvl).hide();
			$mobile_product_for_lvl(lvl).next('.monthly_mobilebottom').hide();
		}

		hide_mobile_product(exp.lvl_to_hide);



		// restyle mobile labels
		$('.mobile_product_label').css({
			'top': 'unset',
			'border-top-left-radius': '5px',
			'border-top-right-radius': '5px',
			'border-bottom-right-radius': 'unset',
			'border-bottom-left-radius': 'unset'
		});

		// hide mobile best value
		$('.labelcontain.topper').hide();









		$('body').append(''
			+'<style>'
				+'.labelcontain.topper{'
					+'background-color: #392E07;'
					+'color: #fff;'
					+'font-family: gothambook, sans-serif;'
					+'padding: 0.45em 0;'
					+'font-size: 15px;'
					+'max-width: 370px;'
				+'}'
				+'.labelcontain.topper span{'
					+'font-family: gothambold, sans-serif;'
				+'}'
			+'</style>'
		+'');


		function add_topper_to_label(lvl, html_message){

			var topper_spacing = lvl==='03' ? 'style="margin-top: 30px;"' : '';

			$mobile_product_for_lvl(lvl).css({
				'border-radius': 'unset',
				'margin-top': '0px'
			});
			$mobile_product_for_lvl(lvl).before(''
				+'<div class="labelcontain topper" '+topper_spacing+'>'
					+ html_message
				+'</div>'
			+'');

		}
		add_topper_to_label('03', '<span>Quarterly</span> Subscription');




		$('.mobile_products_container').prepend(''
			+'<div class="product_group_top_callout" style="max-width: 370px; margin-left: auto; margin-right: auto;">'
				+exp.savings_message
			+'</div>'
		+'');



		function group_mobile_products(bottom_lvl, top_lvl){
			add_topper_to_label(top_lvl, '<span>'+exp.group_name+'</span> Subscriptions');

			$mobile_product_for_lvl(bottom_lvl).css({
				'border-radius': 'unset',
				'margin-top': '0px'
			});

			var $due_today = $mobile_product_for_lvl(top_lvl).next('.monthly_mobilebottom');
			$due_today.css({
				'border-radius': 'unset',
				'border-bottom': '1px solid #bbb'
			});


			// make sure highest level is clicked (so hidden 24m level won't be selected by default)
			$mobile_product_for_lvl(top_lvl).click();
		}

		group_mobile_products(exp.lvls_to_combine[0], exp.lvls_to_combine[1]);



	}, 250);

});