76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav GlassYUI.add('dom-style-ie', function(Y) {
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass(function(Y) {
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glassvar HAS_LAYOUT = 'hasLayout',
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass PX = 'px',
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass FILTER = 'filter',
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass FILTERS = 'filters',
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass OPACITY = 'opacity',
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass AUTO = 'auto',
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass BORDER_WIDTH = 'borderWidth',
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass BORDER_TOP_WIDTH = 'borderTopWidth',
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass BORDER_RIGHT_WIDTH = 'borderRightWidth',
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass BORDER_BOTTOM_WIDTH = 'borderBottomWidth',
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass BORDER_LEFT_WIDTH = 'borderLeftWidth',
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass WIDTH = 'width',
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass HEIGHT = 'height',
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass TRANSPARENT = 'transparent',
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass VISIBLE = 'visible',
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass GET_COMPUTED_STYLE = 'getComputedStyle',
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass UNDEFINED = undefined,
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass documentElement = Y.config.doc.documentElement,
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass testFeature = Y.Features.test,
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass addFeature = Y.Features.add,
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass // TODO: unit-less lineHeight (e.g. 1.22)
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass 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,
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass isIE8 = (Y.UA.ie >= 8),
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass _getStyleObj = function(node) {
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass return node.currentStyle || node.style;
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass },
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass ComputedStyle = {
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass CUSTOM_STYLES: {},
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass get: function(el, property) {
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass var value = '',
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass current;
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass if (el) {
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass current = _getStyleObj(el)[property];
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass if (property === OPACITY && Y.DOM.CUSTOM_STYLES[OPACITY]) {
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass value = Y.DOM.CUSTOM_STYLES[OPACITY].get(el);
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass } else if (!current || (current.indexOf && current.indexOf(PX) > -1)) { // no need to convert
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass value = current;
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass } else if (Y.DOM.IE.COMPUTED[property]) { // use compute function
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass value = Y.DOM.IE.COMPUTED[property](el, property);
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass } else if (re_unit.test(current)) { // convert to pixel
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass value = ComputedStyle.getPixel(el, property) + PX;
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass } else {
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass value = current;
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass }
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass }
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass return value;
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass },
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass sizeOffsets: {
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass width: ['Left', 'Right'],
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass height: ['Top', 'Bottom'],
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass top: ['Top'],
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass bottom: ['Bottom']
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass },
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass getOffset: function(el, prop) {
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass var current = _getStyleObj(el)[prop], // value of "width", "top", etc.
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass capped = prop.charAt(0).toUpperCase() + prop.substr(1), // "Width", "Top", etc.
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass offset = 'offset' + capped, // "offsetWidth", "offsetTop", etc.
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass pixel = 'pixel' + capped, // "pixelWidth", "pixelTop", etc.
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass sizeOffsets = ComputedStyle.sizeOffsets[prop],
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass mode = el.ownerDocument.compatMode,
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass value = '';
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass // IE pixelWidth incorrect for percent
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass // manually compute by subtracting padding and border from offset size
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass // NOTE: clientWidth/Height (size minus border) is 0 when current === AUTO so offsetHeight is used
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass // reverting to auto from auto causes position stacking issues (old impl)
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass if (current === AUTO || current.indexOf('%') > -1) {
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass value = el['offset' + capped];
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass if (mode !== 'BackCompat') {
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass if (sizeOffsets[0]) {
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass value -= ComputedStyle.getPixel(el, 'padding' + sizeOffsets[0]);
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass value -= ComputedStyle.getBorderWidth(el, 'border' + sizeOffsets[0] + 'Width', 1);
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass }
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass if (sizeOffsets[1]) {
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass value -= ComputedStyle.getPixel(el, 'padding' + sizeOffsets[1]);
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass value -= ComputedStyle.getBorderWidth(el, 'border' + sizeOffsets[1] + 'Width', 1);
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass }
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass }
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass } else { // use style.pixelWidth, etc. to convert to pixels
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass // need to map style.width to currentStyle (no currentStyle.pixelWidth)
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass if (!el.style[pixel] && !el.style[prop]) {
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass el.style[prop] = current;
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass }
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass value = el.style[pixel];
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass }
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass return value + PX;
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass },
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass borderMap: {
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass thin: (isIE8) ? '1px' : '2px',
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass medium: (isIE8) ? '3px': '4px',
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass thick: (isIE8) ? '5px' : '6px'
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass },
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass getBorderWidth: function(el, property, omitUnit) {
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass var unit = omitUnit ? '' : PX,
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass current = el.currentStyle[property];
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass if (current.indexOf(PX) < 0) { // look up keywords if a border exists
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass if (ComputedStyle.borderMap[current] &&
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass el.currentStyle.borderStyle !== 'none') {
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass current = ComputedStyle.borderMap[current];
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass } else { // otherwise no border (default is "medium")
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass current = 0;
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass }
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass }
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass return (omitUnit) ? parseFloat(current) : current;
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass },
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass getPixel: function(node, att) {
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass // use pixelRight to convert to px
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass var val = null,
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass style = _getStyleObj(node),
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass styleRight = style.right,
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass current = style[att];
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass node.style.right = current;
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass val = node.style.pixelRight;
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass node.style.right = styleRight; // revert
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass return val;
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass },
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass getMargin: function(node, att) {
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass var val,
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass style = _getStyleObj(node);
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass if (style[att] == AUTO) {
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass val = 0;
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass } else {
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass val = ComputedStyle.getPixel(node, att);
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass }
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass return val + PX;
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass },
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass getVisibility: function(node, att) {
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass var current;
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass while ( (current = node.currentStyle) && current[att] == 'inherit') { // NOTE: assignment in test
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass node = node.parentNode;
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass }
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass return (current) ? current[att] : VISIBLE;
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass },
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass getColor: function(node, att) {
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass var current = _getStyleObj(node)[att];
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass if (!current || current === TRANSPARENT) {
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass Y.DOM.elementByAxis(node, 'parentNode', null, function(parent) {
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass current = _getStyleObj(parent)[att];
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass if (current && current !== TRANSPARENT) {
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass node = parent;
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass return true;
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass }
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass });
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass }
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass return Y.Color.toRGB(current);
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass },
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass getBorderColor: function(node, att) {
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass var current = _getStyleObj(node),
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass val = current[att] || current.color;
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass return Y.Color.toRGB(Y.Color.toHex(val));
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass }
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass },
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass //fontSize: getPixelFont,
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass IEComputed = {};
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav GlassaddFeature('style', 'computedStyle', {
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass test: function() {
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass return 'getComputedStyle' in Y.config.win;
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass }
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass});
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav GlassaddFeature('style', 'opacity', {
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass test: function() {
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass return 'opacity' in documentElement.style;
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass }
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass});
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav GlassaddFeature('style', 'filter', {
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass test: function() {
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass return 'filters' in documentElement;
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass }
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass});
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass// use alpha filter for IE opacity
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glassif (!testFeature('style', 'opacity') && testFeature('style', 'filter')) {
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass Y.DOM.CUSTOM_STYLES[OPACITY] = {
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass get: function(node) {
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass var val = 100;
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass try { // will error if no DXImageTransform
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass val = node[FILTERS]['DXImageTransform.Microsoft.Alpha'][OPACITY];
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass } catch(e) {
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass try { // make sure its in the document
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass val = node[FILTERS]('alpha')[OPACITY];
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass } catch(err) {
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass Y.log('getStyle: IE opacity filter not found; returning 1', 'warn', 'dom-style');
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass }
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass }
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass return val / 100;
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass },
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass set: function(node, val, style) {
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass var current,
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass styleObj = _getStyleObj(node),
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass currentFilter = styleObj[FILTER];
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass style = style || node.style;
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass if (val === '') { // normalize inline style behavior
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass current = (OPACITY in styleObj) ? styleObj[OPACITY] : 1; // revert to original opacity
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass val = current;
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass }
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass if (typeof currentFilter == 'string') { // in case not appended
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass style[FILTER] = currentFilter.replace(/alpha([^)]*\))/gi, '') +
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass ((val < 1) ? 'alpha(' + OPACITY + '=' + val * 100 + ')' : '');
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass if (!style[FILTER]) {
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass style.removeAttribute(FILTER);
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass }
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass if (!styleObj[HAS_LAYOUT]) {
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass style.zoom = 1; // needs layout
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass }
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass }
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass }
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass };
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass}
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glasstry {
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass Y.config.doc.createElement('div').style.height = '-1px';
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass} catch(e) { // IE throws error on invalid style set; trap common cases
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass Y.DOM.CUSTOM_STYLES.height = {
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass set: function(node, val, style) {
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass var floatVal = parseFloat(val);
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass if (floatVal >= 0 || val === 'auto' || val === '') {
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass style.height = val;
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass } else {
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass Y.log('invalid style value for height: ' + val, 'warn', 'dom-style');
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass }
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass }
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass };
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass Y.DOM.CUSTOM_STYLES.width = {
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass set: function(node, val, style) {
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass var floatVal = parseFloat(val);
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass if (floatVal >= 0 || val === 'auto' || val === '') {
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass style.width = val;
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass } else {
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass Y.log('invalid style value for width: ' + val, 'warn', 'dom-style');
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass }
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass }
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass };
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass}
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glassif (!testFeature('style', 'computedStyle')) {
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass // TODO: top, right, bottom, left
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass IEComputed[WIDTH] = IEComputed[HEIGHT] = ComputedStyle.getOffset;
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass IEComputed.color = IEComputed.backgroundColor = ComputedStyle.getColor;
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass IEComputed[BORDER_WIDTH] = IEComputed[BORDER_TOP_WIDTH] = IEComputed[BORDER_RIGHT_WIDTH] =
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass IEComputed[BORDER_BOTTOM_WIDTH] = IEComputed[BORDER_LEFT_WIDTH] =
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass ComputedStyle.getBorderWidth;
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass IEComputed.marginTop = IEComputed.marginRight = IEComputed.marginBottom =
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass IEComputed.marginLeft = ComputedStyle.getMargin;
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass IEComputed.visibility = ComputedStyle.getVisibility;
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass IEComputed.borderColor = IEComputed.borderTopColor =
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass IEComputed.borderRightColor = IEComputed.borderBottomColor =
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass IEComputed.borderLeftColor = ComputedStyle.getBorderColor;
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass Y.DOM[GET_COMPUTED_STYLE] = ComputedStyle.get;
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass Y.namespace('DOM.IE');
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass Y.DOM.IE.COMPUTED = IEComputed;
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass Y.DOM.IE.ComputedStyle = ComputedStyle;
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass}
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass})(Y);
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass}, '@VERSION@' ,{requires:['dom-style']});