Sha256: 19b54a1bceb759b1b583fddaf1b85d1197f341d17f836a1af31bb4211a96b0c3

Contents?: true

Size: 1.53 KB

Versions: 5

Compression:

Stored size: 1.53 KB

Contents

// =[ interface ]=====================================================================================================================

var $formHolder;
var markInvalidateInProgress = false;
var markWasPasted = false;
var fFeedbackFormInvalidate;
var fFeedbackFormOnScroll;

// =[ implementation ]=====================================================================================================================

$(function () {
    if ($("body#contacts").length == 1) {

        $formHolder = $("div#ff");

        fFeedbackFormInvalidate = function () {
            if (!markInvalidateInProgress) {
                markInvalidateInProgress = true;

                if (!markWasPasted) {

                    $('<div id="loading"></div>').appendTo($formHolder);

                    $.ajax({
                        url: '/give_me_form',
                        type: 'POST',
                        dataType: 'script'
                    }).done(function (data, result) {
                        if (result == "success") {
                            markWasPasted = true;
                        }
                    });
                }
            }
        };

        fFeedbackFormOnScroll = function(event) {
            var closeToBottom = jQuery(window).scrollTop() >= 0;
            if (closeToBottom) {
                fFeedbackFormInvalidate();
            }
        };

        // start
        $(document).bind('scroll', fFeedbackFormOnScroll);
        setTimeout(function () {
            fFeedbackFormOnScroll();
        },300);

    }
});

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
c80_feedback_form-0.1.0.4 app/assets/javascripts/frontend/feedback-form-ajax.js
c80_feedback_form-0.1.0.3 app/assets/javascripts/frontend/feedback-form-ajax.js
c80_feedback_form-0.1.0.2 app/assets/javascripts/frontend/feedback-form-ajax.js
c80_feedback_form-0.1.0.1 app/assets/javascripts/frontend/feedback-form-ajax.js
c80_feedback_form-0.1.0 app/assets/javascripts/frontend/feedback-form-ajax.js