1
0
Fork 0
mirror of https://github.com/jellyfin/jellyfin-web synced 2025-03-30 19:56:21 +00:00
jellyfin-web/dashboard-ui/bower_components/jquery/src/css/support.js

122 lines
3.8 KiB
JavaScript
Raw Normal View History

2016-01-09 13:36:35 -05:00
define( [
2015-06-26 11:53:49 -04:00
"../core",
2016-01-09 13:36:35 -05:00
"../var/document",
"../var/documentElement",
2015-06-26 11:53:49 -04:00
"../var/support"
2016-01-09 13:36:35 -05:00
], function( jQuery, document, documentElement, support ) {
2015-06-26 11:53:49 -04:00
2016-01-09 13:36:35 -05:00
( function() {
var pixelPositionVal, boxSizingReliableVal, pixelMarginRightVal, reliableMarginLeftVal,
2015-06-26 11:53:49 -04:00
container = document.createElement( "div" ),
div = document.createElement( "div" );
2016-01-09 13:36:35 -05:00
// Finish early in limited (non-browser) environments
2015-06-26 11:53:49 -04:00
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";
2016-01-09 13:36:35 -05:00
container.style.cssText = "border:0;width:8px;height:0;top:0;left:-9999px;" +
"padding:0;margin-top:1px;position:absolute";
2015-06-26 11:53:49 -04:00
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.
2016-01-09 13:36:35 -05:00
function computeStyleTests() {
2015-06-26 11:53:49 -04:00
div.style.cssText =
2016-01-09 13:36:35 -05:00
2015-06-26 11:53:49 -04:00
// Support: Firefox<29, Android 2.3
// Vendor-prefix box-sizing
2016-01-09 13:36:35 -05:00
"-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%";
2015-06-26 11:53:49 -04:00
div.innerHTML = "";
2016-01-09 13:36:35 -05:00
documentElement.appendChild( container );
2015-06-26 11:53:49 -04:00
2016-01-09 13:36:35 -05:00
var divStyle = window.getComputedStyle( div );
2015-06-26 11:53:49 -04:00
pixelPositionVal = divStyle.top !== "1%";
2016-01-09 13:36:35 -05:00
reliableMarginLeftVal = divStyle.marginLeft === "2px";
2015-06-26 11:53:49 -04:00
boxSizingReliableVal = divStyle.width === "4px";
2016-01-09 13:36:35 -05:00
// 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 );
2015-06-26 11:53:49 -04:00
}
2016-01-09 13:36:35 -05:00
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() {
2015-06-26 11:53:49 -04:00
2016-01-09 13:36:35 -05:00
// Support: IE <=8 only, Android 4.0 - 4.3 only, Firefox <=3 - 37
if ( boxSizingReliableVal == null ) {
computeStyleTests();
2015-06-26 11:53:49 -04:00
}
2016-01-09 13:36:35 -05:00
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;
}
} );
} )();
2015-06-26 11:53:49 -04:00
return support;
2016-01-09 13:36:35 -05:00
} );