Subversion Repositories SmartDukaan

Rev

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


$(document).ready(function(){


        /* ---- Countdown timer ---- */

        $('#counter').countdown({
                timestamp : (new Date(1418149800000)).getTime()
        });
        
        /* ---- Animations ---- */

        $('#links a').hover(
                function(){ $(this).animate({ left: 3 }, 'fast'); },
                function(){ $(this).animate({ left: 0 }, 'fast'); }
        );

        $('footer a').hover(
                function(){ $(this).animate({ top: 3 }, 'fast'); },
                function(){ $(this).animate({ top: 0 }, 'fast'); }
        );


        /* ---- Using Modernizr to check if the "required" and "placeholder" attributes are supported ---- */

        if (!Modernizr.input.placeholder) {
                $('.email').val('Input your e-mail address here...');
                $('.email').focus(function() {
                        if($(this).val() == 'Input your e-mail address here...') {
                                $(this).val('');
                        }
                });
        }

        // for detecting if the browser is Safari
        var browser = navigator.userAgent.toLowerCase();
        if(!Modernizr.input.required || (browser.indexOf("safari") != -1 && browser.indexOf("chrome") == -1)) {
                $('form').submit(function() {
                        $('.popup').remove();
                        if(!$('.email').val() || $('.email').val() == 'Input your e-mail address here...') {
                                $('form').append('<p class="popup">Please fill out this field.</p>');
                                $('.email').focus();
                                return false;
                        }
                });
                $('.email').keydown(function() {
                        $('.popup').remove();
                });
                $('.email').blur(function() {
                        $('.popup').remove();
                });
                
        }
        
        $("#gosf-form").live('submit', function(){
                var userEmail = $('.gosf-email').val();
                console.log(userEmail);
                jQuery.ajax({
                url: "/gosf!notifyGosf?email="+userEmail,
                type: 'POST',
                async: false,
                success: function (data) {
                        showMsg(data);
                },
                         error : function() {
                                 showMsg("OOPS!!!Please try again.");
                         },
                cache: false,
                contentType: "application/x-www-form-urlencoded",
                processData: false
            });
    return false;
        });
        
        function showMsg(msg){
                        $("#msg").html(msg);
                        $("#msg").attr('style', 'color:green;border:1px solid red;box-shadow: red 0 0 30px 1px;');
                        $("#msg").fadeIn(600, function() {
                                window.setTimeout(function() {
                                        $("#msg").fadeOut(800, function() {
                                        $("#msg").removeAttr('style');
                                });
                        }, 3000);
                });
        }
});