Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Replaced the while loop in uni-form.jquery.js with a parent selector …

…the remove posibility of infinate loops.
  • Loading branch information...
commit 5a38605c7857ed9a065767c4ca5355a4708ee3f1 1 parent 749dca6
@agentk agentk authored
Showing with 8 additions and 14 deletions.
  1. +8 −14 uni_form/media/uni_form/uni-form.jquery.js
View
22 uni_form/media/uni_form/uni-form.jquery.js
@@ -14,25 +14,19 @@ jQuery.fn.uniform = function(settings) {
// Focus specific control holder
var focusControlHolder = function(element) {
- var parent = element.parent();
-
- while(typeof(parent) == 'object') {
- if(parent) {
- if(parent[0] && (parent[0].className.indexOf(settings.holder_class) >= 0)) {
- parent.addClass(settings.focused_class);
- return;
- } // if
- } // if
- parent = jQuery(parent.parent());
- } // while
+ element.parent('div[class~=' + settings.holder_class + ']').addClass(settings.focused_class);
};
+ var removeFocusClass = function(){
+ form.find('.' + settings.focused_class).removeClass(settings.focused_class);
+ };
+
// Select form fields and attach them higlighter functionality
form.find(settings.field_selector).focus(function() {
- form.find('.' + settings.focused_class).removeClass(settings.focused_class);
+ removeFocusClass();
focusControlHolder(jQuery(this));
}).blur(function() {
- form.find('.' + settings.focused_class).removeClass(settings.focused_class);
+ removeFocusClass();
});
});
};
@@ -40,4 +34,4 @@ jQuery.fn.uniform = function(settings) {
// Auto set on page load...
$(document).ready(function() {
jQuery('form.uniForm').uniform();
-});
+});
Please sign in to comment.
Something went wrong with that request. Please try again.