r13460 - Products.Archetypes/trunk/Products/Archetypes/skins/archetypes/widgets/js

"Matt Barkau" <[email protected]>
Newsgroups gmane.comp.web.zope.plone.archetypes.cvs
Message-ID <[email protected]>
Author: rmattb
Date: Sat Feb  5 05:28:41 2011
New Revision: 13460

Modified:
   Products.Archetypes/trunk/Products/Archetypes/skins/archetypes/widgets/js/keywordmultiselect.js
Log:
Consolidated redundant variable assignments in JavaScript for keyword multiple select enhancement PLIP. Refs #11017.

Modified: Products.Archetypes/trunk/Products/Archetypes/skins/archetypes/widgets/js/keywordmultiselect.js
==============================================================================
--- Products.Archetypes/trunk/Products/Archetypes/skins/archetypes/widgets/js/keywordmultiselect.js	(original)
+++ Products.Archetypes/trunk/Products/Archetypes/skins/archetypes/widgets/js/keywordmultiselect.js	Sat Feb  5 05:28:41 2011
@@ -110,6 +110,7 @@
 		
 		// Initialize selected options list
 		updateSelected.call(multiSelectA);
+		var allOptions = multiSelectOptions.find('LABEL');
 		
 		// --- Navigation with Mouse ---
 		// Handle mouse hover of option, both
@@ -126,7 +127,7 @@
 			}
 			if( multiSelectA.oldPositionX != e.pageX || multiSelectA.oldPositionY != e.pageY ) {
 				// At this point, the mouse actually did move.  
-				// Format navigated item
+				// Highlight navigated option
 				$(this).parent().parent().find('LABEL').removeClass('hover');
 				$(this).addClass('hover');
 				lastNavTabKeyCheckbox = null;
@@ -172,7 +173,7 @@
 				// Without this, both moused & tabbed checks return focus to multiSelectA, 
 				// causing tabbed checkboxes to lose focus.
 				lastNavTabKeyCheckbox = $(this);
-				// Format navigated item
+				// Highlight navigated option
 				lastNavTabKeyCheckbox.parent().parent().parent().find('LABEL').removeClass('hover');
 				lastNavTabKeyCheckbox.parent('LABEL').addClass('hover');
 			}
@@ -187,7 +188,6 @@
 			// --- Navigation with Arrow or Page Keys ---
 			// Down || Up
 			if( e.keyCode == 40 || e.keyCode == 38) {
-				var allOptions = multiSelectOptions.find('LABEL');
 				var oldHoverIndex = allOptions.index(allOptions.filter('.hover'));
 				var newHoverIndex = -1;
 				
@@ -208,8 +208,8 @@
 				}
 
 				if(newHoverIndex >= 0) {
-					// Format navigated item
-					$(allOptions.get(oldHoverIndex)).removeClass('hover'); // remove the current highlight
+					// Highlight navigated option
+					$(allOptions).removeClass('hover'); // remove old highlights
 					$(allOptions.get(newHoverIndex)).addClass('hover'); // add the new highlight
 					lastNavTabKeyCheckbox = null;
 					
@@ -221,7 +221,6 @@
 			}
 			// Page up || Page down
 			if( e.keyCode == 33 || e.keyCode == 34) {
-				var allOptions = multiSelectOptions.find('LABEL');
 				var oldHoverIndex = allOptions.index(allOptions.filter('.hover'));
 				var newHoverIndex = -1;
 				var optionsPerPage = 8;  // depends on css

------------------------------------------------------------------------------
The modern datacenter depends on network connectivity to access resources
and provide services. The best practices for maximizing a physical server's
connectivity to a physical network are well understood - see how these
rules translate into the virtual world? 
http://p.sf.net/sfu/oracle-sfdevnlfb
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.