Skip to content

Commit b464b1b

Browse files
author
scottjehl
committed
added a workaround for the selectmenu plugin's nativeMenu in Opera. Opera browsers improperly support opacity on select elements, either hiding the menu button but not its text (in Mini), or hiding the text but not the button. Either way, it makes our hidden-select trick look really bad, or unusable. This workaround adds a class to the select in Opera, and makes the native menu visible. In the case of a false positive, that's not a bad outcome. Fixes jquery-archive#897
1 parent 110ba9e commit b464b1b

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

js/jquery.mobile.forms.select.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,14 @@ $.widget( "mobile.selectmenu", $.mobile.widget, {
5555

5656
//multi select or not
5757
isMultiple = self.isMultiple = select[0].multiple;
58+
59+
//Opera does not properly support opacity on select elements
60+
//In Mini, it hides the element, but not its text
61+
//On the desktop,it seems to do the opposite
62+
//for these reasons, using the nativeMenu option results in a full native select in Opera
63+
if( o.nativeMenu && window.opera && window.opera.version ){
64+
select.addClass( "ui-select-nativeonly" );
65+
}
5866

5967
//vars for non-native menus
6068
if( !o.nativeMenu ){

themes/default/jquery.mobile.forms.select.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
.ui-select { display: block; position: relative; }
77
.ui-select select { position: absolute; left: -9999px; top: -9999px; }
88
.ui-select .ui-btn select { cursor: pointer; -webkit-appearance: button; left: 0; top:0; width: 100%; height: 100%; opacity: 0.001; }
9+
.ui-select .ui-btn select.ui-select-nativeonly { opacity: 1; }
910

1011
.ui-select .ui-btn-icon-right .ui-btn-inner { padding-right: 45px; }
1112
.ui-select .ui-btn-icon-right .ui-icon { right: 15px; }

0 commit comments

Comments
 (0)