JSFiddle - React, Tailwind, and code Playground

by eddiemonge

JavaScript

$.fn.comments = function() {
  return $(this).each(function() {
    var link = $(this),
        li_parent = link.parents("li[id*='update']"),
        comment_box = li_parent.find(".add-comment"),
        textarea = li_parent.find("textarea#message_message"),
        button = li_parent.find(".comment_button");

    link.bind("click", function(){
      if (!comment_box.is(':visible')) {
        comment_box.show();
      }
      textarea.focus();
      button.show();
    });

    textarea.bind("focusin", function(){
      button.show();
    }).bind("focusout", function(){
        setTimeout(function() {
            button.hide();
        }, 100);
    });
  });
}