diff --git a/themes/blueprint/js/record.js b/themes/blueprint/js/record.js index 6af84f5a485818867f6943b73d86ac5dc621ea24..1b025385325d6c0d88b3b34bbcaab53926bfe8d1 100644 --- a/themes/blueprint/js/record.js +++ b/themes/blueprint/js/record.js @@ -45,6 +45,38 @@ function setUpCheckRequest() { }); } +function deleteRecordComment(element, recordId, recordSource, commentId) { + var url = path + '/AJAX/JSON?' + $.param({method:'deleteRecordComment',id:commentId}); + $.ajax({ + dataType: 'json', + url: url, + success: function(response) { + if (response.status == 'OK') { + $($(element).parents('li')[0]).remove(); + } + } + }); +} + +function refreshCommentList(recordId, recordSource) { + var url = path + '/AJAX/JSON?' + $.param({method:'getRecordCommentsAsHTML',id:recordId,'source':recordSource}); + $.ajax({ + dataType: 'json', + url: url, + success: function(response) { + if (response.status == 'OK') { + $('#commentList').empty(); + $('#commentList').append(response.data); + $('#commentList a.deleteRecordComment').unbind('click').click(function() { + var commentId = $(this).attr('id').substr('recordComment'.length); + deleteRecordComment(this, recordId, recordSource, commentId); + return false; + }); + } + } + }); +} + function registerAjaxCommentRecord() { $('form[name="commentRecord"]').unbind('submit').submit(function(){ if (!$(this).valid()) { return false; } @@ -79,38 +111,6 @@ function registerAjaxCommentRecord() { }); } -function deleteRecordComment(element, recordId, recordSource, commentId) { - var url = path + '/AJAX/JSON?' + $.param({method:'deleteRecordComment',id:commentId}); - $.ajax({ - dataType: 'json', - url: url, - success: function(response) { - if (response.status == 'OK') { - $($(element).parents('li')[0]).remove(); - } - } - }); -} - -function refreshCommentList(recordId, recordSource) { - var url = path + '/AJAX/JSON?' + $.param({method:'getRecordCommentsAsHTML',id:recordId,'source':recordSource}); - $.ajax({ - dataType: 'json', - url: url, - success: function(response) { - if (response.status == 'OK') { - $('#commentList').empty(); - $('#commentList').append(response.data); - $('#commentList a.deleteRecordComment').unbind('click').click(function() { - var commentId = $(this).attr('id').substr('recordComment'.length); - deleteRecordComment(this, recordId, recordSource, commentId); - return false; - }); - } - } - }); -} - $(document).ready(function(){ // register the record comment form to be submitted via AJAX registerAjaxCommentRecord();