From 18b6e41f614a06d06118568c01e216ac2422915b Mon Sep 17 00:00:00 2001
From: Gabriel Schulhof
Date: Thu, 9 Oct 2014 09:14:37 +0300
Subject: [PATCH 1/3] Loader: Attach to body when no $.mobile.pageContainer
found
Fixes gh-7760
---
js/widgets/loader.js | 14 ++++++++++----
1 file changed, 10 insertions(+), 4 deletions(-)
diff --git a/js/widgets/loader.js b/js/widgets/loader.js
index dd5c501d26c..83c07a849e9 100644
--- a/js/widgets/loader.js
+++ b/js/widgets/loader.js
@@ -3,7 +3,11 @@
//>>label: Loading Message
//>>group: Widgets
-define( [ "jquery", "../core", "../widget" ], function( jQuery ) {
+define( [
+ "jquery",
+ "../helpers",
+ "../defaults",
+ "../widget" ], function( jQuery ) {
//>>excludeEnd("jqmBuildExclude");
(function( $ ) {
@@ -115,7 +119,9 @@ define( [ "jquery", "../core", "../widget" ], function( jQuery ) {
}
// attach the loader to the DOM
- this.element.appendTo( $.mobile.pageContainer );
+ this.element.appendTo(
+ ( $.mobile.pageContainer && $.mobile.pageContainer.length > 0 ) ?
+ $.mobile.pageContainer : $( "body" ) );
// check that the loader is visible
this.checkLoaderPosition();
@@ -131,8 +137,8 @@ define( [ "jquery", "../core", "../widget" ], function( jQuery ) {
this.element.removeClass( "ui-loader-fakefix" );
}
- $.mobile.window.unbind( "scroll", this.fakeFixLoader );
- $.mobile.window.unbind( "scroll", this.checkLoaderPosition );
+ this.window.unbind( "scroll", this.fakeFixLoader );
+ this.window.unbind( "scroll", this.checkLoaderPosition );
}
});
From bde66a30768bfdcdb6328b8e0eebae7e43adc961 Mon Sep 17 00:00:00 2001
From: Gabriel Schulhof
Date: Thu, 9 Oct 2014 09:21:47 +0300
Subject: [PATCH 2/3] Loader: Add individual unit test
Re gh-5987
---
.../unit/individual-modules/loader-tests.html | 36 +++++++++++++++++++
tests/unit/individual-modules/loader_core.js | 10 ++++++
2 files changed, 46 insertions(+)
create mode 100644 tests/unit/individual-modules/loader-tests.html
create mode 100644 tests/unit/individual-modules/loader_core.js
diff --git a/tests/unit/individual-modules/loader-tests.html b/tests/unit/individual-modules/loader-tests.html
new file mode 100644
index 00000000000..1fd78df841c
--- /dev/null
+++ b/tests/unit/individual-modules/loader-tests.html
@@ -0,0 +1,36 @@
+
+
+
+
+
+ jQuery Mobile Loader Test Suite
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/tests/unit/individual-modules/loader_core.js b/tests/unit/individual-modules/loader_core.js
new file mode 100644
index 00000000000..cda0588714a
--- /dev/null
+++ b/tests/unit/individual-modules/loader_core.js
@@ -0,0 +1,10 @@
+test( "Loader attaches to DOM when running individually", function() {
+ var loader = $.mobile.loading( "show" );
+
+ deepEqual( $.contains( document, loader[ 0 ] ), true,
+ "Document contains the loader after it is shown" );
+
+ deepEqual( loader.is( ":visible" ), true, "Loader is visible when shown" );
+
+ $.mobile.loading( "hide" );
+});
From 7b19f97ce1fe6424e508a33cb17c6401e3e1d4c1 Mon Sep 17 00:00:00 2001
From: Gabriel Schulhof
Date: Fri, 24 Oct 2014 13:58:18 +0300
Subject: [PATCH 3/3] Loader: Check for the presence of pagecontainer via
selector
---
js/widgets/loader.js | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/js/widgets/loader.js b/js/widgets/loader.js
index 83c07a849e9..37ac1b7a590 100644
--- a/js/widgets/loader.js
+++ b/js/widgets/loader.js
@@ -118,10 +118,11 @@ define( [
this.element.find( "h1" ).text( message );
}
- // attach the loader to the DOM
- this.element.appendTo(
- ( $.mobile.pageContainer && $.mobile.pageContainer.length > 0 ) ?
- $.mobile.pageContainer : $( "body" ) );
+ // If the pagecontainer widget has been defined we may use the :mobile-pagecontainer
+ // and attach to the element on which the pagecontainer widget has been defined. If not,
+ // we attach to the body.
+ this.element.appendTo( $.mobile.pagecontainer ?
+ $( ":mobile-pagecontainer" ) : $( "body" ) );
// check that the loader is visible
this.checkLoaderPosition();