{I" class:ETI"ProcessedAsset;FI"logical_path;TI"!proclaim/comments_handler.js;FI" pathname;TI"_/home/krf/src/websites/proclaim/app/assets/javascripts/proclaim/comments_handler.js.coffee;FI"content_type;TI"application/javascript;TI" mtime;Tl+¨TI" length;Tiº%I" digest;TI"%881a0bd2a3d0483d60bb38b5ea1538fe;FI" source;TI"º%(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 = "
"; errorMessage += "The following errors have prevented this comment from being saved:"; errorMessage += ""; errorMessage += "
"; return $(event.target).before(errorMessage); }; CommentsHandler.prototype.handleDeleteCommentSuccess = function(event, data, status, xhr) { var commentContainer; commentContainer = $(event.target).closest(this.discussionClass); if (commentContainer.length === 1) { return commentContainer.fadeOut(function() { return commentContainer.remove(); }); } else { return console.error("No comment container for removal!"); } }; CommentsHandler.prototype.handleDeleteCommentFailure = function(event, xhr, status, error) { return console.error("Unable to delete comment!"); }; CommentsHandler.prototype.showNewCommentForm = function(event) { var form, other_forms, target; event.preventDefault(); target = $($(event.target).data("target")); if (target.length !== 1) { console.error("Invalid comment target data!"); return; } if (target.children(this.commentFormClass).length === 0) { form = $(event.target).data("form"); if (form.length === 0) { console.error("Invalid comment form data!"); return; } other_forms = $(document).find(this.commentFormClass).not(this.mainCommentFormClass); if (other_forms.length > 0) { this.removeForm(other_forms); } target.append(form); form = target.children(this.commentFormClass); form.addClass("new_comment"); form.children(this.cancelCommentButtonClass).focus(); return form.children("input:text:visible:first").focus(); } }; CommentsHandler.prototype.showUpdateCommentForm = function(event) { var discussion, form, target; event.preventDefault(); target = $(event.target); form = target.data("form"); if (form.length === 0) { console.error("Invalid comment form data!"); return; } discussion = target.closest(this.discussionClass); target.closest(this.commentClass).hide(); discussion.prepend(form); form = discussion.children(this.commentFormClass); form.addClass("edit_comment"); form.children(this.cancelCommentButtonClass).focus(); return form.children("input:text:visible:first").focus(); }; CommentsHandler.prototype.cancelComment = function(event) { var form; event.preventDefault(); form = $(event.target).closest(this.commentFormClass); if (form.hasClass("edit_comment")) { form.siblings(this.commentClass).show(); } $(event.target).siblings(this.subscribeEmailClass).hide(); return this.removeForm(form); }; CommentsHandler.prototype.handleSubscribeCheckbox = function(event) { if (event.target.checked) { return $(event.target).siblings(this.subscribeEmailClass).show(); } else { $(event.target).siblings(this.subscribeEmailClass).val(""); return $(event.target).siblings(this.subscribeEmailClass).hide(); } }; CommentsHandler.prototype.removeForm = function(form, hideInsteadOfRemove) { if (hideInsteadOfRemove == null) { hideInsteadOfRemove = false; } if (form.length === 0) { console.error("Invalid comment form length for removal!"); return; } form.siblings("div.error").remove(); return form.each((function(_this) { return function(index, element) { var thisForm; thisForm = $(element); if (thisForm.is(_this.mainCommentFormClass)) { return element.reset(); } else { if (hideInsteadOfRemove) { return thisForm.hide(); } else { return thisForm.remove(); } } }; })(this)); }; return CommentsHandler; })(); this.CommentsHandler = CommentsHandler; }).call(this); ;TI"dependency_digest;TI"%fcdc4b1dee9cfd191a24f46eb1ce07bd;FI"required_paths;T[I"_/home/krf/src/websites/proclaim/app/assets/javascripts/proclaim/comments_handler.js.coffee;FI"dependency_paths;T[{I" path;TI"_/home/krf/src/websites/proclaim/app/assets/javascripts/proclaim/comments_handler.js.coffee;FI" mtime;TI"2015-01-03T10:12:02-05:00;TI" digest;TI"%2eb2004f5ff8eddb1058019edf260d5f;FI" _version;TI"%883b724e06f474a3db2deee10c127ab9;F