Skip to content

Commit df71103

Browse files
authored
Fix -ms-filter calculations for jQuery UI 1.13
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-612
1 parent d225761 commit df71103

File tree

2 files changed

+22
-6
lines changed

2 files changed

+22
-6
lines changed

lib/themeroller.js

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -128,9 +128,19 @@ function ThemeRoller( options ) {
128128
// TODO: Remove `filter` style when dropping support for IE8 and earlier.
129129
vars.opacityOverlayPerc = vars.opacityOverlay;
130130
vars.opacityShadowPerc = vars.opacityShadow;
131-
if ( semver.gte( this.jqueryUi.pkg.version, "1.10.0" ) ) {
131+
if ( semver.lt( this.jqueryUi.pkg.version, "1.10.0" ) ) {
132132

133-
// For version >= 1.10.0, filter has its own separate line and variable name.
133+
// For version <1.10.0, `opacity` (W3C) and `filter` (IE) are combined
134+
// into the same line.
135+
opacityFix = function( opacity ) {
136+
return /* w3c */ ( opacity / 100 ).toString().replace( /^0\./, "." ) + /* IE */ ";filter:Alpha(Opacity=" + opacity + ")";
137+
};
138+
vars.opacityOverlay = opacityFix( vars.opacityOverlay );
139+
vars.opacityShadow = opacityFix( vars.opacityShadow );
140+
} else if ( semver.lt( this.jqueryUi.pkg.version, "1.13.0" ) ) {
141+
142+
// For version >=1.10.0 <1.13.0, `filter` has its own separate line
143+
// and variable name.
134144
opacityFix = function( opacity ) {
135145
return ( opacity / 100 ).toString().replace( /^0\./, "." );
136146
};
@@ -143,10 +153,16 @@ function ThemeRoller( options ) {
143153
vars.opacityShadow = opacityFix( vars.opacityShadow );
144154
} else {
145155

146-
// For version < 1.10.0, opacity (w3c) and filter (IE) are combined into the same line.
156+
// For version >=1.13.0, `-ms-filter` has its own separate line
157+
// and variable name.
147158
opacityFix = function( opacity ) {
148-
return /* w3c */ ( opacity / 100 ).toString().replace( /^0\./, "." ) + /* IE */ ";filter:Alpha(Opacity=" + opacity + ")";
159+
return ( opacity / 100 ).toString().replace( /^0\./, "." );
160+
};
161+
opacityFilter = function( opacity ) {
162+
return "\"alpha(opacity=" + opacity + ")\"";
149163
};
164+
vars.opacityFilterOverlay = opacityFilter( vars.opacityOverlay );
165+
vars.opacityFilterShadow = opacityFilter( vars.opacityShadow );
150166
vars.opacityOverlay = opacityFix( vars.opacityOverlay );
151167
vars.opacityShadow = opacityFix( vars.opacityShadow );
152168
}
@@ -210,7 +226,7 @@ function ThemeRoller( options ) {
210226
if ( !this.name ) {
211227

212228
// Pick name based on theme gallery vs. our vars
213-
themeGallery = require( "./themeroller-themegallery" )();
229+
themeGallery = require( "./themeroller-themegallery" )( this.jqueryUi );
214230
themeGallery.some( function( theme ) {
215231
found = theme.isEqual( self );
216232
if ( found ) {

test/fixtures/jquery-ui-1.13.2/themes/smoothness.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -438,7 +438,7 @@ a.ui-button:active,
438438
.ui-widget-overlay {
439439
background: #aaaaaa;
440440
opacity: .3;
441-
-ms-filter: Alpha(Opacity=30); /* support: IE8 */
441+
-ms-filter: "alpha(opacity=30)"; /* support: IE8 */
442442
}
443443
.ui-widget-shadow {
444444
-webkit-box-shadow: -8px -8px 8px #aaaaaa;

0 commit comments

Comments
 (0)