<commit_before>MLS.ui = {

    /*
     * Social Share - Handle clicking of social share toolbar
     *
     */
    /*var serverError = 'Something went wrong. Mind trying again?',
        successMessageTitle = 'Success!',
        successMessage1 = 'You have shared the',
        successMessage2 = 'with:';*/

    socialShare : {
        init: function () {
            var $socialList = $jQ('.social-share-module').find('.social-list'),
            $socialItems = $socialList.find('.social-item'),
            $socialItemsWithContext,
            $overlay,
            $scope,
            listWidth,
            overlayWidth;

            function socialItemReset($context) {
                if ($context !== undefined) {
                    $context.removeClass('active');
                    $context.find('.overlay').hide();
                    $context.find('.social-link').show();
                } else {
                    $socialItems.removeClass('active');
                    $socialItems.find('.overlay').hide();
                    $socialItems.find('.social-link').show();
                }
            }

            function modalClose($context, $content) {
                $jQ('#share-modal-overlay, #share-modal-display').fadeOut('medium');
                $jQ(document).off('keyup.social');
                $jQ($context).html($content);
            }

            socialItemReset();
            $socialItems.not('.active').on('click', function (e) {
                e.preventDefault();
                $scope = $jQ(this);
                $socialItemsWithContext = $scope.parents('.social-list').find('.social-item');

                socialItemReset($socialItemsWithContext);
                $scope.addClass('active');

                if ($scope.hasClass('email')) {
                    var $emlOverlay = $scope.find('.overlay'),
                    $emlModal = $emlOverlay.html();
                    if ($jQ('#share-modal-overlay').length <= 0) {
                        $jQ(document.body).append('<div id="share-modal-overlay"/>');
                    }
                    if ($jQ('#share-modal-display').length <= 0) {
                        $jQ(document.body).append('<div id="share-modal-display"/>');
                    }

                    $socialItemsWithContext.css('width', '20%');
                    $jQ('#share-modal-overlay, #share-modal-display').hide().fadeIn('medium', function () {
                        $jQ('#share-modal-overlay').one('click', function () {
                            modalClose($emlOverlay, $emlModal);
                        });
                        $jQ('#share-modal-display').one('click', '.close-overlay', function (e) {
                            e.preventDefault();
                            modalClose($emlOverlay, $emlModal);
                        });
                        $jQ(document).on('keyup.social', function (e) {
                            if (e.keyCode === 27) {
                                modalClose($emlOverlay, $emlModal);
                            }
                        });
                    });

                    // center modal on screen
                    $jQ('#share-modal-display').css({
                        top: ($jQ(window).outerHeight() / 2 - $jQ('#share-modal-display').outerHeight() / 2) + $jQ(document).scrollTop(),
                        left: ($jQ(window).outerWidth() / 2 - $jQ('#share-modal-display').outerWidth() / 2) - $jQ(document).scrollLeft()
                    });

                    var $shareModalDisplay = $jQ('#share-modal-display');
                    $shareModalDisplay.html($emlModal);
                    $emlOverlay.html('');
                    $jQ('#share-submit').uniform();
                    
                    MLS.ui.placeholderValidationRules();
                    $shareForm = $jQ("#share-modal");
                    MLS.ui.emailValidation($shareForm);
                    
                    $shareForm.on('submit', function (e) {
                        e.preventDefault();
                        e.stopPropagation();

                        var shareFormValid = false;
                        shareFormValid = $shareForm.valid();
                        if (shareFormValid) {    
                            var $theForm = $jQ("#share-modal".form);
                            MLS.ajax.sendRequest(
                                $theForm.attr('action'),
                                $theForm.serialize(),
                                // AJAX request success
                                function (d) {
                                    // server success response
                                    if (data.hasOwnProperty('success')) {
                                        $shareModalDisplay.html(d.success.responseHTML);
                                    }
                                    // server error response
                                    else {
                                        $jQ("#share-modal")[0].reset(); //reset fields
                                        $shareModalDisplay.html(d.error.responseHTML);
                                    }
                                },
                                // AJAX request error
                                function (d) {
                                    // For demo - start error response
                                    //$shareForm[0].reset(); 
                                    //$jQ('#share-modal-display .share-error').html('<p class="message">Something went wrong. Mind trying again?</p>');
                                    //For demo - end error response
                                    //For demo - success response                                     
                                    $shareModalDisplay.html('<div class="share-success"><h3 class="share-title">Success!</h3><a href="#" id="close-social-overlay" class="close-overlay"></a><div class="overlay-content"><figure class="share-fig"><img src="img/product-detail-page/pdp-products/belkin-charger.png" alt="Photo of Belkin AC Charger with Swivel Plug" title="Belkin AC Charger with Swivel Plug"></figure><p class="message">You have shared the Belkin AC Charger with Swivel Plug with: <span class="recipient-email"><EMAIL></span></p></div></div>');
                                }
                            );
                        }
                    });
                } 
                else {
                    $overlay = $scope.find('.overlay'),
                    $socialList = $socialItemsWithContext.parents('.social-list'),
                    listWidth = $socialList.outerWidth();

                    overlayWidth = $overlay.outerWidth();
                    $overlay.show().css('width', 0);
                    $scope.find('.social-link').hide();
<commit_msg>VWLS-1188 | Changed selector for error response<commit_after>MLS.ui = {

    /*
     * Social Share - Handle clicking of social share toolbar
     *
     */
    /*var serverError = 'Something went wrong. Mind trying again?',
        successMessageTitle = 'Success!',
        successMessage1 = 'You have shared the',
        successMessage2 = 'with:';*/

    socialShare : {
        init: function () {
            var $socialList = $jQ('.social-share-module').find('.social-list'),
            $socialItems = $socialList.find('.social-item'),
            $socialItemsWithContext,
            $overlay,
            $scope,
            listWidth,
            overlayWidth;

            function socialItemReset($context) {
                if ($context !== undefined) {
                    $context.removeClass('active');
                    $context.find('.overlay').hide();
                    $context.find('.social-link').show();
                } else {
                    $socialItems.removeClass('active');
                    $socialItems.find('.overlay').hide();
                    $socialItems.find('.social-link').show();
                }
            }

            function modalClose($context, $content) {
                $jQ('#share-modal-overlay, #share-modal-display').fadeOut('medium');
                $jQ(document).off('keyup.social');
                $jQ($context).html($content);
            }

            socialItemReset();
            $socialItems.not('.active').on('click', function (e) {
                e.preventDefault();
                $scope = $jQ(this);
                $socialItemsWithContext = $scope.parents('.social-list').find('.social-item');

                socialItemReset($socialItemsWithContext);
                $scope.addClass('active');

                if ($scope.hasClass('email')) {
                    var $emlOverlay = $scope.find('.overlay'),
                    $emlModal = $emlOverlay.html();
                    if ($jQ('#share-modal-overlay').length <= 0) {
                        $jQ(document.body).append('<div id="share-modal-overlay"/>');
                    }
                    if ($jQ('#share-modal-display').length <= 0) {
                        $jQ(document.body).append('<div id="share-modal-display"/>');
                    }

                    $socialItemsWithContext.css('width', '20%');
                    $jQ('#share-modal-overlay, #share-modal-display').hide().fadeIn('medium', function () {
                        $jQ('#share-modal-overlay').one('click', function () {
                            modalClose($emlOverlay, $emlModal);
                        });
                        $jQ('#share-modal-display').one('click', '.close-overlay', function (e) {
                            e.preventDefault();
                            modalClose($emlOverlay, $emlModal);
                        });
                        $jQ(document).on('keyup.social', function (e) {
                            if (e.keyCode === 27) {
                                modalClose($emlOverlay, $emlModal);
                            }
                        });
                    });

                    // center modal on screen
                    $jQ('#share-modal-display').css({
                        top: ($jQ(window).outerHeight() / 2 - $jQ('#share-modal-display').outerHeight() / 2) + $jQ(document).scrollTop(),
                        left: ($jQ(window).outerWidth() / 2 - $jQ('#share-modal-display').outerWidth() / 2) - $jQ(document).scrollLeft()
                    });

                    var $shareModalDisplay = $jQ('#share-modal-display');
                    $shareModalDisplay.html($emlModal);
                    $emlOverlay.html('');
                    $jQ('#share-submit').uniform();
                    
                    MLS.ui.placeholderValidationRules();
                    $shareForm = $jQ("#share-modal");
                    MLS.ui.emailValidation($shareForm);
                    
                    $shareForm.on('submit', function (e) {
                        e.preventDefault();
                        e.stopPropagation();

                        var shareFormValid = false;
                        shareFormValid = $shareForm.valid();
                        if (shareFormValid) {    
                            var $theForm = $jQ("#share-modal".form);
                            MLS.ajax.sendRequest(
                                $theForm.attr('action'),
                                $theForm.serialize(),
                                // AJAX request success
                                function (d) {
                                    // server success response
                                    if (data.hasOwnProperty('success')) {
                                        $shareModalDisplay.html(d.success.responseHTML);
                                    }
                                    // server error response
                                    else {
                                        $jQ("#share-modal")[0].reset(); //reset fields
                                        $jQ('#share-modal-display .share-error').html(d.error.responseHTML);
                                    }
                                },
                                // AJAX request error
                                function (d) {
                                    // For demo - start error response
                                    //$shareForm[0].reset(); 
                                    //$jQ('#share-modal-display .share-error').html('<p class="message">Something went wrong. Mind trying again?</p>');
                                    //For demo - end error response
                                    //For demo - success response                                     
                                    $shareModalDisplay.html('<div class="share-success"><h3 class="share-title">Success!</h3><a href="#" id="close-social-overlay" class="close-overlay"></a><div class="overlay-content"><figure class="share-fig"><img src="img/product-detail-page/pdp-products/belkin-charger.png" alt="Photo of Belkin AC Charger with Swivel Plug" title="Belkin AC Charger with Swivel Plug"></figure><p class="message">You have shared the Belkin AC Charger with Swivel Plug with: <span class="recipient-email"><EMAIL></span></p></div></div>');
                                }
                            );
                        }
                    });
                } 
                else {
                    $overlay = $scope.find('.overlay'),
                    $socialList = $socialItemsWithContext.parents('.social-list'),
                    listWidth = $socialList.outerWidth();

                    overlayWidth = $overlay.outerWidth();
                    $overlay.show().css('width', 0);
                    $scope.find('.social-link').hide();

{'fraction_non_alphanumeric': 0.13572259377726084, 'fraction_numerical': 0.0027624309392265192, 'mean_word_length': 1.147182768846574, 'pattern_counts': {'":': 0, '<': 47, '<?xml version=': 0, '>': 43, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 36, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6448107', 'n_tokens_mistral': 3288, 'n_tokens_neox': 3061, 'n_words': 506}