[richfaces-svn-commits] JBoss Rich Faces SVN: r712 - trunk/richfaces/modal-panel/src/main/resources/org/richfaces/renderkit/html/scripts.

richfaces-svn-commits at lists.jboss.org richfaces-svn-commits at lists.jboss.org
Tue May 8 14:44:34 EDT 2007


Author: sergeyhalipov
Date: 2007-05-08 14:44:34 -0400 (Tue, 08 May 2007)
New Revision: 712

Modified:
   trunk/richfaces/modal-panel/src/main/resources/org/richfaces/renderkit/html/scripts/modalPanel.js
Log:
Disabling keyboard navigation on main page. Seems to work under IE and FF, Doesn't work in Opera yet. In progress..

Modified: trunk/richfaces/modal-panel/src/main/resources/org/richfaces/renderkit/html/scripts/modalPanel.js
===================================================================
--- trunk/richfaces/modal-panel/src/main/resources/org/richfaces/renderkit/html/scripts/modalPanel.js	2007-05-08 18:30:56 UTC (rev 711)
+++ trunk/richfaces/modal-panel/src/main/resources/org/richfaces/renderkit/html/scripts/modalPanel.js	2007-05-08 18:44:34 UTC (rev 712)
@@ -251,6 +251,8 @@
 	},
 
 	show: function(opts) {
+	this.disableDocumentFocusElements();
+
         this.onSelectStartHandler = document.onselectstart;
 
         document.onselectstart = function () { return false; };
@@ -413,6 +415,8 @@
 	},
 
 	hide: function() {
+	this.enableDocumentFocusElements();
+
         document.onselectstart = this.onSelectStartHandler;
         
         this.traverseSelects(true);
@@ -561,7 +565,113 @@
 		}
 
 		return vetoes;
+	},
+	
+	isInMP: function(elem) {
+		while (elem && elem.parentNode && elem.parentNode.tagName.toLowerCase() != "body")
+			if (elem.parentNode.id == this.cdiv.id)
+				return true;
+			else
+				elem = elem.parentNode;
+		return false;
+	},
+
+	disableDocumentFocusElements: function() {
+		var links = document.getElementsByTagName("a");
+		var forms = document.forms;
+		var inputs = document.getElementsByTagName("input");
+		if (inputs) {
+			for (var i=0; i<inputs.length; i++) 
+				// inputs with type "image" are not included to form.elements array. 
+				// We have to process them separately :(
+				if (!this.isInMP(inputs[i]) && inputs[i].type && inputs[i].type.indexOf("image") == 0) {
+					if (inputs[i].tabIndex)
+						inputs[i].prevTabIndex = inputs[i].tabIndex;
+					inputs[i].tabIndex = -1;
+					if ("FF" == RichFaces.navigatorType() || "OPERA" == RichFaces.navigatorType()) {
+						inputs[i].forceBlur = this.blurFocusElement.bindAsEventListener(inputs[i]);
+						Event.observe(inputs[i], 'focus', inputs[i].forceBlur, false);
+					}
+			}
+		}
+		if (links)
+			for (var i=0; i<links.length; i++) 
+				if (!this.isInMP(links[i])) {
+					if (links[i].tabIndex)
+						links[i].prevTabIndex = links[i].tabIndex;
+					links[i].tabIndex = -1;
+					if ("FF" == RichFaces.navigatorType() || "OPERA" == RichFaces.navigatorType()) {
+						links[i].forceBlur = this.blurFocusElement.bindAsEventListener(links[i]);
+						Event.observe(links[i], 'focus', links[i].forceBlur, false);
+					}
+				}
+		if (forms)
+			for (var i=0; i<forms.length; i++)
+				for (var j=0; j<forms[i].length; j++) 
+					if (!this.isInMP(forms[i][j])) {
+						if (forms[i][j].tabIndex)
+							forms[i][j].prevTabIndex = forms[i][j].tabIndex;
+						forms[i][j].tabIndex = -1;
+						if (forms[i][j].type && forms[i][j].type.indexOf("radio") == 0) {
+							forms[i][j].prevDisabled = forms[i][j].disabled;
+							forms[i][j].disabled = true;
+						}
+						if ("FF" == RichFaces.navigatorType() || "OPERA" == RichFaces.navigatorType()) {
+							forms[i][j].forceBlur = this.blurFocusElement.bindAsEventListener(forms[i][j]);
+							Event.observe(forms[i][j], 'focus', forms[i][j].forceBlur, false);
+						}
+					}
+	},
+
+	enableDocumentFocusElements: function() {
+		var links = document.getElementsByTagName("a");
+		var forms = document.forms;
+		var inputs = document.getElementsByTagName("input");
+		if (inputs)
+			for (var i=0; i<inputs.length; i++) 
+				// inputs with type "image" are not included to form.elements array. 
+				// We have to process them separately :(
+				if (!this.isInMP(inputs[i]) && inputs[i].type && inputs[i].type.indexOf("image") == 0) {
+					if (inputs[i].prevTabIndex)
+						inputs[i].tabIndex = inputs[i].prevTabIndex;
+					else 
+						inputs[i].tabIndex = 0;
+					if ("FF" == RichFaces.navigatorType() || "OPERA" == RichFaces.navigatorType())
+						Event.stopObserving(inputs[i], "focus", inputs[i].forceBlur);
+				}
+		if (links)
+			for (var i=0; i<links.length; i++) 
+				if (!this.isInMP(links[i])) {
+					if (links[i].prevTabIndex)
+						links[i].tabIndex = links[i].prevTabIndex;
+					else 
+						links[i].tabIndex = 0;
+					if ("FF" == RichFaces.navigatorType() || "OPERA" == RichFaces.navigatorType())
+						Event.stopObserving(links[i], "focus", links[i].forceBlur);
+				}
+		if (forms)
+			for (var i=0; i<forms.length; i++)
+				for (var j=0; j<forms[i].length; j++) 
+					if (!this.isInMP(forms[i][j])) {
+						if (forms[i][j].prevTabIndex)
+							forms[i][j].tabIndex = forms[i][j].prevTabIndex;
+						else
+							forms[i][j].tabIndex = 0;
+						if (forms[i][j].type && forms[i][j].type.indexOf("radio") == 0) {
+							if (forms[i][j].prevDisabled)
+								forms[i][j].disabled = forms[i][j].prevDisabled;
+							else
+								forms[i][j].disabled = false;
+						}
+						if ("FF" == RichFaces.navigatorType() || "OPERA" == RichFaces.navigatorType())
+							Event.stopObserving(forms[i][j], "focus", forms[i][j].forceBlur);
+					}
+	},
+
+	blurFocusElement: function() {
+		this.blur();
 	}
+
 }
 
 Richfaces.findModalPanel = function (id) {




More information about the richfaces-svn-commits mailing list