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

Commit

Permalink
Listview: Added a class to set border-bottom on the last LI. This fix…
Browse files Browse the repository at this point in the history
…es missing border on filtered lists and on browsers that don't support :last-child. Fixes #4614 - Items filtered from listview missing a border.
  • Loading branch information
jaspermdegroot committed Jul 13, 2012
1 parent 8b691bc commit 75a3635
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
2 changes: 1 addition & 1 deletion css/structure/jquery.mobile.listview.css
Expand Up @@ -12,7 +12,7 @@ ol.ui-listview, ol.ui-listview .ui-li-divider { counter-reset: listnumbering; }
ol.ui-listview .ui-link-inherit:before, ol.ui-listview .ui-li-static:before, .ui-li-dec { font-size: .8em; display: inline-block; padding-right: .3em; font-weight: normal; counter-increment: listnumbering; content: counter(listnumbering) ". "; }
ol.ui-listview .ui-li-jsnumbering:before { content: "" !important; } /* to avoid chance of duplication */
.ui-listview-inset .ui-li { border-right-width: 1px; border-left-width: 1px; }
.ui-li:last-child, .ui-li.ui-field-contain:last-child { border-bottom-width: 1px; }
.ui-li-last, .ui-li.ui-field-contain.ui-li-last { border-bottom-width: 1px; }
.ui-li>.ui-btn-inner { display: block; position: relative; padding: 0; }
.ui-li .ui-btn-inner a.ui-link-inherit, .ui-li-static.ui-li { padding: .7em 15px; display: block; }
.ui-li-has-thumb .ui-btn-inner a.ui-link-inherit, .ui-li-static.ui-li-has-thumb { min-height: 60px; padding-left: 100px; }
Expand Down
15 changes: 10 additions & 5 deletions js/jquery.mobile.listview.js
Expand Up @@ -62,11 +62,14 @@ $.widget( "mobile.listview", $.mobile.widget, {
$topli,
$bottomli;

if ( this.options.inset ) {
$li = this.element.children( "li" );
// at create time the li are not visible yet so we need to rely on .ui-screen-hidden
$visibleli = create ? $li.not( ".ui-screen-hidden" ) : $li.filter( ":visible" );
$li = this.element.children( "li" );
// at create time the li are not visible yet so we need to rely on .ui-screen-hidden
$visibleli = create ? $li.not( ".ui-screen-hidden" ) : $li.filter( ":visible" );

// ui-li-last is used for setting border-bottom on the last li
$li.find( ".ui-li-last" ).removeClass( "ui-li-last" );

if ( this.options.inset ) {
this._removeCorners( $li );

// Select the first visible li element
Expand All @@ -86,7 +89,7 @@ $.widget( "mobile.listview", $.mobile.widget, {

// Select the last visible li element
$bottomli = $visibleli.last()
.addClass( "ui-corner-bottom" );
.addClass( "ui-corner-bottom ui-li-last" );

$bottomli.add( $bottomli.find( ".ui-btn-inner" ) )
.find( ".ui-li-link-alt" )
Expand All @@ -95,6 +98,8 @@ $.widget( "mobile.listview", $.mobile.widget, {
.find( ".ui-li-thumb" )
.not(".ui-li-icon")
.addClass( "ui-corner-bl" );
} else {
$visibleli.last().addClass( "ui-li-last" );
}
if ( !create ) {
this.element.trigger( "updatelayout" );
Expand Down

0 comments on commit 75a3635

Please sign in to comment.