Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Listview: Added support for start attribute on numbered listviews. Fi…

…xes #4613 - Ordered list ignores "start" attribute.
  • Loading branch information...
commit b6eb00d7d1ffe17d11d288f179d08815423a442f 1 parent 4657b76
@jaspermdegroot jaspermdegroot authored
Showing with 31 additions and 6 deletions.
  1. +31 −6 js/widgets/listview.js
View
37 js/widgets/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,8 +252,17 @@ $.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 {
@@ -245,7 +270,7 @@ $.widget( "mobile.listview", $.mobile.widget, {
}
}
- 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" )
Please sign in to comment.
Something went wrong with that request. Please try again.