Mon Nov 13 2017
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
<style>
        .pushdown {
            display: table;
            height: 200px;
            width: 100%;
            
        }

        .pushdown > div {
            display: table-cell;
            vertical-align: middle;
        }

        .pushdown > .pushdown-left {
            width: 40%;
            background: url('https://www.rosettastone.com/lp/globals/img/get-on-the-list/logo-desktop.png')  no-repeat #ecc200 right center;
            background-size: 50%;
    
        }

        .pushdown-divider {
            width: 25px;
            background: url('https://www.rosettastone.com/lp/globals/img/get-on-the-list/divider.jpg') no-repeat #262626;
            background-size: contain;
        }

        .pushdown > .pushdown-right {
            background: url('https://www.rosettastone.com/lp/globals/img/get-on-the-list/bg-desktop.jpg') #262626;
            padding-left: 2em;
            background-size: contain;
        }
        .pushdown > .pushdown-right h3 {
            font-size: 1.5em;
            color: #fff;
            margin-top:0;
        }

        .pushdown > .pushdown-right p {
            color: #ecc200;
        }

        .pushdown-actions {
            position: relative;
            margin-top: 1em;
        }
        .pushdown > .pushdown-right input[type=email] {
            display: inline-block;
            padding: 8px;
            box-sizing: border-box;
            width: 200px;
            border: 1px solid transparent;
        }

        .pushdown > .pushdown-right input[type=submit] {
            background: transparent;
            border: 2px solid white;
            color: white;
            padding: 8px 20px;
            display: inline-block;
            transition: background-color 0.3s, color 0.3s;
        }

        .pushdown-right input[type=submit]:hover {
            background-color: #fff;
            color: #262626
        }

        .email-error {
            position: absolute;
            bottom: -25px;
            color: red;
            display: none;
        }

        @media (max-width: 600px) {
            .pushdown {
                height: auto;
                padding: 0.5em 0.5em 2em 0.5em;
                box-sizing: border-box;
                display:  block;
                background: url('https://www.rosettastone.com/lp/globals/img/get-on-the-list/bg-mobile.png')  #262626;
                background-size: contain;
            }
            .pushdown, .pushdown > div {
                display:  block;
                margin: 0 auto;
            }

            .pushdown > .pushdown-left {
                width: 100%;               

                
            }
            .pushdown > .pushdown-right {
                padding-left: 0;
                background: url('https://www.rosettastone.com/lp/globals/img/get-on-the-list/logo-mobile.png') no-repeat;
                background-position: top right;
                background-size: 35%;
            }

            .pushdown > .pushdown-right h3 {
                width: 50%;
                padding-top: 20px;
                line-height:  32px;
                font-size: 2em;
            }

            .pushdown > .pushdown-right p {
                margin-top: 15px;
                width: 70%;
                line-height: 25px;
            }
            
            .pushdown-actions {
                text-align: center;                
                position: relative;
            }
            .pushdown > .pushdown-right input[type=email],
            .pushdown > .pushdown-right input[type=submit] {
                display: block;
                width: 100%;
                margin: 0 auto;
                padding: 15px 10px;
            }

            .pushdown > .pushdown-right input[type=submit] {
                margin-top: 1em;
                border-radius: 4px;
            }            
        }
        
    </style>

    <div class="pushdown">
        <div class="pushdown-left"></div>
        <div class="pushdown-divider"></div>
        <div class="pushdown-right">
            <h3>Be the first to know</h3>
            <p>Sign up for a first look at our best Black Friday and Cyber Monday deals.</p>

            <form class="pushdown-actions">
                <input type="email" placeholder="EMAIL ADDRESS" class="pushdown-email">
                <input type="submit" value="GET ON THE LIST">
                <div class="email-error">Email is invalid</div>
            </form>
        </div>
    </div>

    <script>
        /*
         * So i started doing it jqueryless, then used jquery
         * for some dom stuff because we still use jquery everywhere
         * and they want this launched asap.
         * ps: rip viserion
         */
        isDesktop = (function() {
            if (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)) 
            {
                return false
            }
            else
            {
                return true
            }
        })();

        var qs = document.querySelector.bind(document)

        // Append pushdown to top, then make it visible
        var $pushdown = $('.pushdown').detach()
        $('body').prepend($pushdown)
        $pushdown.slideDown()

        var $form = qs('form.pushdown-actions')
        $form.addEventListener('submit', function(e) {
          e.preventDefault()
          var email = qs('.pushdown-email').value

          if (! validateEmail(email))
          {
              showErrorMessage()
          }
          else
          {
            verify_real_email_pushdown(email, emailAcceptedPushdown, emailRejectedPushdown)
          }
        })

        function submitEmailToEC(email)
        {
            var defer = jQuery.Deferred()
            var data = {
                email : email,
                //demo_lang : map[demoLang],
                cis_name : 'GetOnTheList',
                website: 'US_WEBSITE',
                //form_type : 'demo',
                demo_type : isDesktop ? 'Specialoffer_Desktop' : 'Specialoffer_Mobile',
                form_url : window.location.pathname,
                newsletter_type : "Bottom_Landing_GOTL",
                cid : _satellite.getVar("mostrecentcampaign")
            }

            var url = (window.location.href.search(/(\.stg\.)|(\.local)/i)>-1 ?'//www.stg' :'//www')
            + '.rosettastone.com/?p_p_id=rosettaajaxsubmit_WAR_rosettaajaxsubmitportlet&p_p_lifecycle=2&redirect2mobile=no';

            var request = $.ajax({
                url: url,
                type: "POST",
                data: data
            });

            request.done(function(msg) {
            if (JSON.parse(msg)[0]['cisFlag']  == 'true') {
                defer.resolve('success')
            } else {
                defer.resolve('fail')
            }
            })

            return defer.promise()  
        }

        function validateEmail(email)
        {
            var re = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
            return re.test(email);
        }

        function showErrorMessage()
        {
            qs('.email-error').style.display = 'block'
        }

        function emailAcceptedPushdown(email)
        {         
          $.when( submitEmailToEC(email)).then(
            // Success
            function() {
              $(document).trigger('demo_events_version', {version: 1})
              $(document).trigger('special_offer')
              window.setTimeout(function() {
                window.location.href = '//rosettastone.com/lp/sbsr/listagi'
              },1000)
              
            },
            // Rejected
            function() {
              showErrorMessage()
            }
          )
        }

        function emailRejectedPushdown()
        {
          showErrorMessage()
        }

        function verify_real_email_pushdown(email, success_cb, failure_cb)
        {        


          if(window.briteverifyToken)
          {

            var token = window.briteverifyToken;
            var url = 'https://forms-api-v1.briteverify.com/api/submissions/verify.json?callback=briteverify&form_token=4047df1c-5078-4e96-b335-f61aa2b92891&token='+token+'&email='+email+'&_='+Date.now();

            var script = document.createElement('script');
            script.src = url;
            document.body.appendChild(script);


            // if the script url doesn't work (maybe they changed the api)
            script.onerror = function(e)
            {
              // ignore verification and move on
              success_cb(email);
            };

            window.briteverify = function(data)
            {
              try
              {

                if(data.status!=='invalid')
                {
                  success_cb(email);
                }
                else
                {
                  failure_cb();
                }
                document.body.removeChild(script);
            }
            catch(e)
            {
              // if error, ignore verification and move on
              success_cb(email);
            }
              delete window.briteverify;
            }
          }
        }
    </script>