Skip to content

Commit 460957a

Browse files
author
Gabriel Schulhof
committed
Listview: Add classes option
Fixes jquery-archivegh-7692
1 parent 118c17b commit 460957a

File tree

3 files changed

+14
-5
lines changed

3 files changed

+14
-5
lines changed

js/widgets/listview.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ var getAttr = $.mobile.getAttribute;
1414
$.widget( "mobile.listview", $.extend( {
1515

1616
options: {
17+
classes: {
18+
"ui-listview": null,
19+
"ui-listview-item": null
20+
},
1721
theme: null,
1822
dividerTheme: null,
1923
icon: "carat-r",
@@ -36,7 +40,7 @@ $.widget( "mobile.listview", $.extend( {
3640
}
3741

3842
// create listview markup
39-
t.element.addClass( " ui-listview" + listviewClasses );
43+
t.element.addClass( t._classes( "ui-listview" ) + listviewClasses );
4044

4145
t.refresh( true );
4246
},
@@ -62,6 +66,7 @@ $.widget( "mobile.listview", $.extend( {
6266
var buttonClass, pos, numli, item, itemClass, itemTheme, itemIcon, icon, a,
6367
isDivider, startCount, newStartCount, value, last, splittheme, splitThemeClass, spliticon,
6468
altButtonClass, dividerTheme, li,
69+
baseItemClass = this._classes( "ui-listview-item" ),
6570
o = this.options,
6671
$list = this.element,
6772
ol = !!$.nodeName( $list[ 0 ], "ol" ),
@@ -160,7 +165,9 @@ $.widget( "mobile.listview", $.extend( {
160165
// can give us a significant boost on platforms like WP7.5.
161166

162167
for ( itemClass in itemClassDict ) {
163-
$( itemClassDict[ itemClass ] ).addClass( itemClass );
168+
$( itemClassDict[ itemClass ] ).addClass( itemClass +
169+
( itemClass ? " " : "" ) +
170+
baseItemClass );
164171
}
165172

166173
countBubbles.each( function() {

tests/integration/listview/index.html

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,7 @@
2525
"widgets/listview",
2626
"widgets/listview.autodividers",
2727
"widgets/toolbar",
28-
"widgets/collapsible",
29-
"buttonMarkup"
28+
"widgets/collapsible"
3029
],
3130
[ "init" ],
3231
[ "listview_core.js" ]

tests/integration/listview/listview_core.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,16 @@
2222
});
2323

2424
asyncTest( "The page should be enhanced correctly", function(){
25-
expect( 3 );
25+
expect( 4 );
2626
$.testHelper.pageSequence([
2727
function(){
2828
$.mobile.changePage("#basic-linked-test");
2929
},
3030

3131
function() {
32+
deepEqual( $( "#basic-linked-test ul" ).children().is( function() {
33+
return !$( this ).hasClass( "ui-listview-item" );
34+
}), false, "All children have the class ui-listview-item" );
3235
ok($('#basic-linked-test .ui-li-static').length, ".ui-li-static class added to read-only li elements");
3336
ok($('#basic-linked-test .ui-li-divider').length, ".ui-li-divider class added to divider li elements");
3437
ok($('#basic-linked-test li > .ui-btn').length, ".ui-btn classes added to anchors that are immediate child of li elements");

0 commit comments

Comments
 (0)