@@ -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 - z A - Z 0 - 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
0 commit comments