If I understand correctly, you're trying to camelize the jQuery UI class names truncating the "ui-" part.
If so, you can do something like this -
$('*[class^=ui-]').toggleClass(function (index, classNamesToChange) {
$.each(classNamesToChange.split(' '), function(index, classNameToChange){
return classNameToChange[3].toLowerCase() +
classNameToChange.replace(/-([a-z])/g, function (a, b) {
return b.toUpperCase();
}).slice(3);
});
});
Here is the fiddle - http://jsfiddle.net/78GM5/3/
EDIT If you would like to map the camel cased class names to corresponding styles, you can try this. Get the style for the class name using the following.
function css(a) {
var sheets = document.styleSheets, o = {};
for (var i in sheets) {
var rules = sheets[i].rules || sheets[i].cssRules;
for (var r in rules) {
if (a.is(rules[r].selectorText)) {
o = $.extend(o, css2json(rules[r].style), css2json(a.attr('style')));
}
}
}
return o;
}
function css2json(css) {
var s = {};
if (!css) return s;
if (css instanceof CSSStyleDeclaration) {
for (var i in css) {
if ((css[i]).toLowerCase) {
s[(css[i]).toLowerCase()] = (css[css[i]]);
}
}
} else if (typeof css == "string") {
css = css.split("; ");
for (var i in css) {
var l = css[i].split(": ");
s[l[0].toLowerCase()] = (l[1]);
}
}
return s;
}
The above piece of code is from this awesome thread - Can jQuery get all CSS styles associated with an element?
And then use this code to write it into a style.
$('*[class^=ui-]').toggleClass(function (index, classNamesToChange) {
$.each(classNamesToChange.split(' '), function(index, classNameToChange){
var originalClassName = classNameToChange;
var classNameToReturn = classNameToChange[3].toLowerCase() + classNameToChange.replace(/-([a-z])/g, function (a, b) {
return b.toUpperCase();
}).slice(3);
$('style').append('.' + classNameToReturn + JSON.stringify(css($('.' + originalClassName))) );
return classNameToReturn;
});
});
This won't work in jsfiddle for obvious reasons. But just a thought..
Here is the fiddle for this - http://jsfiddle.net/78GM5/6/