diff -r 000000000000 -r 54f784230511 sphinx_django/support/hsbook.js --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sphinx_django/support/hsbook.js Thu Sep 30 11:36:30 2010 +0530 @@ -0,0 +1,126 @@ +function qid(id) { + return id.replace(/([.:])/g, "\\$1"); +} + +function beforeComment(formData, jqForm, options) { + var form = jqForm[0]; + if (!form.comment.value) { + $(options.target + " span.comment_error").empty().append( + "Your comment is empty"); + return false; + } + if (!form.name.value) { + $(options.target + " span.comment_error").empty().append( + "Please provide a name"); + return false; + } + $(options.target + " span.comment_error").empty().after( + ""); + $(options.target + " input[@name=submit]").attr("disabled", true); +} + +function ajaxifyForm(id) { + var q = qid(id); + + $("#form_" + q).ajaxForm({ beforeSubmit: beforeComment, + success: function() { ajaxifyForm(id); }, + target: "#comments_" + q }); +} + +function toggleComment(id) { + $("#toggle_" + qid(id)).nextAll().toggle(); + return false; +} + +function loadComments(id) { + $("#comments_" + qid(id)).load(location.protocol + "//" + location.host + + "/comments/single/" + id + "/", function() { + ajaxifyForm(id); + }); + return false; +} + +function loadAllComments() { + $("a.commenttoggle").each(function() { + var id = $(this).attr("pid"); + if (id) { + loadComments(id); + } + }); +} + + +//this part works don't change +// $(document).ready(function() { +// function loading(id) { +// return " " + +// "Loading..." + +// ""; +// } +// $("p") +// .after("

" + +// "Load all comments (slow)

") +// .toggle(function() { $(this).nextAll().show("normal"); }, +// function() { $(this).nextAll().hide("normal"); }) +// .hover(function() { $(this).fadeTo("normal", 0.8); }, +// function() { $(this).fadeTo("normal", 0.35); }); +// $(".chapter p[@id]").each(function() { +// $(this).append(loading($(this).attr("id"))); +// }); }); +// // $(".chapter table[@id].equation").each(function() { +// // id = $(this).attr("id"); +// // $("#" + id + " tr").after('' + loading($(this).attr("id")) + ''); +// // }); +// // $(".chapter pre[@id]").each(function() { +// // $(this).after(loading($(this).attr("id"))); +// // }) + +$(document).ready(function() { + function loading(id) { + return " " + + "bleeding..." + + ""; + } + $("p") + .after("

" + + "Load all comments (slow)

") + .toggle(function() { $(this).nextAll().show("normal"); }, + function() { $(this).nextAll().hide("normal"); }) + .hover(function() { $(this).fadeTo("normal", 0.8); }, + function() { $(this).fadeTo("normal", 0.35); }); + +// + $("p").each(function() { + $(this).append(loading($(this).attr("id"))); + }); +// // $(".chapter table[@id].equation").each(function() { +// // id = $(this).attr("id"); +// // $("#" + id + " tr").after('' + loading($(this).attr("id")) + ''); +// // }); +// // $(".chapter pre[@id]").each(function() { +// // $(this).after(loading($(this).attr("id"))); +// // }); + + +// // var chapid = $("div.preface, div.chapter, div.appendix, div.bibliography").attr("id"); +// // $("#chapterfeed").attr("href", +// // $("#chapterfeed").attr("href") + chapid + "/"); +// // $.getJSON(location.protocol + "//" + location.host + "/comments/chapter/" + +// // chapid + "/count/", function(data) { +$("p").onclick(function() { +// // // var s = item == 1 ? "" : "s"; + // $(".chapter p[@id]").each(function() { + $(this).replace( + "" + " comment"+ ""); +// // // "pid='" + id + "' " + +// // // "onclick='return loadComments(\"" + id + "\")' " + + }); }); +// // }); +// // $("span.commenttoggle").each(function() { +// // var id = $(this).attr("pid"); +// // $(this).replaceWith("No comments"); +// // }); +// // }); +// // }); \ No newline at end of file