jQuery.noConflict();

var defaultRoleName = "role:10001";
var roleSelected = false;

function changeCommentLevel() {
  if (roleSelected) {
    return;
  }

  if (jQuery('#comment').val() != "") {
    roleSelected = true;
    return;
  }

  var commentLevelSelect = jQuery('.security-level select#commentLevel option[value=\'' + defaultRoleName + '\']');

  if (commentLevelSelect) {
    var labelText = commentLevelSelect.first().text();
    jQuery("select#commentLevel").val(defaultRoleName);
    jQuery("#commentLevel-multi-select a.drop span.icon").removeClass("icon-unlocked").addClass("icon-locked");
    var htmlEscapedLabel = AJS.$("<div/>").text(labelText).html();
    jQuery(".security-level span.current-level").html(AJS.format(AJS.params.securityLevelViewableRestrictedTo, htmlEscapedLabel));
    roleSelected = true;
  }

}

jQuery('#comment').live('focus', changeCommentLevel);

(function ($) {
  var defaultRoleName = "role:10001";

  function changeCommentLevel() {
    var $form = $(this).closest('form');

    if ($(this).val() !== "") {
      return;
    }

    var commentLevelSelect = $('.security-level select#commentLevel option[value=\'' + defaultRoleName + '\']', $form);

    if (commentLevelSelect) {
      var labelText = commentLevelSelect.first().text();
      $("select#commentLevel", $form).val(defaultRoleName);
      $("#commentLevel-multi-select a.drop span.icon", $form).removeClass("icon-unlocked").addClass("icon-locked");
      var htmlEscapedLabel = AJS.$("<div/>").text(labelText).html();
      $(".security-level span.current-level", $form).html(AJS.format(AJS.params.securityLevelViewableRestrictedTo, htmlEscapedLabel));
    }
  }

  $(document).on('focus', '#comment', changeCommentLevel);
})(jQuery);

Update default comment role to work on all comment fields
Update default comment role to work on all comment fields

Wasn't working if you opened an "Assign" modal. Also before it would
only work a single time, and that's silly.
