From 60306165d76799f1a18982dbbc42b5413fd515f0 Mon Sep 17 00:00:00 2001 From: Eric Freese Date: Thu, 21 Feb 2013 12:28:00 -0700 Subject: [PATCH] Fixes #80: Wrapper div should inherit classes from original input elements Applies to: - select (non-multiline) - radio - checkbox - file input Has the side effect that there is now no way to specify a class to be left on the original select or input element. A few possible solutions: - Leave the class on the element all the time - Could result in style conflicts (i.e. styling meant for wrapper div also applies to hidden select/input element. - Add an option to either leave the class on or remove it. - Take the classes off, but rename them with "uniform-" prefix, similar to how id's are inherited. - Use a data attribute such as "data-uniform-class" to specify classes that should be added to the wrapper div - Wouldn't work with jQuery < 1.4.3 - Would require different class definitions for regular inputs that don't use wrapper divs and inputs that do (i.e. class vs. data-uniform-class) --- jquery.uniform.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/jquery.uniform.js b/jquery.uniform.js index 3823661..e8a6ebf 100644 --- a/jquery.uniform.js +++ b/jquery.uniform.js @@ -241,6 +241,12 @@ Enjoy! $div.addClass(divSpanConfig.divClass); } + // Apply any specified classes to the created div + $div.addClass($el.attr("class")); + + // Remove classes from the original element + $el.removeClass(); + if (options.wrapperClass) { $div.addClass(options.wrapperClass); } @@ -789,7 +795,7 @@ Enjoy! } ds = divSpan($el, options, { - divClass: (typeof options.selectClass === "function" ? options.selectClass.apply($el) : options.selectClass), + divClass: options.selectClass, spanHtml: ($el.find(":selected:first") || $el.find("option:first")).html(), spanWrap: "before" });