Improving "centerRight" (include overflow)
Following the suggestions by Olivier about the rigth position, i send you this code for improve the centerRigth ( including overflowns forms) Tougth migth be simplest, i've founded cosmetic issues with paddings and margins (i.e the prompt over the field).
case "centerRight":
var fixpos=0;
if (overflow) {
var fixpos = methods._addProperties(field.css("padding-top"),field.css("margin-top"));
promptTopPosition += promptHeight + fixpos;
};
fixpos = methods._addProperties(field.css("padding-right"),field.css("padding-left"),field.css("margin-right"),field.css("margin-left"));
promptleftPosition+= fieldWidth + fixpos + 13;
break;
Other complication was the "buggy" behavior of parseInt on IE. This made me add the function _addProperties for add values of css properties in a safe way:
_addProperties: function(a,b,c,d,e,f) {
var total=0;
var val= new Array;
val[0]=a;val[1]=b;val[2]=c;val[3]=d;val[4]=e;val[5]=f;
for (i=0;i<6;i++) {
numb=parseFloat(val[i],10);
if (isNaN(numb,10))continue;
total+=numb;
};
return total;
},
This function, besides IE's issues, also avoids problems with the "auto" value in properties. I've tested it on FF4 and IE8 using own examples and the demos too.
Alejandro
will have a look at your patch soon
Ok, thanks.
HI,
I have been looking over your fix, it seems like a complicated fix for something that was 1 line before. What is exactly the bug your are fixing with this?
Looking at FF and IE the old code seems to work in the provided examples.
Well, the ideas are
- Made "centerRight" can work in overflown divs.
- Compensate margins and/or paddings : may be in the others positions this isn't problem but in a center the prompt could overwrite the field, for example. After read your comment i test the above code again and fix some issues
case "centerRight":
var fixpospad = methods._addProperties(field.css("padding-right"),field.css("padding-left"))+5;
if (overflow) {
var fixpostop = methods._addProperties(field.css("margin-top"));
promptTopPosition = promptHeight + fixpostop;
fixpospad += methods._addProperties(field.css("margin-left"));
};
promptleftPosition+= fieldWidth + fixpospad;
break;
and try but ins't shorter, i know. However, it fullfil the 2 upper ideas. May be the main complication for me was avoid problems with parseInt/parseFloat or properties with value of "auto", i.e.; mainly in IE. Because all that, i wrote the function (may be this function could be simplest using jquery, i don't know).
After much thought, I will be removing the overflow mode, (see new issue) and will be introducing a static mode without absolute positioning,
this will "fix" this issue