4 * Hyunjung Kim <hjnim.kim@samsung.com>
7 $( "#radiopage" ).live( "pageinit", function(event) {
12 var unit_radio = function ( input , type ) {
17 radioClassPrefix = "ui-radio";
19 radio = input.parent();
20 ok( radio.hasClass( radioClassPrefix ) , "Create - Single Radio Button" );
22 label = radio.find( "label" );
23 label.trigger( "vclick" );
24 checkClass = radioClassPrefix + "-on";
25 if( !input.is( ":checked" ) ) {
26 checkClass = radioClassPrefix + "-off";
28 ok( label.hasClass( checkClass ), "Click - Radio button" );
30 labelSpan = label.children().children();
31 ok( labelSpan.first().is( ".ui-btn-text, .ui-btn-text-padding-left" ), "Okay - Label Padding" );
33 if ( !input.is( ":disabled" ) ) {
34 label.trigger( "vclick" );
37 // Text Trim, Cause jQueryMobile(JQM) 1.1 forced to add - "\u00a0" in buttonIcon(ButtonMarkup)
38 // JQM 1.1 buttonMarkup code :
39 // - if( buttonIcon ) buttonIcon.appendChild( document.createTextNode( "\u00a0" ) );
40 equal( labelSpan.text().trim(), input.val(), "Label Text" );
44 var unit_radio_group = function ( fieldset , type ) {
50 type = fieldset.jqmData( "type" );
51 if( type === undefined ) {
54 ok( fieldset.is( ".ui-corner-all, .ui-controlgroup, .ui-controlgroup-" + type ) , "Create - ControlGroup" );
56 if( type == "horizontal" ) {
57 labels = fieldset.find( "span.ui-btn-text" ).each( function () {
58 ok( ( $( this ).siblings().length == 0 && $( this ).hasClass( "ui-btn-text" ) ) ? true : false, "Alignment - ControlGroup(Horizontal, Single Radio)" );
62 radios = fieldset.find( "input[type='radio']" );
63 radios.each( function() {
64 unit_radio( $( this ) , "Normal" );
69 for ( i = 0 ; i < raidos.lenght ; i++ ) {
70 label = radios[i].find( "label" );
71 label.trigger( "vclick" );
72 if( !label.hasClass( "ui-radio-on" ) ){
73 throw "error - other button activate";
75 for ( j = 0 ; j < radios.lenght ; j++) {
77 label = radios[j].find( "label" );
78 if( label.hasClass( "ui-radio-on" ) ) {
79 throw "error - other button activate";
83 } catch ( Exception ) {
87 }, "Click - Radio Button( Group )" );
90 test( "radiobutton - Single" , function () {
91 unit_radio( $("#radio-single-1") , "Normal" );
94 test( "radiobutton - Single, Checked, Disabled" , function () {
95 unit_radio( $("#radio-single-2") , "Checked, Disabled" );
98 test( "radiobutton - Single, Disabled" , function () {
99 unit_radio( $("#radio-single-3") , "Disabled" );
102 test( "radiobutton - Group" , function() {
103 unit_radio_group( $("#controlgroup") , "Group" );
106 test( "radiobutton - Group, Horizontal" , function() {
107 unit_radio_group( $("#controlgroup2") , "Group - horizontal" );