1 function findPos(obj) {
2 var curleft = curtop = 0;
3 if (obj.offsetParent) {
5 curleft += obj.offsetLeft;
6 curtop += obj.offsetTop;
8 while (obj = obj.offsetParent);
9 return [curleft,curtop];
13 function setNavClass(el){
14 var link_el = document.getElementById("actions_nav_link");
15 var offsetAry = findPos(link_el);
16 // set position of list
17 el.style.left = offsetAry[0]+"px";
18 el.style.top = offsetAry[1]+30 +"px";
19 el.className+=" actions_nav_list_over";
22 // handles hover sub menus in IE
23 function startList() {
24 if(!document.getElementById("actions_nav_link"))
26 var navList = document.getElementById("actions_nav_list");
27 var navLink = document.getElementById("actions_nav_link");
28 // assign event handlers to each element
29 navLink.onmouseover=function() {
32 navList.onmouseover=function() {
35 navList.onmouseout=function() {
36 navList.className=navList.className.replace(" actions_nav_list_over", "");
38 navLink.onmouseout=function() {
39 navList.className=navList.className.replace(" actions_nav_list_over", "");
43 function uriFor(action, sha1) {
44 return jQuery('#' + action + '-uri').text().replace(/\bHEAD\b/, sha1);
47 function switchBranch() {
48 var branch = jQuery('#branch-list').val();
49 document.location.href = uriFor('current', branch);
52 function compareDiffs(){
53 var path = jQuery('#compare-path').text(),
54 baseSha1 = jQuery('#compare-form input[name=sha1_a]:checked').val(),
55 compSha1 = jQuery('#compare-form input[name=sha1_b]:checked').val(),
56 diffUri = uriFor('diff', baseSha1);
57 document.location.href = diffUri + '/' + compSha1 + (path ? '/' + encodeURIComponent(path) : '');
61 function _loadCommitInfo(cells) {
62 var cell = jQuery(cells.shift());
63 var filename = cell.find('.js-data').text();
64 jQuery.getJSON(uriFor('file_commit_info') + '/' + filename, {}, function(commitInfo) {
66 cell.html('<a href="'+uriFor('commit', commitInfo.sha1)+'">'+commitInfo.comment+'</a> '+commitInfo.age);
68 _loadCommitInfo(cells);
72 function loadCommitInfo() {
73 var cells = jQuery('#commit-tree .message').get();
75 _loadCommitInfo( cells );
79 // Provide sub-nav dropdowns (I think).
82 // JS up any Compare links
83 jQuery('a.compare-link').click(compareDiffs);
84 // Change the URL when a branch is selected
85 jQuery('#branch-list').change(switchBranch);
86 // Wait for image requests to come back first
87 jQuery(window).load(loadCommitInfo);