diff --git a/src/main/twirl/gitbucket/core/repo/blob.scala.html b/src/main/twirl/gitbucket/core/repo/blob.scala.html index 9ce56ba..6bbccd3 100644 --- a/src/main/twirl/gitbucket/core/repo/blob.scala.html +++ b/src/main/twirl/gitbucket/core/repo/blob.scala.html @@ -104,36 +104,38 @@ function updateSourceLineNum(){ $('.source-line-num').remove(); var pos = pre.find('ol.linenums').position(); - $('
').css({ - height:pre.height(), - width:'48px', - cursor:'pointer', - position: 'absolute', - top : pos.top + 'px', - left : pos.left + 'px' - }).click(function(e){ - $(window).hashchange(function(){}) - var pos = $(this).data("pos"); - if(!pos){ - pos = $('ol.linenums li').map(function(){ return {id:$(this).attr("id"),top:$(this).position().top} }).toArray(); - $(this).data("pos",pos); - } - for(var i=0;ie.pageY){ - break; + if(pos){ + $('
').css({ + height : pre.height(), + width : '48px', + cursor : 'pointer', + position: 'absolute', + top : pos.top + 'px', + left : pos.left + 'px' + }).click(function(e){ + $(window).hashchange(function(){}) + var pos = $(this).data("pos"); + if(!pos){ + pos = $('ol.linenums li').map(function(){ return { id: $(this).attr("id"), top: $(this).position().top} }).toArray(); + $(this).data("pos",pos); } - } - var line = pos[i].id.replace(/^L/,''); - var hash = location.hash; - if(e.shiftKey == true && hash.match(/#L\d+(-L\d+)?/)){ - var lines = hash.split('-'); - location.hash = lines[0] + '-L' + line; - } else { - var p = $("#L"+line).attr('id',""); - location.hash = '#L' + line; - p.attr('id','L'+line); - } - }).appendTo(pre); + for(var i = 0; i < pos.length-1; i++){ + if(pos[i + 1].top > e.pageY){ + break; + } + } + var line = pos[i].id.replace(/^L/,''); + var hash = location.hash; + if(e.shiftKey == true && hash.match(/#L\d+(-L\d+)?/)){ + var lines = hash.split('-'); + location.hash = lines[0] + '-L' + line; + } else { + var p = $("#L"+line).attr('id',""); + location.hash = '#L' + line; + p.attr('id','L'+line); + } + }).appendTo(pre); + } } var repository = $('.blame-action').data('repository'); $('.blame-action').click(function(e){ @@ -147,9 +149,9 @@ function updateBlame(){ var m = /^\/(blame|blob)(\/.*)$/.exec(location.href.substring(repository.length)); var mode = m[1]; - $('.blame-action').toggleClass("active", mode=='blame').attr('href', repository + (m[1]=='blame'?'/blob':'/blame')+m[2]); - if(pre.parents("td").find(".blame").length){ - pre.parents("div.container").toggleClass("blame-container", mode=='blame'); + $('.blame-action').toggleClass("active", mode=='blame').attr('href', repository + (m[1] == 'blame' ? '/blob' : '/blame') + m[2]); + if(pre.parents("div.box-content-bottom").find(".blame").length){ + pre.parents("div.container").toggleClass("blame-container", mode == 'blame'); updateSourceLineNum(); return; } @@ -159,45 +161,45 @@ } $(document.body).toggleClass('no-box-shadow',document.body.style.boxShadow===undefined); $('.blame-action').addClass("active"); - var base = $('
').css({height:pre.height()}).prependTo(pre.parents("td")[0]); + var base = $('
').css({height: pre.height()}).prependTo(pre.parents("div.box-content-bottom")); base.parents("div.container").addClass("blame-container"); updateSourceLineNum(); $.get($('.blame-action').data('url')).done(function(data){ var blame = data.blame; var index = []; - for(var i=0;i') - .append($('').attr("href",data.root+'/commit/'+blame.id).text(blame.id.substr(0,7))); + .append($('').attr("href", data.root + '/commit/' + blame.id).text(blame.id.substr(0,7))); if(blame.prev){ sha.append($('
')) - .append($('
').text('prev').attr("href",data.root+'/blame/'+blame.prev+'/'+(blame.prevPath||data.path))); + .append($('').text('prev').attr("href", data.root + '/blame/' + blame.prev + '/' + (blame.prevPath || data.path))); } lastDiv = $('
') - .addClass('heat'+Math.min(10,Math.max(1,Math.ceil((now-blame.commited)/(24*3600*1000*70))))) - .toggleClass('blame-last',blame.id==data.last) + .addClass('heat' + Math.min(10, Math.max(1, Math.ceil((now - blame.commited) / (24 * 3600 * 1000 * 70))))) + .toggleClass('blame-last', blame.id == data.last) .data('line', (i + 1)) .css({ - "top" : p.top + 'px', - "min-height" : h+'px' + "top" : p.top + 'px', + "min-height" : h + 'px' }) .append(sha) - .append($(blame.avatar).addClass('avatar').css({"float":"left"})) + .append($(blame.avatar).addClass('avatar').css({"float": "left"})) .append($('
').text(blame.message)) - .append($('
').html(blame.author+ " authed "+blame.authed)) + .append($('
').html(blame.author + " authed " + blame.authed)) .appendTo(base); } }); @@ -207,6 +209,8 @@ updateBlame(); }); +var scrolling = false; + /** * Hightlight lines which are specified by URL hash. */ @@ -217,7 +221,7 @@ var lines = hash.substr(1).split('-'); if(lines.length == 1){ $('#' + lines[0]).addClass('highlight'); - if(!updateHighlighting.scrolling){ + if(!scrolling){ $(window).scrollTop($('#' + lines[0]).offset().top - 40); } } else if(lines.length > 1){ @@ -226,11 +230,11 @@ for(var i = start; i <= end; i++){ $('#L' + i).addClass('highlight'); } - if(!updateHighlighting.scrolling){ + if(!scrolling){ $(window).scrollTop($('#L' + start).offset().top - 40); } } - updateHighlighting.scrolling = true; + scrolling = true; } } \ No newline at end of file diff --git a/src/main/webapp/assets/common/css/gitbucket.css b/src/main/webapp/assets/common/css/gitbucket.css index 5de423d..41cca57 100644 --- a/src/main/webapp/assets/common/css/gitbucket.css +++ b/src/main/webapp/assets/common/css/gitbucket.css @@ -1755,9 +1755,12 @@ padding-left: 50px; } +/* div.container.blame-container{ width:1270px; } +*/ + .line-age-legend { display: none; }