Commit 2cf3a6df authored by lindonb's avatar lindonb

[ENH] feedback: for ajax feedback without page refresh, show feedback at the...

[ENH] feedback: for ajax feedback without page refresh, show feedback at the top of the screen if div#tikifeedback is not visible. Also make it disappear upon scroll.
parent caad0ff2
......@@ -14,22 +14,35 @@ function smarty_function_feedback($params, $smarty)
$(document).ajaxComplete(function (e, jqxhr) {
var feedback = jqxhr.getResponseHeader("X-Tiki-Feedback");
if (feedback) {
$("#tikifeedback").fadeOut(200, function() {
$("#tikifeedback").html(feedback);
$("#tikifeedback").fadeIn();
});
if ($("#tikifeedback").position().top < $(window).scrollTop()) {
$("html, body").animate({
scrollTop: $("div#tikifeedback").offset().top
}, 500);
var fb = $($.parseHTML(feedback)).filter("#tikifeedback").html();
var divtop = $("#tikifeedback").offset().top;
var wintop = $(window).scrollTop();
if (divtop < wintop) {
$("#tikifeedback").offset({"top": wintop});
$("#tikifeedback").addClass("ajaxmoved");
$("#tikifeedback").css("z-index", 3000);
$(window).on("scroll");
}
$("#tikifeedback").fadeIn(200, function() {
$("#tikifeedback").html(fb);
});
}
$("#tikifeedback .clear").on("click", function () {
$("#tikifeedback").empty();
return false;
});
});
'
$(window).scroll(function(){
if ($("#tikifeedback").hasClass("ajaxmoved")) {
$("#tikifeedback").fadeOut();
$("#tikifeedback").empty();
$("#tikifeedback").fadeIn();
var coltop = $("#col1").offset().top;
$("#tikifeedback").offset({"top": coltop});
$("#tikifeedback").removeClass("ajaxmoved");
}
});
'
);
if (is_array($result)) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment