diff --git a/Makefile b/Makefile
index 8664353a..c90e9cba 100755
--- a/Makefile
+++ b/Makefile
@@ -31,7 +31,8 @@ FILES = js/jquery.ui.widget.js \
js/jquery.mobile.listview.filter.js \
js/jquery.mobile.dialog.js \
js/jquery.mobile.navbar.js \
- js/jquery.mobile.grid.js
+ js/jquery.mobile.grid.js \
+ js/jquery.mobile.init.js
CSSFILES = themes/default/jquery.mobile.theme.css \
themes/default/jquery.mobile.core.css \
diff --git a/build.xml b/build.xml
index 6a8d739d..e80b1e12 100644
--- a/build.xml
+++ b/build.xml
@@ -3,24 +3,23 @@
-
-
+
+
+
diff --git a/js/index.php b/js/index.php
index 7ad1442a..d6683c55 100644
--- a/js/index.php
+++ b/js/index.php
@@ -25,7 +25,8 @@ $elements = array(
'jquery.mobile.listview.filter.js',
'jquery.mobile.dialog.js',
'jquery.mobile.navbar.js',
- 'jquery.mobile.grid.js'
+ 'jquery.mobile.grid.js',
+ 'jquery.mobile.init.js'
);
include('../combine.php');
diff --git a/js/jquery.mobile.core.js b/js/jquery.mobile.core.js
index d233a05f..a1873c60 100644
--- a/js/jquery.mobile.core.js
+++ b/js/jquery.mobile.core.js
@@ -8,7 +8,6 @@
*/
(function( $, window, undefined ) {
-
//jQuery.mobile configurable options
$.extend( $.mobile, {
@@ -93,19 +92,6 @@
}
});
-
- //trigger mobileinit event - useful hook for configuring $.mobile settings before they're used
- $( window.document ).trigger( "mobileinit" );
-
-
- //support conditions
- //if device support condition(s) aren't met, leave things as they are -> a basic, usable experience,
- //otherwise, proceed with the enhancements
- if ( !$.mobile.gradeA() ) {
- return;
- }
-
-
//define vars for interal use
var $window = $(window),
$html = $( "html" ),
@@ -120,15 +106,6 @@
"" )
: undefined;
-
- //add mobile, initial load "rendering" classes to docEl
- $html.addClass( "ui-mobile ui-mobile-rendering" );
-
-
- //define & prepend meta viewport tag, if content is defined
- $.mobile.metaViewportContent ? $( "", { name: "viewport", content: $.mobile.metaViewportContent}).prependTo( $head ) : undefined;
-
-
//expose some core utilities
$.extend($.mobile, {
@@ -167,42 +144,6 @@
setTimeout(function() {
$.event.special.scrollstart.enabled = true;
}, 150 );
- },
-
- // find and enhance the pages in the dom and transition to the first page.
- initializePage: function(){
- //find present pages
- var $pages = $( "[data-role='page']" );
-
- //add dialogs, set data-url attrs
- $pages.add( "[data-role='dialog']" ).each(function(){
- $(this).attr( "data-url", $(this).attr( "id" ));
- });
-
- //define first page in dom case one backs out to the directory root (not always the first page visited, but defined as fallback)
- $.mobile.firstPage = $pages.first();
-
- //define page container
- $.mobile.pageContainer = $pages.first().parent().addClass( "ui-mobile-viewport" );
-
- //cue page loading message
- $.mobile.pageLoading();
-
- // if hashchange listening is disabled or there's no hash deeplink, change to the first page in the DOM
- if( !$.mobile.hashListeningEnabled || !$.mobile.path.stripHash( location.hash ) ){
- $.mobile.changePage( $.mobile.firstPage, false, true, false, true );
- }
- // otherwise, trigger a hashchange to load a deeplink
- else {
- $window.trigger( "hashchange", [ true ] );
- }
}
});
-
- //dom-ready inits
- $($.mobile.initializePage);
-
- //window load event
- //hide iOS browser chrome on load
- $window.load( $.mobile.silentScroll );
})( jQuery, this );
diff --git a/js/jquery.mobile.init.js b/js/jquery.mobile.init.js
new file mode 100644
index 00000000..500f52b5
--- /dev/null
+++ b/js/jquery.mobile.init.js
@@ -0,0 +1,68 @@
+/*!
+ * jQuery Mobile v@VERSION
+ * http://jquerymobile.com/
+ *
+ * Copyright 2010, jQuery Project
+ * Dual licensed under the MIT or GPL Version 2 licenses.
+ * http://jquery.org/license
+ */
+
+(function( $, window, undefined ) {
+ var $html = $( "html" ),
+ $head = $( "head" ),
+ $window = $( window );
+
+ $.extend($.mobile, {
+ // find and enhance the pages in the dom and transition to the first page.
+ initializePage: function(){
+ //find present pages
+ var $pages = $( "[data-role='page']" );
+
+ //add dialogs, set data-url attrs
+ $pages.add( "[data-role='dialog']" ).each(function(){
+ $(this).attr( "data-url", $(this).attr( "id" ));
+ });
+
+ //define first page in dom case one backs out to the directory root (not always the first page visited, but defined as fallback)
+ $.mobile.firstPage = $pages.first();
+
+ //define page container
+ $.mobile.pageContainer = $pages.first().parent().addClass( "ui-mobile-viewport" );
+
+ //cue page loading message
+ $.mobile.pageLoading();
+
+ // if hashchange listening is disabled or there's no hash deeplink, change to the first page in the DOM
+ if( !$.mobile.hashListeningEnabled || !$.mobile.path.stripHash( location.hash ) ){
+ $.mobile.changePage( $.mobile.firstPage, false, true, false, true );
+ }
+ // otherwise, trigger a hashchange to load a deeplink
+ else {
+ $window.trigger( "hashchange", [ true ] );
+ }
+ }
+ });
+
+ //trigger mobileinit event - useful hook for configuring $.mobile settings before they're used
+ $( window.document ).trigger( "mobileinit" );
+
+ //support conditions
+ //if device support condition(s) aren't met, leave things as they are -> a basic, usable experience,
+ //otherwise, proceed with the enhancements
+ if ( !$.mobile.gradeA() ) {
+ return;
+ }
+
+ //add mobile, initial load "rendering" classes to docEl
+ $html.addClass( "ui-mobile ui-mobile-rendering" );
+
+ //define & prepend meta viewport tag, if content is defined
+ $.mobile.metaViewportContent ? $( "", { name: "viewport", content: $.mobile.metaViewportContent}).prependTo( $head ) : undefined;
+
+ //dom-ready inits
+ $( $.mobile.initializePage );
+
+ //window load event
+ //hide iOS browser chrome on load
+ $window.load( $.mobile.silentScroll );
+})( jQuery, this );
diff --git a/tests/unit/core/core.js b/tests/unit/core/core.js
index 9a4f0aba..05034a5e 100644
--- a/tests/unit/core/core.js
+++ b/tests/unit/core/core.js
@@ -8,15 +8,11 @@
extendFn = $.extend;
module(libName, {
- setup: function(){
- // NOTE reset for gradeA tests
- $('html').removeClass('ui-mobile');
+ teardown: function(){
+ $.extend = extendFn;
// NOTE reset for pageLoading tests
$('.ui-loader').remove();
- },
- teardown: function(){
- $.extend = extendFn;
}
});
@@ -31,32 +27,6 @@
ok($.mobile.gradeA());
});
- test( "loading the core library triggers mobilinit on the document", function(){
- expect( 1 );
-
- $(window.document).bind('mobileinit', function(event){
- ok(true);
- });
-
- $.testHelper.reloadLib(libName);
- });
-
- test( "enhancments are skipped when the browser is not grade A", function(){
- setGradeA(false);
- $.testHelper.reloadLib(libName);
-
- //NOTE easiest way to check for enhancements, not the most obvious
- ok(!$("html").hasClass("ui-mobile"));
- });
-
- test( "enhancments are added when the browser is grade A", function(){
- setGradeA(true);
- $.testHelper.reloadLib(libName);
-
- ok($("html").hasClass("ui-mobile"));
- });
-
-
//TODO lots of duplication
test( "pageLoading doesn't add the dialog to the page when loading message is false", function(){
$.testHelper.alterExtend({loadingMessage: false});
@@ -81,69 +51,6 @@
$.testHelper.reloadLib(libName);
$.mobile.pageLoading(false);
ok($(".ui-loader").length);
- });
-
- var metaViewportSelector = "head meta[name=viewport]",
- setViewPortContent = function(value){
- $(metaViewportSelector).remove();
- $.testHelper.alterExtend({metaViewportContent: value});
- $.testHelper.reloadLib(libName);
- };
-
- test( "meta view port element is added to head when defined on mobile", function(){
- setViewPortContent("width=device-width");
- same($(metaViewportSelector).length, 1);
- });
-
- test( "meta view port element not added to head when not defined on mobile", function(){
- setViewPortContent(false);
- same($(metaViewportSelector).length, 0);
- });
-
- var findFirstPage = function() {
- return $("[data-role='page']").first();
- };
-
- test( "active page and start page should be set to the fist page in the selected set", function(){
- var firstPage = findFirstPage();
- $.testHelper.reloadLib(libName);
-
- same($.mobile.firstPage, firstPage);
- same($.mobile.activePage, firstPage);
- });
-
- test( "mobile viewport class is defined on the first page's parent", function(){
- var firstPage = findFirstPage();
- $.testHelper.reloadLib(libName);
-
- ok(firstPage.parent().hasClass('ui-mobile-viewport'));
- });
-
- test( "mobile page container is the first page's parent", function(){
- var firstPage = findFirstPage();
- $.testHelper.reloadLib(libName);
-
- same($.mobile.pageContainer, firstPage.parent());
- });
-
- test( "page loading is called on document ready", function(){
- $.testHelper.alterExtend({ pageLoading: function(){
- start();
- ok("called");
- }});
-
- stop();
- $.testHelper.reloadLib(libName);
- });
-
- test( "hashchange triggered on document ready with single argument: true", function(){
- $(window).bind("hashchange", function(ev, arg){
- same(arg, true);
- start();
- });
-
- stop();
- $.testHelper.reloadLib(libName);
});
});
})(jQuery);
\ No newline at end of file
diff --git a/tests/unit/core/core_mobileinit.js b/tests/unit/core/core_mobileinit.js
deleted file mode 100644
index 3a4b9506..00000000
--- a/tests/unit/core/core_mobileinit.js
+++ /dev/null
@@ -1,18 +0,0 @@
-/*
- * mobile core unit tests
- */
-
-(function($){
- var mobilePage = undefined;
- module('jquery.mobile.core.js');
-
- // NOTE important to use $.fn.one here to make sure library reloads don't fire
- // the event before the test check below
- $(document).one("mobileinit", function(){
- mobilePage = $.mobile.page;
- });
-
- test( "mobile.page is available when mobile init is fired", function(){
- ok(mobilePage !== undefined, "$.mobile.page is defined");
- });
-})(jQuery);
diff --git a/tests/unit/core/index.html b/tests/unit/core/index.html
index 60aeb509..c346223b 100644
--- a/tests/unit/core/index.html
+++ b/tests/unit/core/index.html
@@ -6,8 +6,8 @@
-
+
diff --git a/tests/unit/dialog/index.html b/tests/unit/dialog/index.html
index 79b62ebe..d0f51b1b 100644
--- a/tests/unit/dialog/index.html
+++ b/tests/unit/dialog/index.html
@@ -5,30 +5,7 @@
jQuery Mobile Dialog Test Suite
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
diff --git a/tests/unit/init/index.html b/tests/unit/init/index.html
new file mode 100644
index 00000000..27001694
--- /dev/null
+++ b/tests/unit/init/index.html
@@ -0,0 +1,32 @@
+
+
+
+
+ jQuery Mobile Init Test Suite
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/tests/unit/init/init_core.js b/tests/unit/init/init_core.js
new file mode 100644
index 00000000..4af57e19
--- /dev/null
+++ b/tests/unit/init/init_core.js
@@ -0,0 +1,125 @@
+/*
+ * mobile init tests
+ */
+
+(function($){
+ var mobilePage = undefined, mobileSelect = undefined,
+ libName = 'jquery.mobile.init.js',
+ setGradeA = function(value) { $.mobile.gradeA = function(){ return value; }; },
+ extendFn = $.extend;
+
+ module(libName, {
+ setup: function(){
+ // NOTE reset for gradeA tests
+ $('html').removeClass('ui-mobile');
+ },
+ teardown: function(){
+ $.extend = extendFn;
+ }
+ });
+
+ // NOTE important to use $.fn.one here to make sure library reloads don't fire
+ // the event before the test check below
+ $(document).one("mobileinit", function(){
+ mobilePage = $.mobile.page;
+ mobileSelect = $.mobile.selectmenu;
+ });
+
+ test( "mobile.page is available when mobile init is fired", function(){
+ ok(mobilePage !== undefined, "$.mobile.page is defined");
+ });
+
+ test( "mobile.selectmenu is available when mobile init is fired", function(){
+ ok(mobileSelect !== undefined, "$.mobile.selectmenu is defined");
+ });
+
+ $.testHelper.excludeFileProtocol(function(){
+ test( "loading the init library triggers mobilinit on the document", function(){
+ expect( 1 );
+
+ $(window.document).bind('mobileinit', function(event){
+ ok(true);
+ });
+
+ $.testHelper.reloadLib(libName);
+ });
+
+ test( "enhancments are skipped when the browser is not grade A", function(){
+ setGradeA(false);
+ $.testHelper.reloadLib(libName);
+
+ //NOTE easiest way to check for enhancements, not the most obvious
+ ok(!$("html").hasClass("ui-mobile"));
+ });
+
+ test( "enhancments are added when the browser is grade A", function(){
+ setGradeA(true);
+ $.testHelper.reloadLib(libName);
+
+ ok($("html").hasClass("ui-mobile"));
+ });
+
+ var metaViewportSelector = "head meta[name=viewport]",
+ setViewPortContent = function(value){
+ $(metaViewportSelector).remove();
+ $.mobile.metaViewportContent = value;
+ $.testHelper.reloadLib( libName );
+ };
+
+ test( "meta view port element not added to head when not defined on mobile", function(){
+ setViewPortContent(false);
+ same($(metaViewportSelector).length, 0);
+ });
+
+ test( "meta view port element is added to head when defined on mobile", function(){
+ setViewPortContent("width=device-width");
+ same($(metaViewportSelector).length, 1);
+ });
+
+ var findFirstPage = function() {
+ return $("[data-role='page']").first();
+ };
+
+ test( "active page and start page should be set to the fist page in the selected set", function(){
+ var firstPage = findFirstPage();
+ $.testHelper.reloadLib(libName);
+
+ same($.mobile.firstPage, firstPage);
+ same($.mobile.activePage, firstPage);
+ });
+
+ test( "mobile viewport class is defined on the first page's parent", function(){
+ var firstPage = findFirstPage();
+ $.testHelper.reloadLib(libName);
+
+ ok(firstPage.parent().hasClass('ui-mobile-viewport'));
+ });
+
+ test( "mobile page container is the first page's parent", function(){
+ var firstPage = findFirstPage();
+ $.testHelper.reloadLib(libName);
+
+ same($.mobile.pageContainer, firstPage.parent());
+ });
+
+ test( "page loading is called on document ready", function(){
+ $.testHelper.alterExtend({ pageLoading: function(){
+ start();
+ ok("called");
+ }});
+
+ stop();
+ $.testHelper.reloadLib(libName);
+ });
+
+ test( "hashchange triggered on document ready with single argument: true", function(){
+ $(window).bind("hashchange", function(ev, arg){
+ same(arg, true);
+ start();
+ });
+
+ stop();
+ $.testHelper.reloadLib(libName);
+ });
+ });
+})(jQuery);
diff --git a/tests/unit/navigation/index.html b/tests/unit/navigation/index.html
index 7870653c..44f9a100 100644
--- a/tests/unit/navigation/index.html
+++ b/tests/unit/navigation/index.html
@@ -5,30 +5,7 @@
jQuery Mobile Navigation Test Suite
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
diff --git a/tests/unit/page/index.html b/tests/unit/page/index.html
index 2a496cb9..e7dddc6a 100644
--- a/tests/unit/page/index.html
+++ b/tests/unit/page/index.html
@@ -5,30 +5,7 @@
jQuery Mobile Page Test Suite
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
diff --git a/tests/unit/select/index.html b/tests/unit/select/index.html
index cb6ba2cc..7a052285 100644
--- a/tests/unit/select/index.html
+++ b/tests/unit/select/index.html
@@ -5,30 +5,7 @@
jQuery Mobile Select Events Test Suite
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
diff --git a/tests/unit/slider/index.html b/tests/unit/slider/index.html
index cb4b7a21..06858f24 100644
--- a/tests/unit/slider/index.html
+++ b/tests/unit/slider/index.html
@@ -5,30 +5,7 @@
jQuery Mobile Slider Events Test Suite
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+