Showing with 50 additions and 44 deletions.
  1. +3 −3 css/structure/jquery.mobile.listview.css
  2. +47 −41 js/jquery.mobile.listview.js
@@ -1,4 +1,5 @@
.ui-listview { margin: 0; counter-reset: listnumbering; }
.ui-listview { margin: 0; }
ol.ui-listview, ol.ui-listview .ui-li-divider { counter-reset: listnumbering; }
.ui-content .ui-listview { margin: -15px; }
.ui-content .ui-listview-inset { margin: 1em 0; }
.ui-listview, .ui-li { list-style:none; padding:0; }
@@ -8,11 +9,10 @@
/* Fixes #4254 to prevent inherit font-size from .ui-li-divider, .ui-li-static */
.ui-li-divider .ui-btn-text, .ui-li-static .ui-btn-text { font-size: 16px; }
.ui-li-divider .ui-mini .ui-btn-text, .ui-li-static .ui-mini .ui-btn-text { font-size: inherit; }
.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; }
@@ -62,31 +62,34 @@ $.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
$topli = $visibleli.first()
.addClass( "ui-corner-top" );

$topli.add( $topli.find( ".ui-btn-inner" )
.not( ".ui-li-link-alt span:first-child" ) )
.addClass( "ui-corner-top" )
.end()
.not( ".ui-li-link-alt span:first-child" ) )
.addClass( "ui-corner-top" )
.end()
.find( ".ui-li-link-alt, .ui-li-link-alt span:first-child" )
.addClass( "ui-corner-tr" )
.end()
.find( ".ui-li-thumb" )
.not(".ui-li-icon")
.not( ".ui-li-icon" )
.addClass( "ui-corner-tl" );

// 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" )
@@ -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" );
@@ -160,28 +165,29 @@ $.widget( "mobile.listview", $.mobile.widget, {
listsplittheme = $list.jqmData( "splittheme" ),
listspliticon = $list.jqmData( "spliticon" ),
li = this._getChildrenByTagName( $list[ 0 ], "li", "LI" ),
jsCount = $.support.cssPseudoElement || !$.nodeName( $list[ 0 ], "ol" ) ? false : true,
ol = !!$.nodeName( $list[ 0 ], "ol" ),
jsCount = !$.support.cssPseudoElement,
start = $list.attr( "start" ),
itemClassDict = {},
item, itemClass, itemTheme,
a, last, splittheme, counter, countParent, icon, imgParents, img, linkIcon;
a, last, splittheme, counter, startCount, newStartCount, countParent, icon, imgParents, img, linkIcon;

if ( jsCount ) {
if ( ol && jsCount ) {
$list.find( ".ui-li-dec" ).remove();
}

// Check if a start attribute has been set and take a value of 0 into account
if ( typeof start !== "undefined" && start !== false ) {
if ( !jsCount ) {
var startCount = parseFloat( start ) - 1;
$list.css( "counter-reset", "listnumbering " + startCount );
} else {
counter = parseFloat( start );
}
} else {
if ( jsCount ) {
counter = 1;
}
if ( ol ) {
// Check if a start attribute has been set while taking a value of 0 into account
if ( typeof start !== "undefined" && start !== false ) {
if ( !jsCount ) {
startCount = parseFloat( start ) - 1;
$list.css( "counter-reset", "listnumbering " + startCount );
} else {
counter = parseFloat( start );
}
} else if ( jsCount ) {
counter = 1;
}
}

if ( !o.theme ) {
@@ -194,12 +200,12 @@ $.widget( "mobile.listview", $.mobile.widget, {

// If we're creating the element, we update it regardless
if ( create || !item.hasClass( "ui-li" ) ) {
itemTheme = item.jqmData("theme") || o.theme;
itemTheme = item.jqmData( "theme" ) || o.theme;
a = this._getChildrenByTagName( item[ 0 ], "a", "A" );
var isDivider = ( item.jqmData( "role" ) === "list-divider" );

if ( a.length && !isDivider ) {
icon = item.jqmData("icon");
icon = item.jqmData( "icon" );

item.buttonMarkup({
wrapperEls: "div",
@@ -221,9 +227,9 @@ $.widget( "mobile.listview", $.mobile.widget, {

last = a.last();
splittheme = listsplittheme || last.jqmData( "theme" ) || o.splitTheme;
linkIcon = last.jqmData("icon");
linkIcon = last.jqmData( "icon" );

last.appendTo(item)
last.appendTo( item )
.attr( "title", last.getEncodedText() )
.addClass( "ui-li-link-alt" )
.empty()
@@ -251,26 +257,26 @@ $.widget( "mobile.listview", $.mobile.widget, {
itemClass += " ui-li-divider ui-bar-" + dividertheme;
item.attr( "role", "heading" );

//reset counter when a divider heading is encountered
if ( typeof start !== "undefined" && start !== false ) {
if ( !jsCount ) {
var newStartCount = parseFloat( start ) - 1;
item.css( "counter-reset", "listnumbering " + newStartCount );
} else {
counter = parseFloat( start );
}
} else {
if ( jsCount ) {
counter = 1;
}
if ( ol ) {
//reset counter when a divider heading is encountered
if ( typeof start !== "undefined" && start !== false ) {
if ( !jsCount ) {
newStartCount = parseFloat( start ) - 1;
item.css( "counter-reset", "listnumbering " + newStartCount );
} else {
counter = parseFloat( start );
}
} else if ( jsCount ) {
counter = 1;
}
}

} else {
itemClass += " ui-li-static ui-body-" + itemTheme;
}
}

if ( jsCount && itemClass.indexOf( "ui-li-divider" ) < 0 ) {
if ( ol && jsCount && itemClass.indexOf( "ui-li-divider" ) < 0 ) {
countParent = itemClass.indexOf( "ui-li-static" ) > 0 ? item : item.find( ".ui-link-inherit" );

countParent.addClass( "ui-li-jsnumbering" )