Subversion Repositories SmartDukaan

Rev

Rev 4656 | Rev 6407 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

var $items = $('#vtab>ul>li');

$items.click(function() {
    $items.removeClass('selected');
    $(this).addClass('selected');
    trackEventWithGA('Payment Option', $(this).text(), "");
    var index = $items.index($(this));
    $('#vtab>div').hide().eq(index).show();
}).eq(0).click();

$items.hover(
        function () {
            $(this).addClass("hover");
        },
        function () {
                $(this).removeClass("hover");
        }
);

$("input[type='radio']").click(
        function(){
                var contents = $(this).parent().contents();
                var payment_method = contents.get(contents.index(this) + 2);
                //Appending the value to differentiate between the cases of cards issued inside and out of India.
                var payment_method_text = $(payment_method).text() + '-' + $(this).val();
                trackEventWithGA('Payment Option', payment_method_text, "");
        }
);

function verifyPaymentModeSelectionForm(formName){
        var payment_option = 0;
        var paymentOptionInputs = $("form[name='" + formName + "'] :input[name='payment_option']");
        for(var i=0; i<paymentOptionInputs.length; i++)
                if(paymentOptionInputs[i].checked)
                        payment_option = paymentOptionInputs[i].value; 
        
        if(payment_option == '' || payment_option <= 0){
                dispError("Please select a payment method.");
                return false;
        }
        trackPaymentOptionFormSubmission();
        return true;
}

function verifyCodSelectionForm(formName){
        var captcha_response_input =$("form[name='" + formName + "'] :input[name='captcha_response_field']");
        var entered_text =  $.trim(captcha_response_input.val());
        if(entered_text == '' || entered_text == 'Enter the characters shown'){
                dispError("Please enter the characters shown.");
                captcha_response_input.blur();
                return false;
        }
        trackPaymentOptionFormSubmission();
        return true;
}

function trackPaymentOptionFormSubmission(){
        trackEventWithGA('Order', 'Payment method selected', '');
        return true;
}

function dispError(error){
        alert(error);
}

$('#captchaanchor').click(function () { $('#captchaImage').attr('src', '/captcha?rand=' + Math.floor(Math.random()*100) ); });

$('#captcha_response_box').val('Enter the characters shown')
        .focus(function(){
                if ($(this).val() == 'Enter the characters shown') {
                        $(this).val('');
                        $(this).removeClass('captcha_text_blur');
                        $(this).addClass('captcha_text_focus');
                }
        })
        .blur(function(){
                if ($(this).val() == '') {
                        $(this).val('Enter the characters shown');
                        $(this).removeClass('captcha_text_focus');
                        $(this).addClass('captcha_text_blur');
                }
        });