aboutsummaryrefslogtreecommitdiffstats
path: root/server
diff options
context:
space:
mode:
authorStas Vilchik <vilchiks@gmail.com>2015-02-20 11:04:02 +0100
committerStas Vilchik <vilchiks@gmail.com>2015-02-20 11:04:09 +0100
commit326cf2a887dd5583e97283c08b4102d4f562fde3 (patch)
treef60756b8700ac5d39cb9d2aef2dbb0ea1d86cc34 /server
parenta66973a3b3b249effd46904307d249ae4b5abea5 (diff)
downloadsonarqube-326cf2a887dd5583e97283c08b4102d4f562fde3.tar.gz
sonarqube-326cf2a887dd5583e97283c08b4102d4f562fde3.zip
fix quality flaws
Diffstat (limited to 'server')
-rw-r--r--server/sonar-web/Gruntfile.coffee2
-rw-r--r--server/sonar-web/src/main/js/coding-rules/bulk-change-popup-view.js6
-rw-r--r--server/sonar-web/src/main/js/graphics/barchart.js14
-rw-r--r--server/sonar-web/src/main/js/source-viewer/viewer.js3
-rw-r--r--server/sonar-web/src/main/js/top-search.js172
5 files changed, 11 insertions, 186 deletions
diff --git a/server/sonar-web/Gruntfile.coffee b/server/sonar-web/Gruntfile.coffee
index fbb1f883bc3..840d2784188 100644
--- a/server/sonar-web/Gruntfile.coffee
+++ b/server/sonar-web/Gruntfile.coffee
@@ -102,7 +102,6 @@ module.exports = (grunt) ->
'<%= grunt.option("assetsDir") || pkg.assets %>js/graphics/pie-chart.js'
'<%= grunt.option("assetsDir") || pkg.assets %>js/graphics/timeline.js'
'<%= grunt.option("assetsDir") || pkg.assets %>js/graphics/barchart.js'
- '<%= grunt.option("assetsDir") || pkg.assets %>js/top-search.js'
'<%= grunt.option("assetsDir") || pkg.assets %>js/sortable.js'
'<%= grunt.option("assetsDir") || pkg.assets %>js/common/inputs.js'
'<%= grunt.option("assetsDir") || pkg.assets %>js/common/dialogs.js'
@@ -148,7 +147,6 @@ module.exports = (grunt) ->
'<%= grunt.option("assetsDir") || pkg.assets %>js/graphics/pie-chart.js'
'<%= grunt.option("assetsDir") || pkg.assets %>js/graphics/timeline.js'
'<%= grunt.option("assetsDir") || pkg.assets %>js/graphics/barchart.js'
- '<%= grunt.option("assetsDir") || pkg.assets %>js/top-search.js'
'<%= grunt.option("assetsDir") || pkg.assets %>js/sortable.js'
'<%= grunt.option("assetsDir") || pkg.assets %>js/common/inputs.js'
'<%= grunt.option("assetsDir") || pkg.assets %>js/common/dialogs.js'
diff --git a/server/sonar-web/src/main/js/coding-rules/bulk-change-popup-view.js b/server/sonar-web/src/main/js/coding-rules/bulk-change-popup-view.js
index a8eb0b8fb96..b54ba6a457e 100644
--- a/server/sonar-web/src/main/js/coding-rules/bulk-change-popup-view.js
+++ b/server/sonar-web/src/main/js/coding-rules/bulk-change-popup-view.js
@@ -27,13 +27,13 @@ define([
var query = this.options.app.state.get('query'),
profileKey = query.qprofile,
profile = _.findWhere(this.options.app.qualityProfiles, { key: profileKey }),
- activation = query.activation;
+ activation = '' + query.activation;
return {
qualityProfile: profileKey,
qualityProfileName: profile != null ? profile.name : null,
- allowActivateOnProfile: profileKey != null && (activation === 'false' || activation === false),
- allowDeactivateOnProfile: profileKey != null && (activation === 'true' || activation === true)
+ allowActivateOnProfile: profileKey != null && activation === 'false',
+ allowDeactivateOnProfile: profileKey != null && activation === 'true'
};
}
});
diff --git a/server/sonar-web/src/main/js/graphics/barchart.js b/server/sonar-web/src/main/js/graphics/barchart.js
index 8520bbf5d80..c45b331b2d1 100644
--- a/server/sonar-web/src/main/js/graphics/barchart.js
+++ b/server/sonar-web/src/main/js/graphics/barchart.js
@@ -9,7 +9,12 @@
height: 140,
color: '#1f77b4',
interpolate: 'basis',
- endDate: moment().format('YYYY-MM-DD')
+ endDate: moment().format('YYYY-MM-DD'),
+
+ marginLeft: 1,
+ marginRight: 1,
+ marginTop: 18,
+ marginBottom: 1
};
};
@@ -49,13 +54,6 @@
.domain([0, yScaleMax]);
_.extend(options, {
- marginLeft: 1,
- marginRight: 1,
- marginTop: 18,
- marginBottom: 1
- });
-
- _.extend(options, {
availableWidth: options.width - options.marginLeft - options.marginRight,
availableHeight: options.height - options.marginTop - options.marginBottom
});
diff --git a/server/sonar-web/src/main/js/source-viewer/viewer.js b/server/sonar-web/src/main/js/source-viewer/viewer.js
index cb3f65bfc5a..6d8d9636eaa 100644
--- a/server/sonar-web/src/main/js/source-viewer/viewer.js
+++ b/server/sonar-web/src/main/js/source-viewer/viewer.js
@@ -392,7 +392,8 @@ define([
line = $(e.currentTarget).data('line-number'),
blocks = this.model.get('duplications')[index - 1].blocks;
blocks = _.filter(blocks, function (b) {
- return (b._ref !== '1') || (b._ref === '1' && b.from > line) || (b._ref === '1' && b.from + b.size < line);
+ var outOfBounds = b.from > line || b.from + b.size < line;
+ return (b._ref !== '1') || (b._ref === '1' && outOfBounds);
});
var popup = new DuplicationPopupView({
triggerEl: $(e.currentTarget),
diff --git a/server/sonar-web/src/main/js/top-search.js b/server/sonar-web/src/main/js/top-search.js
deleted file mode 100644
index 31fad10cc27..00000000000
--- a/server/sonar-web/src/main/js/top-search.js
+++ /dev/null
@@ -1,172 +0,0 @@
-(function($) {
-
- $.fn.topSearch = function(options) {
-
- var el = $(this),
- resultsEl = $(options.results),
- spinnerEl = $(options.spinner);
-
- var index, total, selected, items, term, symbol = false;
-
-
- var select = function() {
- if (selected) {
- selected.removeClass('selected');
- }
-
- selected = items.eq(index);
- selected.addClass('selected');
- },
-
- selectPrev = function() {
- if (index > 0) {
- index--;
- }
- select();
- },
-
- selectNext = function() {
- if (index < total - 1) {
- index++;
- }
- select();
- },
-
- choose = function() {
- if (selected) {
- var key = selected.data('key');
- window.location = baseUrl + '/dashboard/index/' + key + dashboardParameters();
- }
- },
-
- show = function(r) {
- resultsEl.empty();
-
- var ul = $('<ul></ul>').appendTo(resultsEl);
-
- r.results.forEach(function(qualifier) {
- qualifier.items.forEach(function(item, idx) {
- var itemEl = $('<li></li>')
- .data('key', item.id),
-
- q = $('<div></div>')
- .addClass('q')
- .appendTo(itemEl),
-
- highlightRegexp = new RegExp(term, 'gi'),
- highlightedName = item.name.replace(highlightRegexp, '<strong>$&</strong>'),
-
- label = $('<span></span>')
- .html(' ' + highlightedName)
- .appendTo(itemEl);
-
- $('<i>')
- .addClass('icon-qualifier-' + qualifier.q.toLowerCase())
- .prependTo(label);
-
- if (idx === 0) {
- q.text(qualifier.name);
- }
-
- itemEl.appendTo(ul);
- });
- });
-
- resultsEl.append('<div class="autocompleteNote">' + r.total + ' ' + resultsEl.data('results') + '</div>');
-
- resultsEl.show();
-
- if (r.total === 0) {
- ul.append('<li>' + resultsEl.data('no-results') + '</li>');
- } else {
- items = resultsEl.find('li');
- index = -1;
- total = items.length;
- selectNext();
-
- items
- .on('mouseover', function() {
- index = items.index($(this));
- select();
- })
- .on('click', function() {
- index = items.index($(this));
- select();
- choose();
- });
- }
- },
-
- hide = function() {
- resultsEl.fadeOut();
- },
-
- onKeyup = function() {
- if (symbol) {
- if (el.val().length >= options.minLength) {
- term = el.val();
-
- spinnerEl.show();
- $.ajax({
- url: baseUrl + '/api/components/suggestions',
- data: { s: term }
- })
- .done(function(r) {
- show(r);
- })
- .fail(hide)
- .always(function() {
- spinnerEl.hide();
- });
- } else {
- hide();
- }
- }
- },
-
- debouncedKeyup = _.debounce(onKeyup, 250),
-
- onKeyDown = function(e) {
- if ([13, 38, 40, 37, 39, 16, 17, 18, 91, 20, 21].indexOf(e.keyCode) !== -1) {
- symbol = false;
- }
-
- switch (e.keyCode) {
- case 13: // return
- e.preventDefault();
- choose();
- return;
- case 38: // up
- e.preventDefault();
- selectPrev();
- return;
- case 40: // down
- e.preventDefault();
- selectNext();
- return;
- default:
- symbol = true;
- }
- };
-
-
- el
- .on('keydown', onKeyDown)
- .on('keyup', debouncedKeyup)
- .on('focus', function() {
- el.data('placeholder', el.val());
- el.val('');
- })
- .on('focusout', function() {
- if (el.val().length === 0) {
- el.val(el.data('placeholder') || '');
- }
- hide();
- });
-
- $('body').on('mousedown', function() {
- hide();
- });
- };
-
-})(jQuery);