From c0bee2675a05271de8612036f0033cdc5bcbbac8 Mon Sep 17 00:00:00 2001
From: Guillaume Thomazon <gtn@kereval.com>
Date: Wed, 23 Apr 2014 15:18:36 +0000
Subject: [PATCH] git-svn-id:
 https://scm.gforge.inria.fr/authscm/ycadoret/svn/gazelle/Maven/gazelle-proxy/trunk@41156
 356b4b1a-1d2b-0410-8bf1-ffa24008f01e

---
 .../src/main/webapp/js/activeModal.js         | 12 +++
 .../src/main/webapp/js/autofocus.js           | 11 +++
 .../src/main/webapp/layout/footer.xhtml       | 82 ++++++++++++-------
 .../src/main/webapp/layout/template.xhtml     |  3 +
 4 files changed, 77 insertions(+), 31 deletions(-)
 create mode 100644 gazelle-proxy-war/src/main/webapp/js/activeModal.js
 create mode 100644 gazelle-proxy-war/src/main/webapp/js/autofocus.js

diff --git a/gazelle-proxy-war/src/main/webapp/js/activeModal.js b/gazelle-proxy-war/src/main/webapp/js/activeModal.js
new file mode 100644
index 00000000..7157f7ea
--- /dev/null
+++ b/gazelle-proxy-war/src/main/webapp/js/activeModal.js
@@ -0,0 +1,12 @@
+/**
+ * select active modal
+ * 
+ * @author Guillaume Thomazon
+ */
+
+var ActiveModal = new function() {
+	this.activeModalPanel = null;
+	this.setActiveModalPanel = function(a) {
+		this.activeModalPanel = a;
+	};
+};
\ No newline at end of file
diff --git a/gazelle-proxy-war/src/main/webapp/js/autofocus.js b/gazelle-proxy-war/src/main/webapp/js/autofocus.js
new file mode 100644
index 00000000..7481760e
--- /dev/null
+++ b/gazelle-proxy-war/src/main/webapp/js/autofocus.js
@@ -0,0 +1,11 @@
+/**
+ * autofocus on modalpanels
+ * @author Abderrazek Boufahja 
+ */
+
+function autofocus(containerId) {
+  var element = jQuery(":input:not(:button):visible:enabled:first", '#'+containerId);
+  if (element != null) {
+    element.focus().select();
+  }
+}
\ No newline at end of file
diff --git a/gazelle-proxy-war/src/main/webapp/layout/footer.xhtml b/gazelle-proxy-war/src/main/webapp/layout/footer.xhtml
index 1c8f2a06..d6615679 100644
--- a/gazelle-proxy-war/src/main/webapp/layout/footer.xhtml
+++ b/gazelle-proxy-war/src/main/webapp/layout/footer.xhtml
@@ -47,51 +47,60 @@
 	<!-- Modal Panel : About the Proxy -->
 	<!-- ******************************************* -->
 
-	<rich:modalPanel id="about" minHeight="150" minWidth="450" height="300"
-		width="500" zindex="2000">
+	<rich:modalPanel id="about"
+		onbeforeshow="ActiveModal.setActiveModalPanel('about')"
+		minHeight="150" minWidth="450" height="300" width="500" zindex="2000">
 
 		<f:facet name="header">
 			<h:outputText value="#{messages['net.ihe.gazelle.proxy.AboutProxy']}" />
 		</f:facet>
 
 		<f:facet name="controls">
-			<h:graphicImage alt="#{messages['net.ihe.gazelle.proxy.Close']}" value="/img/close.gif"
-				style="cursor:pointer" onclick="Richfaces.hideModalPanel('about')" />
+			<h:graphicImage alt="#{messages['net.ihe.gazelle.proxy.Close']}"
+				value="/img/close.gif" style="cursor:pointer"
+				onclick="Richfaces.hideModalPanel('about')" />
 		</f:facet>
 		<h1>
-			<h:outputText value="#{messages['net.ihe.gazelle.proxy.GazelleProxy']}" />
+			<h:outputText
+				value="#{messages['net.ihe.gazelle.proxy.GazelleProxy']}" />
 		</h1>
 		<h2>
-			<h:outputText value="#{messages['net.ihe.gazelle.proxy.IHEIntegratingTheHeathcareEnterprise']}" />
+			<h:outputText
+				value="#{messages['net.ihe.gazelle.proxy.IHEIntegratingTheHeathcareEnterprise']}" />
 		</h2>
 		<h3>
