dom-ie-style.js revision 4f15171c562757e8d3e2b8882e04d6b5a2291732
e8721886dbfd32e88cc7077cbee4b6bb1b44b443Peter Major(function(Y) {
e8721886dbfd32e88cc7077cbee4b6bb1b44b443Peter Major // TODO: unit-less lineHeight (e.g. 1.22)
e8721886dbfd32e88cc7077cbee4b6bb1b44b443Peter Major re_unit = /^(\d[.\d]*)+(em|ex|px|gd|rem|vw|vh|vm|ch|mm|cm|in|pt|pc|deg|rad|ms|s|hz|khz|%){1}?/i,
e8721886dbfd32e88cc7077cbee4b6bb1b44b443Peter Major } else if (!current || (current.indexOf && current.indexOf(PX) > -1)) { // no need to convert
e8721886dbfd32e88cc7077cbee4b6bb1b44b443Peter Major } else if (Y.DOM.IE.COMPUTED[property]) { // use compute function
e8721886dbfd32e88cc7077cbee4b6bb1b44b443Peter Major value = Y.DOM.IE.COMPUTED[property](el, property);
e8721886dbfd32e88cc7077cbee4b6bb1b44b443Peter Major } else if (re_unit.test(current)) { // convert to pixel
e8721886dbfd32e88cc7077cbee4b6bb1b44b443Peter Major value = ComputedStyle.getPixel(el, property) + PX;
e8721886dbfd32e88cc7077cbee4b6bb1b44b443Peter Major var current = _getStyleObj(el)[prop], // value of "width", "top", etc.
e8721886dbfd32e88cc7077cbee4b6bb1b44b443Peter Major capped = prop.charAt(0).toUpperCase() + prop.substr(1), // "Width", "Top", etc.
e8721886dbfd32e88cc7077cbee4b6bb1b44b443Peter Major offset = 'offset' + capped, // "offsetWidth", "offsetTop", etc.
e8721886dbfd32e88cc7077cbee4b6bb1b44b443Peter Major pixel = 'pixel' + capped, // "pixelWidth", "pixelTop", etc.
e8721886dbfd32e88cc7077cbee4b6bb1b44b443Peter Major if (actual === UNDEFINED) { // likely "right" or "bottom"
e8721886dbfd32e88cc7077cbee4b6bb1b44b443Peter Major if (re_size.test(prop)) { // account for box model diff
e8721886dbfd32e88cc7077cbee4b6bb1b44b443Peter Major // the difference is padding + border (works in Standards & Quirks modes)
e8721886dbfd32e88cc7077cbee4b6bb1b44b443Peter Major } else { // convert units to px
e8721886dbfd32e88cc7077cbee4b6bb1b44b443Peter Major if (current.indexOf('%') > -1) { // IE pixelWidth incorrect for percent; manually compute
e8721886dbfd32e88cc7077cbee4b6bb1b44b443Peter Major current = el.clientWidth - // offsetWidth - borderWidth
e8721886dbfd32e88cc7077cbee4b6bb1b44b443Peter Major if (!el.style[pixel] && !el.style[prop]) { // need to map style.width to currentStyle (no currentStyle.pixelWidth)
e8721886dbfd32e88cc7077cbee4b6bb1b44b443Peter Major el.style[prop] = current; // no style.pixelWidth if no style.width
e8721886dbfd32e88cc7077cbee4b6bb1b44b443Peter Major // clientHeight/Width = paddingBox (e.g. offsetWidth - borderWidth)
e8721886dbfd32e88cc7077cbee4b6bb1b44b443Peter Major // clientTop/Left = borderWidth
e8721886dbfd32e88cc7077cbee4b6bb1b44b443Peter Major if (!el.currentStyle || !el.currentStyle[HAS_LAYOUT]) { // TODO: unset layout?
e8721886dbfd32e88cc7077cbee4b6bb1b44b443Peter Major el.style.zoom = 1; // need layout to measure client
e8721886dbfd32e88cc7077cbee4b6bb1b44b443Peter Major value = el.offsetHeight - el.clientHeight - el[CLIENT_TOP];
e8721886dbfd32e88cc7077cbee4b6bb1b44b443Peter Major value = el.offsetWidth - el.clientWidth - el[CLIENT_LEFT];
e8721886dbfd32e88cc7077cbee4b6bb1b44b443Peter Major // use pixelRight to convert to px
e8721886dbfd32e88cc7077cbee4b6bb1b44b443Peter Major while ( (current = node.currentStyle) && current[att] == 'inherit') { // NOTE: assignment in test
e8721886dbfd32e88cc7077cbee4b6bb1b44b443Peter Major Y.DOM.elementByAxis(node, 'parentNode', null, function(parent) {
e8721886dbfd32e88cc7077cbee4b6bb1b44b443Peter Major return true;
e8721886dbfd32e88cc7077cbee4b6bb1b44b443Peter Major //fontSize: getPixelFont,
e8721886dbfd32e88cc7077cbee4b6bb1b44b443Peter Major// use alpha filter for IE opacity
e8721886dbfd32e88cc7077cbee4b6bb1b44b443Peter Majorif (documentElement.style[OPACITY] === UNDEFINED &&
8b6198b1170e3128c5df83267597f0058d07c70dJames Phillpotts try { // will error if no DXImageTransform
8b6198b1170e3128c5df83267597f0058d07c70dJames Phillpotts val = node[FILTERS]['DXImageTransform.Microsoft.Alpha'][OPACITY];
8b6198b1170e3128c5df83267597f0058d07c70dJames Phillpotts try { // make sure its in the document
921c9e8e47accb592cc0dcda4f6973aabc1935ceNeil Madden Y.log('getStyle: IE opacity filter not found; returning 1', 'warn', 'dom-style');
var current,