- 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
<script>
RSUI.util.setCookie('cartexp', 'cart-overlay')
var carthtml = `
<div class="toggler mobile">
<img src="https://www.rosettastone.com/nuxt-assets/img/icons/cart.svg" alt="view cart" class='open'>
</div>
<div id="cart-overlay"></div>
<div id="cart-iframe-wrap">
<div class="toggler desktop">
<img src="https://www.rosettastone.com/nuxt-assets/img/icons/cart.svg" alt="view cart" class='open'>
<img src="https://www.rosettastone.com/nuxt-assets/img/icons/x-thick.svg" alt="hide cart" class='close'>
</div>
<div class="cart-header">
<div class="cart-secure"></div>
<a href="" class="close-cart">×</a>
</div>
<div class="loading-div">
<h4></h4>
<p>Preparing your order</p>
<div class='progress'></div>
</div>
<iframe src="" frameborder="0" id='cart-iframe'></iframe>
</div>
`
$(document.body).append(carthtml)
document.domain="rosettastone.com";
// pick number between 0-2
var randomIndex = Math.floor(Math.random() * Math.floor(3));
var loadingMessages = {
en: [
'Bilinguals tend to make more money at work.<br>Slightly more effective than stocking stuffer lotto tickets.',
'Studies show learning a new language makes you more open-minded.<br>(We think it makes you more attractive, too.)',
'Bilingualism can sharpen problem solving skills. <br>Speaking of which, how are you with tangled Christmas lights?'
]
}
window.setTimeout(function() {
$('.loading-div h4').html( loadingMessages.en[randomIndex] ).fadeIn(200)
$('.loading-div p').fadeIn(500)
$('.progress').addClass('active')
},0)
var isIOS = /iPhone|iPad|iPod/i.test(navigator.userAgent)
var smallerThan1024 = window.innerWidth <= 1024
// SBSR Desktop
var desktopAnchor = '.add-to-cart'
var mobileAnchor = '.product-m.product'
var $cartwrap = $('#cart-iframe-wrap')
var $cartOverlay = $('#cart-overlay')
var $iframe = $('#cart-iframe')
$(desktopAnchor).unbind()
$(desktopAnchor).off()
$(mobileAnchor).unbind()
$(mobileAnchor).off()
// unbind click on mobile's arrow
$('.product-m.product div.arrow').off().unbind()
// If catalog, add 83px margin top because of sticky nav
if (/buy-/.test(window.location.href) ) {
$cartwrap.css({top: '83px', 'min-height':0, 'max-height': (window.innerHeight - 83) + 'px'})
//$cartwrap.css({top: '83px', 'min-height':0})
$('.toggler.mobile').css({right: '82px', height: '67px'})
}
/** Android needs this or iframe isn't visible. */
if (smallerThan1024) {
$cartwrap.css('left', 0)
}
$(desktopAnchor).click(function(e) {
e.preventDefault()
openCartIFrame(true, e.target.href )
})
/**
* Clicking mobile cta opens cart,
* passing cart url to openCartOverlay()
*/
$(mobileAnchor).click(function(e) {
var href = null
if (e.target.tagName == 'A') {
href = e.target.href
} else {
href = $(this).closest('a').attr('href')
}
e.preventDefault()
openCartIFrame(true, href)
})
/** The 'x' icon' */
$('.close-cart').click(function(e) {
e.preventDefault()
closeCartOverlay()
})
$('.toggler.desktop').click(function(e) {
if ($cartwrap.css('margin-right') == '0px') {
closeCartOverlay()
} else {
openCartIFrame(false, 'https://secure.rosettastone.com/us_en_store_view/checkout/cart/')
}
})
$('.toggler.mobile').click(function(e) {
openCartIFrame(false, 'https://secure.rosettastone.com/us_en_store_view/checkout/cart/')
})
function openCartIFrame (showLoadig, href) {
console.log('show loading? ' + showLoadig)
$cartOverlay.fadeIn()
if (showLoadig) {
// $('.loading-div').css({'visibility': 'visible', 'z-index': '1'})
} else {
//$('.loading-div').css({'visibility': 'hidden', 'z-index': '-2'})
}
if ( !isIOS && !smallerThan1024) {
$cartwrap.animate({"margin-right": '+=580px'});
} else {
$cartwrap.fadeIn()
}
$cartwrap.fadeIn().css({display: 'flex'})
$('.toggler.desktop .open').fadeOut()
$('.toggler.desktop .close').fadeIn()
// In mobile, we dont show toggler icon. we show 'X'
if (smallerThan1024) {
$('.toggler.mobile').css({display: 'none'});
}
$("body").css({"position": "fixed", width: '100%'});
if (/stgcart=1/.test(window.location.href)) {
href = href.split('secure')
href = href.join('secure.stg')
}
if (/devcart=1/.test(window.location.href)) {
href = href.split('secure')
href = href.join('secure.dev')
}
if (/prepcart=1/.test(window.location.href)) {
href = href.split('secure')
href = href.join('secure.prep')
//href += (window.location.search ? '&' : '?') + 'theme=overlay'
}
// If not showing loading, toggle icon was clicked.
// Don't change iframe src
if (!showLoadig) {
console.log('showing cart')
return
}
if ( /sku/.test(href)) {
console.log('Updating frame src: ' + href)
$iframe.attr('src', '')
window.setTimeout(function() {
$iframe.attr('src', href)
},200)
}
// hide livechat
$('#launcher').fadeOut()
}
function closeCartOverlay (itemCount) {
$cartOverlay.fadeOut()
//$('.loading-div').css({'visibility': 'hidden', 'z-index': '-2'})
$('.toggler.desktop .close').fadeOut()
$('.toggler.desktop .open').fadeIn()
if ( !isIOS && window.innerWidth > 1024) {
$cartwrap.animate({"margin-right": '-=580px'});
} else {
$cartwrap.fadeOut()
}
$('#launcher').fadeIn()
// In mobile, we dont show toggler icon. we show 'X'
if (smallerThan1024) {
$('.toggler.mobile').css({display: 'flex'});
}
$cartOverlay.fadeOut()
$("body").css("position", "static");
}
document.addEventListener('closeCartOverlay', closeCartOverlay)
window.addEventListener('closeCartOverlay', closeCartOverlay)
// Fix iOS's input zoom problem
if (isIOS) {
$('body').append("<style>#cart-iframe-wrap { width: 100%; left: 0 }</style>")
}
</script>
<style>
#cart-overlay {
position: fixed;
height: 100%;
width: 100%;
left: 0;
top: 0;
background: rgba(0,0,0, 0.7);
display: none;
}
#cart-iframe-wrap {
position: fixed;
top: 0;
bottom: 0;
right: 0;
height: 100%;
min-height: 100% ;
z-index: 5;
background: #fff;
display: flex;
flex-direction:column;
align-items: center;
box-shadow: -2px -1px 9px 0px rgba(0,0,0,0.7);
font-family: effra;
width: 580px;
margin-right: -580px;
-webkit-overflow-scrolling: touch;
overflow-scrolling: touch;
display: none;
}
/* Ipad */
@media only screen and (min-device-width : 768px) and (max-device-width : 1024px) {
/*#cart-iframe-wrap { width: 100%; }*/
}
/* Iphone X */
@media only screen and (min-device-width: 375px) and (max-device-width: 812px) and (-webkit-min-device-pixel-ratio: 3) {
/*#cart-iframe-wrap { width: 100%; }*/
}
.toggler {
background: #ecc200 no-repeat center;
display: flex;
cursor: pointer;
justify-content: center;
width: 40px;
height: 60px;
border-bottom-left-radius: 5px;
border-top-left-radius: 5px;
align-items: center;
}
.toggler.desktop {
position: absolute;
width: 40px;
height: 66px;
left: -40px;
}
.toggler .close {
width: 16px;
height: 16px;
}
.toggler .close {
width: 23px;
height: 20px;
}
.toggler .open { display: none; }
.toggler.mobile {
display: none;
position: fixed;
right: 0;
top: 0;
z-index: 5000;
}
.loading-div {
z-index: -1;
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: rgba(62,148,211,.98);
display: flex;
flex-direction: column;
padding: 1em;
color: #fff;
box-sizing: border-box;
}
.loading-div h4 {
font-size: 32px;
font-weight: 700;
margin:1em 0 20px 0;
letter-spacing: .029em;
line-height: 1.2em;
display: none;
font-family: Helvetica, helvetica_bold, effra;
}
.loading-div p {
font-style: italic;
font-size: 22px;
display: none;
margin-bottom: 20px;
font-family: Helvetica, effra;
}
.progress {
background: white;
width: 0px;
height: 3px;
display: none;
}
.progress.active {
display: block;
animation: progress 8s
}
.cart-header {
background: #262626;
color: #fff;
width: 100%;
padding: 0;
box-sizing: border-box;
font-weight: bold;
display: flex;
position: relative;
justify-content: space-between;
height: 0;
}
.close-cart {
text-decoration: none;
color: #fff;
top: -5px;
right: 13px;
z-index: 10;
position: absolute;
font-size: 25px;
display: none;
}
#cart-iframe {
z-index: 2;
width: 100%;
height: 100%;
}
@media (max-width : 1024px) {
#cart-iframe-wrap { width: 100%; }
.toggler { position: fixed; right: 0, top: 0 }
.toggler .open { display: block!important}
.toggler .close { display: none!important}
.toggler.mobile { display: none }
.close-cart { display: block }
}
@keyframes progress {
0% {
width: 0px
}
100% {
width: 100%;
}
}
</style>