diff options
author | Stas Vilchik <vilchiks@gmail.com> | 2015-09-10 10:42:07 +0200 |
---|---|---|
committer | Stas Vilchik <vilchiks@gmail.com> | 2015-09-10 12:26:16 +0200 |
commit | e1b6cbcba2e342b4671a1bf88e1fd174b55b44cf (patch) | |
tree | 38069eebe3c0ccbcfc2e612f74dbd1dfd772c380 /server/sonar-web/src/main/js/libs | |
parent | 5981d630ff9637a78868d989f22a3f10f15306c5 (diff) | |
download | sonarqube-e1b6cbcba2e342b4671a1bf88e1fd174b55b44cf.tar.gz sonarqube-e1b6cbcba2e342b4671a1bf88e1fd174b55b44cf.zip |
Revert "use single web app"
Diffstat (limited to 'server/sonar-web/src/main/js/libs')
17 files changed, 390 insertions, 160 deletions
diff --git a/server/sonar-web/src/main/js/libs/application.js b/server/sonar-web/src/main/js/libs/application.js index 335ca996ec8..bc3fb63b444 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) { - $('#' + id + 'msg').html(message); - $('#' + id).removeClass('hidden'); - $('#messages-panel').removeClass('hidden'); + $j('#' + id + 'msg').html(message); + $j('#' + id).removeClass('hidden'); + $j('#messages-panel').removeClass('hidden'); }; /** @@ -40,8 +40,8 @@ * @returns {boolean} always false */ window.hideMessage = function (id) { - $('#' + id).addClass('hidden'); - var messagePanel = $('#messages-panel'), + $j('#' + id).addClass('hidden'); + var messagePanel = $j('#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) { - window.showMessage('error', message); + showMessage('error', message); }; /** @@ -60,7 +60,7 @@ * @param {string} message */ window.warning = function (message) { - window.showMessage('warning', message); + showMessage('warning', message); }; /** @@ -68,7 +68,7 @@ * @param {string} message */ window.info = function (message) { - window.showMessage('info', message); + showMessage('info', message); }; /** @@ -76,7 +76,7 @@ * @returns {boolean} always false */ window.hideError = function () { - return window.hideMessage('error'); + return hideMessage('error'); }; /** @@ -84,7 +84,7 @@ * @returns {boolean} always false */ window.hideWarning = function () { - return window.hideMessage('warning'); + return hideMessage('warning'); }; /** @@ -92,29 +92,30 @@ * @returns {boolean} always false */ window.hideInfo = function () { - return window.hideMessage('info'); + return hideMessage('info'); }; })(); -window.toggleFav = function (resourceId, elt) { - $.ajax({ + +function toggleFav (resourceId, elt) { + $j.ajax({ type: 'POST', dataType: 'json', url: baseUrl + '/favourites/toggle/' + resourceId, success: function (data) { - var star = $(elt); + var star = $j(elt); star.removeClass('icon-favorite icon-not-favorite'); star.addClass(data.css); star.attr('title', data.title); } }); -}; +} -window.dashboardParameters = function (urlHasSomething) { +function dashboardParameters (urlHasSomething) { var queryString = window.location.search; var parameters = []; var matchDashboard = queryString.match(/did=\d+/); - if (matchDashboard && $('#is-project-dashboard').length === 1) { + if (matchDashboard && $j('#is-project-dashboard').length === 1) { parameters.push(matchDashboard[0]); } @@ -132,15 +133,15 @@ window.dashboardParameters = function (urlHasSomething) { query = (urlHasSomething ? '&' : '?') + query; } return query; -}; +} -window.openModalWindow = function (url, options) { +function openModalWindow (url, options) { var width = (options && options.width) || 540; - var $dialog = $('#modal'); + var $dialog = $j('#modal'); if (!$dialog.length) { - $dialog = $('<div id="modal" class="ui-widget-overlay ui-front"></div>').appendTo('body'); + $dialog = $j('<div id="modal" class="ui-widget-overlay ui-front"></div>').appendTo('body'); } - $.get(url, function (html) { + $j.get(url, function (html) { $dialog.removeClass('ui-widget-overlay'); $dialog.html(html); $dialog @@ -154,7 +155,7 @@ window.openModalWindow = function (url, options) { resizable: false, title: null, close: function () { - $('#modal').remove(); + $j('#modal').remove(); } }); $dialog.dialog('open'); @@ -162,20 +163,20 @@ window.openModalWindow = function (url, options) { $dialog.removeClass('ui-widget-overlay'); }); return false; -}; +} -(function ($) { - $.fn.extend({ +(function ($j) { + $j.fn.extend({ openModal: function () { return this.each(function () { - var obj = $(this); + var obj = $j(this); var url = obj.attr('modal-url') || obj.attr('href'); - return window.openModalWindow(url, { 'width': obj.attr('modal-width') }); + return openModalWindow(url, { 'width': obj.attr('modal-width') }); }); }, modal: function () { return this.each(function () { - var obj = $(this); + var obj = $j(this); obj.unbind('click'); var $link = obj.bind('click', function () { $link.openModal(); @@ -185,10 +186,10 @@ window.openModalWindow = function (url, options) { }, modalForm: function (ajax_options) { return this.each(function () { - var obj = $(this); + var obj = $j(this); obj.submit(function () { - $('input[type=submit]', this).attr('disabled', 'disabled'); - $.ajax($.extend({ + $j('input[type=submit]', this).attr('disabled', 'disabled'); + $j.ajax($j.extend({ type: 'POST', url: obj.attr('action'), data: obj.serialize(), @@ -200,14 +201,14 @@ window.openModalWindow = function (url, options) { var errorElt = obj.find('.modal-error'); if (errorElt.length) { // Hide all loading images - $('.loading-image').addClass('hidden'); + $j('.loading-image').addClass('hidden'); // Re activate submit button - $('input[type=submit]', obj).removeAttr('disabled'); + $j('input[type=submit]', obj).removeAttr('disabled'); errorElt.show(); - errorElt.html($('<div/>').html(xhr.responseText).text()); + errorElt.html($j('<div/>').html(xhr.responseText).text()); } else { // otherwise replace modal window by the returned text - $('#modal').html(xhr.responseText); + $j('#modal').html(xhr.responseText); } } }, ajax_options)); @@ -218,63 +219,67 @@ window.openModalWindow = function (url, options) { }); })(jQuery); -window.closeModalWindow = function () { - $('#modal').dialog('close'); +function closeModalWindow () { + $j('#modal').dialog('close'); return false; -}; +} + /* * File Path */ -/** - * Return a collapsed path without a file name - * @example - * // returns 'src/.../js/components/navigator/app/models/' - * collapsedDirFromPath('src/main/js/components/navigator/app/models/state.js') - * @param {string} path - * @returns {string|null} - */ -window.collapsedDirFromPath = function (path) { - var limit = 30; - if (typeof path === 'string') { - var tokens = _.initial(path.split('/')); - if (tokens.length > 2) { - var head = _.first(tokens), - tail = _.last(tokens), - middle = _.initial(_.rest(tokens)), - cut = false; - while (middle.join().length > limit && middle.length > 0) { - middle.shift(); - cut = true; +(function () { + /** + * Return a collapsed path without a file name + * @example + * // returns 'src/.../js/components/navigator/app/models/' + * collapsedDirFromPath('src/main/js/components/navigator/app/models/state.js') + * @param {string} path + * @returns {string|null} + */ + window.collapsedDirFromPath = function (path) { + var limit = 30; + if (typeof path === 'string') { + var tokens = _.initial(path.split('/')); + if (tokens.length > 2) { + var head = _.first(tokens), + tail = _.last(tokens), + middle = _.initial(_.rest(tokens)), + cut = false; + while (middle.join().length > limit && middle.length > 0) { + middle.shift(); + cut = true; + } + var body = [].concat(head, cut ? ['...'] : [], middle, tail); + return body.join('/') + '/'; + } else { + return tokens.join('/') + '/'; } - var body = [].concat(head, cut ? ['...'] : [], middle, tail); - return body.join('/') + '/'; } else { - return tokens.join('/') + '/'; + return null; } - } else { - return null; - } -}; - -/** - * Return a file name for a given file path - * * @example - * // returns 'state.js' - * collapsedDirFromPath('src/main/js/components/navigator/app/models/state.js') - * @param {string} path - * @returns {string|null} - */ -window.fileFromPath = function (path) { - if (typeof path === 'string') { - var tokens = path.split('/'); - return _.last(tokens); - } else { - return null; - } -}; + }; + + /** + * Return a file name for a given file path + * * @example + * // returns 'state.js' + * collapsedDirFromPath('src/main/js/components/navigator/app/models/state.js') + * @param {string} path + * @returns {string|null} + */ + window.fileFromPath = function (path) { + if (typeof path === 'string') { + var tokens = path.split('/'); + return _.last(tokens); + } else { + return null; + } + }; +})(); + /* @@ -394,15 +399,15 @@ window.fileFromPath = function (path) { function formatDuration (isNegative, days, hours, minutes) { var formatted = ''; if (shouldDisplayDays(days)) { - formatted += window.tp('work_duration.x_days', isNegative ? -1 * days : days); + formatted += tp('work_duration.x_days', isNegative ? -1 * days : days); } if (shouldDisplayHours(days, hours)) { formatted = addSpaceIfNeeded(formatted); - formatted += window.tp('work_duration.x_hours', isNegative && formatted.length === 0 ? -1 * hours : hours); + formatted += tp('work_duration.x_hours', isNegative && formatted.length === 0 ? -1 * hours : hours); } if (shouldDisplayMinutes(days, hours, minutes)) { formatted = addSpaceIfNeeded(formatted); - formatted += window.tp('work_duration.x_minutes', isNegative && formatted.length === 0 ? -1 * minutes : minutes); + formatted += tp('work_duration.x_minutes', isNegative && formatted.length === 0 ? -1 * minutes : minutes); } return formatted; } @@ -419,18 +424,18 @@ window.fileFromPath = function (path) { var formatted = ''; if (shouldDisplayDays(days)) { var formattedDays = window.formatMeasure(isNegative ? -1 * days : days, 'SHORT_INT'); - formatted += window.tp('work_duration.x_days', formattedDays); + formatted += tp('work_duration.x_days', formattedDays); } if (shouldDisplayHoursInShortFormat(days, hours)) { formatted = addSpaceIfNeeded(formatted); - formatted += window.tp('work_duration.x_hours', isNegative && formatted.length === 0 ? -1 * hours : hours); + formatted += tp('work_duration.x_hours', isNegative && formatted.length === 0 ? -1 * hours : hours); } if (shouldDisplayMinutesInShortFormat(days, hours, minutes)) { formatted = addSpaceIfNeeded(formatted); - formatted += window.tp('work_duration.x_minutes', isNegative && formatted.length === 0 ? -1 * minutes : minutes); + formatted += tp('work_duration.x_minutes', isNegative && formatted.length === 0 ? -1 * minutes : minutes); } if (shouldDisplayAbout(days, hours, minutes)) { - formatted = window.tp('work_duration.about', formatted); + formatted = tp('work_duration.about', formatted); } return formatted; } @@ -444,7 +449,7 @@ window.fileFromPath = function (path) { if (value === 0) { return '0'; } - var hoursInDay = window.sonar.properties['sonar.technicalDebt.hoursInDay'], + var hoursInDay = window.SS.hoursInDay || 8, isNegative = value < 0, absValue = Math.abs(value); var days = Math.floor(absValue / hoursInDay / 60); @@ -464,7 +469,7 @@ window.fileFromPath = function (path) { if (value === 0) { return '0'; } - var hoursInDay = window.sonar.properties['sonar.technicalDebt.hoursInDay'], + var hoursInDay = window.SS.hoursInDay || 8, isNegative = value < 0, absValue = Math.abs(value); var days = Math.floor(absValue / hoursInDay / 60); @@ -556,11 +561,12 @@ window.fileFromPath = function (path) { })(); + /* * Users */ -(function () { +(function() { /** * Convert the result of api/users/search to select2 format @@ -568,7 +574,7 @@ window.fileFromPath = function (path) { window.usersToSelect2 = function (response) { return { more: false, - results: _.map(response.users, function (user) { + results: _.map(response.users, function(user) { return { id: user.login, text: user.name + ' (' + user.login + ')' @@ -580,6 +586,7 @@ window.fileFromPath = function (path) { })(); + /* * Misc */ diff --git a/server/sonar-web/src/main/js/libs/csv.js b/server/sonar-web/src/main/js/libs/csv.js new file mode 100644 index 00000000000..d015f7c5a97 --- /dev/null +++ b/server/sonar-web/src/main/js/libs/csv.js @@ -0,0 +1,27 @@ +/* + * 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. + */ +(function() { + + window.csvEscape = function(value) { + var escaped = value.replace(/"/g, '\\"'); + return '"' + escaped + '"'; + }; + +})(); diff --git a/server/sonar-web/src/main/js/libs/csv.jsx b/server/sonar-web/src/main/js/libs/csv.jsx deleted file mode 100644 index 126bd0f82c7..00000000000 --- a/server/sonar-web/src/main/js/libs/csv.jsx +++ /dev/null @@ -1,4 +0,0 @@ -export default function csvEscape (value) { - var escaped = value.replace(/"/g, '\\"'); - return '"' + escaped + '"'; -}; diff --git a/server/sonar-web/src/main/js/libs/inputs.js b/server/sonar-web/src/main/js/libs/inputs.js index 5e92a3bc0bb..78673a5e70e 100644 --- a/server/sonar-web/src/main/js/libs/inputs.js +++ b/server/sonar-web/src/main/js/libs/inputs.js @@ -9,9 +9,9 @@ if (value === '0') { return 0; } - daysPattern = transformPattern(window.t('work_duration.x_days')); - hoursPattern = transformPattern(window.t('work_duration.x_hours')); - minutesPattern = transformPattern(window.t('work_duration.x_minutes')); + daysPattern = transformPattern(t('work_duration.x_days')); + hoursPattern = transformPattern(t('work_duration.x_hours')); + minutesPattern = transformPattern(t('work_duration.x_minutes')); days = value.match(daysPattern); hours = value.match(hoursPattern); minutes = value.match(minutesPattern); @@ -21,7 +21,7 @@ if (!value) { return value; } else { - return (days * window.sonar.properties['sonar.technicalDebt.hoursInDay'] + hours) * 60 + minutes; + return (days * window.SS.hoursInDay + hours) * 60 + minutes; } } @@ -33,18 +33,18 @@ if (!/^\d+$/.test(value)) { return value; } - days = Math.floor(value / (window.sonar.properties['sonar.technicalDebt.hoursInDay'] * 60)); - hours = Math.floor((value - days * window.sonar.properties['sonar.technicalDebt.hoursInDay'] * 60) / 60); + days = Math.floor(value / (window.SS.hoursInDay * 60)); + hours = Math.floor((value - days * window.SS.hoursInDay * 60) / 60); minutes = value % 60; result = []; if (days > 0) { - result.push(window.t('work_duration.x_days').replace('{0}', days)); + result.push(t('work_duration.x_days').replace('{0}', days)); } if (hours > 0) { - result.push(window.t('work_duration.x_hours').replace('{0}', hours)); + result.push(t('work_duration.x_hours').replace('{0}', hours)); } if (minutes > 0) { - result.push(window.t('work_duration.x_minutes').replace('{0}', minutes)); + result.push(t('work_duration.x_minutes').replace('{0}', minutes)); } return result.join(' '); } diff --git a/server/sonar-web/src/main/js/libs/recent-history.js b/server/sonar-web/src/main/js/libs/recent-history.js new file mode 100644 index 00000000000..f2c17912911 --- /dev/null +++ b/server/sonar-web/src/main/js/libs/recent-history.js @@ -0,0 +1,75 @@ +/* + * 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 () { +}; + +window.Sonar.RecentHistory.prototype.getRecentHistory = function () { + var sonarHistory = localStorage.getItem('sonar_recent_history'); + if (sonarHistory == null) { + sonarHistory = []; + } else { + sonarHistory = JSON.parse(sonarHistory); + } + return sonarHistory; +}; + +window.Sonar.RecentHistory.prototype.clear = function () { + localStorage.removeItem('sonar_recent_history'); +}; + +window.Sonar.RecentHistory.prototype.add = function (resourceKey, resourceName, icon) { + var sonarHistory = this.getRecentHistory(); + + if (resourceKey !== '') { + var newEntry = {'key': resourceKey, 'name': resourceName, 'icon': icon}; + // removes the element of the array if it exists + for (var i = 0; i < sonarHistory.length; i++) { + var item = sonarHistory[i]; + if (item.key === resourceKey) { + sonarHistory.splice(i, 1); + break; + } + } + // then add it to the beginning of the array + sonarHistory.unshift(newEntry); + // and finally slice the array to keep only 10 elements + sonarHistory = sonarHistory.slice(0, 10); + + localStorage.setItem('sonar_recent_history', JSON.stringify(sonarHistory)); + } +}; + +window.Sonar.RecentHistory.prototype.populateRecentHistoryPanel = function () { + var historyLinksList = $j('#recent-history-list'); + historyLinksList.empty(); + + var recentHistory = this.getRecentHistory(); + if (recentHistory.length === 0) { + $j('#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>'); + }); + $j('#recent-history').show(); + } +}; diff --git a/server/sonar-web/src/main/js/libs/recent-history.jsx b/server/sonar-web/src/main/js/libs/recent-history.jsx deleted file mode 100644 index 7a7bb8ef938..00000000000 --- a/server/sonar-web/src/main/js/libs/recent-history.jsx +++ /dev/null @@ -1,35 +0,0 @@ -import _ from 'underscore'; - -const MAX_ITEMS = 10; -const STORAGE_KEY = 'sonar_recent_history'; - -class RecentHistory { - static getRecentHistory () { - let sonarHistory = localStorage.getItem(STORAGE_KEY); - if (sonarHistory == null) { - sonarHistory = []; - } else { - sonarHistory = JSON.parse(sonarHistory); - } - return sonarHistory; - } - - static clear () { - localStorage.removeItem(STORAGE_KEY); - } - - static add (resourceKey, resourceName, icon) { - if (resourceKey !== '') { - let newEntry = { key: resourceKey, name: resourceName, icon: icon }; - - let newHistory = this.getRecentHistory() - .filter(item => item.key !== newEntry.key) - .slice(0, MAX_ITEMS - 1); - newHistory.unshift(newEntry); - - localStorage.setItem(STORAGE_KEY, JSON.stringify(newHistory)); - } - } -} - -export default RecentHistory; 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 f41d32302eb..b57d696ec65 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 @@ -19,7 +19,7 @@ */ /* 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/third-party/backbone-super.js b/server/sonar-web/src/main/js/libs/third-party/backbone-super.js new file mode 100644 index 00000000000..9562638918e --- /dev/null +++ b/server/sonar-web/src/main/js/libs/third-party/backbone-super.js @@ -0,0 +1,111 @@ +// This is a plugin, constructed from parts of Backbone.js and John Resig's inheritance script. +// (See http://backbonejs.org, http://ejohn.org/blog/simple-javascript-inheritance/) +// No credit goes to me as I did absolutely nothing except patch these two together. +(function(root, factory) { + + // Set up Backbone appropriately for the environment. Start with AMD. + if (typeof define === 'function' && define.amd) { + define(['underscore', 'backbone'], function(_, Backbone) { + // Export global even in AMD case in case this script is loaded with + // others that may still expect a global Backbone. + factory( _, Backbone); + }); + + // Next for Node.js or CommonJS. + } else if (typeof exports !== 'undefined' && typeof require === 'function') { + var _ = require('underscore'), + Backbone = require('backbone'); + factory(_, Backbone); + + // Finally, as a browser global. + } else { + factory(root._, root.Backbone); + } + +}(this, function factory(_, Backbone) { + Backbone.Model.extend = Backbone.Collection.extend = Backbone.Router.extend = Backbone.View.extend = function(protoProps, classProps) { + var child = inherits(this, protoProps, classProps); + child.extend = this.extend; + return child; + }; + var unImplementedSuper = function(method){throw "Super does not implement this method: " + method;}; + + var fnTest = /\b_super\b/; + + var makeWrapper = function(parentProto, name, fn) { + var wrapper = function() { + var tmp = this._super; + + // Add a new ._super() method that is the same method + // but on the super-class + this._super = parentProto[name] || unImplementedSuper(name); + + // The method only need to be bound temporarily, so we + // remove it when we're done executing + var ret; + try { + ret = fn.apply(this, arguments); + } finally { + this._super = tmp; + } + return ret; + }; + + //we must move properties from old function to new + for (var prop in fn) { + wrapper[prop] = fn[prop]; + delete fn[prop]; + } + + return wrapper; + }; + + var ctor = function(){}, inherits = function(parent, protoProps, staticProps) { + var child, parentProto = parent.prototype; + + // The constructor function for the new subclass is either defined by you + // (the "constructor" property in your `extend` definition), or defaulted + // by us to simply call the parent's constructor. + if (protoProps && protoProps.hasOwnProperty('constructor')) { + child = protoProps.constructor; + } else { + child = function(){ return parent.apply(this, arguments); }; + } + + // Inherit class (static) properties from parent. + _.extend(child, parent, staticProps); + + // Set the prototype chain to inherit from `parent`, without calling + // `parent`'s constructor function. + ctor.prototype = parentProto; + child.prototype = new ctor(); + + // Add prototype properties (instance properties) to the subclass, + // if supplied. + if (protoProps) { + _.extend(child.prototype, protoProps); + + // Copy the properties over onto the new prototype + for (var name in protoProps) { + // Check if we're overwriting an existing function + if (typeof protoProps[name] == "function" && fnTest.test(protoProps[name])) { + child.prototype[name] = makeWrapper(parentProto, name, protoProps[name]); + } + } + } + + // Add static properties to the constructor function, if supplied. + if (staticProps) _.extend(child, staticProps); + + // Correctly set child's `prototype.constructor`. + child.prototype.constructor = child; + + // Set a convenience property in case the parent's prototype is needed later. + child.__super__ = parentProto; + + return child; + }; + + return inherits; +})); + diff --git a/server/sonar-web/src/main/js/libs/third-party/shim/backbone-shim.js b/server/sonar-web/src/main/js/libs/third-party/shim/backbone-shim.js new file mode 100644 index 00000000000..041e0eae3ef --- /dev/null +++ b/server/sonar-web/src/main/js/libs/third-party/shim/backbone-shim.js @@ -0,0 +1,3 @@ +define(function () { + return window.Backbone; +}); diff --git a/server/sonar-web/src/main/js/libs/shim/jquery-shim.js b/server/sonar-web/src/main/js/libs/third-party/shim/jquery-shim.js index aa31e60d459..aa31e60d459 100644 --- a/server/sonar-web/src/main/js/libs/shim/jquery-shim.js +++ b/server/sonar-web/src/main/js/libs/third-party/shim/jquery-shim.js diff --git a/server/sonar-web/src/main/js/libs/third-party/shim/marionette-shim.js b/server/sonar-web/src/main/js/libs/third-party/shim/marionette-shim.js new file mode 100644 index 00000000000..84220542147 --- /dev/null +++ b/server/sonar-web/src/main/js/libs/third-party/shim/marionette-shim.js @@ -0,0 +1,3 @@ +define(function () { + return window.Marionette; +}); diff --git a/server/sonar-web/src/main/js/libs/shim/underscore-shim.js b/server/sonar-web/src/main/js/libs/third-party/shim/underscore-shim.js index c49e9f8fc1c..c49e9f8fc1c 100644 --- a/server/sonar-web/src/main/js/libs/shim/underscore-shim.js +++ b/server/sonar-web/src/main/js/libs/third-party/shim/underscore-shim.js diff --git a/server/sonar-web/src/main/js/libs/translate.js b/server/sonar-web/src/main/js/libs/translate.js index 0f29009952d..6317c610bb6 100644 --- a/server/sonar-web/src/main/js/libs/translate.js +++ b/server/sonar-web/src/main/js/libs/translate.js @@ -17,10 +17,10 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -(function () { +(function() { window.suppressTranslationWarnings = false; - window.t = function () { + window.t = function() { if (!window.messages) { return window.translate.apply(this, arguments); } @@ -30,12 +30,12 @@ return window.messages[key] != null ? window.messages[key] : key; }; - window.tp = function () { + window.tp = function() { var args = Array.prototype.slice.call(arguments, 0), - key = args.shift(), - message = window.messages[key]; + key = args.shift(), + message = window.messages[key]; if (message) { - args.forEach(function (p, i) { + args.forEach(function(p, i) { message = message.replace('{' + i + '}', p); }); } @@ -43,9 +43,9 @@ }; - window.translate = function () { + window.translate = function() { var args = Array.prototype.slice.call(arguments, 0), - tokens = args.reduce(function (prev, current) { + tokens = args.reduce(function(prev, current) { return prev.concat(current.split('.')); }, []), key = tokens.join('.'), @@ -54,7 +54,7 @@ result = ''; if (found) { - result = tokens.reduce(function (prev, current) { + result = tokens.reduce(function(prev, current) { if (!current || !prev[current]) { found = false; } @@ -66,7 +66,7 @@ }; - window.requestMessages = function () { + window.requestMessages = function() { var currentLocale = window.pageLang, cachedLocale = localStorage.getItem('l10n.locale'); if (cachedLocale !== currentLocale) { @@ -85,12 +85,12 @@ data: params, dataType: 'json', statusCode: { - 304: function () { + 304: function() { window.messages = JSON.parse(localStorage.getItem('l10n.bundle')); } } - }).done(function (bundle, textStatus, jqXHR) { - if (bundle) { + }).done(function(bundle, textStatus, jqXHR) { + if(bundle !== undefined) { bundleTimestamp = new Date().toISOString(); bundleTimestamp = bundleTimestamp.substr(0, bundleTimestamp.indexOf('.')) + '+0000'; localStorage.setItem('l10n.timestamp', bundleTimestamp); 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 274597a68e3..fc166404423 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 @@ -1,3 +1,24 @@ +/* + * 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. + */ +/*global d3:false, baseUrl:false */ + window.SonarWidgets = window.SonarWidgets == null ? {} : window.SonarWidgets; (function () { @@ -199,8 +220,8 @@ window.SonarWidgets = window.SonarWidgets == null ? {} : window.SonarWidgets; sizeMetricValue = d.measures[widget.sizeMetric].fval; return '<div class="text-left">' + - window.collapsedDirFromPath(d.longName) + '<br>' + - window.fileFromPath(d.longName) + '<br>' + '<br>' + + collapsedDirFromPath(d.longName) + '<br>' + + fileFromPath(d.longName) + '<br>' + '<br>' + xMetricName + ': ' + xMetricValue + '<br>' + yMetricName + ': ' + yMetricValue + '<br>' + sizeMetricName + ': ' + sizeMetricValue + diff --git a/server/sonar-web/src/main/js/libs/widgets/pie-chart.js b/server/sonar-web/src/main/js/libs/widgets/pie-chart.js index 60ac72290ee..a88f0941c55 100644 --- a/server/sonar-web/src/main/js/libs/widgets/pie-chart.js +++ b/server/sonar-web/src/main/js/libs/widgets/pie-chart.js @@ -1,3 +1,25 @@ +/* + * 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. + */ +/*global d3:false, baseUrl:false */ +/*jshint eqnull:true */ + window.SonarWidgets = window.SonarWidgets == null ? {} : window.SonarWidgets; (function () { diff --git a/server/sonar-web/src/main/js/libs/widgets/tag-cloud.js b/server/sonar-web/src/main/js/libs/widgets/tag-cloud.js index cd2851ab8a2..d09f38b55bb 100644 --- a/server/sonar-web/src/main/js/libs/widgets/tag-cloud.js +++ b/server/sonar-web/src/main/js/libs/widgets/tag-cloud.js @@ -64,7 +64,7 @@ TagCloud.prototype.tooltip = function (d) { var suffixKey = d.value === 1 ? 'issue' : 'issues', - suffix = window.t(suffixKey); + suffix = t(suffixKey); return (d.value + '\u00a0') + suffix; }; 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 4fa9c0123ac..5b871e5994e 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; } |