aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-web/src/main/js/libs
diff options
context:
space:
mode:
authorStas Vilchik <vilchiks@gmail.com>2015-09-10 17:21:38 +0200
committerStas Vilchik <vilchiks@gmail.com>2015-09-10 17:21:47 +0200
commitab4f18fbeba4cc4a8db3371008e0dbb29c99f10b (patch)
treec871458807e114007e73970c6cd14d9e6bbcb1d9 /server/sonar-web/src/main/js/libs
parentcbf5602a23ce9138b62c593d4e290566eaf97522 (diff)
downloadsonarqube-ab4f18fbeba4cc4a8db3371008e0dbb29c99f10b.tar.gz
sonarqube-ab4f18fbeba4cc4a8db3371008e0dbb29c99f10b.zip
improve code quality
Diffstat (limited to 'server/sonar-web/src/main/js/libs')
-rw-r--r--server/sonar-web/src/main/js/libs/application.js60
-rw-r--r--server/sonar-web/src/main/js/libs/recent-history.js28
-rw-r--r--server/sonar-web/src/main/js/libs/select2-jquery-ui-fix.js21
-rw-r--r--server/sonar-web/src/main/js/libs/widgets/bubble-chart.js4
-rw-r--r--server/sonar-web/src/main/js/libs/widgets/timeline.js2
5 files changed, 39 insertions, 76 deletions
diff --git a/server/sonar-web/src/main/js/libs/application.js b/server/sonar-web/src/main/js/libs/application.js
index bc3fb63b444..bdbc78a7524 100644
--- a/server/sonar-web/src/main/js/libs/application.js
+++ b/server/sonar-web/src/main/js/libs/application.js
@@ -29,9 +29,9 @@
* @param {string} message
*/
window.showMessage = function (id, message) {
- $j('#' + id + 'msg').html(message);
- $j('#' + id).removeClass('hidden');
- $j('#messages-panel').removeClass('hidden');
+ jQuery('#' + id + 'msg').html(message);
+ jQuery('#' + id).removeClass('hidden');
+ jQuery('#messages-panel').removeClass('hidden');
};
/**
@@ -40,8 +40,8 @@
* @returns {boolean} always false
*/
window.hideMessage = function (id) {
- $j('#' + id).addClass('hidden');
- var messagePanel = $j('#messages-panel'),
+ jQuery('#' + id).addClass('hidden');
+ var messagePanel = jQuery('#messages-panel'),
isEmpty = messagePanel.children('*:not(.hidden)').length === 0;
messagePanel.toggleClass('hidden', isEmpty);
return false;
@@ -52,7 +52,7 @@
* @param {string} message
*/
window.error = function (message) {
- showMessage('error', message);
+ window.showMessage('error', message);
};
/**
@@ -60,7 +60,7 @@
* @param {string} message
*/
window.warning = function (message) {
- showMessage('warning', message);
+ window.showMessage('warning', message);
};
/**
@@ -68,7 +68,7 @@
* @param {string} message
*/
window.info = function (message) {
- showMessage('info', message);
+ window.showMessage('info', message);
};
/**
@@ -76,7 +76,7 @@
* @returns {boolean} always false
*/
window.hideError = function () {
- return hideMessage('error');
+ return window.hideMessage('error');
};
/**
@@ -84,7 +84,7 @@
* @returns {boolean} always false
*/
window.hideWarning = function () {
- return hideMessage('warning');
+ return window.hideMessage('warning');
};
/**
@@ -92,17 +92,17 @@
* @returns {boolean} always false
*/
window.hideInfo = function () {
- return hideMessage('info');
+ return window.hideMessage('info');
};
})();
function toggleFav (resourceId, elt) {
- $j.ajax({
+ jQuery.ajax({
type: 'POST', dataType: 'json', url: baseUrl + '/favourites/toggle/' + resourceId,
success: function (data) {
- var star = $j(elt);
+ var star = jQuery(elt);
star.removeClass('icon-favorite icon-not-favorite');
star.addClass(data.css);
star.attr('title', data.title);
@@ -115,7 +115,7 @@ function dashboardParameters (urlHasSomething) {
var parameters = [];
var matchDashboard = queryString.match(/did=\d+/);
- if (matchDashboard && $j('#is-project-dashboard').length === 1) {
+ if (matchDashboard && jQuery('#is-project-dashboard').length === 1) {
parameters.push(matchDashboard[0]);
}
@@ -137,11 +137,11 @@ function dashboardParameters (urlHasSomething) {
function openModalWindow (url, options) {
var width = (options && options.width) || 540;
- var $dialog = $j('#modal');
+ var $dialog = jQuery('#modal');
if (!$dialog.length) {
- $dialog = $j('<div id="modal" class="ui-widget-overlay ui-front"></div>').appendTo('body');
+ $dialog = jQuery('<div id="modal" class="ui-widget-overlay ui-front"></div>').appendTo('body');
}
- $j.get(url, function (html) {
+ jQuery.get(url, function (html) {
$dialog.removeClass('ui-widget-overlay');
$dialog.html(html);
$dialog
@@ -155,7 +155,7 @@ function openModalWindow (url, options) {
resizable: false,
title: null,
close: function () {
- $j('#modal').remove();
+ jQuery('#modal').remove();
}
});
$dialog.dialog('open');
@@ -165,18 +165,18 @@ function openModalWindow (url, options) {
return false;
}
-(function ($j) {
- $j.fn.extend({
+(function (jQuery) {
+ jQuery.fn.extend({
openModal: function () {
return this.each(function () {
- var obj = $j(this);
+ var obj = jQuery(this);
var url = obj.attr('modal-url') || obj.attr('href');
return openModalWindow(url, { 'width': obj.attr('modal-width') });
});
},
modal: function () {
return this.each(function () {
- var obj = $j(this);
+ var obj = jQuery(this);
obj.unbind('click');
var $link = obj.bind('click', function () {
$link.openModal();
@@ -186,10 +186,10 @@ function openModalWindow (url, options) {
},
modalForm: function (ajax_options) {
return this.each(function () {
- var obj = $j(this);
+ var obj = jQuery(this);
obj.submit(function () {
- $j('input[type=submit]', this).attr('disabled', 'disabled');
- $j.ajax($j.extend({
+ jQuery('input[type=submit]', this).attr('disabled', 'disabled');
+ jQuery.ajax(jQuery.extend({
type: 'POST',
url: obj.attr('action'),
data: obj.serialize(),
@@ -201,14 +201,14 @@ function openModalWindow (url, options) {
var errorElt = obj.find('.modal-error');
if (errorElt.length) {
// Hide all loading images
- $j('.loading-image').addClass('hidden');
+ jQuery('.loading-image').addClass('hidden');
// Re activate submit button
- $j('input[type=submit]', obj).removeAttr('disabled');
+ jQuery('input[type=submit]', obj).removeAttr('disabled');
errorElt.show();
- errorElt.html($j('<div/>').html(xhr.responseText).text());
+ errorElt.html(jQuery('<div/>').html(xhr.responseText).text());
} else {
// otherwise replace modal window by the returned text
- $j('#modal').html(xhr.responseText);
+ jQuery('#modal').html(xhr.responseText);
}
}
}, ajax_options));
@@ -220,7 +220,7 @@ function openModalWindow (url, options) {
})(jQuery);
function closeModalWindow () {
- $j('#modal').dialog('close');
+ jQuery('#modal').dialog('close');
return false;
}
diff --git a/server/sonar-web/src/main/js/libs/recent-history.js b/server/sonar-web/src/main/js/libs/recent-history.js
index f2c17912911..b9e54a7ccb6 100644
--- a/server/sonar-web/src/main/js/libs/recent-history.js
+++ b/server/sonar-web/src/main/js/libs/recent-history.js
@@ -1,22 +1,3 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * SonarQube is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
window.Sonar = {};
window.Sonar.RecentHistory = function () {
@@ -59,17 +40,18 @@ window.Sonar.RecentHistory.prototype.add = function (resourceKey, resourceName,
};
window.Sonar.RecentHistory.prototype.populateRecentHistoryPanel = function () {
- var historyLinksList = $j('#recent-history-list');
+ var historyLinksList = jQuery('#recent-history-list');
historyLinksList.empty();
var recentHistory = this.getRecentHistory();
if (recentHistory.length === 0) {
- $j('#recent-history').hide();
+ jQuery('#recent-history').hide();
} else {
recentHistory.forEach(function (resource) {
historyLinksList.append('<li><i class="icon-qualifier-' + resource.icon + '"></i><a href="' +
- baseUrl + '/dashboard/index/' + resource.key + dashboardParameters() + '"> ' + resource.name + '</a></li>');
+ baseUrl + '/dashboard/index/' + resource.key + window.dashboardParameters() + '"> ' +
+ resource.name + '</a></li>');
});
- $j('#recent-history').show();
+ jQuery('#recent-history').show();
}
};
diff --git a/server/sonar-web/src/main/js/libs/select2-jquery-ui-fix.js b/server/sonar-web/src/main/js/libs/select2-jquery-ui-fix.js
index b57d696ec65..eab60772b21 100644
--- a/server/sonar-web/src/main/js/libs/select2-jquery-ui-fix.js
+++ b/server/sonar-web/src/main/js/libs/select2-jquery-ui-fix.js
@@ -1,25 +1,6 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * SonarQube is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
/* https://github.com/ivaynberg/select2/issues/1246 */
-;(function($) {
+(function($) {
$.ui.dialog.prototype._allowInteraction = function(e) {
return !!$(e.target).closest('.ui-dialog, .ui-datepicker, .select2-drop').length;
diff --git a/server/sonar-web/src/main/js/libs/widgets/bubble-chart.js b/server/sonar-web/src/main/js/libs/widgets/bubble-chart.js
index fc166404423..dba3c8f918e 100644
--- a/server/sonar-web/src/main/js/libs/widgets/bubble-chart.js
+++ b/server/sonar-web/src/main/js/libs/widgets/bubble-chart.js
@@ -220,8 +220,8 @@ window.SonarWidgets = window.SonarWidgets == null ? {} : window.SonarWidgets;
sizeMetricValue = d.measures[widget.sizeMetric].fval;
return '<div class="text-left">' +
- collapsedDirFromPath(d.longName) + '<br>' +
- fileFromPath(d.longName) + '<br>' + '<br>' +
+ window.collapsedDirFromPath(d.longName) + '<br>' +
+ window.fileFromPath(d.longName) + '<br>' + '<br>' +
xMetricName + ': ' + xMetricValue + '<br>' +
yMetricName + ': ' + yMetricValue + '<br>' +
sizeMetricName + ': ' + sizeMetricValue +
diff --git a/server/sonar-web/src/main/js/libs/widgets/timeline.js b/server/sonar-web/src/main/js/libs/widgets/timeline.js
index 5b871e5994e..4fa9c0123ac 100644
--- a/server/sonar-web/src/main/js/libs/widgets/timeline.js
+++ b/server/sonar-web/src/main/js/libs/widgets/timeline.js
@@ -310,7 +310,7 @@ window.SonarWidgets = window.SonarWidgets == null ? {} : window.SonarWidgets;
.attr('transform', function() { return trans(x, metricY); });
});
- if (metricY > -1) {
+ if (metricY > -1) {
metricY += 17;
}