]> source.dussan.org Git - sonarqube.git/commitdiff
fix quality flaws
authorStas Vilchik <vilchiks@gmail.com>
Fri, 20 Feb 2015 10:04:02 +0000 (11:04 +0100)
committerStas Vilchik <vilchiks@gmail.com>
Fri, 20 Feb 2015 10:04:09 +0000 (11:04 +0100)
server/sonar-web/Gruntfile.coffee
server/sonar-web/src/main/js/coding-rules/bulk-change-popup-view.js
server/sonar-web/src/main/js/graphics/barchart.js
server/sonar-web/src/main/js/source-viewer/viewer.js
server/sonar-web/src/main/js/top-search.js [deleted file]

index fbb1f883bc3efa55175aee96c9303cd620f53193..840d2784188081c598ee1f915b4c663564874fda 100644 (file)
@@ -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'
index a8eb0b8fb9668e3d238e467a63f859789cc2d1ce..b54ba6a457ea5a1dc72949fdeb2ebd1ba8a109a2 100644 (file)
@@ -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'
       };
     }
   });
index 8520bbf5d805b4871d187c887f6a415417cc374e..c45b331b2d1d97cc19bad9997000e120c74a3be8 100644 (file)
@@ -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
     };
   };
 
           yScale = d3.scale.linear()
               .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
index cb3f65bfc5a99f99f7b9ba464d9fcd538c274a97..6d8d9636eaafe4c7e6cc4a28cb704adb9e700c01 100644 (file)
@@ -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 (file)
index 31fad10..0000000
+++ /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);