Skip to content
This repository
Browse code

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
Jasper de Groot authored July 12, 2012

Showing 1 changed file with 31 additions and 6 deletions. Show diff stats Hide diff stats

  1. 37  js/widgets/listview.js
37  js/widgets/listview.js
@@ -155,18 +155,34 @@ $.widget( "mobile.listview", $.mobile.widget, {
155 155
 		var o = this.options,
156 156
 			$list = this.element,
157 157
 			self = this,
  158
+			listIcon = $list.jqmData( "icon" ) || o.icon,
158 159
 			dividertheme = $list.jqmData( "dividertheme" ) || o.dividerTheme,
159 160
 			listsplittheme = $list.jqmData( "splittheme" ),
160 161
 			listspliticon = $list.jqmData( "spliticon" ),
161 162
 			li = this._getChildrenByTagName( $list[ 0 ], "li", "LI" ),
162  
-			counter = $.support.cssPseudoElement || !$.nodeName( $list[ 0 ], "ol" ) ? 0 : 1,
  163
+			jsCount = $.support.cssPseudoElement || !$.nodeName( $list[ 0 ], "ol" ) ? false : true,
  164
+			start = $list.attr( "start" ),
163 165
 			itemClassDict = {},
164 166
 			item, itemClass, itemTheme,
165  
-			a, last, splittheme, countParent, icon, imgParents, img, linkIcon;
  167
+			a, last, splittheme, counter, countParent, icon, imgParents, img, linkIcon;
166 168
 
167  
-		if ( counter ) {
  169
+		if ( jsCount ) {
168 170
 			$list.find( ".ui-li-dec" ).remove();
169 171
 		}
  172
+		
  173
+		// Check if a start attribute has been set and take a value of 0 into account
  174
+		if ( typeof start !== "undefined" && start !== false ) {
  175
+			if ( !jsCount ) {
  176
+				var startAt = parseInt( start ) - 1;
  177
+				$list.css( "counter-reset", "listnumbering " + startAt );
  178
+			} else {
  179
+				counter = parseInt( start );
  180
+			}
  181
+		} else {
  182
+			if ( jsCount ) {
  183
+				counter = 1;
  184
+			}
  185
+		}
170 186
 
171 187
 		if ( !o.theme ) {
172 188
 			o.theme = $.mobile.getInheritedTheme( this.element, "c" );
@@ -236,8 +252,17 @@ $.widget( "mobile.listview", $.mobile.widget, {
236 252
 					item.attr( "role", "heading" );
237 253
 
238 254
 					//reset counter when a divider heading is encountered
239  
-					if ( counter ) {
240  
-						counter = 1;
  255
+					if ( typeof start !== "undefined" && start !== false ) {
  256
+						if ( !jsCount ) {
  257
+							var startAt = parseInt( start ) - 1;
  258
+							item.css( "counter-reset", "listnumbering " + startAt );
  259
+						} else {
  260
+							counter = parseInt( start );
  261
+						}
  262
+					} else {
  263
+						if ( jsCount ) {
  264
+							counter = 1;
  265
+						}
241 266
 					}
242 267
 
243 268
 				} else {
@@ -245,7 +270,7 @@ $.widget( "mobile.listview", $.mobile.widget, {
245 270
 				}
246 271
 			}
247 272
 
248  
-			if ( counter && itemClass.indexOf( "ui-li-divider" ) < 0 ) {
  273
+			if ( jsCount && itemClass.indexOf( "ui-li-divider" ) < 0 ) {
249 274
 				countParent = itemClass.indexOf( "ui-li-static" ) > 0 ? item : item.find( ".ui-link-inherit" );
250 275
 
251 276
 				countParent.addClass( "ui-li-jsnumbering" )

0 notes on commit b6eb00d

Please sign in to comment.
Something went wrong with that request. Please try again.