- 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
- 313
- 314
- 315
- 316
- 317
- 318
- 319
- 320
- 321
- 322
- 323
- 324
- 325
- 326
- 327
- 328
- 329
- 330
- 331
- 332
- 333
- 334
- 335
- 336
- 337
- 338
- 339
- 340
- 341
- 342
- 343
- 344
- 345
- 346
- 347
- 348
- 349
- 350
- 351
- 352
- 353
- 354
- 355
- 356
- 357
- 358
- 359
- 360
- 361
- 362
- 363
- 364
- 365
- 366
- 367
- 368
- 369
- 370
- 371
- 372
- 373
- 374
- 375
- 376
- 377
- 378
- 379
- 380
- 381
- 382
- 383
- 384
- 385
- 386
- 387
- 388
- 389
- 390
- 391
- 392
- 393
- 394
- 395
- 396
- 397
- 398
- 399
- 400
- 401
- 402
- 403
- 404
- 405
- 406
- 407
- 408
- 409
- 410
- 411
- 412
- 413
- 414
- 415
- 416
- 417
- 418
- 419
- 420
- 421
- 422
- 423
- 424
- 425
- 426
- 427
- 428
- 429
- 430
- 431
- 432
- 433
- 434
- 435
- 436
- 437
- 438
- 439
- 440
- 441
- 442
- 443
- 444
- 445
- 446
- 447
- 448
- 449
- 450
- 451
- 452
- 453
- 454
- 455
- 456
- 457
- 458
- 459
- 460
- 461
- 462
- 463
- 464
- 465
- 466
- 467
- 468
- 469
- 470
- 471
- 472
- 473
- 474
- 475
- 476
- 477
- 478
- 479
- 480
- 481
- 482
- 483
// These languages will show test modules
var pricepoint = 199 //RSI({cat: 'eng', lvl: 'S5', media: 'box'})[0].price
var data = {
fra: {
'3 Months': {
order: 1,
sku: 97357,
msrp: '79.00',
promos: {
q2_199: {code: null, price: '69.00'},
q2_179: {code: null, price: '59.00'},
q2_169: {code: null, price: '59.00'}
}
},
'6 Months': {
order: 2,
sku: 97352,
msrp: '119.00',
promos: {
q2_199: {code: null, price: '89.00'},
q2_179: {code: null, price: '99.00'},
q2_169: {code: null, price: '79.00'}
}
},
'12 Months': {
order: 3,
sku: 97342,
msrp: '179.00',
promos: {
q2_199: {code: null, price: '149.00'},
q2_179: {code: null, price: '129.00'},
q2_169: {code: null, price: '119.00'}
}
},
lifetime: {
order: 4,
sku: 99053,
msrp: '249.00',
promos: {
q2_199: {code: null, price: '199.00'},
q2_179: {code: null, price: '179.00'},
q2_169: {code: null, price: '169.00'}
}
}
},
eng: {
online: {
'1 Month': {
order: 1,
sku: 90472,
msrp: '79.00',
promos: {
199: {code: null, price: '69.00'},
179: {code: null, price: '59.00'},
169: {code: null, price: '59.00'}
}
},
'12 Months': {
order: 2,
sku: 97342,
msrp: '179.00',
promos: {
199: {code: null, price: '149.00'},
179: {code: null, price: '129.00'},
169: {code: null, price: '119.00'}
}
},
Lifetime: {
order: 3,
sku: 99053,
msrp: '249.00',
promos: {
199: {code: null, price: '199.00'},
179: {code: null, price: '179.00'},
169: {code: null, price: '169.00'}
}
}
},
download: {
'Level 1': {
order: 1,
sku: 24360,
msrp: '124.00',
promos: {
199: {code: 'tremblant_L1DL', price: '99.00'},
179: {code: 'kiev_L1DL', price: '89.00'},
169: {code: 'hamburg_L1DL', price: '84.00'}
},
backup: {
sku: 52313,
promos: {
199: {code: 'tremblant_L1CDB', price: '25.00'},
179: {code: 'kiev_L1CDB', price: '25.00'},
169: {code: 'hamburg_L1CDB', price: '25.00'}
}
}
},
'Levels 1-3': {
order: 2,
sku: 24361,
msrp: '199.00',
promos: {
199: {code: 'tremblant_S3DL', price: '159.00'},
179: {code: 'kiev_S3DL', price: '144.00'},
169: {code: 'hamburg_S3DL', price: '134.00'}
},
backup: {
sku: 52315,
promos: {
199: {code: 'tremblant_S3CDB', price: '25.00'},
179: {code: 'kiev_S3CDB', price: '25.00'},
169: {code: 'hamburg_S3CDB', price: '25.00'}
}
}
},
'Levels 1-5': {
order: 3,
sku: 24362,
msrp: '199.00',
promos: {
199: {code: 'tremblant_S5DL', price: '199.00'},
179: {code: 'kiev_S5DL', price: '179.00'},
169: {code: 'hamburg_S5DL', price: '169.00'}
},
backup: {
sku: 52317,
promos: {
199: {code: 'tremblant_S5CDB', price: '25.00'},
179: {code: 'kiev_S5CDB', price: '25.00'},
169: {code: 'hamburg_S5CDB', price: '25.00'}
}
}
}
}
}
}
/*
* Toggles control product area on/off
*/
function toggleControl(flag) {
if (flag == 'off') {
// hide mobile control
$('#products-mobile > .container > *:not(.select-holder):not(#portfolio-mobile-wrap-eng)').hide()
$('#products-mobile').find('.desktop .content > *').hide()
// hide desktop control
$('#prod-options > form').hide()
} else {
$('#products').css({background: '#f8f8f8'})
$('#products-mobile > .container > *:not(.select-holder):not(#portfolio-mobile-wrap-eng)').show()
$('#products-mobile').find('.desktop .content > *').show()
// Show desktop control
$('#prod-options > form').show()
$('a#compareButton').show()
// hide english layout
$desktop_eng.hide()
$desktop_fra.hide()
$mobile_eng.hide()
//$mobile_fra.hide()
}
}
/*
* Handles English
* product area for desktop
*/
function handleEngDesktop() {
toggleControl('off')
$desktop_fra.hide()
$desktop_eng.show()
//var langname = RSI({cat:selectedLang,media:'download'})[0];
var $form_online = $('form.portfolio-poducts-desktop-online')
var $form_download = $('form.portfolio-poducts-desktop-download')
$form_online.find('.labels').empty()
$form_download.find('.labels').empty()
var rendered_form_online = renderEngForm('online')
var rendered_form_download = renderEngForm('download')
$form_online.find('.labels').prepend(rendered_form_online)
$form_download.find('.labels').prepend(rendered_form_download)
$('a#compareButton').hide()
}
/*
* Handles English
* product area for mobile
*/
function handleEngMobile() {
toggleControl('off')
$('#products').css({background: '#f8f8f8'})
$desktop_fra.hide()
$mobile_eng.show()
//var langname = RSI({cat:selectedLang,media:'download'})[0];
var compiled_template_online = ''
var compiled_template_download = ''
$form_online = $('form.portfolio-poducts-desktop-online')
$form_download = $('form.portfolio-poducts-desktop-download')
$form_online.find('.labels').empty()
$form_download.find('.labels').empty()
// **** COMPILE FORM FOR ONLINE
var rendered_form_online = renderEngForm('online')
var rendered_form_download = renderEngForm('download')
$form_online.find('.labels').prepend(rendered_form_online)
$form_download.find('.labels').prepend(rendered_form_download)
// When page loads, we update big sale price with sale price of checked input
var initialprice_online = $('#portfolio-mobile-wrap-eng form:eq(0) input[type=radio]:checked')
.parent()
.siblings('.portfolio-saleprice')
.children('span')
.html()
$('#portfolio-mobile-wrap-eng form:eq(0) > .portfolio-saleprice').html(initialprice_online)
var initialprice_download = $('#portfolio-mobile-wrap-eng form:eq(1) input[type=radio]:checked')
.parent()
.siblings('.portfolio-saleprice')
.children('span')
.html()
$('#portfolio-mobile-wrap-eng form:eq(1) > .portfolio-saleprice').html(initialprice_download)
}
/*
* Handles French, Italian, German
* product area for desktop AND mobile.
*/
function handleFra() {
toggleControl('off')
$desktop_eng.hide()
$mobile_eng.hide()
$desktop_fra.show()
$('a#compareButton').hide()
$('#products').css({background: '#fff'})
//$('#dropdown-language + .portfolio-desktop-wrap-fra').remove()
//$('#dropdown-language').after($desktop_fra.clone(true))
}
/*
* Handles French, Italian, German
* product area for mobile
*/
/*function handleFraMobile() {
toggleControl('off')
$mobile_eng.hide()
}*/
// TnT adds the divs to bottom of page. Put them where we need them
$desktop_eng = $('#portfolio-desktop-wrap-eng').detach()
$('#prod-options').append($desktop_eng)
$mobile_eng = $('#portfolio-mobile-wrap-eng').detach()
$('#products-mobile').append($mobile_eng)
$desktop_fra = $('.portfolio-desktop-wrap-fra').detach()
$('#prod-options').after($desktop_fra)
$('#products-mobile').after($desktop_fra)
//$mobile_fra = $('#portfolio-mobile-wrap-fra').detach()
//
/*
* DESKTOP LANG CLICK - overwrite control's
* Test module only handles FIGS. We still let the original click
* handler do its other jobs, but if language is FIGS, we
* add on to the handler (by adding another handler =/ )
*/
$('.language-buy-list li a').click(function() {
selectedLang = $(this).attr('id')
var $desktop;
if (selectedLang == 'eng') {
handleEngDesktop()
//$('.nolanguage').hide()
//$('span.langname').html(langname)
} else if (selectedLang.match(/deu|fra|ita/)) {
handleFra()
} else {
// show control module
toggleControl('on')
}
})
// ********** ADDING TO CART - ENG DESKTOP AND MOBILE
$('a.portfolio-addtocart-eng').click(function(e) {
e.preventDefault()
if ($(this).hasClass('portfolio-mobile-addtocart')) {
// add to cart was clicked in mobile
var $form = $('#portfolio-mobile-wrap-eng .tabs-content > div:visible form')
} else {
// add to cart was clicked in desktop
var $form = $(this).parents('form')
}
// grab sku of select
var sku = $form.find('input[type=radio]:checked').data('sku')
// grab promocode
var promo = $form.find('input[type=radio]:checked').data('promo')
// Key so we can get cd backup if needed
var key = $form.find('input[type=radio]:checked').data('key')
echo('sku: ', sku)
echo('promo: ', promo)
echo('key: ', key)
// Update sku and promo if cd backup is checked
var related_sku = null
if ($form.hasClass('portfolio-poducts-desktop-download') && $form.find('input[name=backupcd]').is(':checked')) {
related_sku = data.eng.download[key].backup.sku
promo = data.eng.download[key].backup.promos[pricepoint].code
}
if ($form.find('input[name=gift]').is(':checked')) {
}
// http://secure.stg.rosettastone.com/us_en_store_view/checkout/cart/add/sku/24362/category_id/ENG/related_sku/52317
// But Back up cd has promocode too, pass two promocodes? or do we overwrite other promo?
carturl = 'https://secure.rosettastone.com/us_en_store_view/checkout/cart/add/sku/' + sku + '/category_id/' + selectedLang.toUpperCase()
carturl += related_sku ? '/related_sku/' + related_sku + '/' : ''
carturl += '?pc=' + promo
console.log(carturl)
})
// ********** ADDING TO CART - ENG MOBILE
$('.portfolio-mobile-addtocart').click(function(e) {
e.preventDefault()
// find which tab content is visible, and grab value from its form.
var sku = $form.find('input[type=radio]:checked').data('sku')
console.log(sku)
})
// ********** ADDING TO CART - FRA/iTA/DEU DESKTOP + MOBILE
$('a.portfolio-addtocart-fra').click(function(e,i) {
e.preventDefault()
alert(5)
})
/*
* MOBILE LANG CLICK - overwrite control's
*
*/
$('select#dropdown-language').change(function() {
if (selectedLang == 'eng') {
handleEngMobile()
} else if (selectedLang.match(/deu|fra|ita/)) {
handleFra()
} else {
// Show control
toggleControl('on')
}
});
/*
* Handle mobile form click - we basically update the big price
* under the radio buttons
*/
$('#portfolio-mobile-wrap-eng form').on('change', 'input[type=radio]', function() {
var saleprice = $(this).parents('label').find('.portfolio-saleprice span').html()
$(this).parents('form').children('.portfolio-saleprice').html(saleprice)
})
/*
* Show right products when clicking tabs in mobile
*/
var $tabscontent = $('.tabs-content')
$('.tabs > a').click(function(e, i) {
e.preventDefault()
$(this).parent().find('.active').removeClass('active')
$(this).addClass('active')
var index = $(this).index()
$tabscontent.children('div').hide()
$tabscontent.children('div').eq(index).show()
})
/*
* Renders product form for English.
* @param {str} type - 'online' or 'download'
*/
function renderEngForm(type) {
var compiled = ''
Object.keys(data.eng[type]).forEach(function(key,i) {
var obj = data.eng[type][key]
var sku = obj.sku
var msrp = obj.msrp
var promo = obj.promos[pricepoint].code
var price = obj.promos[pricepoint].price
var checked = i == 0 ? 'checked' : ''
compiled += '<label>'
+ '<div class="fakeinput">'
+ '<input type="radio" name="length" '+ checked +' data-sku="'+ sku +'" data-promo="'+ promo +'" data-key="'+key+'">'
+ '<span></span>'
+ '</div>'
+ '<div class="durationcopy">'+ key +'</div>'
+ '<div class="portfolio-msrpprice"><span>$'+ msrp +'</span></div>'
+ '<div class="portfolio-saleprice"><span>$'+ price +'</span></div>'
+ '</label>'
})
return compiled
}
if (grabUrlParam('language')) {
$('#' + grabUrlParam('language')).click()
}
window.console = window.console || {
echo: function (mg) { console.log(msg)}
};
echo = window.console.log