Вот решение, которое я использовал в конце:
CSS
.appui-form-label{
display:block !important;
margin:0.3em 2em 0.3em 0;
padding-right: 60px;
float:left !important;
clear:left !important;
vertical-align:top;
position:relative;
min-height:1.5em;
white-space:nowrap;
width: 200px;
}
.appui-form-field{
display:block !important;
margin:0.3em 0;
float:left !important;
clear:right !important;
vertical-align:top;
position:relative;
width: 500px;
}
.appui-elem-hidden{
display:none !important;
}
Javascript
(function($){
$.fn.redraw = function(options){
return this.each(function(){
var ele = this,
w = 0,
center,
total,
cont,
space,
$lbl,
$fld,
$hiddenEle,
$fieldsets = $("form", ele),
$hiddenChildren = {};
if ( $fieldsets.length > 0 ){
$fieldsets.each(function(i){
center = false, $hiddenEle = false, cont = this, $fieldset = $(this);
$hiddenChildren = $hiddenChildren ?
$fieldset.children(".appui-elem-hidden").removeClass("appui-elem-hidden") :
$hiddenChildren.add($fieldset.children(".appui-elem-hidden").removeClass("appui-elem-hidden"));
$(".appui-form-label",cont).each(function(){
$lbl = $(this);
if ( $lbl.parents(":hidden").length > 0 ){
$hiddenEle = $hiddenEle ? $hiddenEle.add($lbl.parents(":hidden").show()) : $lbl.parents(":hidden").show();
}
$lbl.css("width","auto");
if ( $lbl.hasClass("appui-c") ){
center = 1;
}
var w2 = $lbl.width();
if ( w2 > w ){
w = w2;
}
if ( !space ){
$fld = $lbl.nextAll(".appui-form-field").first();
space = ( $lbl.outerWidth(true) - $lbl.width() ) + ( $fld.outerWidth(true) - $fld.width() );
}
});
});
if ( w > 0 ){
total = false;
for ( var $par = $lbl.parent(); !total; $par = $par.parent() ){
total = $par.width();
if ( $par.width() < total ){
total = $par.width();
}
}
if ( total > 0 ){
total -= ( 20 + space );
if ( center ){
var w1 = Math.round(total/2);
w = w1;
}
else{
var w1 = total - w;
}
$fieldsets.each(function(i){
cont = this, $fieldset = $(this);
$(".appui-form-label",cont).each(function(){
var $l = $(this);
$l.width(w);
if ( center ){
$l.css("text-align","right");
}
if ( $l.parent().prop("tagName").toLowerCase() === 'a' ){
$l = $l.parent();
}
var $f = $l.nextAll(".appui-form-field").first();
if ( $f.length === 0 ){
$f = $l.nextAll("a:first").find(".appui-form-field");
}
if ( $f.length === 0 ){
appui.f.log('Unable to find a corresponding field (' + $l.text() + ')');
}
else{
var t = $f.prop("tagName");
if ( t.toLowerCase() === 'div' || t.toLowerCase() === 'textarea' ){
$f.css("width",w1+"px");
}
else{
$f.css("max-width",w1+"px");
}
}
});
});
}
$hiddenChildren.addClass("appui-elem-hidden");
if ( $hiddenEle ){
$hiddenEle.hide();
}
}
}
});
};
})(jQuery);