diff options
Diffstat (limited to 'sonar-server/src/main/webapp/javascripts/application.js')
-rw-r--r-- | sonar-server/src/main/webapp/javascripts/application.js | 69 |
1 files changed, 68 insertions, 1 deletions
diff --git a/sonar-server/src/main/webapp/javascripts/application.js b/sonar-server/src/main/webapp/javascripts/application.js index b7a40fd9ee0..eb13eac4303 100644 --- a/sonar-server/src/main/webapp/javascripts/application.js +++ b/sonar-server/src/main/webapp/javascripts/application.js @@ -138,4 +138,71 @@ var SelectBox = { box.options[i].selected = 'selected'; } } -};
\ No newline at end of file +}; + +var treemapContexts = {}; + +function addTmEvent(treemap_id, elt_index) { + var elt = $('tm-node-' + treemap_id + '-' + elt_index); + elt.oncontextmenu = function () { + return false + }; + elt.observe('mouseup', function (event) { + context = treemapContexts[treemap_id]; + onTmClick(treemap_id, event, context); + }); +} + +function onTmClick(treemap_id, event, context) { + if (Event.isLeftClick(event)) { + var link = event.findElement('a'); + if (link != null) { + event.stopPropagation(); + return false; + } + + var elt = event.findElement('div'); + var rid = elt.readAttribute('rid'); + var browsable = elt.hasAttribute('b'); + if (browsable) { + var label = elt.innerText || elt.textContent; + context.push([rid, label]); + refreshTm(treemap_id, rid); + } else { + openResource(rid); + } + + } else if (Event.isRightClick(event)) { + if (context.length > 1) { + context.pop(); + var rid = context[context.length - 1][0]; + refreshTm(treemap_id, rid); + } + } +} + +function refreshTm(treemap_id, resource_id) { + var size = $F('tm-size-' + treemap_id); + var color = $F('tm-color-' + treemap_id); + var width = $('tm-' + treemap_id).getWidth() - 10; + var height = Math.round(width * parseFloat($F('tm-h-' + treemap_id) / 100.0)); + + context = treemapContexts[treemap_id]; + var output = ''; + context.each(function (elt) { + output += elt[1] + ' / '; + }); + $('tm-bc-' + treemap_id).innerHTML = output; + $('tm-loading-' + treemap_id).show(); + + new Ajax.Request( + baseUrl + '/treemap/index?id=' + treemap_id + '&width=' + width + '&height=' + height + '&size_metric=' + size + '&color_metric=' + color + '&resource=' + resource_id, + {asynchronous:true, evalScripts:true}); + + return false; +} + +function openResource(key) { + document.location = baseUrl + '/dashboard/index/' + key; + return false; +}
\ No newline at end of file |