~lutostag/ubuntu/utopic/maas/1.5.2

« back to all changes in this revision

Viewing changes to src/maasserver/static/jslibs/yui/3.4.1/build/dom-style-ie/dom-style-ie.js

  • Committer: Package Import Robot
  • Author(s): Andres Rodriguez
  • Date: 2012-03-15 18:14:08 UTC
  • mfrom: (1.1.3)
  • Revision ID: package-import@ubuntu.com-20120315181408-zgl94hzo0x4n99an
Tags: 0.1+bzr295+dfsg-0ubuntu2
* debian/patches:
  - 01-fix-database-settings.patch: Update to set PSERV_URL.
  - 02-pserv-config.patch: Set port to 8001.
* debian/maas.postinst: Run maas-import-isos on install.
* debian/control: Depends on rabbitmq-server.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
YUI 3.4.1 (build 4118)
 
3
Copyright 2011 Yahoo! Inc. All rights reserved.
 
4
Licensed under the BSD License.
 
5
http://yuilibrary.com/license/
 
6
*/
 
7
YUI.add('dom-style-ie', function(Y) {
 
8
 
 
9
(function(Y) {
 
10
var HAS_LAYOUT = 'hasLayout',
 
11
    PX = 'px',
 
12
    FILTER = 'filter',
 
13
    FILTERS = 'filters',
 
14
    OPACITY = 'opacity',
 
15
    AUTO = 'auto',
 
16
 
 
17
    BORDER_WIDTH = 'borderWidth',
 
18
    BORDER_TOP_WIDTH = 'borderTopWidth',
 
19
    BORDER_RIGHT_WIDTH = 'borderRightWidth',
 
20
    BORDER_BOTTOM_WIDTH = 'borderBottomWidth',
 
21
    BORDER_LEFT_WIDTH = 'borderLeftWidth',
 
22
    WIDTH = 'width',
 
23
    HEIGHT = 'height',
 
24
    TRANSPARENT = 'transparent',
 
25
    VISIBLE = 'visible',
 
26
    GET_COMPUTED_STYLE = 'getComputedStyle',
 
27
    UNDEFINED = undefined,
 
28
    documentElement = Y.config.doc.documentElement,
 
29
 
 
30
    testFeature = Y.Features.test,
 
31
    addFeature = Y.Features.add,
 
32
 
 
33
    // TODO: unit-less lineHeight (e.g. 1.22)
 
34
    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,
 
35
 
 
36
    isIE8 = (Y.UA.ie >= 8),
 
37
 
 
38
    _getStyleObj = function(node) {
 
39
        return node.currentStyle || node.style;
 
40
    },
 
41
 
 
42
    ComputedStyle = {
 
43
        CUSTOM_STYLES: {},
 
44
 
 
45
        get: function(el, property) {
 
46
            var value = '',
 
47
                current;
 
48
 
 
49
            if (el) {
 
50
                    current = _getStyleObj(el)[property];
 
51
 
 
52
                if (property === OPACITY && Y.DOM.CUSTOM_STYLES[OPACITY]) {
 
53
                    value = Y.DOM.CUSTOM_STYLES[OPACITY].get(el);        
 
54
                } else if (!current || (current.indexOf && current.indexOf(PX) > -1)) { // no need to convert
 
55
                    value = current;
 
56
                } else if (Y.DOM.IE.COMPUTED[property]) { // use compute function
 
57
                    value = Y.DOM.IE.COMPUTED[property](el, property);
 
58
                } else if (re_unit.test(current)) { // convert to pixel
 
59
                    value = ComputedStyle.getPixel(el, property) + PX;
 
60
                } else {
 
61
                    value = current;
 
62
                }
 
63
            }
 
64
 
 
65
            return value;
 
66
        },
 
67
 
 
68
        sizeOffsets: {
 
69
            width: ['Left', 'Right'],
 
70
            height: ['Top', 'Bottom'],
 
71
            top: ['Top'],
 
72
            bottom: ['Bottom']
 
73
        },
 
74
 
 
75
        getOffset: function(el, prop) {
 
76
            var current = _getStyleObj(el)[prop],                     // value of "width", "top", etc.
 
77
                capped = prop.charAt(0).toUpperCase() + prop.substr(1), // "Width", "Top", etc.
 
78
                offset = 'offset' + capped,                             // "offsetWidth", "offsetTop", etc.
 
79
                pixel = 'pixel' + capped,                               // "pixelWidth", "pixelTop", etc.
 
80
                sizeOffsets = ComputedStyle.sizeOffsets[prop], 
 
81
                mode = el.ownerDocument.compatMode,
 
82
                value = '';
 
83
 
 
84
            // IE pixelWidth incorrect for percent
 
85
            // manually compute by subtracting padding and border from offset size
 
86
            // NOTE: clientWidth/Height (size minus border) is 0 when current === AUTO so offsetHeight is used
 
87
            // reverting to auto from auto causes position stacking issues (old impl)
 
88
            if (current === AUTO || current.indexOf('%') > -1) {
 
89
                value = el['offset' + capped];
 
90
 
 
91
                if (mode !== 'BackCompat') {
 
92
                    if (sizeOffsets[0]) {
 
93
                        value -= ComputedStyle.getPixel(el, 'padding' + sizeOffsets[0]);
 
94
                        value -= ComputedStyle.getBorderWidth(el, 'border' + sizeOffsets[0] + 'Width', 1);
 
95
                    }
 
96
 
 
97
                    if (sizeOffsets[1]) {
 
98
                        value -= ComputedStyle.getPixel(el, 'padding' + sizeOffsets[1]);
 
99
                        value -= ComputedStyle.getBorderWidth(el, 'border' + sizeOffsets[1] + 'Width', 1);
 
100
                    }
 
101
                }
 
102
 
 
103
            } else { // use style.pixelWidth, etc. to convert to pixels
 
104
                // need to map style.width to currentStyle (no currentStyle.pixelWidth)
 
105
                if (!el.style[pixel] && !el.style[prop]) {
 
106
                    el.style[prop] = current;
 
107
                }
 
108
                value = el.style[pixel];
 
109
                
 
110
            }
 
111
            return value + PX;
 
112
        },
 
113
 
 
114
        borderMap: {
 
115
            thin: (isIE8) ? '1px' : '2px',
 
116
            medium: (isIE8) ? '3px': '4px', 
 
117
            thick: (isIE8) ? '5px' : '6px'
 
118
        },
 
119
 
 
120
        getBorderWidth: function(el, property, omitUnit) {
 
121
            var unit = omitUnit ? '' : PX,
 
122
                current = el.currentStyle[property];
 
123
 
 
124
            if (current.indexOf(PX) < 0) { // look up keywords if a border exists
 
125
                if (ComputedStyle.borderMap[current] &&
 
126
                        el.currentStyle.borderStyle !== 'none') {
 
127
                    current = ComputedStyle.borderMap[current];
 
128
                } else { // otherwise no border (default is "medium")
 
129
                    current = 0;
 
130
                }
 
131
            }
 
132
            return (omitUnit) ? parseFloat(current) : current;
 
133
        },
 
134
 
 
135
        getPixel: function(node, att) {
 
136
            // use pixelRight to convert to px
 
137
            var val = null,
 
138
                style = _getStyleObj(node),
 
139
                styleRight = style.right,
 
140
                current = style[att];
 
141
 
 
142
            node.style.right = current;
 
143
            val = node.style.pixelRight;
 
144
            node.style.right = styleRight; // revert
 
145
 
 
146
            return val;
 
147
        },
 
148
 
 
149
        getMargin: function(node, att) {
 
150
            var val,
 
151
                style = _getStyleObj(node);
 
152
 
 
153
            if (style[att] == AUTO) {
 
154
                val = 0;
 
155
            } else {
 
156
                val = ComputedStyle.getPixel(node, att);
 
157
            }
 
158
            return val + PX;
 
159
        },
 
160
 
 
161
        getVisibility: function(node, att) {
 
162
            var current;
 
163
            while ( (current = node.currentStyle) && current[att] == 'inherit') { // NOTE: assignment in test
 
164
                node = node.parentNode;
 
165
            }
 
166
            return (current) ? current[att] : VISIBLE;
 
167
        },
 
168
 
 
169
        getColor: function(node, att) {
 
170
            var current = _getStyleObj(node)[att];
 
171
 
 
172
            if (!current || current === TRANSPARENT) {
 
173
                Y.DOM.elementByAxis(node, 'parentNode', null, function(parent) {
 
174
                    current = _getStyleObj(parent)[att];
 
175
                    if (current && current !== TRANSPARENT) {
 
176
                        node = parent;
 
177
                        return true;
 
178
                    }
 
179
                });
 
180
            }
 
181
 
 
182
            return Y.Color.toRGB(current);
 
183
        },
 
184
 
 
185
        getBorderColor: function(node, att) {
 
186
            var current = _getStyleObj(node),
 
187
                val = current[att] || current.color;
 
188
            return Y.Color.toRGB(Y.Color.toHex(val));
 
189
        }
 
190
    },
 
191
 
 
192
    //fontSize: getPixelFont,
 
193
    IEComputed = {};
 
194
 
 
195
addFeature('style', 'computedStyle', {
 
196
    test: function() {
 
197
        return 'getComputedStyle' in Y.config.win;
 
198
    }
 
199
});
 
200
 
 
201
addFeature('style', 'opacity', {
 
202
    test: function() {
 
203
        return 'opacity' in documentElement.style;
 
204
    }
 
205
});
 
206
 
 
207
addFeature('style', 'filter', {
 
208
    test: function() {
 
209
        return 'filters' in documentElement;
 
210
    }
 
211
});
 
212
 
 
213
// use alpha filter for IE opacity
 
214
if (!testFeature('style', 'opacity') && testFeature('style', 'filter')) {
 
215
    Y.DOM.CUSTOM_STYLES[OPACITY] = {
 
216
        get: function(node) {
 
217
            var val = 100;
 
218
            try { // will error if no DXImageTransform
 
219
                val = node[FILTERS]['DXImageTransform.Microsoft.Alpha'][OPACITY];
 
220
 
 
221
            } catch(e) {
 
222
                try { // make sure its in the document
 
223
                    val = node[FILTERS]('alpha')[OPACITY];
 
224
                } catch(err) {
 
225
                }
 
226
            }
 
227
            return val / 100;
 
228
        },
 
229
 
 
230
        set: function(node, val, style) {
 
231
            var current,
 
232
                styleObj = _getStyleObj(node),
 
233
                currentFilter = styleObj[FILTER];
 
234
 
 
235
            style = style || node.style;
 
236
            if (val === '') { // normalize inline style behavior
 
237
                current = (OPACITY in styleObj) ? styleObj[OPACITY] : 1; // revert to original opacity
 
238
                val = current;
 
239
            }
 
240
 
 
241
            if (typeof currentFilter == 'string') { // in case not appended
 
242
                style[FILTER] = currentFilter.replace(/alpha([^)]*\))/gi, '') +
 
243
                        ((val < 1) ? 'alpha(' + OPACITY + '=' + val * 100 + ')' : '');
 
244
 
 
245
                if (!style[FILTER]) {
 
246
                    style.removeAttribute(FILTER);
 
247
                }
 
248
 
 
249
                if (!styleObj[HAS_LAYOUT]) {
 
250
                    style.zoom = 1; // needs layout 
 
251
                }
 
252
            }
 
253
        }
 
254
    };
 
255
}
 
256
 
 
257
try {
 
258
    Y.config.doc.createElement('div').style.height = '-1px';
 
259
} catch(e) { // IE throws error on invalid style set; trap common cases
 
260
    Y.DOM.CUSTOM_STYLES.height = {
 
261
        set: function(node, val, style) {
 
262
            var floatVal = parseFloat(val);
 
263
            if (floatVal >= 0 || val === 'auto' || val === '') {
 
264
                style.height = val;
 
265
            } else {
 
266
            }
 
267
        }
 
268
    };
 
269
 
 
270
    Y.DOM.CUSTOM_STYLES.width = {
 
271
        set: function(node, val, style) {
 
272
            var floatVal = parseFloat(val);
 
273
            if (floatVal >= 0 || val === 'auto' || val === '') {
 
274
                style.width = val;
 
275
            } else {
 
276
            }
 
277
        }
 
278
    };
 
279
}
 
280
 
 
281
if (!testFeature('style', 'computedStyle')) {
 
282
    // TODO: top, right, bottom, left
 
283
    IEComputed[WIDTH] = IEComputed[HEIGHT] = ComputedStyle.getOffset;
 
284
 
 
285
    IEComputed.color = IEComputed.backgroundColor = ComputedStyle.getColor;
 
286
 
 
287
    IEComputed[BORDER_WIDTH] = IEComputed[BORDER_TOP_WIDTH] = IEComputed[BORDER_RIGHT_WIDTH] =
 
288
            IEComputed[BORDER_BOTTOM_WIDTH] = IEComputed[BORDER_LEFT_WIDTH] =
 
289
            ComputedStyle.getBorderWidth;
 
290
 
 
291
    IEComputed.marginTop = IEComputed.marginRight = IEComputed.marginBottom =
 
292
            IEComputed.marginLeft = ComputedStyle.getMargin;
 
293
 
 
294
    IEComputed.visibility = ComputedStyle.getVisibility;
 
295
    IEComputed.borderColor = IEComputed.borderTopColor =
 
296
            IEComputed.borderRightColor = IEComputed.borderBottomColor =
 
297
            IEComputed.borderLeftColor = ComputedStyle.getBorderColor;
 
298
 
 
299
    Y.DOM[GET_COMPUTED_STYLE] = ComputedStyle.get; 
 
300
 
 
301
    Y.namespace('DOM.IE');
 
302
    Y.DOM.IE.COMPUTED = IEComputed;
 
303
    Y.DOM.IE.ComputedStyle = ComputedStyle;
 
304
}
 
305
 
 
306
})(Y);
 
307
 
 
308
 
 
309
}, '3.4.1' ,{requires:['dom-style']});