-			<i> <h:outputText value="#{messages['net.ihe.gazelle.proxy.ChangingTheWayHealthcareConnects']}" />
+			<i> <h:outputText
+					value="#{messages['net.ihe.gazelle.proxy.ChangingTheWayHealthcareConnects']}" />
 			</i>
 		</h3>
-		<a href="http://www.ihe.net"> <h:outputText value="#{messages['net.ihe.gazelle.proxy.Wwwihenet']}" />
+		<a href="http://www.ihe.net"> <h:outputText
+				value="#{messages['net.ihe.gazelle.proxy.Wwwihenet']}" />
 		</a>
 
 		<p>
-			<h:outputText value="#{messages['net.ihe.gazelle.proxy.ProxyVersion']} " />
+			<h:outputText
+				value="#{messages['net.ihe.gazelle.proxy.ProxyVersion']} " />
 			<h:outputText id="versionDetails" value="${version}" />
 		</p>
 		<p>
-			<h:outputText value="#{messages['net.ihe.gazelle.proxy.ReleaseDate']} " />
+			<h:outputText
+				value="#{messages['net.ihe.gazelle.proxy.ReleaseDate']} " />
 			<h:outputText value="${build.date.full}" />
 		</p>
 		<p>
-			<a
-				href="#{applicationConfigurationManager.releaseNoteUrl}">#{messages['net.ihe.gazelle.proxy.ReleaseNotes']}</a>
+			<a href="#{applicationConfigurationManager.releaseNoteUrl}">#{messages['net.ihe.gazelle.proxy.ReleaseNotes']}</a>
 		</p>
 		<p>
 			<a href="#{applicationConfigurationManager.documentation}">#{messages['net.ihe.gazelle.proxy.Documentation']}</a>
 		</p>
 		<p>
-			<h:outputText value="#{messages['net.ihe.gazelle.proxy.DevelopedForIHEByIHE']}" />
+			<h:outputText
+				value="#{messages['net.ihe.gazelle.proxy.DevelopedForIHEByIHE']}" />
 
 		</p>
 		<p>
-			<h:outputText value="#{messages['net.ihe.gazelle.proxy.ThanksToUseThisApplication']}" />
+			<h:outputText
+				value="#{messages['net.ihe.gazelle.proxy.ThanksToUseThisApplication']}" />
 		</p>
 		<p align="right">
 			<a href="javascript:Richfaces.hideModalPanel('about')"> <h:outputText
@@ -106,37 +115,45 @@
 	<!-- ******************************************* -->
 	<!-- Modal Panel : Contact Us 					 -->
 	<!-- ******************************************* -->
-	<rich:modalPanel id="contactUs" minHeight="200" minWidth="400"
-		height="200" width="420" zindex="2000">
+	<rich:modalPanel id="contactUs"
+		onbeforeshow="ActiveModal.setActiveModalPanel('contactUs')"
+		minHeight="200" minWidth="400" height="200" width="420" zindex="2000">
 		<f:facet name="header">
-			<h:outputText value="#{messages['net.ihe.gazelle.proxy.ContactUs_2']}" />
+			<h:outputText
+				value="#{messages['net.ihe.gazelle.proxy.ContactUs_2']}" />
 		</f:facet>
 		<f:facet name="controls">
-			<h:graphicImage alt="#{messages['net.ihe.gazelle.proxy.Close']}" value="/img/close.gif"
-				style="cursor:pointer"
+			<h:graphicImage alt="#{messages['net.ihe.gazelle.proxy.Close']}"
+				value="/img/close.gif" style="cursor:pointer"
 				onclick="Richfaces.hideModalPanel('contactUs')" />
 		</f:facet>
 
 		<h1>
-			<h:outputText value="#{messages['net.ihe.gazelle.proxy.GazelleProxy']}" />
+			<h:outputText
+				value="#{messages['net.ihe.gazelle.proxy.GazelleProxy']}" />
 		</h1>
 		<h2>
-			<h:outputText value="#{messages['net.ihe.gazelle.proxy.IHEIntegratingTheHeathcareEnterprise']}" />
+			<h:outputText
+				value="#{messages['net.ihe.gazelle.proxy.IHEIntegratingTheHeathcareEnterprise']}" />
 		</h2>
 		<h3>
