diff options
Diffstat (limited to 'static/website/js/thread-user.js')
-rw-r--r-- | static/website/js/thread-user.js | 60 |
1 files changed, 49 insertions, 11 deletions
diff --git a/static/website/js/thread-user.js b/static/website/js/thread-user.js index dbf9bdd..698a946 100644 --- a/static/website/js/thread-user.js +++ b/static/website/js/thread-user.js @@ -9,17 +9,20 @@ bkLib.onDomLoaded(function() { }); $(document).ready(function() { - /*set the jquery variables */ + /* + * question edit section + * set the jquery variables + */ $question = $(".question"); - $modify = $(".modify"); - $edit = $(".modify .edit"); - $save = $(".modify .save"); + $question_modify = $(".question .modify"); + $question_edit = $(".question .modify .edit"); + $question_save = $(".question .modify .save"); $questionNicPanel = $("#questionNicPanel"); $questionInstance = $("#questionInstance"); /* make the question editable and show modify */ $question.addClass("editable"); - $modify.show(); + $question_modify.show(); /* edit and save click events */ function modify(thisObj){ @@ -28,20 +31,20 @@ $(document).ready(function() { $questionNicPanel.show(); $questionInstance.focus(); } - $edit.click(function () { - modify($edit); + $question_edit.click(function () { + modify($question_edit); }); $questionInstance.click(function() { - modify($edit); + modify($question_edit); }); - $save.click(function () { + $question_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)); + var id_length = $question_save.attr("id").length; + var question_id = parseInt($question_save.attr("id").substr(id_length-1)); console.log(question_id); var question_body = $questionInstance.html(); $.ajax({ @@ -57,5 +60,40 @@ $(document).ready(function() { } }); }); + + /* + * reply edit section + * set the dom variables + */ + $reply_edit = $('.reply .edit'); + $reply_save = $(".reply .save"); + $replyPanelWrapper = $("#replyPanelWrapper"); + + var replyNicEditor = new nicEditor({ + buttonList : ['fontSize','bold','italic','underline','strikeThrough','subscript','superscript','html','image'], + iconsPath: "/static/website/js/nicEditorIcons.gif", + }); + replyNicEditor.panelInstance('replyNicPanel'); + + $reply_edit.click(function() { + var reply_body = $(this).data("target"); + console.log(reply_body); + replyNicEditor.addInstance(reply_body); + $(this).parents("div.reply").prepend($replyPanelWrapper); + $replyPanelWrapper.show(); + $('#replyPanelWrapper .nicEdit-panelContain').parent().width('100%'); + $('#replyPanelWrapper .nicEdit-panelContain').parent().next().width('100%'); + $(this).hide(); + $(this).next().show(); + }); + + $reply_save.click(function() { + var reply_body = $(this).data("target"); + replyNicEditor.removeInstance(reply_body); + $replyPanelWrapper.hide(); + $('#replyPanelWrapper .nicEdit-panelContain').parent().width('100%'); + $(this).hide(); + $(this).prev().show(); + }); }); |