Permalink
Browse files

Listview: Added support for start attribute on numbered listviews. Fixes

 #4613 - Ordered list ignores "start" attribute.
  • Loading branch information...
jaspermdegroot committed Jul 12, 2012
1 parent 82d0eaf commit aa996743f7edb757e14ff615dab08138f8ed13b7
Showing with 31 additions and 6 deletions.
  1. +31 −6 js/jquery.mobile.listview.js
@@ -155,18 +155,34 @@ $.widget( "mobile.listview", $.mobile.widget, {
var o = this.options,
$list = this.element,
self = this,
listIcon = $list.jqmData( "icon" ) || o.icon,
dividertheme = $list.jqmData( "dividertheme" ) || o.dividerTheme,
listsplittheme = $list.jqmData( "splittheme" ),
listspliticon = $list.jqmData( "spliticon" ),
li = this._getChildrenByTagName( $list[ 0 ], "li", "LI" ),
counter = $.support.cssPseudoElement || !$.nodeName( $list[ 0 ], "ol" ) ? 0 : 1,
jsCount = $.support.cssPseudoElement || !$.nodeName( $list[ 0 ], "ol" ) ? false : true,
start = $list.attr( "start" ),
itemClassDict = {},
item, itemClass, itemTheme,
a, last, splittheme, countParent, icon, imgParents, img, linkIcon;
a, last, splittheme, counter, countParent, icon, imgParents, img, linkIcon;
if ( counter ) {
if ( 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 startAt = parseInt( start ) - 1;
$list.css( "counter-reset", "listnumbering " + startAt );
} else {
counter = parseInt( start );
}
} else {
if ( jsCount ) {
counter = 1;
}
}
if ( !o.theme ) {
o.theme = $.mobile.getInheritedTheme( this.element, "c" );
@@ -236,16 +252,25 @@ $.widget( "mobile.listview", $.mobile.widget, {
item.attr( "role", "heading" );
//reset counter when a divider heading is encountered
if ( counter ) {
counter = 1;
if ( typeof start !== "undefined" && start !== false ) {
if ( !jsCount ) {
var startAt = parseInt( start ) - 1;
item.css( "counter-reset", "listnumbering " + startAt );
} else {
counter = parseInt( start );
}
} else {
if ( jsCount ) {
counter = 1;
}
}
} else {
itemClass += " ui-li-static ui-body-" + itemTheme;
}
}
if ( counter && itemClass.indexOf( "ui-li-divider" ) < 0 ) {
if ( 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" )

0 comments on commit aa99674

Please sign in to comment.