-			<i> <h:outputText value="#{messages['net.ihe.gazelle.proxy.ChangingTheWayHealthcareConnects']}" />
+			<i> <h:outputText
+					value="#{messages['net.ihe.gazelle.proxy.ChangingTheWayHealthcareConnects']}" />
 			</i>
 		</h3>
-		<a href="http://www.ihe.net"> <h:outputText value="#{messages['net.ihe.gazelle.proxy.Wwwihenet']}" />
+		<a href="http://www.ihe.net"> <h:outputText
+				value="#{messages['net.ihe.gazelle.proxy.Wwwihenet']}" />
 		</a>
 
 		<p></p>
 		<p>
-			<h:outputText value="#{messages['net.ihe.gazelle.proxy.PleaseEmailQuestionsToIHEEUManager']} (" />
+			<h:outputText
+				value="#{messages['net.ihe.gazelle.proxy.PleaseEmailQuestionsToIHEEUManager']} (" />
 			<a href="mailto:eric.poiseau@inria.fr}"> <h:outputText
 					value="#{messages['net.ihe.gazelle.proxy.EricPoiseau']}" />
 			</a>
-			<h:outputText value="), #{messages['net.ihe.gazelle.proxy.AndHeWillGuideYouThroughTheProcess']}" />
+			<h:outputText
+				value="), #{messages['net.ihe.gazelle.proxy.AndHeWillGuideYouThroughTheProcess']}" />
 		</p>
 		<p>
 			<a href="javascript:Richfaces.hideModalPanel('contactUs')"> <h:outputText
@@ -151,14 +168,16 @@
 	<!-- ******************************************* -->
 	<!-- Modal Panel : Issue Tracker						   -->
 	<!-- ******************************************* -->
-	<rich:modalPanel id="issueTracker" minHeight="200" minWidth="540"
-		height="200" width="540" zindex="2000">
+	<rich:modalPanel id="issueTracker"
+		onbeforeshow="ActiveModal.setActiveModalPanel('issueTracker')"
+		minHeight="200" minWidth="540" height="200" width="540" zindex="2000">
 		<f:facet name="header">
-			<h:outputText value="#{messages['net.ihe.gazelle.proxy.IssueTracker_2']}" />
+			<h:outputText
+				value="#{messages['net.ihe.gazelle.proxy.IssueTracker_2']}" />
 		</f:facet>
 		<f:facet name="controls">
-			<h:graphicImage alt="#{messages['net.ihe.gazelle.proxy.Close']}" value="/img/close.gif"
-				style="cursor:pointer"
+			<h:graphicImage alt="#{messages['net.ihe.gazelle.proxy.Close']}"
+				value="/img/close.gif" style="cursor:pointer"
 				onclick="Richfaces.hideModalPanel('issueTracker')" />
 		</f:facet>
 		<p />
@@ -170,7 +189,8 @@
 		<h:outputText
 			value="#{messages['net.ihe.gazelle.proxy.ADevelopmentTeamWorksEachDayToImproveThisApplica']}" />
 		<p />
-		<h:outputText value="#{messages['net.ihe.gazelle.proxy.ClickOnThatLinkToReportAProblem']}" />
+		<h:outputText
+			value="#{messages['net.ihe.gazelle.proxy.ClickOnThatLinkToReportAProblem']}" />
 		<a href="#{applicationConfigurationManager.issueTracker}"> <h:outputText
 				value="#{applicationConfigurationManager.issueTracker}" />
 		</a>
diff --git a/gazelle-proxy-war/src/main/webapp/layout/template.xhtml b/gazelle-proxy-war/src/main/webapp/layout/template.xhtml
index 93af7288..9cc91d65 100644
--- a/gazelle-proxy-war/src/main/webapp/layout/template.xhtml
+++ b/gazelle-proxy-war/src/main/webapp/layout/template.xhtml
@@ -15,6 +15,9 @@
 <link rel="shortcut icon" href="#{request.contextPath}/favicon.ico" />
 <a:loadStyle src="resource:///stylesheet/theme.xcss" />
 <a:loadStyle src="/stylesheet/theme-simu.css" />
+<a:loadScript src="/js/autofocus.js" />
+<a:loadScript src="/js/activeModal.js" />
+
 <ui:insert name="head" />
 </head>
 <body>
-- 
GitLab