From 899e9581e938a722ff7d1cca5bf1bdb4064b95e6 Mon Sep 17 00:00:00 2001 From: tschaub Date: Wed, 16 Feb 2011 05:08:20 +0800 Subject: [PATCH 01/10] P free hamster. --- docs/forms/forms-all.html | 2 +- docs/forms/forms-radiobuttons.html | 4 ++-- docs/forms/forms-themes.html | 10 +++++----- experiments/scrollview/sv-test-01.html | 2 +- 4 files changed, 9 insertions(+), 9 deletions(-) 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/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(){ - + From 3759f8717369b8e87de48a0554565f024f60273f Mon Sep 17 00:00:00 2001 From: John Bender Date: Tue, 15 Feb 2011 22:24:15 -0800 Subject: [PATCH 02/10] reverted to regex method of retrieving the data-url from ajax loaded content to guarantee base is set, regex's courtesy of jblas --- js/jquery.mobile.navigation.js | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/js/jquery.mobile.navigation.js b/js/jquery.mobile.navigation.js index 95f55cdf..478d06f4 100644 --- a/js/jquery.mobile.navigation.js +++ b/js/jquery.mobile.navigation.js @@ -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 ); From bec975ad3a399e853cf4893b035ddd3cba709246 Mon Sep 17 00:00:00 2001 From: John Bender Date: Tue, 15 Feb 2011 22:59:54 -0800 Subject: [PATCH 03/10] added tests for data url regexs --- .../navigation/data-url-tests/data-url.html | 9 +++++ .../navigation/data-url-tests/nested.html | 8 +++++ .../data-url-tests/non-data-url.html | 9 +++++ .../data-url-tests/reverse-attr.html | 8 +++++ .../data-url-tests/single-quotes.html | 8 +++++ tests/unit/navigation/index.html | 17 +++++++-- tests/unit/navigation/navigation_core.js | 35 ++++++++++++------- 7 files changed, 79 insertions(+), 15 deletions(-) create mode 100644 tests/unit/navigation/data-url-tests/data-url.html create mode 100644 tests/unit/navigation/data-url-tests/nested.html create mode 100644 tests/unit/navigation/data-url-tests/non-data-url.html create mode 100644 tests/unit/navigation/data-url-tests/reverse-attr.html create mode 100644 tests/unit/navigation/data-url-tests/single-quotes.html diff --git a/tests/unit/navigation/data-url-tests/data-url.html b/tests/unit/navigation/data-url-tests/data-url.html new file mode 100644 index 00000000..6f8bf224 --- /dev/null +++ b/tests/unit/navigation/data-url-tests/data-url.html @@ -0,0 +1,9 @@ + + + + + +
+
+ + 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/data-url-tests/non-data-url.html b/tests/unit/navigation/data-url-tests/non-data-url.html new file mode 100644 index 00000000..c1a4d6a8 --- /dev/null +++ b/tests/unit/navigation/data-url-tests/non-data-url.html @@ -0,0 +1,9 @@ + + + + + +
+
+ + 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..ac841591 100644 --- a/tests/unit/navigation/index.html +++ b/tests/unit/navigation/index.html @@ -80,13 +80,26 @@
- +
- +
+
+ +
+ +
+ +
+ +
+ +
+ +
diff --git a/tests/unit/navigation/navigation_core.js b/tests/unit/navigation/navigation_core.js index 224ff068..6d7e10de 100644 --- a/tests/unit/navigation/navigation_core.js +++ b/tests/unit/navigation/navigation_core.js @@ -205,25 +205,34 @@ }, 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 defined on a sub element set the hash with that url", function(){ + testDataUrlHash("#data-url a", /^#foo\//); }); - 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( "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$/); + }); - setTimeout(function(){ - ok(location.hash.indexOf("#non-data-url.html") >= 0); - start(); - }, 1000); - stop(); + test( "data url works for nested paths", function(){ + testDataUrlHash("#nested-data-url a", /^#foo\/bar.html$/); + }); + + 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); From 8ea018147cbc37613fe9ee0f818626ff0dcf519f Mon Sep 17 00:00:00 2001 From: John Bender Date: Tue, 15 Feb 2011 23:01:22 -0800 Subject: [PATCH 04/10] removed old test pages for navigation and one unneeded test --- tests/unit/navigation/data-url.html | 9 --------- tests/unit/navigation/navigation_core.js | 4 ---- tests/unit/navigation/non-data-url.html | 9 --------- 3 files changed, 22 deletions(-) delete mode 100644 tests/unit/navigation/data-url.html delete mode 100644 tests/unit/navigation/non-data-url.html diff --git a/tests/unit/navigation/data-url.html b/tests/unit/navigation/data-url.html deleted file mode 100644 index 6f8bf224..00000000 --- a/tests/unit/navigation/data-url.html +++ /dev/null @@ -1,9 +0,0 @@ - - - - - -
-
- - diff --git a/tests/unit/navigation/navigation_core.js b/tests/unit/navigation/navigation_core.js index 6d7e10de..7b2632ff 100644 --- a/tests/unit/navigation/navigation_core.js +++ b/tests/unit/navigation/navigation_core.js @@ -216,10 +216,6 @@ stop(); }; - test( "when loading a page where data-url is defined on a sub element set the hash with that url", function(){ - testDataUrlHash("#data-url a", /^#foo\//); - }); - 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$/); }); diff --git a/tests/unit/navigation/non-data-url.html b/tests/unit/navigation/non-data-url.html deleted file mode 100644 index c1a4d6a8..00000000 --- a/tests/unit/navigation/non-data-url.html +++ /dev/null @@ -1,9 +0,0 @@ - - - - - -
-
- - From 9aa1a38a328cb97305ee21f1fc141092f93fbde9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ernesto=20Jime=CC=81nez?= Date: Wed, 16 Feb 2011 22:22:28 +0000 Subject: [PATCH 05/10] Reviewing the code realised that this var was implicitly declared as global. --- js/jquery.mobile.navigation.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/jquery.mobile.navigation.js b/js/jquery.mobile.navigation.js index 478d06f4..2bd09252 100644 --- a/js/jquery.mobile.navigation.js +++ b/js/jquery.mobile.navigation.js @@ -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 )), From 61b7b2e002e268bd2106ec004c280b70e67eeeae Mon Sep 17 00:00:00 2001 From: John Bender Date: Wed, 16 Feb 2011 19:55:01 -0800 Subject: [PATCH 06/10] removed unnecessary var declaration --- js/jquery.mobile.navigation.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/js/jquery.mobile.navigation.js b/js/jquery.mobile.navigation.js index 2bd09252..a27cce6f 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"); From ee1a8c1977c7946a4cedc2e4e52caa962f7b35a6 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 3 Feb 2011 15:50:18 +1100 Subject: [PATCH 07/10] listview thumb styling via listview('refresh'). Fixes 947 --- js/jquery.mobile.listview.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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" ); }); From 47a98f09c8fc0b972886ef18dd79146a978518fd Mon Sep 17 00:00:00 2001 From: John Bender Date: Wed, 16 Feb 2011 22:35:48 -0800 Subject: [PATCH 08/10] test for thumb styling with listview('refresh') --- tests/unit/listview/listview_core.js | 9 +++++++++ 1 file changed, 9 insertions(+) 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 From 709d12e4d60f455f0961e67a3585130e87538a07 Mon Sep 17 00:00:00 2001 From: John Bender Date: Wed, 16 Feb 2011 22:52:14 -0800 Subject: [PATCH 09/10] resolved conflict for default dialog transition to pop --- js/jquery.mobile.navigation.js | 2 +- tests/unit/navigation/index.html | 9 +++- tests/unit/navigation/navigation_core.js | 4 +- .../unit/navigation/navigation_transitions.js | 51 +++++++++++-------- 4 files changed, 41 insertions(+), 25 deletions(-) diff --git a/js/jquery.mobile.navigation.js b/js/jquery.mobile.navigation.js index a27cce6f..0f2f747e 100644 --- a/js/jquery.mobile.navigation.js +++ b/js/jquery.mobile.navigation.js @@ -336,7 +336,7 @@ function defaultTransition(){ if(transition === undefined){ - transition = $.mobile.defaultTransition; + transition = ( nextPageRole && nextPageRole === 'dialog' ) ? 'pop' : $.mobile.defaultTransition; } } diff --git a/tests/unit/navigation/index.html b/tests/unit/navigation/index.html index ac841591..7870653c 100644 --- a/tests/unit/navigation/index.html +++ b/tests/unit/navigation/index.html @@ -99,7 +99,6 @@
    -
    @@ -110,5 +109,13 @@
    + +
    + +
    + +
    +
    + diff --git a/tests/unit/navigation/navigation_core.js b/tests/unit/navigation/navigation_core.js index 7b2632ff..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"); @@ -232,3 +229,4 @@ 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); From 767c35c62979e419e729c1fb3f49322a00eed71f Mon Sep 17 00:00:00 2001 From: Ashley Streb Date: Thu, 13 Jan 2011 10:22:38 -0500 Subject: [PATCH 10/10] Updating docs to specify that the default transition for dialogs is 'pop' --- docs/api/globalconfig.html | 2 +- docs/pages/docs-dialogs.html | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) 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/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>