moved the IE test to support.js, added a workaround to the listview refresh method to prevent default on mousedown, which makes the tap highlight color look right in Windows Phone 7. Without this workaround, it still works fine, but the entire listview is highlighted when an LI is clicked.

This commit is contained in:
scottjehl 2011-03-13 17:01:51 -04:00
parent 4596769b5e
commit d3a170db09
3 changed files with 24 additions and 11 deletions

View file

@ -53,17 +53,9 @@
metaViewportContent: "width=device-width, minimum-scale=1, maximum-scale=1",
//support conditions that must be met in order to proceed
gradeA: function(){
//non-UA-based IE version check by James Padolsey, modified by jdalton - from http://gist.github.com/527683
//allows for inclusion of IE 6+, including Windows Mobile 7
var ie = (function() {
var v = 3, div = document.createElement('div'), a = div.all || [];
while (div.innerHTML = '<!--[if gt IE '+(++v)+']><br><![endif]-->', a[0]);
return v > 4 ? v : !v;
}());
return $.support.mediaquery || ie && ie >= 6;
//default enhanced qualifications are media query support OR IE 6+
gradeA: function(){
return $.support.mediaquery || $.mobile.browser.ie && $.mobile.browser.ie >= 6;
},
//TODO might be useful upstream in jquery itself ?

View file

@ -116,6 +116,7 @@ $.widget( "mobile.listview", $.mobile.widget, {
return false;
}
});
},
_itemApply: function( $list, item ) {
@ -168,6 +169,16 @@ $.widget( "mobile.listview", $.mobile.widget, {
li.attr({ "role": "option", "tabindex": "-1" });
li.first().attr( "tabindex", "0" );
//workaround for Windows Phone 7 focus/active tap color
//without this, delegated events will highlight the whole list, rather than the LI
if( $.mobile.browser.ie && $.mobile.browser.ie <= 8 ){
li
.unbind( "mousedown.iefocus" )
.bind( "mousedown.iefocus", function(e){
e.preventDefault();
});
}
li.each(function( pos ) {
var item = $( this ),

View file

@ -46,6 +46,16 @@ function baseTagTest(){
return rebase.indexOf(fauxBase) === 0;
};
//non-UA-based IE version check by James Padolsey, modified by jdalton - from http://gist.github.com/527683
//allows for inclusion of IE 6+, including Windows Mobile 7
$.mobile.browser = {};
$.mobile.browser.ie = (function() {
var v = 3, div = document.createElement('div'), a = div.all || [];
while (div.innerHTML = '<!--[if gt IE '+(++v)+']><br><![endif]-->', a[0]);
return v > 4 ? v : !v;
}());
$.extend( $.support, {
orientation: "orientation" in window,
touch: "ontouchend" in document,