Commit 4ed8278870640017b93f18b476532824eba70ac2
1 parent
7978f8dd
Exists in
master
and in
4 other branches
Fix a bunch of smaller glitches.
Showing
4 changed files
with
83 additions
and
112 deletions
Show diff stats
app/assets/javascripts/notes.js
| @@ -58,12 +58,6 @@ var NoteList = { | @@ -58,12 +58,6 @@ var NoteList = { | ||
| 58 | ".js-close-discussion-note-form", | 58 | ".js-close-discussion-note-form", |
| 59 | NoteList.removeDiscussionNoteForm); | 59 | NoteList.removeDiscussionNoteForm); |
| 60 | 60 | ||
| 61 | - // do some specific housekeeping when removing a diff or discussion note | ||
| 62 | - $(document).on("click", | ||
| 63 | - ".diff_file .js-note-delete," + | ||
| 64 | - ".discussion .js-note-delete", | ||
| 65 | - NoteList.removeDiscussionNote); | ||
| 66 | - | ||
| 67 | // remove a note (in general) | 61 | // remove a note (in general) |
| 68 | $(document).on("click", | 62 | $(document).on("click", |
| 69 | ".js-note-delete", | 63 | ".js-note-delete", |
| @@ -96,9 +90,6 @@ var NoteList = { | @@ -96,9 +90,6 @@ var NoteList = { | ||
| 96 | previewContainer.removeClass("on"); | 90 | previewContainer.removeClass("on"); |
| 97 | } | 91 | } |
| 98 | form.find(".js-note-text").val("").trigger("input"); | 92 | form.find(".js-note-text").val("").trigger("input"); |
| 99 | - | ||
| 100 | - // re-enable submit button | ||
| 101 | - form.find(".js-comment-button").enable(); | ||
| 102 | }, | 93 | }, |
| 103 | 94 | ||
| 104 | /** | 95 | /** |
| @@ -144,8 +135,6 @@ var NoteList = { | @@ -144,8 +135,6 @@ var NoteList = { | ||
| 144 | var preview = form.find('.js-note-preview'); | 135 | var preview = form.find('.js-note-preview'); |
| 145 | var noteText = form.find('.js-note-text').val(); | 136 | var noteText = form.find('.js-note-text').val(); |
| 146 | 137 | ||
| 147 | - console.log("preview", noteText); | ||
| 148 | - | ||
| 149 | if(noteText.trim().length === 0) { | 138 | if(noteText.trim().length === 0) { |
| 150 | preview.text('Nothing to preview.'); | 139 | preview.text('Nothing to preview.'); |
| 151 | } else { | 140 | } else { |
| @@ -158,35 +147,12 @@ var NoteList = { | @@ -158,35 +147,12 @@ var NoteList = { | ||
| 158 | }, | 147 | }, |
| 159 | 148 | ||
| 160 | /** | 149 | /** |
| 161 | - * Called in response to deleting a note on a diff line. | ||
| 162 | - * | ||
| 163 | - * Removes the actual note from view. | ||
| 164 | - * Removes the whole notes row if the last note for that line is being removed. | ||
| 165 | - * | ||
| 166 | - * Note: must be called before removeNote() | ||
| 167 | - */ | ||
| 168 | - removeDiscussionNote: function() { | ||
| 169 | - var notes = $(this).closest(".notes"); | ||
| 170 | - | ||
| 171 | - // check if this is the last note for this line | ||
| 172 | - if (notes.find(".note").length === 1) { | ||
| 173 | - // for discussions | ||
| 174 | - notes.closest(".discussion").remove(); | ||
| 175 | - | ||
| 176 | - // for diff lines | ||
| 177 | - notes.closest("tr").remove(); | ||
| 178 | - } | ||
| 179 | - }, | ||
| 180 | - | ||
| 181 | - /** | ||
| 182 | * Called in response to "cancel" on a diff note form. | 150 | * Called in response to "cancel" on a diff note form. |
| 183 | * | 151 | * |
| 184 | * Shows the reply button again. | 152 | * Shows the reply button again. |
| 185 | * Removes the form and if necessary it's temporary row. | 153 | * Removes the form and if necessary it's temporary row. |
| 186 | */ | 154 | */ |
| 187 | - removeDiscussionNoteForm: function(e) { | ||
| 188 | - e.preventDefault(); | ||
| 189 | - | 155 | + removeDiscussionNoteForm: function() { |
| 190 | var form = $(this).closest("form"); | 156 | var form = $(this).closest("form"); |
| 191 | var row = form.closest("tr"); | 157 | var row = form.closest("tr"); |
| 192 | 158 | ||
| @@ -206,9 +172,22 @@ var NoteList = { | @@ -206,9 +172,22 @@ var NoteList = { | ||
| 206 | * Called in response to deleting a note of any kind. | 172 | * Called in response to deleting a note of any kind. |
| 207 | * | 173 | * |
| 208 | * Removes the actual note from view. | 174 | * Removes the actual note from view. |
| 175 | + * Removes the whole discussion if the last note is being removed. | ||
| 209 | */ | 176 | */ |
| 210 | removeNote: function() { | 177 | removeNote: function() { |
| 211 | - $(this).closest(".note").remove(); | 178 | + var note = $(this).closest(".note"); |
| 179 | + var notes = note.closest(".notes"); | ||
| 180 | + | ||
| 181 | + // check if this is the last note for this line | ||
| 182 | + if (notes.find(".note").length === 1) { | ||
| 183 | + // for discussions | ||
| 184 | + notes.closest(".discussion").remove(); | ||
| 185 | + | ||
| 186 | + // for diff lines | ||
| 187 | + notes.closest("tr").remove(); | ||
| 188 | + } | ||
| 189 | + | ||
| 190 | + note.remove(); | ||
| 212 | NoteList.updateVotes(); | 191 | NoteList.updateVotes(); |
| 213 | }, | 192 | }, |
| 214 | 193 | ||
| @@ -274,6 +253,7 @@ var NoteList = { | @@ -274,6 +253,7 @@ var NoteList = { | ||
| 274 | 253 | ||
| 275 | NoteList.setupNoteForm(form); | 254 | NoteList.setupNoteForm(form); |
| 276 | 255 | ||
| 256 | + form.find(".js-note-text").focus(); | ||
| 277 | }, | 257 | }, |
| 278 | 258 | ||
| 279 | /** | 259 | /** |
| @@ -312,16 +292,18 @@ var NoteList = { | @@ -312,16 +292,18 @@ var NoteList = { | ||
| 312 | setupNoteForm: function(form) { | 292 | setupNoteForm: function(form) { |
| 313 | disableButtonIfEmptyField(form.find(".js-note-text"), form.find(".js-comment-button")); | 293 | disableButtonIfEmptyField(form.find(".js-note-text"), form.find(".js-comment-button")); |
| 314 | 294 | ||
| 295 | + form.removeClass("js-new-note-form"); | ||
| 296 | + | ||
| 315 | // setup preview buttons | 297 | // setup preview buttons |
| 316 | - $(".js-note-edit-button, .js-note-preview-button").tooltip({ placement: 'left' }); | 298 | + form.find(".js-note-edit-button, .js-note-preview-button") |
| 299 | + .tooltip({ placement: 'left' }); | ||
| 317 | 300 | ||
| 318 | - previewButton = $(".js-note-preview-button"); | ||
| 319 | - previewButton.hide(); | 301 | + previewButton = form.find(".js-note-preview-button"); |
| 320 | form.find(".js-note-text").on("input", function() { | 302 | form.find(".js-note-text").on("input", function() { |
| 321 | if ($(this).val().trim() !== "") { | 303 | if ($(this).val().trim() !== "") { |
| 322 | - previewButton.fadeIn(); | 304 | + previewButton.removeClass("turn-off").addClass("turn-on"); |
| 323 | } else { | 305 | } else { |
| 324 | - previewButton.fadeOut(); | 306 | + previewButton.removeClass("turn-on").addClass("turn-off"); |
| 325 | } | 307 | } |
| 326 | }); | 308 | }); |
| 327 | 309 | ||
| @@ -344,8 +326,8 @@ var NoteList = { | @@ -344,8 +326,8 @@ var NoteList = { | ||
| 344 | $.ajax({ | 326 | $.ajax({ |
| 345 | url: NoteList.notes_path, | 327 | url: NoteList.notes_path, |
| 346 | data: NoteList.target_params, | 328 | data: NoteList.target_params, |
| 347 | - complete: function(){ $('.notes-status').removeClass("loading")}, | ||
| 348 | - beforeSend: function() { $('.notes-status').addClass("loading") }, | 329 | + complete: function(){ $('.js-notes-busy').removeClass("loading")}, |
| 330 | + beforeSend: function() { $('.js-notes-busy').addClass("loading") }, | ||
| 349 | dataType: "script" | 331 | dataType: "script" |
| 350 | }); | 332 | }); |
| 351 | }, | 333 | }, |
| @@ -404,8 +386,8 @@ var NoteList = { | @@ -404,8 +386,8 @@ var NoteList = { | ||
| 404 | $.ajax({ | 386 | $.ajax({ |
| 405 | url: NoteList.notes_path, | 387 | url: NoteList.notes_path, |
| 406 | data: NoteList.target_params + "&loading_more=1&" + (NoteList.reversed ? "before_id" : "after_id") + "=" + NoteList.bottom_id, | 388 | data: NoteList.target_params + "&loading_more=1&" + (NoteList.reversed ? "before_id" : "after_id") + "=" + NoteList.bottom_id, |
| 407 | - complete: function(){ $('.notes-status').removeClass("loading")}, | ||
| 408 | - beforeSend: function() { $('.notes-status').addClass("loading") }, | 389 | + complete: function(){ $('.js-notes-busy').removeClass("loading")}, |
| 390 | + beforeSend: function() { $('.js-notes-busy').addClass("loading") }, | ||
| 409 | dataType: "script" | 391 | dataType: "script" |
| 410 | }); | 392 | }); |
| 411 | }, | 393 | }, |
app/assets/stylesheets/sections/notes.scss
| @@ -135,9 +135,12 @@ ul.notes { | @@ -135,9 +135,12 @@ ul.notes { | ||
| 135 | } | 135 | } |
| 136 | } | 136 | } |
| 137 | 137 | ||
| 138 | + | ||
| 139 | + | ||
| 138 | /** | 140 | /** |
| 139 | - * Discussion/Note Actions | 141 | + * Actions for Discussions/Notes |
| 140 | */ | 142 | */ |
| 143 | + | ||
| 141 | .discussion, | 144 | .discussion, |
| 142 | .note { | 145 | .note { |
| 143 | &.note:hover { | 146 | &.note:hover { |
| @@ -174,33 +177,12 @@ ul.notes { | @@ -174,33 +177,12 @@ ul.notes { | ||
| 174 | top: 0; | 177 | top: 0; |
| 175 | } | 178 | } |
| 176 | 179 | ||
| 177 | -// TODO: start cleaup | ||
| 178 | -.issue_notes, | ||
| 179 | -.wiki_notes { | ||
| 180 | - .note_content { | ||
| 181 | - float: left; | ||
| 182 | - width: 400px; | ||
| 183 | - } | ||
| 184 | -} | ||
| 185 | - | ||
| 186 | -/* for loading indicator */ | ||
| 187 | -.notes-status { | ||
| 188 | - margin: 18px; | ||
| 189 | -} | ||
| 190 | 180 | ||
| 191 | 181 | ||
| 192 | -p.notify_controls input{ | ||
| 193 | - margin: 5px; | ||
| 194 | -} | ||
| 195 | - | ||
| 196 | -p.notify_controls span{ | ||
| 197 | - font-weight: 700; | ||
| 198 | -} | ||
| 199 | -// TODO: end cleaup | ||
| 200 | - | ||
| 201 | /** | 182 | /** |
| 202 | - * line note button on the side of diffs | 183 | + * Line note button on the side of diffs |
| 203 | */ | 184 | */ |
| 185 | + | ||
| 204 | .diff_file tr.line_holder { | 186 | .diff_file tr.line_holder { |
| 205 | .add-diff-note { | 187 | .add-diff-note { |
| 206 | background: url("diff_note_add.png") no-repeat left 0; | 188 | background: url("diff_note_add.png") no-repeat left 0; |
| @@ -231,8 +213,10 @@ p.notify_controls span{ | @@ -231,8 +213,10 @@ p.notify_controls span{ | ||
| 231 | } | 213 | } |
| 232 | } | 214 | } |
| 233 | 215 | ||
| 216 | + | ||
| 217 | + | ||
| 234 | /** | 218 | /** |
| 235 | - * Note Forms | 219 | + * Note Form |
| 236 | */ | 220 | */ |
| 237 | 221 | ||
| 238 | .comment-btn, | 222 | .comment-btn, |
| @@ -257,6 +241,46 @@ p.notify_controls span{ | @@ -257,6 +241,46 @@ p.notify_controls span{ | ||
| 257 | line-height: 32px; | 241 | line-height: 32px; |
| 258 | padding-right: 15px; | 242 | padding-right: 15px; |
| 259 | } | 243 | } |
| 244 | + | ||
| 245 | + // TODO: start cleanup | ||
| 246 | + .attachments { | ||
| 247 | + position: relative; | ||
| 248 | + width: 350px; | ||
| 249 | + height: 50px; | ||
| 250 | + overflow: hidden; | ||
| 251 | + margin:0 0 5px !important; | ||
| 252 | + | ||
| 253 | + .input_file { | ||
| 254 | + .file_name { | ||
| 255 | + line-height: 30px; | ||
| 256 | + width: 240px; | ||
| 257 | + height: 28px; | ||
| 258 | + overflow: hidden; | ||
| 259 | + } | ||
| 260 | + .file_upload { | ||
| 261 | + position: absolute; | ||
| 262 | + right:14px; | ||
| 263 | + top:7px; | ||
| 264 | + } | ||
| 265 | + .input-file { | ||
| 266 | + width: 260px; | ||
| 267 | + height: 41px; | ||
| 268 | + float: right; | ||
| 269 | + } | ||
| 270 | + } | ||
| 271 | + } | ||
| 272 | + .input-file { | ||
| 273 | + font: 500px monospace; | ||
| 274 | + opacity:0; | ||
| 275 | + filter: alpha(opacity=0); | ||
| 276 | + position: absolute; | ||
| 277 | + z-index: 1; | ||
| 278 | + top:0; | ||
| 279 | + right:0; | ||
| 280 | + padding:0; | ||
| 281 | + margin: 0; | ||
| 282 | + } | ||
| 283 | + // TODO: end cleanup | ||
| 260 | } | 284 | } |
| 261 | .note_text_and_preview { | 285 | .note_text_and_preview { |
| 262 | // makes the "absolute" position for links relative to this | 286 | // makes the "absolute" position for links relative to this |
| @@ -282,44 +306,9 @@ p.notify_controls span{ | @@ -282,44 +306,9 @@ p.notify_controls span{ | ||
| 282 | width: 98.6%; | 306 | width: 98.6%; |
| 283 | } | 307 | } |
| 284 | } | 308 | } |
| 309 | +} | ||
| 285 | 310 | ||
| 286 | - // TODO: start cleanup | ||
| 287 | - .attachments { | ||
| 288 | - position: relative; | ||
| 289 | - width: 350px; | ||
| 290 | - height: 50px; | ||
| 291 | - overflow: hidden; | ||
| 292 | - margin:0 0 5px !important; | ||
| 293 | - | ||
| 294 | - .input_file { | ||
| 295 | - .file_name { | ||
| 296 | - line-height: 30px; | ||
| 297 | - width: 240px; | ||
| 298 | - height: 28px; | ||
| 299 | - overflow: hidden; | ||
| 300 | - } | ||
| 301 | - .file_upload { | ||
| 302 | - position: absolute; | ||
| 303 | - right:14px; | ||
| 304 | - top:7px; | ||
| 305 | - } | ||
| 306 | - .input-file { | ||
| 307 | - width: 260px; | ||
| 308 | - height: 41px; | ||
| 309 | - float: right; | ||
| 310 | - } | ||
| 311 | - } | ||
| 312 | - } | ||
| 313 | - .input-file { | ||
| 314 | - font: 500px monospace; | ||
| 315 | - opacity:0; | ||
| 316 | - filter: alpha(opacity=0); | ||
| 317 | - position: absolute; | ||
| 318 | - z-index: 1; | ||
| 319 | - top:0; | ||
| 320 | - right:0; | ||
| 321 | - padding:0; | ||
| 322 | - margin: 0; | ||
| 323 | - } | ||
| 324 | - // TODO: end cleanup | 311 | +/* loading indicator */ |
| 312 | +.notes-busy { | ||
| 313 | + margin: 18px; | ||
| 325 | } | 314 | } |
app/views/issues/show.html.haml
app/views/notes/_form.html.haml
| @@ -6,7 +6,7 @@ | @@ -6,7 +6,7 @@ | ||
| 6 | = f.hidden_field :noteable_type | 6 | = f.hidden_field :noteable_type |
| 7 | 7 | ||
| 8 | .note_text_and_preview.js-toggler-container | 8 | .note_text_and_preview.js-toggler-container |
| 9 | - %a.js-note-preview-button.js-toggler-target.turn-on{ href: "javascript:;", data: {title: "Preview", url: preview_project_notes_path(@project)} } | 9 | + %a.js-note-preview-button.js-toggler-target.turn-off{ href: "javascript:;", data: {title: "Preview", url: preview_project_notes_path(@project)} } |
| 10 | %i.icon-eye-open | 10 | %i.icon-eye-open |
| 11 | %a.js-note-edit-button.js-toggler-target.turn-off{ href: "javascript:;", data: {title: "Edit"} } | 11 | %a.js-note-edit-button.js-toggler-target.turn-off{ href: "javascript:;", data: {title: "Edit"} } |
| 12 | %i.icon-edit | 12 | %i.icon-edit |
| @@ -37,7 +37,7 @@ | @@ -37,7 +37,7 @@ | ||
| 37 | = check_box_tag :notify, 1, !@note.for_commit? | 37 | = check_box_tag :notify, 1, !@note.for_commit? |
| 38 | %span Project team | 38 | %span Project team |
| 39 | 39 | ||
| 40 | - - if @note.notify_only_author?(current_user) | 40 | + - if @note.notify_only_author?(current_user) # FIXME: put in JS |
| 41 | = label_tag :notify_author do | 41 | = label_tag :notify_author do |
| 42 | = check_box_tag :notify_author, 1 , !@note.for_commit? | 42 | = check_box_tag :notify_author, 1 , !@note.for_commit? |
| 43 | %span Commit author | 43 | %span Commit author |