mirror of
https://github.com/Hopiu/jquery-mobile.git
synced 2026-04-26 17:14:42 +00:00
more flexible async loading helper, converted select test
This commit is contained in:
parent
797378b1af
commit
0e9868465a
2 changed files with 22 additions and 26 deletions
|
|
@ -4,32 +4,27 @@
|
|||
|
||||
(function( $ ) {
|
||||
$.testHelper = {
|
||||
asyncLoad: function( opts ) {
|
||||
var baseUrl = opts.baseUrl || "../../../js";
|
||||
// synchronously loads sets of asynchronous dependencies
|
||||
asyncLoad: function( seq ) {
|
||||
function loadSeq( seq, i ){
|
||||
if( !seq[i] ){
|
||||
QUnit.start();
|
||||
return;
|
||||
}
|
||||
|
||||
require({
|
||||
baseUrl: (seq[i][0].indexOf(".") > -1) ? "../../../js" : location.pathname
|
||||
});
|
||||
|
||||
require( seq[i], function() {
|
||||
loadSeq(seq, i + 1);
|
||||
});
|
||||
}
|
||||
|
||||
// stop qunit from running the tests until everything is in the page
|
||||
QUnit.config.autostart = false;
|
||||
|
||||
// set the baseUrl to the js dir or the default
|
||||
require({
|
||||
baseUrl: baseUrl
|
||||
});
|
||||
|
||||
// require the libs required to pass the test suite
|
||||
require( opts.libs, function() {
|
||||
|
||||
// init the mobile library
|
||||
require( ["jquery.mobile.init"], function() {
|
||||
|
||||
// reset the base dir to the current directory for including the test libs
|
||||
require({
|
||||
baseUrl: location.pathname
|
||||
});
|
||||
|
||||
// after everything is inplace start the test suite
|
||||
require( opts.testLibs, QUnit.start);
|
||||
});
|
||||
});
|
||||
loadSeq( seq, 0 );
|
||||
},
|
||||
|
||||
excludeFileProtocol: function(callback){
|
||||
|
|
|
|||
|
|
@ -11,18 +11,19 @@
|
|||
<script src="../../../tests/jquery.testHelper.js"></script>
|
||||
<script src="../../../external/require.js"></script>
|
||||
<script>
|
||||
$.testHelper.asyncLoad({
|
||||
libs: [
|
||||
$.testHelper.asyncLoad([
|
||||
[
|
||||
"jquery.mobile.forms.select",
|
||||
"jquery.mobile.forms.select.custom"
|
||||
],
|
||||
testLibs: [
|
||||
[ "jquery.mobile.init" ],
|
||||
[
|
||||
"select_events",
|
||||
"select_native",
|
||||
"select_cached",
|
||||
"select_core"
|
||||
]
|
||||
});
|
||||
]);
|
||||
</script>
|
||||
|
||||
<link rel="stylesheet" href="../../../css/themes/default/"/>
|
||||
|
|
|
|||
Loading…
Reference in a new issue