Skip to content

Fix -ms-filter calculations for jQuery UI 1.13 #612

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 21 additions & 5 deletions lib/themeroller.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,19 @@ function ThemeRoller( options ) {
// TODO: Remove `filter` style when dropping support for IE8 and earlier.
vars.opacityOverlayPerc = vars.opacityOverlay;
vars.opacityShadowPerc = vars.opacityShadow;
if ( semver.gte( this.jqueryUi.pkg.version, "1.10.0" ) ) {
if ( semver.lt( this.jqueryUi.pkg.version, "1.10.0" ) ) {

// For version >= 1.10.0, filter has its own separate line and variable name.
// 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 if ( semver.lt( this.jqueryUi.pkg.version, "1.13.0" ) ) {

// 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 @@ -143,10 +153,16 @@ function ThemeRoller( options ) {
vars.opacityShadow = opacityFix( vars.opacityShadow );
} else {

// For version < 1.10.0, opacity (w3c) and filter (IE) are combined into the same line.
// For version >=1.13.0, `-ms-filter` has its own separate line
// and variable name.
opacityFix = function( opacity ) {
return /* w3c */ ( opacity / 100 ).toString().replace( /^0\./, "." ) + /* IE */ ";filter:Alpha(Opacity=" + 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 );
}
Expand Down Expand Up @@ -210,7 +226,7 @@ function ThemeRoller( options ) {
if ( !this.name ) {

// Pick name based on theme gallery vs. our vars
themeGallery = require( "./themeroller-themegallery" )();
themeGallery = require( "./themeroller-themegallery" )( this.jqueryUi );
themeGallery.some( function( theme ) {
found = theme.isEqual( self );
if ( found ) {
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