|
5 | 5 | //>>css.structure: ../css/structure/jquery.mobile.listview.css |
6 | 6 | //>>css.theme: ../css/themes/default/jquery.mobile.theme.css |
7 | 7 |
|
8 | | -define( [ "jquery", "../jquery.mobile.widget", "../jquery.mobile.buttonMarkup", "./page", "./page.sections" ], function( $ ) { |
| 8 | +define( [ "jquery", "../jquery.mobile.widget", "../jquery.mobile.buttonMarkup", "./page", "./page.sections", "./addFirstLastClasses" ], function( $ ) { |
9 | 9 | //>>excludeEnd("jqmBuildExclude"); |
10 | 10 | (function( $, undefined ) { |
11 | 11 |
|
@@ -49,28 +49,6 @@ $.widget( "mobile.listview", $.mobile.widget, { |
49 | 49 | t.refresh( true ); |
50 | 50 | }, |
51 | 51 |
|
52 | | - _addFirstLastClasses: function( create ) { |
53 | | - var lis = this.element.children( "li" ), |
54 | | - visiblelis; |
55 | | - |
56 | | - lis.removeClass( "ui-first-child ui-last-child" ); |
57 | | - // At create time and when autodividers calls refresh the li are not visible yet so we need to rely on .ui-screen-hidden |
58 | | - if ( create ) { |
59 | | - visiblelis = lis.not( ".ui-screen-hidden" ); |
60 | | - } else { |
61 | | - visiblelis = lis.filter( ":visible" ); |
62 | | - if ( visiblelis.length === 0 ) { |
63 | | - visiblelis = lis.not( ".ui-screen-hidden" ); |
64 | | - } |
65 | | - } |
66 | | - |
67 | | - visiblelis.eq( 0 ).addClass( "ui-first-child" ).end().last().addClass( "ui-last-child" ); |
68 | | - |
69 | | - if ( !create ) { |
70 | | - this.element.trigger( "updatelayout" ); |
71 | | - } |
72 | | - }, |
73 | | - |
74 | 52 | // This is a generic utility method for finding the first |
75 | 53 | // node with a given nodeName. It uses basic DOM traversal |
76 | 54 | // to be fast and is meant to be a substitute for simple |
@@ -301,7 +279,7 @@ $.widget( "mobile.listview", $.mobile.widget, { |
301 | 279 | this._addThumbClasses( li ); |
302 | 280 | this._addThumbClasses( $list.find( ".ui-link-inherit" ) ); |
303 | 281 |
|
304 | | - this._addFirstLastClasses( create ); |
| 282 | + this._addFirstLastClasses( li, this._getVisibles( li, create ), create ); |
305 | 283 | // autodividers binds to this to redraw dividers after the listview refresh |
306 | 284 | this._trigger( "afterrefresh" ); |
307 | 285 | }, |
@@ -402,6 +380,8 @@ $.widget( "mobile.listview", $.mobile.widget, { |
402 | 380 | } |
403 | 381 | }); |
404 | 382 |
|
| 383 | +$.widget( "mobile.listview", $.mobile.listview, $.mobile.behaviors.addFirstLastClasses ); |
| 384 | + |
405 | 385 | //auto self-init widgets |
406 | 386 | $( document ).bind( "pagecreate create", function( e ) { |
407 | 387 | $.mobile.listview.prototype.enhanceWithin( e.target ); |
|
0 commit comments