Skip to content
This repository has been archived by the owner on Jun 11, 2024. It is now read-only.

Commit

Permalink
Fix -ms-filter calculations for jQuery UI 1.13
Browse files Browse the repository at this point in the history
jQuery UI 1.13 uses `-ms-filter` which has to have its entire value put
in quotes.

Fixes jquery/jquery-ui/issues/2190
Closes gh-19
  • Loading branch information
mgol authored Apr 21, 2024
1 parent af35252 commit cc474ee
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
23 changes: 20 additions & 3 deletions lib/themeroller.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,16 +98,18 @@ function ThemeRoller( baseThemeCss, vars, options ) {
vars.opacityShadowPerc = vars.opacityShadow;
if ( options.version && semver.lt( options.version, "1.10.0" ) ) {

// For version < 1.10.0, opacity (w3c) and filter (IE) are combined into the same line.
// For version <1.10.0, `opacity` (W3C) and `filter` (IE) are combined
// into the same line.
opacityFix = function( opacity ) {
return /* w3c */ ( opacity / 100 ).toString().replace( /^0\./, "." ) + /* IE */ ";filter:Alpha(Opacity=" + opacity + ")";
};
vars.opacityOverlay = opacityFix( vars.opacityOverlay );
vars.opacityShadow = opacityFix( vars.opacityShadow );

} else {
} else if ( options.version && semver.lt( options.version, "1.13.0" ) ) {

// For version >= 1.10.0, filter has its own separate line and variable name.
// For version >=1.10.0 <1.13.0, `filter` has its own separate line
// and variable name.
opacityFix = function( opacity ) {
return ( opacity / 100 ).toString().replace( /^0\./, "." );
};
Expand All @@ -118,6 +120,21 @@ function ThemeRoller( baseThemeCss, vars, options ) {
vars.opacityFilterShadow = opacityFilter( vars.opacityShadow );
vars.opacityOverlay = opacityFix( vars.opacityOverlay );
vars.opacityShadow = opacityFix( vars.opacityShadow );

} else {

// For version >=1.13.0, `-ms-filter` has its own separate line
// and variable name.
opacityFix = function( opacity ) {
return ( opacity / 100 ).toString().replace( /^0\./, "." );
};
opacityFilter = function( opacity ) {
return "\"alpha(opacity=" + opacity + ")\"";
};
vars.opacityFilterOverlay = opacityFilter( vars.opacityOverlay );
vars.opacityFilterShadow = opacityFilter( vars.opacityShadow );
vars.opacityOverlay = opacityFix( vars.opacityOverlay );
vars.opacityShadow = opacityFix( vars.opacityShadow );
}

// Add '#' in the beginning of the colors if needed
Expand Down
2 changes: 1 addition & 1 deletion test/fixtures/jquery-ui-1.13.2/themes/smoothness.css
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,7 @@ a.ui-button:active,
.ui-widget-overlay {
background: #aaaaaa;
opacity: .3;
-ms-filter: Alpha(Opacity=30); /* support: IE8 */
-ms-filter: "alpha(opacity=30)"; /* support: IE8 */
}
.ui-widget-shadow {
-webkit-box-shadow: -8px -8px 8px #aaaaaa;
Expand Down

0 comments on commit cc474ee

Please sign in to comment.