Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.
 
 
 
 
 
 

103 řádky
3.4 KiB

  1. (function($){
  2. window.enableBlame = function(url, original_path) {
  3. var message = null;
  4. var message_rev = null;
  5. /* for each blame cell containing a changeset link... */
  6. var rev_paths = {};
  7. $("table.code th.blame a").each(function() {
  8. href = $(this).attr("href");
  9. $(this).removeAttr("href");
  10. rev_href = href.substr(href.indexOf("changeset/") + 10);
  11. elts = rev_href.split("/");
  12. var path = elts.slice(1).join("/");
  13. if (path != original_path)
  14. rev_paths["r"+elts[0]] = path;
  15. });
  16. /* for each blame cell... */
  17. $("table.code th.blame").each(function() {
  18. var rev = $(this).attr("class").split(" ")[1]; // "blame r123"
  19. var path = rev_paths[rev] || original_path; // only found if != orig
  20. if (!rev)
  21. return;
  22. $(this).css("cursor", "pointer").click(function() {
  23. var row = this.parentNode;
  24. var message_is_visible = message && message.css("display") == "block";
  25. var highlight_rev = null;
  26. function show() {
  27. /* Display commit message for the selected revision */
  28. var message_w = message.get(0).offsetWidth;
  29. // limit message panel width to 3/5 of the row width
  30. var row_w = row.offsetWidth;
  31. var max_w = (3.0 * row_w / 5.0);
  32. if (!message_w || message_w > max_w) {
  33. message_w = max_w;
  34. var borderw = (3+8)*2; // borderwidth + padding on both sides
  35. message.css({width: message_w - borderw + "px"});
  36. }
  37. var row_offset = $(row).offset();
  38. var left = row_offset.left + row.offsetWidth - message_w;
  39. message.css({display: "block", top: row_offset.top+"px", left: left-2+"px"});
  40. }
  41. function hide() {
  42. /* Hide commit message */
  43. message.css({display: "none"});
  44. /* Remove highlighting for lines of the current revision */
  45. $("table.code th."+message_rev).each(function() {
  46. $(this.parentNode).removeClass("hilite")
  47. });
  48. }
  49. if (message_rev != rev) { // fetch a new revision
  50. if (message_is_visible) {
  51. hide();
  52. }
  53. message_rev = rev;
  54. highlight_rev = message_rev;
  55. $.get(url + rev.substr(1), {annotate: path}, function(data) {
  56. // remove former message panel if any
  57. if (message)
  58. message.remove();
  59. // create new message panel
  60. message = $('<div class="message">').css("position", "absolute")
  61. .append($('<div class="inlinebuttons">')
  62. .append($('<input value="Close" type="button">').click(hide)))
  63. .append($('<div>').html(data || "<strong>(no changeset information)</strong>"))
  64. .appendTo("body");
  65. // workaround non-clickable "Close" issue in Firefox
  66. if ($.browser.mozilla)
  67. message.find("div.inlinebuttons").next().css("clear", "right");
  68. show();
  69. });
  70. } else if (message_is_visible) {
  71. hide();
  72. } else {
  73. show();
  74. highlight_rev = message_rev;
  75. }
  76. /* Highlight all lines of the current revision */
  77. $("table.code th."+highlight_rev).each(function() {
  78. $(this.parentNode).addClass("hilite")
  79. });
  80. });
  81. });
  82. }
  83. })(jQuery);