Changeset - 8cca07df79dd
[Not reviewed]
beta
0 1 0
Marcin Kuzminski - 15 years ago 2011-05-08 20:11:26
marcin@python-works.com
fixed small bug in selection links when sorting messes up for <10 numbers
1 file changed with 3 insertions and 2 deletions:
0 comments (0 inline, 0 general)
rhodecode/templates/files/files_source.html
Show inline comments
 
@@ -87,87 +87,88 @@
 
           
 
           //sets old anchor 
 
           window.location.hash = old_hash;
 
           
 
           }
 
       </script>
 
     %endif		
 
	</div>
 
</div>
 

	
 
<script type="text/javascript">
 
YUE.onDOMReady(function(){
 
    YUE.on('show_rev','click',function(e){
 
    	YUE.preventDefault(e);
 
        var cs = YAHOO.util.Dom.get('diff1').value;
 
        var url = "${h.url('files_home',repo_name=c.repo_name,revision='__CS__',f_path=c.f_path)}".replace('__CS__',cs);
 
        window.location = url;
 
    });
 
    
 
    function getIdentNode(n){
 
    	//iterate thru nodes untill matched interesting node !
 
    	
 
    	if (typeof n == 'undefined'){
 
    		return -1
 
    	}
 
    	
 
    	if(typeof n.id != "undefined" && n.id.match('L[0-9]+')){
 
   			return n
 
   		}
 
    	else{
 
    		return getIdentNode(n.parentNode);
 
    	}
 
    }
 
    
 
    function getSelectionLink() {
 
        //get selection from start/to nodes    	
 
        if (typeof window.getSelection != "undefined") {
 
        	s = window.getSelection();
 

	
 
           	from = getIdentNode(s.anchorNode);
 
           	till = getIdentNode(s.focusNode);
 
            
 
            f_int = parseInt(from.id.replace('L',''));
 
            t_int = parseInt(till.id.replace('L',''));
 
            
 
            if (f_int > t_int){
 
            	//highlight from bottom 
 
            	offset = -35;
 
            	ranges = [t_int,f_int];
 
            	
 
            }
 
            else{
 
            	//highligth from top 
 
            	offset = 35;
 
            	ranges = [f_int,t_int];
 
            }
 
            
 
            ranges = [f_int,t_int].sort();
 
            
 
            if (ranges[0] != ranges[1]){
 
	            if(YUD.get('linktt') == null){
 
	                hl_div = document.createElement('div');
 
	                hl_div.id = 'linktt';
 
	            }
 
	            anchor = '#L'+ranges[0]+'-'+ranges[1];
 
	            hl_div.innerHTML = '';
 
	            l = document.createElement('a');
 
	            l.href = location.href.substring(0,location.href.indexOf('#'))+anchor;
 
	            l.innerHTML = "${_('Selection link')}"
 
	            hl_div.appendChild(l);
 
	            
 
	            YUD.get('body').appendChild(hl_div);
 
	            
 
	            xy = YUD.getXY(till.id);
 
	            
 
	            YUD.addClass('linktt','yui-tt');
 
	            YUD.setStyle('linktt','top',xy[1]+offset+'px');
 
	            YUD.setStyle('linktt','left',xy[0]+'px');
 
	            YUD.setStyle('linktt','visibility','visible');
 
            }
 
            else{
 
            	YUD.setStyle('linktt','visibility','hidden');
 
            }
 
        }
 
   }
 
    
 
    YUE.on('hlcode','mouseup',getSelectionLink)
 
    
 
   });
 
</script>
 
\ No newline at end of file
0 comments (0 inline, 0 general)