Show More
@@ -230,7 +230,7 b' var initCodeMirror = function(textAreadI' | |||
|
230 | 230 | return myCodeMirror; |
|
231 | 231 | }; |
|
232 | 232 | |
|
233 | var initCommentBoxCodeMirror = function(textAreaId, triggerActions){ | |
|
233 | var initCommentBoxCodeMirror = function(CommentForm, textAreaId, triggerActions){ | |
|
234 | 234 | var initialHeight = 100; |
|
235 | 235 | |
|
236 | 236 | if (typeof userHintsCache === "undefined") { |
@@ -288,10 +288,100 b' var initCommentBoxCodeMirror = function(' | |||
|
288 | 288 | |
|
289 | 289 | var completeActions = function(actions){ |
|
290 | 290 | |
|
291 | var registeredActions = []; | |
|
292 | var allActions = [ | |
|
293 | { | |
|
294 | text: "approve", | |
|
295 | searchText: "status approved", | |
|
296 | displayText: _gettext('Set status to Approved'), | |
|
297 | hint: function(CodeMirror, data, completion) { | |
|
298 | CodeMirror.replaceRange("", completion.from || data.from, | |
|
299 | completion.to || data.to, "complete"); | |
|
300 | $(CommentForm.statusChange).select2("val", 'approved').trigger('change'); | |
|
301 | }, | |
|
302 | render: function(elt, data, completion) { | |
|
303 | var el = document.createElement('div'); | |
|
304 | el.className = "flag_status flag_status_comment_box approved pull-left"; | |
|
305 | elt.appendChild(el); | |
|
306 | ||
|
307 | el = document.createElement('span'); | |
|
308 | el.innerHTML = completion.displayText; | |
|
309 | elt.appendChild(el); | |
|
310 | } | |
|
311 | }, | |
|
312 | { | |
|
313 | text: "reject", | |
|
314 | searchText: "status rejected", | |
|
315 | displayText: _gettext('Set status to Rejected'), | |
|
316 | hint: function(CodeMirror, data, completion) { | |
|
317 | CodeMirror.replaceRange("", completion.from || data.from, | |
|
318 | completion.to || data.to, "complete"); | |
|
319 | $(CommentForm.statusChange).select2("val", 'rejected').trigger('change'); | |
|
320 | }, | |
|
321 | render: function(elt, data, completion) { | |
|
322 | var el = document.createElement('div'); | |
|
323 | el.className = "flag_status flag_status_comment_box rejected pull-left"; | |
|
324 | elt.appendChild(el); | |
|
325 | ||
|
326 | el = document.createElement('span'); | |
|
327 | el.innerHTML = completion.displayText; | |
|
328 | elt.appendChild(el); | |
|
329 | } | |
|
330 | }, | |
|
331 | { | |
|
332 | text: "as_todo", | |
|
333 | searchText: "todo comment", | |
|
334 | displayText: _gettext('TODO comment'), | |
|
335 | hint: function(CodeMirror, data, completion) { | |
|
336 | CodeMirror.replaceRange("", completion.from || data.from, | |
|
337 | completion.to || data.to, "complete"); | |
|
338 | ||
|
339 | $(CommentForm.commentType).val('todo'); | |
|
340 | }, | |
|
341 | render: function(elt, data, completion) { | |
|
342 | var el = document.createElement('div'); | |
|
343 | el.className = "pull-left"; | |
|
344 | elt.appendChild(el); | |
|
345 | ||
|
346 | el = document.createElement('span'); | |
|
347 | el.innerHTML = completion.displayText; | |
|
348 | elt.appendChild(el); | |
|
349 | } | |
|
350 | }, | |
|
351 | { | |
|
352 | text: "as_note", | |
|
353 | searchText: "note comment", | |
|
354 | displayText: _gettext('Note Comment'), | |
|
355 | hint: function(CodeMirror, data, completion) { | |
|
356 | CodeMirror.replaceRange("", completion.from || data.from, | |
|
357 | completion.to || data.to, "complete"); | |
|
358 | ||
|
359 | $(CommentForm.commentType).val('note'); | |
|
360 | }, | |
|
361 | render: function(elt, data, completion) { | |
|
362 | var el = document.createElement('div'); | |
|
363 | el.className = "pull-left"; | |
|
364 | elt.appendChild(el); | |
|
365 | ||
|
366 | el = document.createElement('span'); | |
|
367 | el.innerHTML = completion.displayText; | |
|
368 | elt.appendChild(el); | |
|
369 | } | |
|
370 | } | |
|
371 | ]; | |
|
372 | ||
|
373 | $.each(allActions, function(index, value){ | |
|
374 | var actionData = allActions[index]; | |
|
375 | if (actions.indexOf(actionData['text']) != -1) { | |
|
376 | registeredActions.push(actionData); | |
|
377 | } | |
|
378 | }); | |
|
379 | ||
|
291 | 380 | return function(cm, pred) { |
|
292 | 381 | var cur = cm.getCursor(); |
|
293 | 382 | var options = { |
|
294 | closeOnUnfocus: true | |
|
383 | closeOnUnfocus: true, | |
|
384 | registeredActions: registeredActions | |
|
295 | 385 | }; |
|
296 | 386 | setTimeout(function() { |
|
297 | 387 | if (!cm.state.completionActive) { |
@@ -356,6 +446,7 b' var initCommentBoxCodeMirror = function(' | |||
|
356 | 446 | }); |
|
357 | 447 | |
|
358 | 448 | var actionHint = function(editor, options) { |
|
449 | ||
|
359 | 450 | var cur = editor.getCursor(); |
|
360 | 451 | var curLine = editor.getLine(cur.line).slice(0, cur.ch); |
|
361 | 452 | |
@@ -374,87 +465,8 b' var initCommentBoxCodeMirror = function(' | |||
|
374 | 465 | type: null |
|
375 | 466 | }; |
|
376 | 467 | |
|
377 | var actions = [ | |
|
378 | { | |
|
379 | text: "approve", | |
|
380 | searchText: "status approved", | |
|
381 | displayText: _gettext('Set status to Approved'), | |
|
382 | hint: function(CodeMirror, data, completion) { | |
|
383 | CodeMirror.replaceRange("", completion.from || data.from, | |
|
384 | completion.to || data.to, "complete"); | |
|
385 | $('#change_status_general').select2("val", 'approved').trigger('change'); | |
|
386 | }, | |
|
387 | render: function(elt, data, completion) { | |
|
388 | var el = document.createElement('div'); | |
|
389 | el.className = "flag_status flag_status_comment_box approved pull-left"; | |
|
390 | elt.appendChild(el); | |
|
391 | ||
|
392 | el = document.createElement('span'); | |
|
393 | el.innerHTML = completion.displayText; | |
|
394 | elt.appendChild(el); | |
|
395 | } | |
|
396 | }, | |
|
397 | { | |
|
398 | text: "reject", | |
|
399 | searchText: "status rejected", | |
|
400 | displayText: _gettext('Set status to Rejected'), | |
|
401 | hint: function(CodeMirror, data, completion) { | |
|
402 | CodeMirror.replaceRange("", completion.from || data.from, | |
|
403 | completion.to || data.to, "complete"); | |
|
404 | $('#change_status_general').select2("val", 'rejected').trigger('change'); | |
|
405 | }, | |
|
406 | render: function(elt, data, completion) { | |
|
407 | var el = document.createElement('div'); | |
|
408 | el.className = "flag_status flag_status_comment_box rejected pull-left"; | |
|
409 | elt.appendChild(el); | |
|
410 | ||
|
411 | el = document.createElement('span'); | |
|
412 | el.innerHTML = completion.displayText; | |
|
413 | elt.appendChild(el); | |
|
414 | } | |
|
415 | }, | |
|
416 | { | |
|
417 | text: "as_todo", | |
|
418 | searchText: "todo comment", | |
|
419 | displayText: _gettext('TODO comment'), | |
|
420 | hint: function(CodeMirror, data, completion) { | |
|
421 | CodeMirror.replaceRange("", completion.from || data.from, | |
|
422 | completion.to || data.to, "complete"); | |
|
423 | $('#comment_type_general').val('todo') | |
|
424 | }, | |
|
425 | render: function(elt, data, completion) { | |
|
426 | var el = document.createElement('div'); | |
|
427 | el.className = "pull-left"; | |
|
428 | elt.appendChild(el); | |
|
429 | ||
|
430 | el = document.createElement('span'); | |
|
431 | el.innerHTML = completion.displayText; | |
|
432 | elt.appendChild(el); | |
|
433 | } | |
|
434 | }, | |
|
435 | { | |
|
436 | text: "as_note", | |
|
437 | searchText: "note comment", | |
|
438 | displayText: _gettext('Note Comment'), | |
|
439 | hint: function(CodeMirror, data, completion) { | |
|
440 | CodeMirror.replaceRange("", completion.from || data.from, | |
|
441 | completion.to || data.to, "complete"); | |
|
442 | $('#comment_type_general').val('note') | |
|
443 | }, | |
|
444 | render: function(elt, data, completion) { | |
|
445 | var el = document.createElement('div'); | |
|
446 | el.className = "pull-left"; | |
|
447 | elt.appendChild(el); | |
|
448 | ||
|
449 | el = document.createElement('span'); | |
|
450 | el.innerHTML = completion.displayText; | |
|
451 | elt.appendChild(el); | |
|
452 | } | |
|
453 | } | |
|
454 | ]; | |
|
455 | ||
|
456 | 468 | return { |
|
457 |
list: filterActions( |
|
|
469 | list: filterActions(options.registeredActions, context), | |
|
458 | 470 | from: CodeMirror.Pos(cur.line, context.start), |
|
459 | 471 | to: CodeMirror.Pos(cur.line, context.end) |
|
460 | 472 | }; |
@@ -93,7 +93,7 b' var bindToggleButtons = function() {' | |||
|
93 | 93 | this.resolvesActionId = null; |
|
94 | 94 | |
|
95 | 95 | this.cmBox = this.withLineNo('#text'); |
|
96 | this.cm = initCommentBoxCodeMirror(this.cmBox, this.initAutocompleteActions); | |
|
96 | this.cm = initCommentBoxCodeMirror(this, this.cmBox, this.initAutocompleteActions); | |
|
97 | 97 | |
|
98 | 98 | this.statusChange = this.withLineNo('#change_status'); |
|
99 | 99 | |
@@ -627,8 +627,9 b' var CommentsController = function() {' | |||
|
627 | 627 | $formPlaceholder.append($form); |
|
628 | 628 | |
|
629 | 629 | var _form = $($form[0]); |
|
630 | var autocompleteActions = ['approve', 'reject', 'as_note', 'as_todo']; | |
|
630 | 631 | var commentForm = this.createCommentForm( |
|
631 |
_form, lineNo, placeholderText, t |
|
|
632 | _form, lineNo, placeholderText, autocompleteActions, resolvesCommentId); | |
|
632 | 633 | commentForm.initStatusChangeSelector(); |
|
633 | 634 | |
|
634 | 635 | return commentForm; |
@@ -662,9 +663,9 b' var CommentsController = function() {' | |||
|
662 | 663 | |
|
663 | 664 | var placeholderText = _gettext('Leave a comment on line {0}.').format(lineno); |
|
664 | 665 | var _form = $($form[0]).find('form'); |
|
665 | ||
|
666 | var autocompleteActions = ['as_note', 'as_todo']; | |
|
666 | 667 | var commentForm = this.createCommentForm( |
|
667 |
_form, lineno, placeholderText, |
|
|
668 | _form, lineno, placeholderText, autocompleteActions, resolvesCommentId); | |
|
668 | 669 | |
|
669 | 670 | $.Topic('/ui/plugins/code/comment_form_built').prepareOrPublish({ |
|
670 | 671 | form: _form, |
General Comments 0
You need to be logged in to leave comments.
Login now