Commit 8fb70d924dbb089fdac89125664e3aa73212d8fc

Authored by Riyad Preukschas
1 parent 61eb650d

Rename 'notes/create_*' partials

app/views/notes/_create_common.js.haml
... ... @@ -1,13 +0,0 @@
1   -- if note.valid?
2   - :plain
3   - $(".note-form-holder .error").remove();
4   - $('.note-form-holder textarea').val("");
5   - $('.note-form-holder #preview-link').text('Preview');
6   - $('.note-form-holder #preview-note').hide();
7   - $('.note-form-holder').show();
8   - NoteList.appendNewNote(#{note.id}, "#{escape_javascript(render "notes/show", note: note)}");
9   -
10   -- else
11   - :plain
12   - $(".note-form-holder").replaceWith("#{escape_javascript(render 'form')}");
13   -
app/views/notes/_create_common_note.js.haml 0 → 100644
... ... @@ -0,0 +1,13 @@
  1 +- if note.valid?
  2 + :plain
  3 + $(".note-form-holder .error").remove();
  4 + $('.note-form-holder textarea').val("");
  5 + $('.note-form-holder #preview-link').text('Preview');
  6 + $('.note-form-holder #preview-note').hide();
  7 + $('.note-form-holder').show();
  8 + NoteList.appendNewNote(#{note.id}, "#{escape_javascript(render "notes/show", note: note)}");
  9 +
  10 +- else
  11 + :plain
  12 + $(".note-form-holder").replaceWith("#{escape_javascript(render 'form')}");
  13 +
... ...
app/views/notes/_create_line.js.haml
... ... @@ -1,19 +0,0 @@
1   -- if note.valid?
2   - :plain
3   - // hide and reset the form
4   - $(".per_line_form").hide();
5   - $('.line-note-form-holder textarea').val("");
6   -
7   - // find the reply button for this line
8   - // (might not be there if this is the first note)
9   - var trRpl = $("a.line_note_reply_link[data-line-code='#{note.line_code}']").closest("tr");
10   - if (trRpl.size() == 0) {
11   - // find the commented line ...
12   - var trEl = $(".#{note.line_code}").parent();
13   - // ... and insert the note and the reply button after it
14   - trEl.after("#{escape_javascript(render "notes/reply_button", line_code: note.line_code)}");
15   - trEl.after("#{escape_javascript(render "notes/per_line_show", note: note)}");
16   - } else {
17   - // instert new note before reply button
18   - trRpl.before("#{escape_javascript(render "notes/per_line_show", note: note)}");
19   - }
app/views/notes/_create_per_line_note.js.haml 0 → 100644
... ... @@ -0,0 +1,19 @@
  1 +- if note.valid?
  2 + :plain
  3 + // hide and reset the form
  4 + $(".per_line_form").hide();
  5 + $('.line-note-form-holder textarea').val("");
  6 +
  7 + // find the reply button for this line
  8 + // (might not be there if this is the first note)
  9 + var trRpl = $("a.line_note_reply_link[data-line-code='#{note.line_code}']").closest("tr");
  10 + if (trRpl.size() == 0) {
  11 + // find the commented line ...
  12 + var trEl = $(".#{note.line_code}").parent();
  13 + // ... and insert the note and the reply button after it
  14 + trEl.after("#{escape_javascript(render "notes/reply_button", line_code: note.line_code)}");
  15 + trEl.after("#{escape_javascript(render "notes/per_line_show", note: note)}");
  16 + } else {
  17 + // instert new note before reply button
  18 + trRpl.before("#{escape_javascript(render "notes/per_line_show", note: note)}");
  19 + }
... ...
app/views/notes/create.js.haml
1 1 - if @note.line_code
2   - = render "create_line", note: @note
  2 + = render "create_per_line_note", note: @note
3 3 - else
4   - = render "create_common", note: @note
  4 + = render "create_common_note", note: @note
5 5  
6 6 -# Enable submit button
7 7 :plain
... ...