BigW Consortium Gitlab

_create_per_line_note.js.haml 854 Bytes
Newer Older
1 2
- if note.valid?
  :plain
3
    // hide and reset the form
4
    $(".per_line_form").hide();
5
    $('.line-note-form-holder textarea').val("");
6 7 8 9 10 11 12 13

    // find the reply button for this line
    // (might not be there if this is the first note)
    var trRpl = $("a.line_note_reply_link[data-line-code='#{note.line_code}']").closest("tr");
    if (trRpl.size() == 0) {
      // find the commented line ...
      var trEl = $(".#{note.line_code}").parent();
      // ... and insert the note and the reply button after it
14
      trEl.after("#{escape_javascript(render "notes/per_line_reply_button", line_code: note.line_code)}");
15
      trEl.after("#{escape_javascript(render "notes/per_line_note", note: note)}");
16 17
    } else {
      // instert new note before reply button
18
      trRpl.before("#{escape_javascript(render "notes/per_line_note", note: note)}");
19
    }