]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-3972 Dropdown menus hide when click outside
authorFabrice Bellingard <fabrice.bellingard@sonarsource.com>
Wed, 5 Dec 2012 15:54:09 +0000 (16:54 +0100)
committerFabrice Bellingard <fabrice.bellingard@sonarsource.com>
Thu, 6 Dec 2012 08:58:46 +0000 (09:58 +0100)
sonar-server/src/main/webapp/WEB-INF/app/views/layouts/_menu_projects.html.erb
sonar-server/src/main/webapp/WEB-INF/app/views/layouts/_menu_resource_settings.html.erb
sonar-server/src/main/webapp/WEB-INF/app/views/layouts/_menu_user.html.erb
sonar-server/src/main/webapp/WEB-INF/app/views/resource/_violation.html.erb
sonar-server/src/main/webapp/javascripts/application.js

index 2a9604974e9826b27d243f0de46eac9279d1224f..32f7f4bafb37fcccd7e93ab84bc514b03de5b1eb 100644 (file)
@@ -5,9 +5,9 @@
 </script>
 
 <li>
-  <a href="#" onclick="if (sonarRecentHistory) { sonarRecentHistory.populateRecentHistoryPanel(); }; $j('#projects-menu').toggle(); return false;" class="link-more"><%= message('layout.projects') -%></a>
+  <a href="#" onclick="if (sonarRecentHistory) { sonarRecentHistory.populateRecentHistoryPanel(); }; showDropdownMenu('projects-menu'); return false;" class="link-more"><%= message('layout.projects') -%></a>
   
-  <div id="projects-menu" class="dropdown-menu" style="max-width: none; display: none;" onmouseout="$j(this).hide();" onmouseover="$j(this).show();">
+  <div id="projects-menu" class="dropdown-menu" style="max-width: none; display: none;">
     <div id="recent-history" style="border-bottom: 1px solid #ccc; padding-bottom: 10px;">
       <h2><%= message('layout.recent_activity') -%></h2>
       <ul id="recent-history-list">
index 4093ba3a6d1013e075ac654a88be064450f44d1e..049c1acdfc361e394b856d8ae79ba410ce046b6a 100644 (file)
@@ -1,7 +1,7 @@
 <li>
-  <a href="#" onclick="$j('#project-settings-menu').toggle(); return false;" class="link-more"><%= message('layout.configuration') -%></a>
+  <a href="#" onclick="showDropdownMenu('project-settings-menu'); return false;" class="link-more"><%= message('layout.configuration') -%></a>
   
-  <div id="project-settings-menu" class="dropdown-menu" style="display: none" onmouseout="$j(this).hide();" onmouseover="$j(this).show();">
+  <div id="project-settings-menu" class="dropdown-menu" style="display: none">
     <ul>
       <% if (@project.project?) %>
         <li><a href="<%= ApplicationController.root_context -%>/project/profile/<%= @project.id -%>"><%= message('project_quality_profiles.page') -%></a></li>
index 90a8fd33544582537baad10dd1aeaa33a8bd537f..5e07958c406062a45330a3fda4703a9aa7474e3c 100644 (file)
@@ -1,7 +1,7 @@
 <li>
-  <a href="#" onclick="$j('#user-panel').toggle(); return false;" class="link-more"><%= current_user.name(true) -%></a>
+  <a href="#" onclick="showDropdownMenu('user-panel'); return false;" class="link-more"><%= current_user.name(true) -%></a>
   
-  <div id="user-panel" class="dropdown-menu" style="display: none" onmouseout="$j(this).hide();" onmouseover="$j(this).show();">
+  <div id="user-panel" class="dropdown-menu" style="display: none">
     <ul>
       <li><a href="<%= ApplicationController.root_context -%>/account/index"><%= message('layout.user_panel.my_profile') -%></a></li>
       <li><a href="<%= ApplicationController.root_context -%>/sessions/logout" onclick="if (sonarRecentHistory) { sonarRecentHistory.clear(); }"><%= message('layout.logout') -%></a></li>
index 514ab668cb7d37dda80eaae52fa715fa50670562..9d1c0345a92d8d780e2f67b804d002138ff9bb65 100644 (file)
 
         <% unless violation.switched_off? && violation.review && violation.review.resolved? %>
         <div class="dropdown">
-          <a href="#" class="link-action link-more" onclick="$('more<%= violation.id -%>').toggle();return false;"><%= message('more_actions') -%></a>
-          <ul style="display: none" class="dropdown-menu" id="more<%= violation.id -%>" onmouseout="this.hide();" onmouseover="this.show();">
+          <a href="#" class="link-action link-more" onclick="showDropdownMenu('more<%= violation.id -%>');return false;"><%= message('more_actions') -%></a>
+          <ul style="display: none" class="dropdown-menu" id="more<%= violation.id -%>">
             <% if !violation.switched_off? %>
               <li><%= link_to_function (violation.review && violation.review.resolved? ? message('reviews.reopen') : message('reviews.resolved')),
                                        "sCStF(#{violation.id})", :name => (violation.review && violation.review.resolved? ? 'bReopen' : 'bResolved') -%></li>
index 8cf2fb241674ff5461110b8ddd2fde5b18fe922b..f2f152bc27359cdd1ea795df0745a1b40ea1b8d9 100644 (file)
@@ -310,4 +310,14 @@ function supports_html5_storage() {
   } catch (e) {
     return false;
   }
-}
\ No newline at end of file
+}
+
+var hideDropdownMenus = function() {
+  $j('.dropdown-menu').hide();
+  $j(document).unbind('mouseup', hideDropdownMenus);
+}
+
+function showDropdownMenu(menuId) {
+  $j(document).bind('mouseup', hideDropdownMenus);
+  $j('#' + menuId).show();
+}