layout.evaluation=Embedded database should be used for evaluation purpose only
layout.ie6_warn=Your web browser is outdated. This website may not display correctly.
layout.dashboards=Dashboards
+layout.recent_history.link=Recent history
+layout.recent_history.clear=Clear
+layout.recent_history.no_history_yet=No history yet
sidebar.project_settings=Configuration
sidebar.security=Security
<include>**/dashboard-min.js</include>
<include>**/duplication-min.js</include>
<include>**/resource-min.js</include>
+ <include>**/recent-history.js</include>
</includes>
<output>${project.build.directory}/${project.build.finalName}/javascripts/sonar.js</output>
</aggregation>
<%= javascript_include_tag 'dashboard' %>
<%= javascript_include_tag 'duplication' %>
<%= javascript_include_tag 'resource' %>
+ <%= javascript_include_tag 'recent-history' %>
<% end %>
<!--[if lte IE 8]><%= javascript_include_tag 'protovis-msie' -%><![endif]-->
<script>var baseUrl = '<%= ApplicationController.root_context -%>';
<li><a href="<%= ApplicationController.root_context -%>/sessions/new?return_to=<%= u (request.request_uri) -%>"><%= message('layout.login') -%></a></li>
<% end %>
<li><a href="<%= ApplicationController.root_context -%>/profiles"><%= message('layout.configuration') -%></a></li>
+ <%= render 'layouts/resource_history' -%>
</ul>
</div>
<div id="searchResourcesResults" class="autocomplete" style="display:none"></div>
--- /dev/null
+<script>
+ var sonarRecentHistory = new Sonar.RecentHistory('<%= ApplicationController.root_context -%>')
+ .addTranslation('clear', '<%= message('layout.recent_history.clear') -%>')
+ .addTranslation('no_history_yet', '<%= message('layout.recent_history.no_history_yet') -%>');
+
+ sonarRecentHistory.add('<%= @resource ? @resource.key : "" -%>',
+ '<%= @resource ? @resource.name : "" -%>',
+ '<%= @resource ? @resource.qualifier : "" -%>');
+</script>
+
+<div class="dropdown">
+ <a href="#" class="link-more" onclick="sonarRecentHistory.populateRecentHistoryDropDown(); $('sonar_recent_history_dropdown').toggle();return false;"><%= message('layout.recent_history.link') -%></a>
+
+ <ul style="display: none" class="dropdown-menu" id="sonar_recent_history_dropdown" onmouseout="this.hide();" onmouseover="this.show();">
+ </ul>
+
+</div>
\ No newline at end of file
+<script>
+ sonarRecentHistory.add('<%= @resource.key -%>',
+ '<%= @resource.name -%>',
+ '<%= @resource.qualifier -%>');
+</script>
+
<%= render :partial => 'tabs' -%>
<%= render :partial => "resource/header_#{@extension.getId()}" -%>
--- /dev/null
+window.Sonar = {};
+
+Sonar.RecentHistory = function (applicationContext) {
+ this.appContext = applicationContext;
+ this.translations = {};
+ this.addTranslation = function (key, value) {
+ this.translations[key] = value;
+ return this;
+ }
+};
+
+Sonar.RecentHistory.prototype.getRecentHistory = function() {
+ var sonarHistory = localStorage.getItem("sonar_recent_history");
+ if (sonarHistory == null) {
+ sonarHistory = new Array();
+ } else {
+ sonarHistory = JSON.parse(sonarHistory);
+ }
+ return sonarHistory;
+};
+
+Sonar.RecentHistory.prototype.clear = function () {
+ localStorage.clear();
+ $("sonar_recent_history_dropdown").hide();
+ this.populateRecentHistoryDropDown();
+};
+
+Sonar.RecentHistory.prototype.add = function (resourceKey, resourceName, resourceQualifier) {
+ var sonarHistory = this.getRecentHistory();
+
+ if (resourceKey != '') {
+ var newEntry = {'key': resourceKey, 'name': resourceName, 'qualifier': resourceQualifier};
+ // removes the element of the array if it exists
+ for (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));
+ }
+};
+
+Sonar.RecentHistory.prototype.populateRecentHistoryDropDown = function () {
+ var dropdown = $j('#sonar_recent_history_dropdown');
+ dropdown.empty();
+
+ var recentHistory = this.getRecentHistory();
+
+ recentHistory.forEach(function (resource) {
+ dropdown.append('<li><img width="16" height="16" src="'
+ + sonarRecentHistory.appContext
+ + '/images/q/'
+ + resource['qualifier']
+ + '.png"><a href="'
+ + sonarRecentHistory.appContext
+ + '/dashboard/index/'
+ + resource['key']
+ + '">'
+ + resource['name']
+ + '</a></li>');
+ });
+
+ if (recentHistory.length == 0) {
+ dropdown.append('<li style="color: #000 !important">' + this.translations['no_history_yet'] + '</li>');
+ } else {
+ dropdown.append('<li class="clear_list"><a href="#" onclick="sonarRecentHistory.clear(); return false;">' + this.translations['clear'] + '</a></li>');
+ }
+};
#bc li a {
text-decoration: none;
}
+
#bc li a:hover, #bc li a:focus {
text-decoration: underline;
}
+
#crumbs-ops {
float: right;
padding: 0 5px 0 0;
}
+#sonar_recent_history_dropdown a {
+ color: #000 !important;
+ display: inline !important;
+ padding-left: 5px !important;
+}
+
+#sonar_recent_history_dropdown li:hover a {
+ color: #fff !important;
+}
+
+#sonar_recent_history_dropdown li.clear_list {
+ background-color: #EFEFEF !important;
+ border-top: 1px solid #CCCCCC !important;
+ color: #EFEFEF !important;
+}
+
+#sonar_recent_history_dropdown li.clear_list:hover a {
+ color: #000 !important;
+}
+
#nonav {
text-align: left;
margin: 50px 180px 0;