Index: lams_central/web/comments/comments.jsp =================================================================== diff -u -rfe19797ec82718905555353176ed719bec11043e -rf14a45648947b8813b4b99842665fcf87f5dfbed --- lams_central/web/comments/comments.jsp (.../comments.jsp) (revision fe19797ec82718905555353176ed719bec11043e) +++ lams_central/web/comments/comments.jsp (.../comments.jsp) (revision f14a45648947b8813b4b99842665fcf87f5dfbed) @@ -1,71 +1,156 @@ <%@ include file="/common/taglibs.jsp"%> - - - + +<%@ page import="org.lamsfoundation.lams.comments.CommentConstants"%> - - - - - - - - - - - - - + + - + + + + + $("#commentDiv").on("change", "#sortMenu", function() { + var url = "comments/viewTopic.do?sessionMapID=${sessionMapID}&sticky=true&sortBy=" + + $(this).find("option:selected").attr('value'); + reloadDivs(url); + }); + + $('#newForm').submit(function() { // catch the form's submit event + newCommentSubmit(); + }); + }); + + function refreshComments() { + var reqIDVar = new Date(); + reloadDivs('comments/viewTopic.do?sessionMapID=${sessionMapID}&sticky=true&reqUid=' + + reqIDVar.getTime()); + } + + function reloadDivs(url) { + $('.scroll').data('jscroll', null); + $.ajaxSetup({ + cache : true + }); + $('#commentDiv').load(url); + } + + function scrollDoneCallback() { + } + + var btnName = "newCommentSubmitButton"; + + function newCommentSubmit() { + if ( isDisabled(btnName) ) { + return false; + } - - - -
- -
- <%@ include file="new.jsp"%> -
-
+ var theForm = $(newForm); + disableButton(btnName); - - + if (validateBodyText( + $('#newFormBody').val(), + <%=CommentConstants.MAX_BODY_LENGTH%>, + "" + )) { + $.ajax({ // create an AJAX call... + data : theForm.serialize(), + processData : false, // tell jQuery not to process the data + contentType : false, // tell jQuery not to set contentType + type : theForm.attr('method'), // GET or POST + url : theForm.attr('action'), // the file to call + + }).done(function(response) { + var threadUid = response.threadUid; + var commentUid = response.commentUid; + var sessionMapID = response.sessionMapID; -
- <%@ include file="allview.jsp"%> -
+ // have just added it as a standalone comment, so show the posting at the top. + var newCommentDiv = document.getElementById('newcomments'); + var newThreadDiv = document.createElement("div"); + newThreadDiv.id = 'thread' + commentUid; + newCommentDiv.insertBefore(newThreadDiv, newCommentDiv.firstChild); + + if (!newCommentDiv || !newThreadDiv) { + alert(''); + } else if (commentUid) { + var loadString = 'comments/viewTopicThread.do?sessionMapID=' + + response.sessionMapID + + "&threadUid=" + + threadUid + + "&commentUid=" + commentUid; + $.ajaxSetup({ cache: true }); + $(newThreadDiv).load(loadString, + function() { + highlightMessage(); + }); + clearNewForm(); + } else if (response.errMessage) { + alert(response.errMessage); + enableButton(btnName); + } else { + alert(''); + } + }); + } // end validateBodyText + else { + enableButton(btnName); + } + return false; + } + + function clearNewForm() { + $('#newFormBody').val(''); + $('#commentAnonymousNew').prop('checked',false); + enableButton(btnName); + return false; + } + + + +
+
+
+
+
+ + + + +
+ + + +
+ + + + + <%@include file="anonymouscheckbox.jsp"%> + +
- - \ No newline at end of file +
+
+
+
+ +
+ <%@ include file="allview.jsp"%> +
\ No newline at end of file