This repository has been archived by the owner on Oct 8, 2021. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Flipswitch: Transfer tabindex to "on" button and make input unfocusable
The "on" button must be an anchor for it to be focusable just like an input even when it does not have an explicitly set tabindex. Although the input becomes unfocusable, a focus handler that transfers focus to the "on" button is nevertheless attached to it in case third-party code focuses the input manually. Fixes gh-6955
- Loading branch information
Gabriel Schulhof
committed
Feb 6, 2014
1 parent
126432e
commit acea5f8
Showing
4 changed files
with
114 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* | ||
* mobile flipswitch unit tests | ||
*/ | ||
(function($){ | ||
|
||
var testFocusTransfer = function( element ) { | ||
expect( 1 ); | ||
$.testHelper.detailedEventCascade([ | ||
function() { | ||
element.focus(); | ||
}, | ||
{ | ||
focus: { | ||
src: element.siblings( "a" ), | ||
event: "focus.TransfersFocus1" | ||
} | ||
}, | ||
function( result ) { | ||
deepEqual( result.focus.timedOut, false, | ||
"'on' button received focus event" ); | ||
start(); | ||
} | ||
]); | ||
}; | ||
|
||
asyncTest( "select based flipswitch transfers focus to 'on' button", | ||
function() { | ||
testFocusTransfer( $( "#flip-select" ) ); | ||
}); | ||
|
||
asyncTest( "checkbox based flipswitch transfers focus to 'on' button", | ||
function() { | ||
testFocusTransfer( $( "#flip-checkbox" ) ); | ||
}); | ||
|
||
})( jQuery ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1"> | ||
<title>jQuery Mobile Button Test Suite</title> | ||
|
||
<script src="../../../external/requirejs/require.js"></script> | ||
<script src="../../../js/requirejs.config.js"></script> | ||
<script src="../../../js/jquery.tag.inserter.js"></script> | ||
<script src="../../jquery.setNameSpace.js"></script> | ||
<script src="../../../tests/jquery.testHelper.js"></script> | ||
|
||
|
||
<link rel="stylesheet" href="../../../css/themes/default/jquery.mobile.css"/> | ||
<link rel="stylesheet" href="../../../external/qunit/qunit.css"/> | ||
<script src="../../../external/qunit/qunit.js"></script> | ||
<script> | ||
$.testHelper.asyncLoad([ | ||
[ "widgets/page" ], | ||
[ | ||
"widgets/forms/flipswitch", | ||
], | ||
[ "jquery.mobile.init" ], | ||
[ | ||
"flipswitch_core.js" | ||
] | ||
]); | ||
</script> | ||
|
||
<script src="../../swarminject.js"></script> | ||
</head> | ||
<body> | ||
<div id="qunit"></div> | ||
|
||
<div data-nstest-role="page" data-nstest-theme="a"> | ||
<div data-nstest-role="content" data-nstest-theme="b"> | ||
<input type="checkbox" data-nstest-role="flipswitch" name="flip-checkbox" id="flip-checkbox"/> | ||
<select id="flip-select" name="flip-select" data-nstest-role="flipswitch"> | ||
<option>On</option> | ||
<option>Off</option> | ||
</select> | ||
</div> | ||
</div> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters