| 1 | define( [
|
| 2 | "../core",
|
| 3 | "../var/document",
|
| 4 | "../var/documentElement",
|
| 5 | "../var/support"
|
| 6 | ], function( jQuery, document, documentElement, support ) {
|
| 7 |
|
| 8 | "use strict";
|
| 9 |
|
| 10 | ( function() {
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 | function computeStyleTests() {
|
| 15 |
|
| 16 |
|
| 17 | if ( !div ) {
|
| 18 | return;
|
| 19 | }
|
| 20 |
|
| 21 | container.style.cssText = "position:absolute;left:-11111px;width:60px;" +
|
| 22 | "margin-top:1px;padding:0;border:0";
|
| 23 | div.style.cssText =
|
| 24 | "position:relative;display:block;box-sizing:border-box;overflow:scroll;" +
|
| 25 | "margin:auto;border:1px;padding:1px;" +
|
| 26 | "width:60%;top:1%";
|
| 27 | documentElement.appendChild( container ).appendChild( div );
|
| 28 |
|
| 29 | var divStyle = window.getComputedStyle( div );
|
| 30 | pixelPositionVal = divStyle.top !== "1%";
|
| 31 |
|
| 32 |
|
| 33 | reliableMarginLeftVal = roundPixelMeasures( divStyle.marginLeft ) === 12;
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 | div.style.right = "60%";
|
| 38 | pixelBoxStylesVal = roundPixelMeasures( divStyle.right ) === 36;
|
| 39 |
|
| 40 |
|
| 41 |
|
| 42 | boxSizingReliableVal = roundPixelMeasures( divStyle.width ) === 36;
|
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
|
| 48 | div.style.position = "absolute";
|
| 49 | scrollboxSizeVal = roundPixelMeasures( div.offsetWidth / 3 ) === 12;
|
| 50 |
|
| 51 | documentElement.removeChild( container );
|
| 52 |
|
| 53 |
|
| 54 |
|
| 55 | div = null;
|
| 56 | }
|
| 57 |
|
| 58 | function roundPixelMeasures( measure ) {
|
| 59 | return Math.round( parseFloat( measure ) );
|
| 60 | }
|
| 61 |
|
| 62 | var pixelPositionVal, boxSizingReliableVal, scrollboxSizeVal, pixelBoxStylesVal,
|
| 63 | reliableTrDimensionsVal, reliableMarginLeftVal,
|
| 64 | container = document.createElement( "div" ),
|
| 65 | div = document.createElement( "div" );
|
| 66 |
|
| 67 |
|
| 68 | if ( !div.style ) {
|
| 69 | return;
|
| 70 | }
|
| 71 |
|
| 72 |
|
| 73 |
|
| 74 | div.style.backgroundClip = "content-box";
|
| 75 | div.cloneNode( true ).style.backgroundClip = "";
|
| 76 | support.clearCloneStyle = div.style.backgroundClip === "content-box";
|
| 77 |
|
| 78 | jQuery.extend( support, {
|
| 79 | boxSizingReliable: function() {
|
| 80 | computeStyleTests();
|
| 81 | return boxSizingReliableVal;
|
| 82 | },
|
| 83 | pixelBoxStyles: function() {
|
| 84 | computeStyleTests();
|
| 85 | return pixelBoxStylesVal;
|
| 86 | },
|
| 87 | pixelPosition: function() {
|
| 88 | computeStyleTests();
|
| 89 | return pixelPositionVal;
|
| 90 | },
|
| 91 | reliableMarginLeft: function() {
|
| 92 | computeStyleTests();
|
| 93 | return reliableMarginLeftVal;
|
| 94 | },
|
| 95 | scrollboxSize: function() {
|
| 96 | computeStyleTests();
|
| 97 | return scrollboxSizeVal;
|
| 98 | },
|
| 99 |
|
| 100 |
|
| 101 |
|
| 102 |
|
| 103 |
|
| 104 |
|
| 105 |
|
| 106 |
|
| 107 |
|
| 108 |
|
| 109 | reliableTrDimensions: function() {
|
| 110 | var table, tr, trChild, trStyle;
|
| 111 | if ( reliableTrDimensionsVal == null ) {
|
| 112 | table = document.createElement( "table" );
|
| 113 | tr = document.createElement( "tr" );
|
| 114 | trChild = document.createElement( "div" );
|
| 115 |
|
| 116 | table.style.cssText = "position:absolute;left:-11111px;border-collapse:separate";
|
| 117 | tr.style.cssText = "border:1px solid";
|
| 118 |
|
| 119 |
|
| 120 |
|
| 121 |
|
| 122 | tr.style.height = "1px";
|
| 123 | trChild.style.height = "9px";
|
| 124 |
|
| 125 |
|
| 126 |
|
| 127 |
|
| 128 |
|
| 129 |
|
| 130 |
|
| 131 | trChild.style.display = "block";
|
| 132 |
|
| 133 | documentElement
|
| 134 | .appendChild( table )
|
| 135 | .appendChild( tr )
|
| 136 | .appendChild( trChild );
|
| 137 |
|
| 138 | trStyle = window.getComputedStyle( tr );
|
| 139 | reliableTrDimensionsVal = ( parseInt( trStyle.height, 10 ) +
|
| 140 | parseInt( trStyle.borderTopWidth, 10 ) +
|
| 141 | parseInt( trStyle.borderBottomWidth, 10 ) ) === tr.offsetHeight;
|
| 142 |
|
| 143 | documentElement.removeChild( table );
|
| 144 | }
|
| 145 | return reliableTrDimensionsVal;
|
| 146 | }
|
| 147 | } );
|
| 148 | } )();
|
| 149 |
|
| 150 | return support;
|
| 151 |
|
| 152 | } );
|