Skip to content
This repository was archived by the owner on Oct 8, 2021. It is now read-only.

Commit 923a83e

Browse files
committed
Nested Listviews: Remove nested listviews depreceated in 1.3.0
1 parent 8d61fb2 commit 923a83e

File tree

4 files changed

+1
-747
lines changed

4 files changed

+1
-747
lines changed

js/widgets/listview.js

Lines changed: 1 addition & 92 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@ define( [ "jquery", "../jquery.mobile.widget", "../jquery.mobile.buttonMarkup",
1212
//Keeps track of the number of lists per page UID
1313
//This allows support for multiple nested list in the same page
1414
//https://github.com/jquery/jquery-mobile/issues/1617
15-
var listCountPerPage = {},
16-
getAttr = $.mobile.getAttribute;
15+
var getAttr = $.mobile.getAttribute;
1716

1817
$.widget( "mobile.listview", $.mobile.widget, $.extend( {
1918

@@ -98,7 +97,6 @@ $.widget( "mobile.listview", $.mobile.widget, $.extend( {
9897

9998
refresh: function( create ) {
10099
this.parentPage = this.element.closest( ".ui-page" );
101-
this._createSubPages();
102100

103101
var o = this.options,
104102
$list = this.element,
@@ -287,95 +285,6 @@ $.widget( "mobile.listview", $.mobile.widget, $.extend( {
287285
//create a string for ID/subpage url creation
288286
_idStringEscape: function( str ) {
289287
return str.replace(/[^a-zA-Z0-9]/g, "-");
290-
},
291-
292-
_createSubPages: function() {
293-
var parentList = this.element,
294-
parentPage = parentList.closest( ".ui-page" ),
295-
parentUrl = getAttr( parentPage[ 0 ], "url", true ),
296-
parentId = parentUrl || parentPage[ 0 ][ $.expando ],
297-
parentListId = parentList.attr( "id" ),
298-
o = this.options,
299-
dns = "data-" + $.mobile.ns,
300-
self = this,
301-
persistentFooter = parentPage.find( ":jqmData(role='footer')" ),
302-
persistentFooterID = ( persistentFooter.length > 0 ? getAttr( persistentFooter[ 0 ], "id", true ) : undefined ),
303-
hasSubPages,
304-
newRemove = function( e, ui ) {
305-
var nextPage = ui.nextPage, npURL,
306-
prEvent = new $.Event( "pageremove" );
307-
308-
if ( ui.nextPage ) {
309-
npURL = getAttr( nextPage[ 0 ], "url", true );
310-
if ( npURL.indexOf( parentUrl + "&" + $.mobile.subPageUrlKey ) !== 0 ) {
311-
self.childPages().remove();
312-
parentPage.trigger( prEvent );
313-
if ( !prEvent.isDefaultPrevented() ) {
314-
parentPage.removeWithDependents();
315-
}
316-
}
317-
}
318-
};
319-
320-
if ( typeof listCountPerPage[ parentId ] === "undefined" ) {
321-
listCountPerPage[ parentId ] = -1;
322-
}
323-
324-
parentListId = parentListId || ++listCountPerPage[ parentId ];
325-
326-
$( parentList.find( "li>ul, li>ol" ).toArray().reverse() ).each(function( i ) {
327-
var list = $( this ),
328-
listId = list.attr( "id" ) || parentListId + "-" + i,
329-
parent = list.parent(),
330-
nodeElsFull = $( list.prevAll().toArray().reverse() ),
331-
nodeEls = nodeElsFull.length ? nodeElsFull : $( "<span>" + $.trim(parent.contents()[ 0 ].nodeValue) + "</span>" ),
332-
title = nodeEls.first().getEncodedText(),//url limits to first 30 chars of text
333-
id = ( parentUrl || "" ) + "&" + $.mobile.subPageUrlKey + "=" + listId,
334-
theme = getAttr( list[ 0 ], "theme", true ) || o.theme,
335-
countTheme = getAttr( list[ 0 ], "counttheme", true ) || getAttr( parentList[ 0 ], "counttheme", true ) || o.countTheme,
336-
newPage, anchor;
337-
338-
//define hasSubPages for use in later removal
339-
hasSubPages = true;
340-
341-
newPage = list.detach()
342-
.wrap( "<div " + dns + "role='page' " + dns + "url='" + id + "' " + dns + "theme='" + theme + "' " + dns + "count-theme='" + countTheme + "'><div " + dns + "role='content'></div></div>" )
343-
.parent()
344-
.before( "<div " + dns + "role='header' " + dns + "theme='" + o.headerTheme + "'><div class='ui-title'>" + title + "</div></div>" )
345-
.after( persistentFooterID ? $( "<div " + dns + "role='footer' " + dns + "id='"+ persistentFooterID +"'>" ) : "" )
346-
.parent()
347-
.appendTo( $.mobile.pageContainer );
348-
349-
newPage.page();
350-
351-
anchor = parent.find( "a:first" );
352-
353-
if ( !anchor.length ) {
354-
anchor = $( "<a/>" ).html( nodeEls || title ).prependTo( parent.empty() );
355-
}
356-
357-
anchor.attr( "href", "#" + id );
358-
359-
}).listview();
360-
361-
// on pagehide, remove any nested pages along with the parent page, as long as they aren't active
362-
// and aren't embedded
363-
if ( hasSubPages &&
364-
parentPage.is( ":jqmData(external-page='true')" ) &&
365-
parentPage.data( "mobile-page" ).options.domCache === false ) {
366-
367-
// unbind the original page remove and replace with our specialized version
368-
parentPage
369-
.unbind( "pagehide.remove" )
370-
.bind( "pagehide.remove", newRemove);
371-
}
372-
},
373-
374-
// TODO sort out a better way to track sub pages of the listview this is brittle
375-
childPages: function() {
376-
var parentUrl = this.parentPage.jqmData( "url" );
377-
378-
return $( ":jqmData(url^='"+ parentUrl + "&" + $.mobile.subPageUrlKey + "')" );
379288
}
380289
}, $.mobile.behaviors.addFirstLastClasses ) );
381290

tests/integration/listview/listview_core.js

Lines changed: 0 additions & 131 deletions
Original file line numberDiff line numberDiff line change
@@ -855,137 +855,6 @@
855855

856856
module( "Cached Linked List" );
857857

858-
var findNestedPages = function(selector){
859-
return $( selector + " #topmost" ).listview( 'childPages' );
860-
};
861-
862-
asyncTest( "nested pages are removed from the dom by default", function(){
863-
$.testHelper.pageSequence([
864-
function(){
865-
//reset for relative url refs
866-
$.mobile.changePage( home );
867-
},
868-
869-
function(){
870-
$.mobile.changePage( "cache-tests/uncached-nested.html" );
871-
},
872-
873-
function(){
874-
ok( findNestedPages( "#uncached-nested-list" ).length > 0, "verify that there are nested pages" );
875-
$.mobile.changePage( home );
876-
},
877-
878-
function() {
879-
$.mobile.changePage( "cache-tests/clear.html" );
880-
},
881-
882-
function(){
883-
deepEqual( findNestedPages( "#uncached-nested-list" ).length, 0 );
884-
start();
885-
}
886-
]);
887-
});
888-
889-
asyncTest( "nested pages preserved when parent page is cached", function(){
890-
891-
$.testHelper.pageSequence([
892-
function(){
893-
//reset for relative url refs
894-
$.mobile.changePage( home );
895-
},
896-
897-
function(){
898-
$.mobile.changePage( "cache-tests/cached-nested.html" );
899-
},
900-
901-
function(){
902-
ok( findNestedPages( "#cached-nested-list" ).length > 0, "verify that there are nested pages" );
903-
$.mobile.changePage( home );
904-
},
905-
906-
function() {
907-
$.mobile.changePage( "cache-tests/clear.html" );
908-
},
909-
910-
function(){
911-
ok( findNestedPages( "#cached-nested-list" ).length > 0, "nested pages remain" );
912-
start();
913-
}
914-
]);
915-
});
916-
917-
asyncTest( "parent page is not removed when visiting a sub page", function(){
918-
$.testHelper.pageSequence([
919-
function(){
920-
//reset for relative url refs
921-
$.mobile.changePage( home );
922-
},
923-
924-
function(){
925-
$.mobile.changePage( "cache-tests/cached-nested.html" );
926-
},
927-
928-
function(){
929-
deepEqual( $("#cached-nested-list").length, 1 );
930-
$.mobile.changePage( home );
931-
},
932-
933-
function() {
934-
$.mobile.changePage( "cache-tests/clear.html" );
935-
},
936-
937-
function(){
938-
deepEqual( $("#cached-nested-list").length, 1 );
939-
start();
940-
}
941-
]);
942-
});
943-
944-
asyncTest( "nested pages hash key is always in the hash (replaceState)", function(){
945-
$.testHelper.pageSequence([
946-
function(){
947-
//reset for relative url refs
948-
$.mobile.changePage( home );
949-
},
950-
951-
function(){
952-
// https://github.com/jquery/jquery-mobile/issues/1617
953-
$.mobile.changePage("#nested-lists-test");
954-
},
955-
956-
function(){
957-
// Click on the link of the third li element
958-
$('.ui-page-active li:eq(2) a:eq(0)').click();
959-
},
960-
961-
function(){
962-
ok( location.hash.search($.mobile.subPageUrlKey) >= 0 );
963-
start();
964-
}
965-
]);
966-
});
967-
968-
asyncTest( "embedded listview page with nested pages is not removed from the dom", function() {
969-
$.testHelper.pageSequence([
970-
function() {
971-
// open the nested list page
972-
deepEqual( $("div#nested-list-test").length, 1 );
973-
$( "a#nested-list-test-anchor" ).click();
974-
},
975-
976-
function() {
977-
// go back to the origin page
978-
window.history.back();
979-
},
980-
981-
function() {
982-
// make sure the page is still in place
983-
deepEqual( $("div#nested-list-test").length, 1 );
984-
start();
985-
}
986-
]);
987-
});
988-
989858

990859
asyncTest( "list inherits theme from parent", function() {
991860
$.testHelper.pageSequence([

tests/integration/listview/listview_nested.js

Lines changed: 0 additions & 103 deletions
This file was deleted.

0 commit comments

Comments
 (0)