Sha256: 8139ebb3daa595756e5e70b820eb4f28fc6b609e8522025ead850b910f1bb0a2

Contents?: true

Size: 1.55 KB

Versions: 3

Compression:

Stored size: 1.55 KB

Contents

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

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

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

$(function () {

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

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

        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

3 entries across 3 versions & 1 rubygems

Version Path
c80_feedback_form-0.1.0.8 app/assets/javascripts/frontend/feedback-form-ajax.js
c80_feedback_form-0.1.0.6 app/assets/javascripts/frontend/feedback-form-ajax.js
c80_feedback_form-0.1.0.5 app/assets/javascripts/frontend/feedback-form-ajax.js