From f3b46da3ab01e77bc848f074209d796e9d06cd29 Mon Sep 17 00:00:00 2001 From: Ghislain Seguin Date: Fri, 3 Jun 2011 08:05:18 -0700 Subject: [PATCH 1/6] Fixed test case for issue #1617 --- tests/unit/listview/listview_core.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/unit/listview/listview_core.js b/tests/unit/listview/listview_core.js index 15d09e094dd..65527f86aa5 100644 --- a/tests/unit/listview/listview_core.js +++ b/tests/unit/listview/listview_core.js @@ -122,7 +122,9 @@ function(){ $('.ui-page-active li:eq(2) a:eq(0)').click(); - + }, + + function(){ equal($('.ui-page-active .ui-content .ui-listview li').text(), "Sub Item 10Sub Item 11Sub Item 12", 'Text should be "Sub Item 10Sub Item 11Sub Item 12"'); start(); } From 83731055a5c898e121b197d70ff1b686f31a0513 Mon Sep 17 00:00:00 2001 From: Ghislain Seguin Date: Fri, 3 Jun 2011 08:08:18 -0700 Subject: [PATCH 2/6] Fix for issue #1617: Nested lists with same parent text resolve to the same sub-page. --- js/jquery.mobile.listview.js | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/js/jquery.mobile.listview.js b/js/jquery.mobile.listview.js index 9fd9a6605eb..3e29ded088f 100644 --- a/js/jquery.mobile.listview.js +++ b/js/jquery.mobile.listview.js @@ -5,6 +5,10 @@ * http://jquery.org/license */ (function($, undefined ) { +//Keeps track of the number of lists per page UID +//This allows support for multiple nested list in the same page +//https://github.com/jquery/jquery-mobile/issues/1617 +var listCountPerPage = {}; $.widget( "mobile.listview", $.mobile.widget, { options: { @@ -189,23 +193,31 @@ $.widget( "mobile.listview", $.mobile.widget, { _idStringEscape: function( str ){ return str.replace(/[^a-zA-Z0-9]/g, '-'); }, - + _createSubPages: function() { var parentList = this.element, parentPage = parentList.closest( ".ui-page" ), - parentId = parentPage.jqmData( "url" ), + parentUrl = parentPage.jqmData( "url" ), + parentId = parentUrl || parentPage[ 0 ][ $.expando ], + parentListId = parentList.attr( "id" ), o = this.options, dns = "data-" + $.mobile.ns, self = this, persistentFooterID = parentPage.find( ":jqmData(role='footer')" ).jqmData( "id" ); + if ( typeof( listCountPerPage[ parentId ] ) === 'undefined' ) { + listCountPerPage[ parentId ] = -1; + } + parentListId = parentListId || ++listCountPerPage[ parentId ]; + $( parentList.find( "li>ul, li>ol" ).toArray().reverse() ).each(function( i ) { var list = $( this ), + listId = list.attr( "id" ) || parentListId + "-" + i, parent = list.parent(), nodeEls = $( list.prevAll().toArray().reverse() ), nodeEls = nodeEls.length ? nodeEls : $( "" + $.trim(parent.contents()[ 0 ].nodeValue) + "" ), title = nodeEls.first().text(),//url limits to first 30 chars of text - id = parentId + "&" + $.mobile.subPageUrlKey + "=" + self._idStringEscape(title + " " + i), + id = ( parentUrl || "" ) + "&" + $.mobile.subPageUrlKey + "=" + listId; theme = list.jqmData( "theme" ) || o.theme, countTheme = list.jqmData( "counttheme" ) || parentList.jqmData( "counttheme" ) || o.countTheme, newPage = list.detach() From 9e696b8d26c12b0f8a7391a37cda6cb9292d594d Mon Sep 17 00:00:00 2001 From: Kin Blas Date: Fri, 3 Jun 2011 09:29:41 -0700 Subject: [PATCH 3/6] Backing out commit for "fix height issue for transitioning page" https://github.com/jquery/jquery-mobile/pull/1723 https://github.com/jquery/jquery-mobile/commit/b2a534c217a4fa18918002a43db17bbdcd0a2a42 It was causing a few issues including: https://github.com/jquery/jquery-mobile/issues/1770 --- themes/default/jquery.mobile.core.css | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/themes/default/jquery.mobile.core.css b/themes/default/jquery.mobile.core.css index 982b18dc58d..0d3bc0649ea 100644 --- a/themes/default/jquery.mobile.core.css +++ b/themes/default/jquery.mobile.core.css @@ -14,14 +14,14 @@ .ui-mobile-viewport { margin: 0; overflow-x: hidden; -webkit-text-size-adjust: none; -ms-text-size-adjust:none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); } /* "page" containers - full-screen views, one should always be in view post-pageload */ -.ui-mobile [data-role=page], .ui-mobile [data-role=dialog], .ui-page { top: 0; left: 0; width: 100%; min-height: 100%; height: auto !important; height: 100%; position: absolute; display: none; border: 0; } +.ui-mobile [data-role=page], .ui-mobile [data-role=dialog], .ui-page { top: 0; left: 0; width: 100%; min-height: 100%; position: absolute; display: none; border: 0; } .ui-mobile .ui-page-active { display: block; overflow: visible; } /*orientations from js are available */ .portrait, .portrait .ui-page, .landscape, -.landscape .ui-page { min-height: 100%; height: auto !important; height: 100%; } +.landscape .ui-page { min-height: 100%; } /* loading screen */ .ui-loading .ui-mobile-viewport { overflow: hidden !important; } From 0985fc98d12a7ee754b34d561eee3c40ba4abb27 Mon Sep 17 00:00:00 2001 From: Ghislain Seguin Date: Fri, 3 Jun 2011 08:05:18 -0700 Subject: [PATCH 4/6] Fixed test case for issue #1617 --- tests/unit/listview/listview_core.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/unit/listview/listview_core.js b/tests/unit/listview/listview_core.js index 15d09e094dd..65527f86aa5 100644 --- a/tests/unit/listview/listview_core.js +++ b/tests/unit/listview/listview_core.js @@ -122,7 +122,9 @@ function(){ $('.ui-page-active li:eq(2) a:eq(0)').click(); - + }, + + function(){ equal($('.ui-page-active .ui-content .ui-listview li').text(), "Sub Item 10Sub Item 11Sub Item 12", 'Text should be "Sub Item 10Sub Item 11Sub Item 12"'); start(); } From d615b478cc10aeaae341cd1afee5fc5232a9ac44 Mon Sep 17 00:00:00 2001 From: Ghislain Seguin Date: Fri, 3 Jun 2011 08:08:18 -0700 Subject: [PATCH 5/6] Fix for issue #1617: Nested lists with same parent text resolve to the same sub-page. --- js/jquery.mobile.listview.js | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/js/jquery.mobile.listview.js b/js/jquery.mobile.listview.js index 9fd9a6605eb..3e29ded088f 100644 --- a/js/jquery.mobile.listview.js +++ b/js/jquery.mobile.listview.js @@ -5,6 +5,10 @@ * http://jquery.org/license */ (function($, undefined ) { +//Keeps track of the number of lists per page UID +//This allows support for multiple nested list in the same page +//https://github.com/jquery/jquery-mobile/issues/1617 +var listCountPerPage = {}; $.widget( "mobile.listview", $.mobile.widget, { options: { @@ -189,23 +193,31 @@ $.widget( "mobile.listview", $.mobile.widget, { _idStringEscape: function( str ){ return str.replace(/[^a-zA-Z0-9]/g, '-'); }, - + _createSubPages: function() { var parentList = this.element, parentPage = parentList.closest( ".ui-page" ), - parentId = parentPage.jqmData( "url" ), + parentUrl = parentPage.jqmData( "url" ), + parentId = parentUrl || parentPage[ 0 ][ $.expando ], + parentListId = parentList.attr( "id" ), o = this.options, dns = "data-" + $.mobile.ns, self = this, persistentFooterID = parentPage.find( ":jqmData(role='footer')" ).jqmData( "id" ); + if ( typeof( listCountPerPage[ parentId ] ) === 'undefined' ) { + listCountPerPage[ parentId ] = -1; + } + parentListId = parentListId || ++listCountPerPage[ parentId ]; + $( parentList.find( "li>ul, li>ol" ).toArray().reverse() ).each(function( i ) { var list = $( this ), + listId = list.attr( "id" ) || parentListId + "-" + i, parent = list.parent(), nodeEls = $( list.prevAll().toArray().reverse() ), nodeEls = nodeEls.length ? nodeEls : $( "" + $.trim(parent.contents()[ 0 ].nodeValue) + "" ), title = nodeEls.first().text(),//url limits to first 30 chars of text - id = parentId + "&" + $.mobile.subPageUrlKey + "=" + self._idStringEscape(title + " " + i), + id = ( parentUrl || "" ) + "&" + $.mobile.subPageUrlKey + "=" + listId; theme = list.jqmData( "theme" ) || o.theme, countTheme = list.jqmData( "counttheme" ) || parentList.jqmData( "counttheme" ) || o.countTheme, newPage = list.detach() From 90d63214969ef5415bafcb54ac5ce94053ccac7c Mon Sep 17 00:00:00 2001 From: Ghislain Seguin Date: Fri, 3 Jun 2011 10:03:44 -0700 Subject: [PATCH 6/6] Fixed nested lists tests following id generation change (8373105) --- tests/unit/listview/listview_core.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/tests/unit/listview/listview_core.js b/tests/unit/listview/listview_core.js index 65527f86aa5..40cd2622895 100644 --- a/tests/unit/listview/listview_core.js +++ b/tests/unit/listview/listview_core.js @@ -63,8 +63,8 @@ function(){ ok($('#nested-list-test').hasClass('ui-page-active'), "makes nested list test page active"); - ok($(':jqmData(url="nested-list-test&ui-page=More-animals-0")').length == 1, "Adds first UL to the page"); - ok($(':jqmData(url="nested-list-test&ui-page=Groups-of-animals-1")').length == 1, "Adds second nested UL to the page"); + ok($(':jqmData(url="nested-list-test&ui-page=0-0")').length == 1, "Adds first UL to the page"); + ok($(':jqmData(url="nested-list-test&ui-page=0-1")').length == 1, "Adds second nested UL to the page"); start(); } ]); @@ -82,7 +82,7 @@ }, function(){ - var $new_page = $(':jqmData(url="nested-list-test&ui-page=More-animals-0")'); + var $new_page = $(':jqmData(url="nested-list-test&ui-page=0-0")'); ok($new_page.hasClass('ui-page-active'), 'Makes the nested page the active page.'); ok($('.ui-listview', $new_page).find(":contains('Rhumba of rattlesnakes')").length == 1, "The current page should have the proper text in the list."); @@ -95,7 +95,7 @@ asyncTest( "should go back to top level when the back button is clicked", function() { $.testHelper.pageSequence([ function(){ - $.testHelper.openPage("#nested-list-test&ui-page=More-animals-0"); + $.testHelper.openPage("#nested-list-test&ui-page=0-0"); }, function(){ @@ -113,7 +113,7 @@ ok($('#nested-list-test .linebreaknode').text() === "More animals", 'Text should be "More animals"'); }); - asyncTest( "Multiple nested lists on a page", function() { + asyncTest( "Multiple nested lists on a page with same labels", function() { $.testHelper.pageSequence([ function(){ // https://github.com/jquery/jquery-mobile/issues/1617 @@ -121,6 +121,7 @@ }, function(){ + // Click on the link of the third li element $('.ui-page-active li:eq(2) a:eq(0)').click(); },