From 668c03e9d570c5a5800c0db2092251bb26a9933f Mon Sep 17 00:00:00 2001 From: Julien Lancelot Date: Mon, 19 Aug 2013 16:30:48 +0200 Subject: [PATCH] SONAR-3524 Impossible to go back on empty treemap --- .../main/webapp/javascripts/application.js | 54 +++++++++++-------- 1 file changed, 32 insertions(+), 22 deletions(-) diff --git a/sonar-server/src/main/webapp/javascripts/application.js b/sonar-server/src/main/webapp/javascripts/application.js index 501fd589a24..4dd69d27b1d 100644 --- a/sonar-server/src/main/webapp/javascripts/application.js +++ b/sonar-server/src/main/webapp/javascripts/application.js @@ -213,38 +213,48 @@ Treemap.prototype.rootNode = function () { Treemap.prototype.initNodes = function () { var self = this; + console.log(this); $j('#tm-' + this.id).find('a').each(function (index) { $j(this).on("click", function (event) { event.stopPropagation(); }); }); - $j('#tm-' + this.id).find('[rid]').each(function (index) { - $j(this).on("contextmenu", function (event) { - event.stopPropagation(); - event.preventDefault(); - // right click - if (self.breadcrumb.length > 1) { - self.breadcrumb.pop(); - self.load(); - } else if (self.breadcrumb.length == 1) { - $j("#tm-loading-" + self.id).show(); - location.reload(); - } + if ($j('#tm-' + this.id).is(':empty')){ + // SONAR-3524 + // If the content is empty, then the right click should lead to return to the parent (will in fact reload the page) + $j('#tm-' + this.id).on("contextmenu", function (event) { + location.reload(); return false; }); - $j(this).on("click", function (event) { - var source = $j(this); - var rid = source.attr('rid'); - var has_leaves = !!(source.attr('l')); - if (!has_leaves) { - var context = new TreemapContext(rid, source.text()); - self.breadcrumb.push(context); + } else { + $j('#tm-' + this.id).find('[rid]').each(function (index) { + $j(this).on("contextmenu", function (event) { + event.stopPropagation(); + event.preventDefault(); + // right click + if (self.breadcrumb.length > 1) { + self.breadcrumb.pop(); self.load(); + } else if (self.breadcrumb.length == 1) { + $j("#tm-loading-" + self.id).show(); + location.reload(); } + return false; + }); + $j(this).on("click", function (event) { + var source = $j(this); + var rid = source.attr('rid'); + var has_leaves = !!(source.attr('l')); + if (!has_leaves) { + var context = new TreemapContext(rid, source.text()); + self.breadcrumb.push(context); + self.load(); + } - } - ); - }); + } + ); + }); + } }; function openModalWindow(url, options) { -- 2.39.5