diff options
author | Fabrice Bellingard <bellingard@gmail.com> | 2012-03-13 10:10:44 +0100 |
---|---|---|
committer | Fabrice Bellingard <bellingard@gmail.com> | 2012-03-13 10:10:44 +0100 |
commit | 9435bfa417b9d52b87fa0b2521550c0cd3426e6a (patch) | |
tree | 5b900a1747a10b8e772e357090fec6e3c177684a /sonar-server/src/main/webapp/WEB-INF | |
parent | 1d631531e60d1897f1c0dc7f20e39ec9bf59c60f (diff) | |
download | sonarqube-9435bfa417b9d52b87fa0b2521550c0cd3426e6a.tar.gz sonarqube-9435bfa417b9d52b87fa0b2521550c0cd3426e6a.zip |
SONAR-3243 Pass params and anchor to the file page
Diffstat (limited to 'sonar-server/src/main/webapp/WEB-INF')
-rw-r--r-- | sonar-server/src/main/webapp/WEB-INF/app/helpers/application_helper.rb | 9 | ||||
-rw-r--r-- | sonar-server/src/main/webapp/WEB-INF/app/views/dashboard/no_dashboard.html.erb | 15 |
2 files changed, 19 insertions, 5 deletions
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/helpers/application_helper.rb b/sonar-server/src/main/webapp/WEB-INF/app/helpers/application_helper.rb index f55ef40d90a..5463fe9e32a 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/helpers/application_helper.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/helpers/application_helper.rb @@ -320,14 +320,17 @@ module ApplicationHelper # # - # link to the current page with the given resource. If file, then open a popup to display resource viewers. + # link to the current page with the given resource. # # def link_to_resource(resource, name=nil, options={}) period_index=options[:period] period_index=nil if period_index && period_index<=0 - link_to(name || resource.name, {:overwrite_params => {:controller => 'dashboard', :action => 'index', :id => resource.id, :period => period_index, - :tab => options[:tab], :rule => options[:rule]}}, :title => options[:title]) + if options[:line] + anchor= 'L' + options[:line].to_s + end + link_to(name || resource.name, {:controller => 'dashboard', :action => 'index', :id => resource.id, :period => period_index, + :tab => options[:tab], :rule => options[:rule], :anchor => anchor}, :title => options[:title]) end diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/dashboard/no_dashboard.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/dashboard/no_dashboard.html.erb index 6d99650df91..4043a26546b 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/dashboard/no_dashboard.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/dashboard/no_dashboard.html.erb @@ -5,12 +5,23 @@ <div id="resource_container"></div> <script type="text/javascript"> - new Ajax.Updater('resource_container', '<%= ApplicationController.root_context-%>/resource/index/<%= @file.id -%>', + // see if an anchor has been passed + var anchor; + var stripped_url = document.location.toString().split("#"); + if (stripped_url.length > 1) { + anchor = stripped_url[1]; + } + + // and call the resource page + new Ajax.Updater('resource_container', '<%= url_for params.merge({:controller => 'resource', :action => 'index', :id => @file.id}) -%>', { asynchronous:true, evalScripts:true, onComplete:function (transport) { - $('page_loading').hide() + $('page_loading').hide(); + if (anchor!=null) { + window.location.hash = anchor; + } } }); |