{I" class:EFI"ProcessedAsset; FI"logical_path; FI"!proclaim/comments_handler.js; TI" pathname; FI"_/home/krf/src/websites/proclaim/app/assets/javascripts/proclaim/comments_handler.js.coffee; TI"content_type; FI"application/javascript; FI" mtime; Fl+d}¨TI"length; Fiº%I"digest; F"%881a0bd2a3d0483d60bb38b5ea1538feI"source; FI"º%(function() { var CommentsHandler, __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }; CommentsHandler = (function() { function CommentsHandler(discussionClass, commentClass, commentFormClass, mainCommentFormClass, cancelCommentButtonClass, replyLinkClass, updateLinkClass, deleteLinkClass, subscribeCheckboxClass, subscribeEmailClass) { this.discussionClass = discussionClass; this.commentClass = commentClass; this.commentFormClass = commentFormClass; this.mainCommentFormClass = mainCommentFormClass; this.cancelCommentButtonClass = cancelCommentButtonClass; this.replyLinkClass = replyLinkClass; this.updateLinkClass = updateLinkClass; this.deleteLinkClass = deleteLinkClass; this.subscribeCheckboxClass = subscribeCheckboxClass; this.subscribeEmailClass = subscribeEmailClass; this.handleSubscribeCheckbox = __bind(this.handleSubscribeCheckbox, this); this.cancelComment = __bind(this.cancelComment, this); this.showUpdateCommentForm = __bind(this.showUpdateCommentForm, this); this.showNewCommentForm = __bind(this.showNewCommentForm, this); this.handleDeleteCommentFailure = __bind(this.handleDeleteCommentFailure, this); this.handleDeleteCommentSuccess = __bind(this.handleDeleteCommentSuccess, this); this.handleCommentFailure = __bind(this.handleCommentFailure, this); this.handleCommentSuccess = __bind(this.handleCommentSuccess, this); this.handleCommentFinished = __bind(this.handleCommentFinished, this); this.handleCommentStarted = __bind(this.handleCommentStarted, this); if ((this.discussionClass.length > 0) && (this.commentClass.length > 0) && (this.commentFormClass.length > 0) && (this.mainCommentFormClass.length > 0) && (this.cancelCommentButtonClass.length > 0) && (this.replyLinkClass.length > 0) && (this.updateLinkClass.length > 0) && (this.deleteLinkClass.length > 0) && (this.subscribeCheckboxClass.length > 0) && (this.subscribeEmailClass.length > 0)) { this.cleanBindings(); this.addBindings(); } else { console.error("Invalid length for comment classes!"); } } CommentsHandler.prototype.addBindings = function() { $(document).on("click", this.replyLinkClass, this.showNewCommentForm); $(document).on("click", this.updateLinkClass, this.showUpdateCommentForm); $(document).on("click", this.cancelCommentButtonClass, this.cancelComment); $(document).on("ajax:beforeSend", this.commentFormClass, this.handleCommentStarted); $(document).on("ajax:complete", this.commentFormClass, this.handleCommentFinished); $(document).on("ajax:success", this.commentFormClass, this.handleCommentSuccess); $(document).on("ajax:error", this.commentFormClass, this.handleCommentFailure); $(document).on("ajax:success", this.deleteLinkClass, this.handleDeleteCommentSuccess); $(document).on("ajax:error", this.deleteLinkClass, this.handleDeleteCommentFailure); return $(document).on("change", this.subscribeCheckboxClass, this.handleSubscribeCheckbox); }; CommentsHandler.prototype.cleanBindings = function() { $(document).off("click", this.replyLinkClass); $(document).off("click", this.updateLinkClass); $(document).off("click", this.cancelCommentButtonClass); $(document).off("ajax:beforeSend", this.commentFormClass); $(document).off("ajax:complete", this.commentFormClass); $(document).off("ajax:success", this.commentFormClass); $(document).off("ajax:error", this.commentFormClass); $(document).off("ajax:success", this.deleteLinkClass); $(document).off("ajax:error", this.deleteLinkClass); return $(document).off("change", this.subscribeCheckboxClass); }; CommentsHandler.prototype.handleCommentStarted = function(event, xhr, settings) { var form; form = $(event.target); form.find(":input").prop("disabled", true); return form.before('
'); }; CommentsHandler.prototype.handleCommentFinished = function(event, xhr, status) { var form, target; form = $(event.target); target = $(form.data("target")); form.find(":input").prop("disabled", false); form.siblings('div.loading').remove(); if (status === "success") { return this.removeForm(form); } }; CommentsHandler.prototype.handleCommentSuccess = function(event, data, status, xhr) { var form, target; if (data.html.length === 0) { console.error("Invalid comment HTML!"); return; } form = $(event.target); if (form.hasClass("edit_comment")) { return form.closest(this.discussionClass).replaceWith(data.html); } else { target = $(form.data("target")); if (target.length === 1) { target.append(data.html); } else { console.error("Invalid comment target!"); return; } return this.removeForm(form, true); } }; CommentsHandler.prototype.handleCommentFailure = function(event, xhr, status, error) { var errorMessage, _i, _len, _ref; $(event.target).siblings("div.error").remove(); errorMessage = "