summaryrefslogtreecommitdiff
path: root/static/website/js/thread-user.js
diff options
context:
space:
mode:
Diffstat (limited to 'static/website/js/thread-user.js')
-rw-r--r--static/website/js/thread-user.js61
1 files changed, 61 insertions, 0 deletions
diff --git a/static/website/js/thread-user.js b/static/website/js/thread-user.js
new file mode 100644
index 0000000..dbf9bdd
--- /dev/null
+++ b/static/website/js/thread-user.js
@@ -0,0 +1,61 @@
+bkLib.onDomLoaded(function() {
+
+ var questionNicEditor = new nicEditor({
+ buttonList : ['fontSize','bold','italic','underline','strikeThrough','subscript','superscript','html','image'],
+ iconsPath: "/static/website/js/nicEditorIcons.gif",
+ });
+ questionNicEditor.setPanel('questionNicPanel');
+ questionNicEditor.addInstance('questionInstance');
+});
+
+$(document).ready(function() {
+ /*set the jquery variables */
+ $question = $(".question");
+ $modify = $(".modify");
+ $edit = $(".modify .edit");
+ $save = $(".modify .save");
+ $questionNicPanel = $("#questionNicPanel");
+ $questionInstance = $("#questionInstance");
+
+ /* make the question editable and show modify */
+ $question.addClass("editable");
+ $modify.show();
+
+ /* edit and save click events */
+ function modify(thisObj){
+ thisObj.hide();
+ thisObj.next().css("display", "block");
+ $questionNicPanel.show();
+ $questionInstance.focus();
+ }
+ $edit.click(function () {
+ modify($edit);
+ });
+ $questionInstance.click(function() {
+ modify($edit);
+ });
+ $save.click(function () {
+ $(this).hide();
+ $questionNicPanel.hide();
+ $(this).prev().css("display", "block");
+
+ /* make the ajax call */
+ var id_length = $save.attr("id").length;
+ var question_id = parseInt($save.attr("id").substr(id_length-1));
+ console.log(question_id);
+ var question_body = $questionInstance.html();
+ $.ajax({
+ url: "/ajax-question-update/",
+ data:{
+ question_id: question_id,
+ question_body: question_body,
+ },
+ type: "POST",
+ dataType: "html",
+ success: function(data){
+ console.log(data);
+ }
+ });
+ });
+});
+