diff --git a/docs/api/globalconfig.html b/docs/api/globalconfig.html index f2f0fd27..fcd8aa1a 100755 --- a/docs/api/globalconfig.html +++ b/docs/api/globalconfig.html @@ -92,7 +92,7 @@ $(document).bind("mobileinit", function(){
jQuery Mobile will automatically handle form submissions through Ajax, when possible.
defaultTransition (string, default: 'slide'):
-
Set the default transition for page changes that use Ajax. Set to 'none' for no transitions by default.
+
Set the default transition for page changes that use Ajax. The default transition for dialog presentation is 'pop'. Set to 'none' for no transitions by default.
loadingMessage (string, default: "loading"):
Set the text that appears when a page is loading. If set to false, the message will not appear at all.
diff --git a/docs/forms/forms-all.html b/docs/forms/forms-all.html index 1b319ed2..48e7e36b 100755 --- a/docs/forms/forms-all.html +++ b/docs/forms/forms-all.html @@ -96,7 +96,7 @@ - + diff --git a/docs/forms/forms-radiobuttons.html b/docs/forms/forms-radiobuttons.html index 0603dfb8..8592768b 100755 --- a/docs/forms/forms-radiobuttons.html +++ b/docs/forms/forms-radiobuttons.html @@ -46,7 +46,7 @@ <label for="radio-choice-2">Dog</label> <input type="radio" name="radio-choice-1" id="radio-choice-3" value="choice-3" /> - <label for="radio-choice-3">Hampster</label> + <label for="radio-choice-3">Hamster</label> <input type="radio" name="radio-choice-1" id="radio-choice-4" value="choice-4" /> <label for="radio-choice-4">Lizard</label> @@ -66,7 +66,7 @@ - + diff --git a/docs/forms/forms-themes.html b/docs/forms/forms-themes.html index d407574c..6f277152 100755 --- a/docs/forms/forms-themes.html +++ b/docs/forms/forms-themes.html @@ -72,7 +72,7 @@ - + @@ -137,7 +137,7 @@ - + @@ -204,7 +204,7 @@ - + @@ -272,7 +272,7 @@ - + @@ -339,7 +339,7 @@ - + diff --git a/docs/pages/docs-dialogs.html b/docs/pages/docs-dialogs.html index 99713cca..a043cc0d 100755 --- a/docs/pages/docs-dialogs.html +++ b/docs/pages/docs-dialogs.html @@ -32,7 +32,7 @@

Transitions

-

Since the dialog is a standard "page", it will open with the standard slide transition that's applied to all pages. And like all pages, you can specify any page transition you want on the dialog by adding the data-transition attribute to the link. To make it feel more dialog-like, we recommend specifying a transition of "pop", "slideup" or "flip".

+

By default, the dialog will open with a 'pop' transition. Like all pages, you can specify any page transition you want on the dialog by adding the data-transition attribute to the link. To make it feel more dialog-like, we recommend specifying a transition of "pop", "slideup" or "flip".

<a href="foo.html" data-rel="dialog" data-transition="pop">Open dialog</a> diff --git a/experiments/scrollview/sv-test-01.html b/experiments/scrollview/sv-test-01.html index e041e1fb..2ee6b5ac 100644 --- a/experiments/scrollview/sv-test-01.html +++ b/experiments/scrollview/sv-test-01.html @@ -120,7 +120,7 @@ $(function(){ - + diff --git a/js/jquery.mobile.listview.js b/js/jquery.mobile.listview.js index 919cb925..0ceb6fd5 100644 --- a/js/jquery.mobile.listview.js +++ b/js/jquery.mobile.listview.js @@ -127,7 +127,7 @@ $.widget( "mobile.listview", $.mobile.widget, { item.find( "p, dl" ).addClass( "ui-li-desc" ); - item.find( "li" ).find( "img:eq(0)" ).addClass( "ui-li-thumb" ).each(function() { + $list.find( "li" ).find( "img:eq(0)" ).addClass( "ui-li-thumb" ).each(function() { $( this ).closest( "li" ) .addClass( $(this).is( ".ui-li-icon" ) ? "ui-li-has-icon" : "ui-li-has-thumb" ); }); diff --git a/js/jquery.mobile.navigation.js b/js/jquery.mobile.navigation.js index 95f55cdf..0f2f747e 100644 --- a/js/jquery.mobile.navigation.js +++ b/js/jquery.mobile.navigation.js @@ -135,13 +135,13 @@ isPageTransitioning = false, //nonsense hash change key for dialogs, so they create a history entry - dialogHashKey = "&ui-state=dialog"; + dialogHashKey = "&ui-state=dialog", //existing base tag? - var $base = $head.children("base"), - hostURL = location.protocol + '//' + location.host, - docLocation = path.get( hostURL + location.pathname ), - docBase = docLocation; + $base = $head.children("base"), + hostURL = location.protocol + '//' + location.host, + docLocation = path.get( hostURL + location.pathname ), + docBase = docLocation; if ($base.length){ var href = $base.attr("href"); @@ -171,7 +171,7 @@ } //base element management, defined depending on dynamic base tag support - base = $.support.dynamicBaseTag ? { + var base = $.support.dynamicBaseTag ? { //define base element, for use in routing asset urls that are referenced in Ajax-requested markup element: ($base.length ? $base : $("", { href: docBase }).prependTo( $head )), @@ -336,7 +336,7 @@ function defaultTransition(){ if(transition === undefined){ - transition = $.mobile.defaultTransition; + transition = ( nextPageRole && nextPageRole === 'dialog' ) ? 'pop' : $.mobile.defaultTransition; } } @@ -517,12 +517,16 @@ //pre-parse html to check for a data-url, //use it as the new fileUrl, base path, etc var all = $("
"), - redirectLoc; + redirectLoc, + // TODO handle dialogs again + pageElemRegex = /.*(<[^>]*\bdata-role=["']?page["']?[^>]*>).*/, + dataUrlRegex = /\bdata-url=["']?([^"'>]*)["']?/; - //workaround to allow scripts to execute when included in page divs - all.get(0).innerHTML = html; - to = all.find('[data-role="page"], [data-role="dialog"]').first(); - redirectLoc = all.find('[data-url]').data('url'); + // data-url must be provided for the base tag so resource requests can be directed to the + // correct url. loading into a temprorary element makes these requests immediately + if(pageElemRegex.test(html) && RegExp.$1 && dataUrlRegex.test(RegExp.$1) && RegExp.$1) { + redirectLoc = RegExp.$1; + } if( redirectLoc ){ if(base){ @@ -536,6 +540,10 @@ } } + //workaround to allow scripts to execute when included in page divs + all.get(0).innerHTML = html; + to = all.find('[data-role="page"], [data-role="dialog"]').first(); + //rewrite src and href attrs to use a base url if( !$.support.dynamicBaseTag ){ var newPath = path.get( fileUrl ); diff --git a/tests/unit/listview/listview_core.js b/tests/unit/listview/listview_core.js index 86d21feb..7063b679 100644 --- a/tests/unit/listview/listview_core.js +++ b/tests/unit/listview/listview_core.js @@ -207,4 +207,13 @@ start(); }, 1000); }); + + test( "Refresh applys thumb styling", function(){ + var ul = $('.ui-page-active ul'); + + ul.append("
  • "); + ok(!ul.find("#fiz img").hasClass("ui-li-thumb")); + ul.listview('refresh'); + ok(ul.find("#fiz img").hasClass("ui-li-thumb")); + }); })(jQuery); \ No newline at end of file diff --git a/tests/unit/navigation/data-url.html b/tests/unit/navigation/data-url-tests/data-url.html similarity index 100% rename from tests/unit/navigation/data-url.html rename to tests/unit/navigation/data-url-tests/data-url.html diff --git a/tests/unit/navigation/data-url-tests/nested.html b/tests/unit/navigation/data-url-tests/nested.html new file mode 100644 index 00000000..9c1b6348 --- /dev/null +++ b/tests/unit/navigation/data-url-tests/nested.html @@ -0,0 +1,8 @@ + + + + + +
    + + diff --git a/tests/unit/navigation/non-data-url.html b/tests/unit/navigation/data-url-tests/non-data-url.html similarity index 100% rename from tests/unit/navigation/non-data-url.html rename to tests/unit/navigation/data-url-tests/non-data-url.html diff --git a/tests/unit/navigation/data-url-tests/reverse-attr.html b/tests/unit/navigation/data-url-tests/reverse-attr.html new file mode 100644 index 00000000..1074175a --- /dev/null +++ b/tests/unit/navigation/data-url-tests/reverse-attr.html @@ -0,0 +1,8 @@ + + + + + +
    + + diff --git a/tests/unit/navigation/data-url-tests/single-quotes.html b/tests/unit/navigation/data-url-tests/single-quotes.html new file mode 100644 index 00000000..63596923 --- /dev/null +++ b/tests/unit/navigation/data-url-tests/single-quotes.html @@ -0,0 +1,8 @@ + + + + + +
    + + diff --git a/tests/unit/navigation/index.html b/tests/unit/navigation/index.html index 85625249..7870653c 100644 --- a/tests/unit/navigation/index.html +++ b/tests/unit/navigation/index.html @@ -80,11 +80,23 @@
    - +
    - + +
    + +
    + +
    + +
    + +
    + +
    +
    @@ -97,5 +109,13 @@
    + +
    + +
    + +
    +
    + diff --git a/tests/unit/navigation/navigation_core.js b/tests/unit/navigation/navigation_core.js index 224ff068..84defe33 100644 --- a/tests/unit/navigation/navigation_core.js +++ b/tests/unit/navigation/navigation_core.js @@ -55,9 +55,6 @@ }, 500); }); - - - test( "path.get method is working properly", function(){ window.location.hash = "foo" same($.mobile.path.get(), "foo", "get method returns location.hash minus hash character"); @@ -205,25 +202,31 @@ }, 500); }); - asyncTest( "when loading a page where data-url is defined on a sub element set the hash with that url", function(){ - location.hash = ""; - $("#data-url a").click(); + var testDataUrlHash = function(linkSelector, hashRegex){ + window.location.hash = ""; + $(linkSelector).click(); setTimeout(function(){ - ok(location.hash.indexOf("#foo/") >= 0); + ok(hashRegex.test(location.hash)); start(); - }, 1000); + }, 600); stop(); + }; + + test( "when loading a page where data-url is not defined on a sub element hash defaults to the url", function(){ + testDataUrlHash("#non-data-url a", /^#data-url-tests\/non-data-url.html$/); }); - asyncTest( "when loading a page where data-url is not defined on a sub element hash defaults to the url", function(){ - location.hash = ""; - $("#non-data-url a").click(); + test( "data url works for nested paths", function(){ + testDataUrlHash("#nested-data-url a", /^#foo\/bar.html$/); + }); - setTimeout(function(){ - ok(location.hash.indexOf("#non-data-url.html") >= 0); - start(); - }, 1000); - stop(); + test( "data url works for single quoted paths and roles", function(){ + testDataUrlHash("#single-quotes-data-url a", /^#foo\/bar\/single.html$/); + }); + + test( "data url works when role and url are reversed on the page element", function(){ + testDataUrlHash("#reverse-attr-data-url a", /^#foo\/bar\/reverse.html$/); }); })(jQuery); + diff --git a/tests/unit/navigation/navigation_transitions.js b/tests/unit/navigation/navigation_transitions.js index 249ed887..65179d0e 100644 --- a/tests/unit/navigation/navigation_transitions.js +++ b/tests/unit/navigation/navigation_transitions.js @@ -8,24 +8,24 @@ //TODO centralize class names? transitionTypes = "in out fade slide flip reverse pop", - + isTransitioning = function(page){ return $.grep(transitionTypes.split(" "), function(className, i){ - return page.hasClass(className) + return page.hasClass(className); }).length > 0; }, - + isTransitioningIn = function(page){ return page.hasClass("in") && isTransitioning(page); }, - + //animationComplete callback queue callbackQueue = [], - + finishPageTransition = function(){ callbackQueue.pop()(); }, - + clearPageTransitionStack = function(){ stop(); var checkTransitionStack = function(){ @@ -33,7 +33,7 @@ setTimeout(function(){ finishPageTransition(); checkTransitionStack(); - },0) + },0); } else { start(); @@ -41,13 +41,13 @@ }; checkTransitionStack(); }, - + //wipe all urls clearUrlHistory = function(){ $.mobile.urlHistory.stack = []; $.mobile.urlHistory.activeIndex = 0; }; - + module('jquery.mobile.navigation.js', { setup: function(){ @@ -55,7 +55,7 @@ $.fn.animationComplete = function(callback){ callbackQueue.unshift(callback); }; - + }, teardown: function(){ @@ -63,15 +63,15 @@ $.fn.animationComplete = animationCompleteFn; } }); - + QUnit.testStart = function (name) { clearPageTransitionStack(); clearUrlHistory(); }; - + test( "changePage applys perspective class to mobile viewport for flip", function(){ $("#foo > a").click(); - + ok($("body").hasClass(perspective), "has perspective class"); }); @@ -83,7 +83,7 @@ test( "changePage applys transition class to mobile viewport for default transition", function(){ $("#baz > a").click(); - + ok($("body").hasClass(transitioning), "has transitioning class"); }); @@ -112,21 +112,21 @@ start(); },0); }); - + test( "changePage queues requests", function(){ var firstPage = $("#foo"), secondPage = $("#bar"); - + $.mobile.changePage(firstPage); $.mobile.changePage(secondPage); - + stop(); setTimeout(function(){ ok(isTransitioningIn(firstPage), "first page begins transition"); ok(!isTransitioningIn(secondPage), "second page doesn't transition yet"); - + finishPageTransition(); - + setTimeout(function(){ ok(!isTransitioningIn(firstPage), "first page transition should be complete"); ok(isTransitioningIn(secondPage), "second page should begin transitioning"); @@ -134,5 +134,16 @@ },0); },0); }); - + + test( "default transition is pop for a dialog", function(){ + expect( 1 ); + stop(); + setTimeout(function(){ + $("#default-trans-dialog > a").click(); + + ok($("#no-trans-dialog").hasClass("pop"), "expected the pop class to be present but instead was " + $("#no-trans-dialog").attr('class')); + + start(); + }, 900); + }); })(jQuery);