/** * Class for incrementally loading page comments using XHR. * @author Stefan T. * @copyright Godengo Inc., 2008 * * DEPENDENCIES: * prototype.js must be loaded prior to this **/ /* @global */ UserCommentsLoader = Class.create(); UserCommentsLoader.prototype = { initialize: function (commentsContainer, config) { this.commentsContainer = $(commentsContainer); this.loader_img = config.loader_img || '/core/media/images/ajax-loader.gif'; this.backendurl = config.backendurl || '/core/ajaxserver.php'; this.max = config.max || 10; this.publicationid = config.publicationid || 0; }, //load a paginated commments list with pager via AJAX-calls as HTML //and update the given container element with it. get: function(pageid, offset, cp, order) { var ajaxRequest = new Ajax.Updater(this.commentsContainer, this.backendurl, { method: 'get', parameters: { 'req':'getUserComments', 'pageid' : pageid, 'offset' : offset || 0, 'max' : this.max, 'cp_comments_pager' : cp || 1, 'sortorder': order || 'asc', 'publicationid' : this.publicationid }, asynchronous: true, onLoading : this.onLoading(), onFailure: this.onFailure(), onComplete : this.onComplete() }); }, //replace comments list with a 'loading' text and progress image onLoading : function(transport) { if(this.commentsContainer) this.commentsContainer.innerHTML = '
Loading comments ...