Blame view

bower_components/jquery/src/css/support.js 3.81 KB
a1a3bc73   Luigi Serra   graphs updates
1
  define( [
74249687   Luigi Serra   Cross browser con...
2
  	"../core",
a1a3bc73   Luigi Serra   graphs updates
3
4
  	"../var/document",
  	"../var/documentElement",
74249687   Luigi Serra   Cross browser con...
5
  	"../var/support"
a1a3bc73   Luigi Serra   graphs updates
6
  ], function( jQuery, document, documentElement, support ) {
74249687   Luigi Serra   Cross browser con...
7
  
a1a3bc73   Luigi Serra   graphs updates
8
9
  ( function() {
  	var pixelPositionVal, boxSizingReliableVal, pixelMarginRightVal, reliableMarginLeftVal,
74249687   Luigi Serra   Cross browser con...
10
11
12
  		container = document.createElement( "div" ),
  		div = document.createElement( "div" );
  
a1a3bc73   Luigi Serra   graphs updates
13
  	// Finish early in limited (non-browser) environments
74249687   Luigi Serra   Cross browser con...
14
15
16
17
18
19
20
21
22
23
  	if ( !div.style ) {
  		return;
  	}
  
  	// Support: IE9-11+
  	// Style of cloned element affects source element cloned (#8908)
  	div.style.backgroundClip = "content-box";
  	div.cloneNode( true ).style.backgroundClip = "";
  	support.clearCloneStyle = div.style.backgroundClip === "content-box";
  
a1a3bc73   Luigi Serra   graphs updates
24
25
  	container.style.cssText = "border:0;width:8px;height:0;top:0;left:-9999px;" +
  		"padding:0;margin-top:1px;position:absolute";
74249687   Luigi Serra   Cross browser con...
26
27
28
29
  	container.appendChild( div );
  
  	// Executing both pixelPosition & boxSizingReliable tests require only one layout
  	// so they're executed at the same time to save the second computation.
a1a3bc73   Luigi Serra   graphs updates
30
  	function computeStyleTests() {
74249687   Luigi Serra   Cross browser con...
31
  		div.style.cssText =
a1a3bc73   Luigi Serra   graphs updates
32
  
74249687   Luigi Serra   Cross browser con...
33
34
  			// Support: Firefox<29, Android 2.3
  			// Vendor-prefix box-sizing
a1a3bc73   Luigi Serra   graphs updates
35
36
37
38
  			"-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;" +
  			"position:relative;display:block;" +
  			"margin:auto;border:1px;padding:1px;" +
  			"top:1%;width:50%";
74249687   Luigi Serra   Cross browser con...
39
  		div.innerHTML = "";
a1a3bc73   Luigi Serra   graphs updates
40
  		documentElement.appendChild( container );
74249687   Luigi Serra   Cross browser con...
41
  
a1a3bc73   Luigi Serra   graphs updates
42
  		var divStyle = window.getComputedStyle( div );
74249687   Luigi Serra   Cross browser con...
43
  		pixelPositionVal = divStyle.top !== "1%";
a1a3bc73   Luigi Serra   graphs updates
44
  		reliableMarginLeftVal = divStyle.marginLeft === "2px";
74249687   Luigi Serra   Cross browser con...
45
46
  		boxSizingReliableVal = divStyle.width === "4px";
  
a1a3bc73   Luigi Serra   graphs updates
47
48
49
50
51
52
  		// Support: Android 4.0 - 4.3 only
  		// Some styles come back with percentage values, even though they shouldn't
  		div.style.marginRight = "50%";
  		pixelMarginRightVal = divStyle.marginRight === "4px";
  
  		documentElement.removeChild( container );
74249687   Luigi Serra   Cross browser con...
53
54
  	}
  
a1a3bc73   Luigi Serra   graphs updates
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
  	jQuery.extend( support, {
  		pixelPosition: function() {
  
  			// This test is executed only once but we still do memoizing
  			// since we can use the boxSizingReliable pre-computing.
  			// No need to check if the test was already performed, though.
  			computeStyleTests();
  			return pixelPositionVal;
  		},
  		boxSizingReliable: function() {
  			if ( boxSizingReliableVal == null ) {
  				computeStyleTests();
  			}
  			return boxSizingReliableVal;
  		},
  		pixelMarginRight: function() {
  
  			// Support: Android 4.0-4.3
  			// We're checking for boxSizingReliableVal here instead of pixelMarginRightVal
  			// since that compresses better and they're computed together anyway.
  			if ( boxSizingReliableVal == null ) {
  				computeStyleTests();
  			}
  			return pixelMarginRightVal;
  		},
  		reliableMarginLeft: function() {
74249687   Luigi Serra   Cross browser con...
81
  
a1a3bc73   Luigi Serra   graphs updates
82
83
84
  			// Support: IE <=8 only, Android 4.0 - 4.3 only, Firefox <=3 - 37
  			if ( boxSizingReliableVal == null ) {
  				computeStyleTests();
74249687   Luigi Serra   Cross browser con...
85
  			}
a1a3bc73   Luigi Serra   graphs updates
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
  			return reliableMarginLeftVal;
  		},
  		reliableMarginRight: function() {
  
  			// Support: Android 2.3
  			// Check if div with explicit width and no margin-right incorrectly
  			// gets computed margin-right based on width of container. (#3333)
  			// WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right
  			// This support function is only executed once so no memoizing is needed.
  			var ret,
  				marginDiv = div.appendChild( document.createElement( "div" ) );
  
  			// Reset CSS: box-sizing; display; margin; border; padding
  			marginDiv.style.cssText = div.style.cssText =
  
  				// Support: Android 2.3
  				// Vendor-prefix box-sizing
  				"-webkit-box-sizing:content-box;box-sizing:content-box;" +
  				"display:block;margin:0;border:0;padding:0";
  			marginDiv.style.marginRight = marginDiv.style.width = "0";
  			div.style.width = "1px";
  			documentElement.appendChild( container );
  
  			ret = !parseFloat( window.getComputedStyle( marginDiv ).marginRight );
  
  			documentElement.removeChild( container );
  			div.removeChild( marginDiv );
  
  			return ret;
  		}
  	} );
  } )();
74249687   Luigi Serra   Cross browser con...
118
119
120
  
  return support;
  
a1a3bc73   Luigi Serra   graphs updates
121
  } );