Merge branch 'master' of https://github.com/jquery/jquery-mobile
1
external/qunit.css
vendored
|
|
@ -65,7 +65,6 @@
|
|||
|
||||
#qunit-tests {
|
||||
list-style-position: inside;
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
|
||||
#qunit-tests li {
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ $.fn.controlgroup = function(options){
|
|||
.end()
|
||||
.filter(':last').addClass(flCorners[1]).addClass('ui-controlgroup-last');
|
||||
}
|
||||
flipClasses($(this).find('.ui-btn'));
|
||||
flipClasses($(this).find('.ui-btn'+(o.dontFilterOutInvisible?'':':visible')));
|
||||
flipClasses($(this).find('.ui-btn-inner'));
|
||||
if(o.shadow){
|
||||
$(this).addClass('ui-shadow');
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@
|
|||
|
||||
//automatically handle clicks and form submissions through Ajax, when same-domain
|
||||
ajaxEnabled: true,
|
||||
|
||||
|
||||
//When enabled, clicks and taps that result in Ajax page changes will happen slightly sooner on touch devices.
|
||||
//Also, it will prevent the address bar from appearing on platforms like iOS during page transitions.
|
||||
//This option has no effect on non-touch devices, but enabling it may interfere with jQuery plugins that bind to click events
|
||||
|
|
@ -43,7 +43,7 @@
|
|||
|
||||
//set default page transition - 'none' for no transitions
|
||||
defaultPageTransition: "slide",
|
||||
|
||||
|
||||
//minimum scroll distance that will be remembered when returning to a page
|
||||
minScrollBack: screen.height / 2,
|
||||
|
||||
|
|
@ -111,16 +111,13 @@
|
|||
setTimeout(function() {
|
||||
window.scrollTo( 0, ypos );
|
||||
$(document).trigger( "silentscroll", { x: 0, y: ypos });
|
||||
},20);
|
||||
}, 20);
|
||||
|
||||
setTimeout(function() {
|
||||
$.event.special.scrollstart.enabled = true;
|
||||
}, 150 );
|
||||
},
|
||||
|
||||
// compile the namespace normalization regex once
|
||||
normalizeRegex: /-([a-z])/g,
|
||||
|
||||
// take a data attribute property, prepend the namespace
|
||||
// and then camel case the attribute string
|
||||
nsNormalize: function(prop){
|
||||
|
|
|
|||
|
|
@ -16,8 +16,14 @@ $.widget( "mobile.checkboxradio", $.mobile.widget, {
|
|||
//filter works though.
|
||||
label = input.closest("form,fieldset,:jqmData(role='page')").find("label").filter('[for="' + input[0].id + '"]'),
|
||||
inputtype = input.attr( "type" ),
|
||||
checkedicon = "ui-icon-" + inputtype + "-on",
|
||||
uncheckedicon = "ui-icon-" + inputtype + "-off";
|
||||
checkedState = inputtype + "-on",
|
||||
uncheckedState = inputtype + "-off",
|
||||
icon = input.parents( ":jqmData(type='horizontal')" ).length ? undefined : uncheckedState,
|
||||
activeBtn = icon ? "" : " " + $.mobile.activeBtnClass,
|
||||
checkedClass = "ui-"+ checkedState + activeBtn,
|
||||
uncheckedClass = "ui-"+ uncheckedState,
|
||||
checkedicon = "ui-icon-" + checkedState,
|
||||
uncheckedicon = "ui-icon-" + uncheckedState;
|
||||
|
||||
if ( inputtype != "checkbox" && inputtype != "radio" ) { return; }
|
||||
|
||||
|
|
@ -25,6 +31,8 @@ $.widget( "mobile.checkboxradio", $.mobile.widget, {
|
|||
$.extend( this,{
|
||||
label : label,
|
||||
inputtype : inputtype,
|
||||
checkedClass : checkedClass,
|
||||
uncheckedClass : uncheckedClass,
|
||||
checkedicon : checkedicon,
|
||||
uncheckedicon : uncheckedicon
|
||||
});
|
||||
|
|
@ -37,7 +45,7 @@ $.widget( "mobile.checkboxradio", $.mobile.widget, {
|
|||
label
|
||||
.buttonMarkup({
|
||||
theme: this.options.theme,
|
||||
icon: this.element.parents( ":jqmData(type='horizontal')" ).length ? undefined : uncheckedicon,
|
||||
icon: icon,
|
||||
shadow: false
|
||||
});
|
||||
|
||||
|
|
@ -133,11 +141,11 @@ $.widget( "mobile.checkboxradio", $.mobile.widget, {
|
|||
// input[0].checked expando doesn't always report the proper value
|
||||
// for checked='checked'
|
||||
if ( $(input[0]).prop('checked') ) {
|
||||
label.addClass( $.mobile.activeBtnClass );
|
||||
label.addClass( this.checkedClass ).removeClass( this.uncheckedClass );
|
||||
icon.addClass( this.checkedicon ).removeClass( this.uncheckedicon );
|
||||
|
||||
} else {
|
||||
label.removeClass( $.mobile.activeBtnClass );
|
||||
label.removeClass( this.checkedClass ).addClass( this.uncheckedClass );
|
||||
icon.removeClass( this.checkedicon ).addClass( this.uncheckedicon );
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -100,7 +100,11 @@ $( ":jqmData(role='listview')" ).live( "listviewcreate", function() {
|
|||
wrapper.addClass( "ui-listview-filter-inset" );
|
||||
}
|
||||
|
||||
wrapper.insertBefore( list );
|
||||
wrapper
|
||||
.bind( "submit", function() {
|
||||
return false;
|
||||
})
|
||||
.insertBefore( list );
|
||||
});
|
||||
|
||||
})( jQuery );
|
||||
|
|
@ -134,7 +134,7 @@ $.widget( "mobile.page", $.mobile.widget, {
|
|||
|
||||
$elem
|
||||
.find(":jqmData(role='controlgroup')")
|
||||
.controlgroup();
|
||||
.controlgroup({dontFilterOutInvisible: true});
|
||||
|
||||
//links within content areas
|
||||
$elem.find( "a:not(.ui-btn):not(.ui-link-inherit)" )
|
||||
|
|
|
|||
|
|
@ -2,87 +2,87 @@
|
|||
* mobile checkboxradio unit tests
|
||||
*/
|
||||
(function($){
|
||||
module('jquery.mobile.forms.checkboxradio.js');
|
||||
module( 'jquery.mobile.forms.checkboxradio.js' );
|
||||
|
||||
test( "widget can be disabled and enabled", function(){
|
||||
var input = $("#checkbox-1");
|
||||
var button = input.parent().find(".ui-btn");
|
||||
var input = $( "#checkbox-1" ),
|
||||
button = input.parent().find( ".ui-btn" );
|
||||
|
||||
input.checkboxradio("disable");
|
||||
input.checkboxradio("enable");
|
||||
ok(!input.attr("disabled"), "start input as enabled");
|
||||
ok(!input.parent().hasClass("ui-disabled"), "no disabled styles");
|
||||
ok(!input.attr("checked"), "not checked before click");
|
||||
button.trigger("click");
|
||||
ok(input.attr("checked"), "checked after click");
|
||||
ok(button.hasClass("ui-btn-active"), "active styles after click");
|
||||
button.trigger("click");
|
||||
input.checkboxradio( "disable" );
|
||||
input.checkboxradio( "enable" );
|
||||
ok( !input.attr( "disabled" ), "start input as enabled" );
|
||||
ok( !input.parent().hasClass( "ui-disabled" ), "no disabled styles" );
|
||||
ok( !input.attr( "checked" ), "not checked before click" );
|
||||
button.trigger( "click" );
|
||||
ok( input.attr( "checked" ), "checked after click" );
|
||||
ok( button.hasClass( "ui-checkbox-on" ), "active styles after click" );
|
||||
button.trigger( "click" );
|
||||
|
||||
input.checkboxradio("disable");
|
||||
ok(input.attr("disabled"), "input disabled");
|
||||
ok(input.parent().hasClass("ui-disabled"), "disabled styles");
|
||||
ok(!input.attr("checked"), "not checked before click");
|
||||
button.trigger("click");
|
||||
ok(!input.attr("checked"), "not checked after click");
|
||||
ok(!button.hasClass("ui-btn-active"), "no active styles after click");
|
||||
input.checkboxradio( "disable" );
|
||||
ok( input.attr( "disabled" ), "input disabled" );
|
||||
ok( input.parent().hasClass( "ui-disabled" ), "disabled styles" );
|
||||
ok( !input.attr( "checked" ), "not checked before click" );
|
||||
button.trigger( "click" );
|
||||
ok( !input.attr( "checked" ), "not checked after click" );
|
||||
ok( !button.hasClass( "ui-checkbox-on" ), "no active styles after click" );
|
||||
});
|
||||
|
||||
asyncTest( "change events fired on checkbox for both check and uncheck", function(){
|
||||
var $checkbox = $("#checkbox-2"),
|
||||
$checkboxLabel = $checkbox.parent().find(".ui-btn");
|
||||
var $checkbox = $( "#checkbox-2" ),
|
||||
$checkboxLabel = $checkbox.parent().find( ".ui-btn" );
|
||||
|
||||
$checkbox.unbind("change");
|
||||
$checkbox.unbind( "change" );
|
||||
|
||||
expect( 2 );
|
||||
|
||||
$checkbox.change(function(){
|
||||
ok(true, "change fired on click to check the box");
|
||||
ok( true, "change fired on click to check the box" );
|
||||
});
|
||||
|
||||
$checkboxLabel.trigger("click");
|
||||
$checkboxLabel.trigger( "click" );
|
||||
|
||||
//test above will be triggered twice, and the start here once
|
||||
$checkbox.change(function(){
|
||||
$checkbox.change( function(){
|
||||
start();
|
||||
});
|
||||
|
||||
$checkboxLabel.trigger("click");
|
||||
$checkboxLabel.trigger( "click" );
|
||||
});
|
||||
|
||||
asyncTest( "radio button labels should update the active button class to last clicked and clear checked", function(){
|
||||
var $radioBtns = $('#radio-active-btn-test input'),
|
||||
singleActiveAndChecked = function(){
|
||||
same($("#radio-active-btn-test .ui-btn-active").length, 1, "there should be only one active button");
|
||||
same($("#radio-active-btn-test :checked").length, 1, "there should be only one checked");
|
||||
};
|
||||
var $radioBtns = $( '#radio-active-btn-test input' ),
|
||||
singleActiveAndChecked = function(){
|
||||
same( $( "#radio-active-btn-test .ui-radio-on" ).length, 1, "there should be only one active button" );
|
||||
same( $( "#radio-active-btn-test :checked" ).length, 1, "there should be only one checked" );
|
||||
};
|
||||
|
||||
$.testHelper.sequence([
|
||||
function(){
|
||||
$radioBtns.last().siblings('label').click();
|
||||
$radioBtns.last().siblings( 'label' ).click();
|
||||
},
|
||||
|
||||
function(){
|
||||
ok($radioBtns.last().attr('checked'));
|
||||
ok($radioBtns.last().siblings('label').hasClass('ui-btn-active'),
|
||||
"last input label is an active button");
|
||||
ok( $radioBtns.last().attr( 'checked' ) );
|
||||
ok( $radioBtns.last().siblings( 'label' ).hasClass( 'ui-radio-on' ),
|
||||
"last input label is an active button" );
|
||||
|
||||
ok(!$radioBtns.first().attr('checked'));
|
||||
ok(!$radioBtns.first().siblings('label').hasClass('ui-btn-active'),
|
||||
"first input label is not active");
|
||||
ok( !$radioBtns.first().attr( 'checked' ) );
|
||||
ok( !$radioBtns.first().siblings( 'label' ).hasClass( 'ui-radio-on' ),
|
||||
"first input label is not active" );
|
||||
|
||||
singleActiveAndChecked();
|
||||
|
||||
$radioBtns.first().siblings('label').click();
|
||||
$radioBtns.first().siblings( 'label' ).click();
|
||||
},
|
||||
|
||||
function(){
|
||||
ok($radioBtns.first().attr('checked'));
|
||||
ok($radioBtns.first().siblings('label').hasClass('ui-btn-active'),
|
||||
"first input label is an active button");
|
||||
ok( $radioBtns.first().attr( 'checked' ));
|
||||
ok( $radioBtns.first().siblings( 'label' ).hasClass( 'ui-radio-on' ),
|
||||
"first input label is an active button" );
|
||||
|
||||
ok(!$radioBtns.last().attr('checked'));
|
||||
ok(!$radioBtns.last().siblings('label').hasClass('ui-btn-active'),
|
||||
"last input label is not active");
|
||||
ok( !$radioBtns.last().attr( 'checked' ));
|
||||
ok( !$radioBtns.last().siblings( 'label' ).hasClass( 'ui-radio-on' ),
|
||||
"last input label is not active" );
|
||||
|
||||
singleActiveAndChecked();
|
||||
|
||||
|
|
|
|||
122
tests/unit/controlgroup/controlgroup_core.js
Normal file
|
|
@ -0,0 +1,122 @@
|
|||
/*
|
||||
* mobile checkboxradio unit tests
|
||||
*/
|
||||
(function($){
|
||||
module( 'vertical controlgroup, no refresh' , {
|
||||
setup: function() {
|
||||
this.vcontrolgroup = $( "#vertical-controlgroup" );
|
||||
}
|
||||
});
|
||||
|
||||
test( "vertical controlgroup classes", function() {
|
||||
var buttons = this.vcontrolgroup.find( ".ui-btn" ),
|
||||
middlebuttons = buttons.filter(function(index) { return index > 0 && index < (length-1)}),
|
||||
length = buttons.length;
|
||||
|
||||
ok( !buttons.hasClass( "ui-btn-corner-all" ), "no button should have class 'ui-btn-corner-all'");
|
||||
ok( buttons.first().hasClass( "ui-corner-top" ), "first button should have class 'ui-corner-top'" );
|
||||
ok( !middlebuttons.hasClass( "ui-corner-top" ), "middle buttons should not have class 'ui-corner-top'" );
|
||||
ok( !middlebuttons.hasClass( "ui-corner-bottom" ), "middle buttons should not have class 'ui-corner-bottom'" );
|
||||
ok( buttons.last().hasClass( "ui-corner-bottom"), "last button should have class 'ui-corner-bottom'" );
|
||||
});
|
||||
|
||||
module( 'vertical controlgroup, refresh', {
|
||||
setup: function() {
|
||||
this.vcontrolgroup = $( "#vertical-controlgroup" );
|
||||
this.vcontrolgroup.find( ".ui-btn" ).show();
|
||||
this.vcontrolgroup.controlgroup();
|
||||
}
|
||||
});
|
||||
|
||||
test( "vertical controlgroup after first button was hidden", function() {
|
||||
//https://github.com/jquery/jquery-mobile/issues/1929
|
||||
|
||||
//We hide the first button and refresh
|
||||
this.vcontrolgroup.find( ".ui-btn" ).first().hide();
|
||||
this.vcontrolgroup.controlgroup();
|
||||
|
||||
var buttons = this.vcontrolgroup.find( ".ui-btn" ).filter( ":visible" ),
|
||||
middlebuttons = buttons.filter(function(index) { return index > 0 && index < (length-1)}),
|
||||
length = buttons.length;
|
||||
|
||||
ok( buttons.first().hasClass( "ui-corner-top" ), "first visible button should have class 'ui-corner-top'" );
|
||||
ok( !middlebuttons.hasClass( "ui-corner-top" ), "middle buttons should not have class 'ui-corner-top'" );
|
||||
ok( !middlebuttons.hasClass( "ui-corner-bottom" ), "middle buttons should not have class 'ui-corner-bottom'" );
|
||||
ok( buttons.last().hasClass( "ui-corner-bottom"), "last visible button should have class 'ui-corner-bottom'" );
|
||||
});
|
||||
|
||||
test( "vertical controlgroup after last button was hidden", function() {
|
||||
//https://github.com/jquery/jquery-mobile/issues/1929
|
||||
|
||||
//We hide the last button and refresh
|
||||
this.vcontrolgroup.find( ".ui-btn" ).last().hide();
|
||||
this.vcontrolgroup.controlgroup();
|
||||
|
||||
var buttons = this.vcontrolgroup.find( ".ui-btn" ).filter( ":visible" ),
|
||||
middlebuttons = buttons.filter(function(index) { return index > 0 && index < (length-1)}),
|
||||
length = buttons.length;
|
||||
|
||||
ok( buttons.first().hasClass( "ui-corner-top" ), "first visible button should have class 'ui-corner-top'" );
|
||||
ok( !middlebuttons.hasClass( "ui-corner-top" ), "middle buttons should not have class 'ui-corner-top'" );
|
||||
ok( !middlebuttons.hasClass( "ui-corner-bottom" ), "middle buttons should not have class 'ui-corner-bottom'" );
|
||||
ok( buttons.last().hasClass( "ui-corner-bottom"), "last visible button should have class 'ui-corner-bottom'" );
|
||||
});
|
||||
|
||||
module( 'horizontal controlgroup, no refresh', {
|
||||
setup: function() {
|
||||
this.hcontrolgroup = $( "#horizontal-controlgroup" );
|
||||
}
|
||||
});
|
||||
|
||||
test( "horizontal controlgroup classes", function() {
|
||||
var buttons = this.hcontrolgroup.find( ".ui-btn" ),
|
||||
middlebuttons = buttons.filter(function(index) { return index > 0 && index < (length-1)}),
|
||||
length = buttons.length;
|
||||
|
||||
ok( !buttons.hasClass( "ui-btn-corner-all" ), "no button should have class 'ui-btn-corner-all'");
|
||||
ok( buttons.first().hasClass( "ui-corner-left" ), "first button should have class 'ui-corner-left'" );
|
||||
ok( !middlebuttons.hasClass( "ui-corner-left" ), "middle buttons should not have class 'ui-corner-left'" );
|
||||
ok( !middlebuttons.hasClass( "ui-corner-right" ), "middle buttons should not have class 'ui-corner-right'" );
|
||||
ok( buttons.last().hasClass( "ui-corner-right"), "last button should have class 'ui-corner-right'" );
|
||||
});
|
||||
|
||||
module( 'horizontal controlgroup, refresh', {
|
||||
setup: function() {
|
||||
this.hcontrolgroup = $( "#horizontal-controlgroup" );
|
||||
this.hcontrolgroup.find( ".ui-btn" ).show();
|
||||
this.hcontrolgroup.controlgroup();
|
||||
}
|
||||
});
|
||||
|
||||
test( "horizontal controlgroup after first button was hidden", function() {
|
||||
//We hide the first button and refresh
|
||||
this.hcontrolgroup.find( ".ui-btn" ).first().hide();
|
||||
this.hcontrolgroup.controlgroup();
|
||||
|
||||
var buttons = this.hcontrolgroup.find( ".ui-btn" ).filter( ":visible" ),
|
||||
middlebuttons = buttons.filter(function(index) { return index > 0 && index < (length-1)}),
|
||||
length = buttons.length;
|
||||
|
||||
ok( buttons.first().hasClass( "ui-corner-left" ), "first visible button should have class 'ui-corner-left'" );
|
||||
ok( !middlebuttons.hasClass( "ui-corner-left" ), "middle buttons should not have class 'ui-corner-left'" );
|
||||
ok( !middlebuttons.hasClass( "ui-corner-right" ), "middle buttons should not have class 'ui-corner-right'" );
|
||||
ok( buttons.last().hasClass( "ui-corner-right"), "last visible button should have class 'ui-corner-right'" );
|
||||
});
|
||||
|
||||
test( "horizontal controlgroup after last button was hidden", function() {
|
||||
//We hide the last button and refresh
|
||||
this.hcontrolgroup.find( ".ui-btn" ).last().hide();
|
||||
this.hcontrolgroup.controlgroup();
|
||||
|
||||
var buttons = this.hcontrolgroup.find( ".ui-btn" ).filter( ":visible" ),
|
||||
middlebuttons = buttons.filter(function(index) { return index > 0 && index < (length-1)}),
|
||||
length = buttons.length;
|
||||
|
||||
ok( buttons.first().hasClass( "ui-corner-left" ), "first visible button should have class 'ui-corner-left'" );
|
||||
ok( !middlebuttons.hasClass( "ui-corner-left" ), "middle buttons should not have class 'ui-corner-left'" );
|
||||
ok( !middlebuttons.hasClass( "ui-corner-right" ), "middle buttons should not have class 'ui-corner-right'" );
|
||||
ok( buttons.last().hasClass( "ui-corner-right"), "last visible button should have class 'ui-corner-right'" );
|
||||
});
|
||||
|
||||
|
||||
})(jQuery);
|
||||
68
tests/unit/controlgroup/index.html
Normal file
|
|
@ -0,0 +1,68 @@
|
|||
<!DOCTYPE html>
|
||||
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<title>jQuery Mobile Checkboxradio Test Suite</title>
|
||||
|
||||
<script src="../../../js/jquery.js"></script>
|
||||
<script src="../jquery.setNameSpace.js"></script>
|
||||
<script src="../../../js/"></script>
|
||||
<script src="../../../tests/jquery.testHelper.js"></script>
|
||||
|
||||
<link rel="stylesheet" href="../../../themes/default/"/>
|
||||
<link rel="stylesheet" href="../../../external/qunit.css"/>
|
||||
<script src="../../../external/qunit.js"></script>
|
||||
|
||||
<script src="controlgroup_core.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<h1 id="qunit-header">jQuery Mobile Controlgroup Test Suite</h1>
|
||||
<h2 id="qunit-banner"></h2>
|
||||
<h2 id="qunit-userAgent"></h2>
|
||||
<ol id="qunit-tests">
|
||||
</ol>
|
||||
|
||||
<div data-nstest-role="page">
|
||||
<div data-nstest-role="content">
|
||||
|
||||
<div data-nstest-role="fieldcontain" id="radio-active-btn-test">
|
||||
<fieldset data-nstest-role="controlgroup" id="vertical-controlgroup">
|
||||
<legend>Choose a pet:</legend>
|
||||
<input type="radio" name="radio-pet-active-btn" id="radio-pet-1" value="choice-1" checked="checked" />
|
||||
<label for="radio-pet-1">Cat</label>
|
||||
|
||||
<input type="radio" name="radio-pet-active-btn" id="radio-pet-2" value="choice-2" />
|
||||
<label for="radio-pet-2">Dog</label>
|
||||
|
||||
<input type="radio" name="radio-pet-active-btn" id="radio-pet-3" value="choice-3" />
|
||||
<label for="radio-pet-3">Hamster</label>
|
||||
|
||||
<input type="radio" name="radio-pet-active-btn" id="radio-pet-4" value="choice-4" />
|
||||
<label for="radio-pet-4">Lizard</label>
|
||||
</fieldset>
|
||||
</div>
|
||||
|
||||
<div data-nstest-role="fieldcontain">
|
||||
<fieldset data-nstest-role="controlgroup" data-nstest-type="horizontal" id="horizontal-controlgroup">
|
||||
<legend>Font styling:</legend>
|
||||
<input type="checkbox" name="checkbox-6" id="checkbox-6" class="custom" />
|
||||
<label for="checkbox-6">b</label>
|
||||
|
||||
<input type="checkbox" name="checkbox-7" id="checkbox-7" class="custom" />
|
||||
<label for="checkbox-7"><em>i</em></label>
|
||||
|
||||
<input type="checkbox" name="checkbox-8" id="checkbox-8" class="custom" />
|
||||
<label for="checkbox-8"><em>s</em></label>
|
||||
|
||||
<input type="checkbox" name="checkbox-9" id="checkbox-9" class="custom" />
|
||||
<label for="checkbox-9">u</label>
|
||||
</fieldset>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -14,7 +14,6 @@
|
|||
|
||||
teardown: function(){
|
||||
$("#scroll-testing").remove();
|
||||
window.fizz = '';
|
||||
}
|
||||
});
|
||||
|
||||
|
|
@ -43,14 +42,10 @@
|
|||
}, scrollTimeout);
|
||||
});
|
||||
|
||||
// NOTE may be brittle depending on timing
|
||||
asyncTest( "silent scroll takes at least 20 ms to scroll to the top", function(){
|
||||
test( "silent scroll is async", function(){
|
||||
scrollUp();
|
||||
|
||||
setTimeout(function(){
|
||||
ok($(window).scrollTop() != 0, "scrolltop position should not be zero");
|
||||
start();
|
||||
}, scrollTimeout - 5);
|
||||
ok($(window).scrollTop() != 0, "scrolltop position should not be zero");
|
||||
start();
|
||||
});
|
||||
|
||||
asyncTest( "scrolling marks scrollstart as disabled for 150 ms", function(){
|
||||
|
|
|
|||
22
tests/unit/index.php
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<link rel="stylesheet" href="../../external/qunit.css"></link>
|
||||
</head>
|
||||
<body>
|
||||
<div style="float: left; width: 500px;">
|
||||
<h1 id="qunit-header"><a href="#">jQuery Mobile Complete Test Suite</a></h1>
|
||||
<h2 id="qunit-banner"></h2>
|
||||
<ol id="qunit-tests">
|
||||
</ol>
|
||||
</div>
|
||||
<!-- under normal circumstances inline styles would be a poor choice, but in this case
|
||||
I think an entire link and stylesheet is a waste -->
|
||||
<iframe data-src="../../tests/unit/{{testdir}}" name="testFrame" id="testFrame" width="800px" height="100%" style="float: left; border: 0px; height: 100%;" scrolling="no">
|
||||
</iframe>
|
||||
<script src="../../js/jquery.js"></script>
|
||||
<script src="../../external/qunit.js"></script>
|
||||
<script src="runner.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
17
tests/unit/ls.php
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
<?php
|
||||
header("Content-Type: application/json");
|
||||
|
||||
$response = array( 'directories' => array());
|
||||
|
||||
if ($handle = opendir(getcwd())) {
|
||||
while (false !== ($file = readdir($handle))) {
|
||||
if (is_dir($file) && $file[0] !== "." ) {
|
||||
array_push($response['directories'], $file);
|
||||
}
|
||||
}
|
||||
|
||||
closedir($handle);
|
||||
}
|
||||
|
||||
echo json_encode($response)
|
||||
?>
|
||||
58
tests/unit/runner.js
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
(function(){
|
||||
var test = function(data){
|
||||
var $frameElem = $("#testFrame"),
|
||||
template = $frameElem.attr("data-src"),
|
||||
updateFrame = function(dir){
|
||||
return $frameElem.attr("src", template.replace("{{testdir}}", dir));
|
||||
};
|
||||
|
||||
$.each(data.directories, function(i, dir){
|
||||
asyncTest( dir, function(){
|
||||
var testTimeout = 2 * 60 * 1000, checkInterval = 2000;
|
||||
|
||||
// establish a timeout for a given suite in case of async tests hanging
|
||||
var testTimer = setTimeout( function(){
|
||||
// prevent any schedule checks for completion
|
||||
clearTimeouts();
|
||||
start();
|
||||
}, testTimeout ),
|
||||
|
||||
checkTimer = setInterval( check, checkInterval ),
|
||||
|
||||
clearTimeouts = function(){
|
||||
// prevent the next interval of the check function and the test timeout
|
||||
clearTimeout( checkTimer );
|
||||
clearTimeout( testTimer );
|
||||
};
|
||||
|
||||
// check the iframe for success or failure and respond accordingly
|
||||
function check(){
|
||||
// check for the frames jquery object each time
|
||||
var framejQuery = window.frames["testFrame"].jQuery;
|
||||
|
||||
// if the iframe hasn't loaded (ie loaded jQuery) check back again shortly
|
||||
if( !framejQuery ) return;
|
||||
|
||||
// grab the result of the iframe test suite
|
||||
// TODO strip extra white space
|
||||
var result = framejQuery( "#qunit-banner" ).attr( "class" );
|
||||
|
||||
// if we have a result check it, otherwise check back shortly
|
||||
if( result ){
|
||||
ok( result === "qunit-pass" );
|
||||
clearTimeouts();
|
||||
start();
|
||||
}
|
||||
};
|
||||
|
||||
expect( 1 );
|
||||
|
||||
// set the test suite page on the iframe
|
||||
updateFrame( dir );
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
// get the test directories
|
||||
$.get("ls.php", test);
|
||||
})();
|
||||
|
|
@ -31,5 +31,9 @@
|
|||
|
||||
</div>
|
||||
|
||||
<div id="foo" data-role="page">
|
||||
</div>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
|||
|
Before Width: | Height: | Size: 2.1 KiB After Width: | Height: | Size: 2 KiB |
|
Before Width: | Height: | Size: 2.2 KiB After Width: | Height: | Size: 2.1 KiB |
|
Before Width: | Height: | Size: 3.9 KiB After Width: | Height: | Size: 3.3 KiB |
|
Before Width: | Height: | Size: 4.2 KiB After Width: | Height: | Size: 3.9 KiB |
|
|
@ -819,14 +819,18 @@ a.ui-link-inherit {
|
|||
|
||||
|
||||
/* checks,radios */
|
||||
.ui-checkbox .ui-icon {
|
||||
-moz-border-radius: 3px;
|
||||
-webkit-border-radius: 3px;
|
||||
border-radius: 3px;
|
||||
}
|
||||
.ui-icon-checkbox-off,
|
||||
.ui-icon-checkbox-on,
|
||||
.ui-icon-radio-off,
|
||||
.ui-icon-radio-on {
|
||||
background-color: transparent;
|
||||
-moz-border-radius: 0;
|
||||
-webkit-border-radius: 0;
|
||||
border-radius: 0;
|
||||
.ui-icon-radio-off {
|
||||
background-color: transparent;
|
||||
}
|
||||
.ui-checkbox-on .ui-icon,
|
||||
.ui-radio-on .ui-icon {
|
||||
background-color: #4596ce; /* NOTE: this hex should match the active state color. It's repeated here for cascade */
|
||||
}
|
||||
.ui-icon-searchfield {
|
||||
background-image: url(images/icon-search-black.png);
|
||||
|
|
|
|||
|
Before Width: | Height: | Size: 2.1 KiB After Width: | Height: | Size: 2 KiB |
|
Before Width: | Height: | Size: 2.2 KiB After Width: | Height: | Size: 2.1 KiB |
|
Before Width: | Height: | Size: 3.9 KiB After Width: | Height: | Size: 3.3 KiB |
|
Before Width: | Height: | Size: 4.2 KiB After Width: | Height: | Size: 3.9 KiB |
|
|
@ -618,7 +618,7 @@ a.ui-link-inherit {
|
|||
cursor: pointer;
|
||||
text-decoration: none;
|
||||
border: 1px solid #FFBC19;
|
||||
background: #4596ce;
|
||||
background: #FFBC19;
|
||||
color: #222;
|
||||
text-shadow: 0 1px 0px #eee;
|
||||
background-image: -moz-linear-gradient(top,
|
||||
|
|
@ -830,14 +830,18 @@ a.ui-link-inherit {
|
|||
|
||||
|
||||
/* checks,radios */
|
||||
.ui-checkbox .ui-icon {
|
||||
-moz-border-radius: 3px;
|
||||
-webkit-border-radius: 3px;
|
||||
border-radius: 3px;
|
||||
}
|
||||
.ui-icon-checkbox-off,
|
||||
.ui-icon-checkbox-on,
|
||||
.ui-icon-radio-off,
|
||||
.ui-icon-radio-on {
|
||||
background-color: transparent;
|
||||
-moz-border-radius: 0;
|
||||
-webkit-border-radius: 0;
|
||||
border-radius: 0;
|
||||
.ui-icon-radio-off {
|
||||
background-color: transparent;
|
||||
}
|
||||
.ui-checkbox-on .ui-icon,
|
||||
.ui-radio-on .ui-icon {
|
||||
background-color: #FFBC19; /* NOTE: this hex should match the active state color. It's repeated here for cascade */
|
||||
}
|
||||
.ui-icon-searchfield {
|
||||
background-image: url(images/icon-search-black.png);
|
||||
|
|
|
|||