4 * Youmin Ha <youmin.ha@samsung.com>
9 $.mobile.defaultTransition = "none";
11 module( "ExpandableList", {
13 var page = $( 'div#expandablelist-main:jqmData(role="page")' ),
15 <div data-role="header">\
16 <h1>expandable list</h1>\
18 <div data-role="content">\
19 <ul data-role="listview" id="list1">\
20 <li id="exp1" data-expandable="true" data-initial-expansion="true">exp1</li>\
21 <li id="exp1-1" data-expandable="true" data-expanded-by="exp1" data-initial-expansion="false">exp1-1</li>\
22 <li id="exp1-1-1" data-expanded-by="exp1-1">exp1-1-1</li>\
23 <li id="exp2" data-expandable="true">exp2</li>\
32 page.append( $( initHtml ) );
34 obj = $( ':jqmData(role="listview")' );
37 obj = $( ':jqmData(expandable="true")' );
38 obj.expandablelist( );
40 teardown: function ( ) {
41 var page = $( 'div#expandablelist-main:jqmData(role="page")' );
50 function expandCollapseTest ( ) {
51 var transitionTimeout = 1000,
52 elist = $( ":jqmData(expandable='true')" ),
58 elist.expandablelist( );
59 ok( elist, "expandablelist object creation" );
62 li1_1 = $( "li#exp1-1" );
63 li1_1_1 = $( "li#exp1-1-1" );
65 val = li1_1.height( );
66 console.log( "li1_1's height=" + val );
67 notEqual( val, 0, "Expanded listitem with expandable parent having data-initial-expansion=true must be visible (height > 0)" );
69 equal( li1_1_1.height(), 0, "Expanded listitem with expandable parent having data-initial-expansion=false must not be visible (height == 0)" );
71 li1_1.trigger( 'vclick' );
72 setTimeout( function ( ) {
73 notEqual( li1_1_1.height( ), 0, "After click, expanded listitem must be visible (height > 0)" );
75 li1.trigger( 'vclick' );
76 setTimeout( function ( ) {
77 // All children must be collapsed when top-level expandable listitem is clicked.
78 equal( li1_1.height(), 0, "After click, all children must be collapsed. (height == 0)" );
79 equal( li1_1_1.height(), 0, "After click, all children must be collapsed. (height == 0)" );
82 }, transitionTimeout );
84 }, transitionTimeout );
87 asyncTest( "Basic expand-collapse test", 6, function ( ) {
88 expandCollapseTest( );
91 asyncTest( "style test - checkbox" , 6, function ( ) {
92 var li = $( "li#exp1-1" ),
93 subitem = $( '<input type="checkbox" id="checkbox1" >' );
97 li.addClass( 'ui-li-1line-check1' )
98 .addClass( 'ui-li-dialogue' );
99 subitem.checkboxradio( );
100 li.trigger( 'refresh' );
103 expandCollapseTest( );