Skip to content

Commit

Permalink
only force the message if the argument is explicit, not if it is set …
Browse files Browse the repository at this point in the history
…globally
  • Loading branch information
johnbender committed Jun 20, 2012
1 parent 1a75d10 commit 8358b16
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 2 deletions.
4 changes: 3 additions & 1 deletion js/widgets/loader.js
Expand Up @@ -135,9 +135,11 @@ define( [ "jquery", "../jquery.mobile.core", "../jquery.mobile.widget" ], functi
}

// add the proper css given the options (theme, text, etc)
// Force text visibility if the second argument was supplied, or
// if the text was explicitly set in the object args
this.element.attr("class", loaderClass +
" ui-corner-all ui-body-" + theme +
" ui-loader-" + ( textVisible || message ? "verbose" : "default" ) +
" ui-loader-" + ( textVisible || msgText || theme.text ? "verbose" : "default" ) +
( loadSettings.textonly || textonly ? " ui-loader-textonly" : "" ) );

// TODO verify that jquery.fn.html is ok to use in both cases here
Expand Down
28 changes: 27 additions & 1 deletion tests/unit/init/init_core.js
Expand Up @@ -217,7 +217,7 @@
same($(".ui-loader > div.foo").length, 1, "loader has a custom html");
});

test( "page loading should always contain text when passed", function() {
test( "page loading should always contain text when passed as the second arg", function() {
$.mobile.loadingMessageTextVisible = false;

// simulate error call in navigation ajax error callback
Expand All @@ -226,6 +226,32 @@
same($(".ui-loader").text(), "foo serious", "loader has message regardless of global setting");
});

test( "page loading should always contain text when passed as an object prop", function() {
$.mobile.loadingMessageTextVisible = false;

// simulate error call in navigation ajax error callback
$.mobile.showPageLoadingMsg({ theme: "e", text: "foo serious second", textonly: true });

same($(".ui-loader").text(), "foo serious second", "loader has message regardless of global setting");
});

test( "page loading should not contain text when default is used and visible prop is false", function() {
$.mobile.loadingMessageTextVisible = false;

// simulate error call in navigation ajax error callback
$.mobile.showPageLoadingMsg({ theme: "e", textonly: true });

ok($(".ui-loader").hasClass("ui-loader-default"), "loader text is hidden");

$.mobile.hidePageLoadingMsg();

// simulate error call in navigation ajax error callback
$.mobile.showPageLoadingMsg( "e", undefined, true );

ok($(".ui-loader").hasClass("ui-loader-default"), "loader text is hidden");
});


test( "test the loading config object precedence", function() {
$.mobile.loadingMessage = "fozzle";
$.mobile.loadingMessageTheme = "x";
Expand Down

0 comments on commit 8358b16

Please sign in to comment.