diff --git a/war/src/main/js/widgets/config/model/ConfigSection.js b/war/src/main/js/widgets/config/model/ConfigSection.js index 827c8678e8eda2b088901613d34cd833ad8f3cb3..295181af829150c283bf4f19f055b831969d531d 100644 --- a/war/src/main/js/widgets/config/model/ConfigSection.js +++ b/war/src/main/js/widgets/config/model/ConfigSection.js @@ -102,6 +102,29 @@ ConfigSection.prototype.markRowsAsActive = function() { this.updateRowGroupVisibility(); }; +ConfigSection.prototype.hasText = function(text) { + var $ = jQD.getJQuery(); + var selector = ":containsci('" + text + "')"; + var sectionRows = this.getRows(); + + for (var i1 = 0; i1 < sectionRows.length; i1++) { + var row = sectionRows[i1]; + var elementsWithText = $(selector, row); + + if (elementsWithText.size() > 0) { + return true; + } + } + + for (var i2 = 0; i2 < this.subSections.length; i2++) { + if (this.subSections[i2].hasText(text)) { + return true; + } + } + + return false; +}; + ConfigSection.prototype.activeRowCount = function() { var activeRowCount = 0; var rows = this.getRows(); @@ -190,8 +213,8 @@ ConfigSection.prototype.highlightText = function(text) { var selector = ":containsci('" + text + "')"; var rows = this.getRows(); - for (var i = 0; i < rows.length; i++) { - var row = rows[i]; + for (var i1 = 0; i1 < rows.length; i1++) { + var row = rows[i1]; /*jshint loopfunc: true */ $('span.highlight-split', row).each(function() { // jshint ignore:line @@ -209,11 +232,16 @@ ConfigSection.prototype.highlightText = function(text) { $this.contents().each(function () { // We specifically only mess with text nodes if (this.nodeType === 3) { - var highlightedMarkup = this.wholeText.replace(regex, '$1'); - $(this).replaceWith('' + highlightedMarkup + ''); + var $textNode = $(this); + var highlightedMarkup = $textNode.text().replace(regex, '$1'); + $textNode.replaceWith('' + highlightedMarkup + ''); } }); }); } } + + for (var i2 = 0; i2 < this.subSections.length; i2++) { + this.subSections[i2].highlightText(text); + } }; diff --git a/war/src/main/js/widgets/config/model/ConfigTableMetaData.js b/war/src/main/js/widgets/config/model/ConfigTableMetaData.js index a3940eb684f0c5083c5ac9722f993ae5896efa2e..6ee7905a807203ba3f9833aad0803d4ae28b8c7c 100644 --- a/war/src/main/js/widgets/config/model/ConfigTableMetaData.js +++ b/war/src/main/js/widgets/config/model/ConfigTableMetaData.js @@ -262,7 +262,7 @@ ConfigTableMetaData.prototype.showSections = function(withText) { if (withText === '') { if (this.hasSections()) { for (var i1 = 0; i1 < this.sections.length; i1++) { - this.sections[i1].activator.show(); + this.sections[i1].activator.removeClass('hidden'); } var activeSection = this.activeSection(); if (!activeSection) { @@ -273,30 +273,16 @@ ConfigTableMetaData.prototype.showSections = function(withText) { } } else { if (this.hasSections()) { - var $ = jQD.getJQuery(); - var selector = ":containsci('" + withText + "')"; var sectionsWithText = []; for (var i2 = 0; i2 < this.sections.length; i2++) { var section = this.sections[i2]; - var containsText = false; - var sectionRows = section.getRows(); - - for (var i3 = 0; i3 < sectionRows.length; i3++) { - var row = sectionRows[i3]; - var elementsWithText = $(selector, row); - - if (elementsWithText.size() > 0) { - containsText = true; - break; - } - } - if (containsText) { - section.activator.show(); + if (section.hasText(withText)) { + section.activator.removeClass('hidden'); sectionsWithText.push(section); } else { - section.activator.hide(); + section.activator.addClass('hidden'); } } diff --git a/war/src/main/js/widgets/jenkins-widgets.less b/war/src/main/js/widgets/jenkins-widgets.less index 49fc0a6bf2c5350939d33ea5041198733879e7c5..c2a9e87f6b6abf683bef62a8bd75e6cfeb27bf33 100644 --- a/war/src/main/js/widgets/jenkins-widgets.less +++ b/war/src/main/js/widgets/jenkins-widgets.less @@ -10,4 +10,9 @@ /* * Widget styles */ -@import "config/tabbar"; \ No newline at end of file +@import "config/tabbar"; + + +.hidden { + display: none; +} \ No newline at end of file diff --git a/war/src/test/js/widgets/config/freestyle-config.html b/war/src/test/js/widgets/config/freestyle-config.html index c01cf97fd64d23e4494c55cae31754198a676dd9..a236ee0f45c21705990728652ec7c75b513fee4d 100644 --- a/war/src/test/js/widgets/config/freestyle-config.html +++ b/war/src/test/js/widgets/config/freestyle-config.html @@ -129,7 +129,8 @@