Merge pull request #1660 from gseguin/issue-1470

Fix for #1470
This commit is contained in:
Ghislain Seguin 2011-06-28 22:26:00 -07:00
commit d0ec1ec452
3 changed files with 67 additions and 10 deletions

View file

@ -47,7 +47,12 @@ $.widget( "mobile.listview", $.mobile.widget, {
});
},
_removeCorners: function( li ) {
_removeCorners: function( li, which ) {
which = which || ["top", "bottom"];
var classes = {
top: "ui-corner-top ui-corner-tr ui-corner-tl",
bottom: "ui-corner-bottom ui-corner-br ui-corner-bl"
};
li
.add( li.find(".ui-btn-inner, .ui-li-link-alt, .ui-li-thumb") )
.removeClass( "ui-corner-top ui-corner-bottom ui-corner-br ui-corner-bl ui-corner-tr ui-corner-tl" );
@ -165,7 +170,9 @@ $.widget( "mobile.listview", $.mobile.widget, {
if(item.prev().prev().length){
self._removeCorners( item.prev() );
}
} else if (item.prev().length) {
self._removeCorners( item.prev(), ["bottom"]);
}
}
}

View file

@ -241,6 +241,11 @@
</div>
</div>
<!-- Programmatically generated list items !-->
<div data-nstest-role="page" id="programmatically-generated-list">
<ul data-nstest-role="listview" data-nstest-inset="true" id="programmatically-generated-list-items"></ul>
</div>
<!-- Removing items from list -->
<div data-nstest-role="page" id='removing-items-from-list-test'>
<div data-nstest-role="header" data-nstest-position="inline">

View file

@ -390,15 +390,60 @@
}, 1000);
});
module("Programmatic list items manipulation");
module( "Programmatically generated list items", {
setup: function(){
var item,
data = [
{
id: 1,
label: "Item 1"
},
{
id: 2,
label: "Item 2"
},
{
id: 3,
label: "Item 3"
},
{
id: 4,
label: "Item 4"
}
];
asyncTest( "Removing list items", 4, function() {
$.testHelper.pageSequence([
function(){
$.testHelper.openPage("#removing-items-from-list-test");
},
$( "#programmatically-generated-list-items" ).html("");
function(){
for ( var i = 0, len = data.length; i < len; i++ ) {
item = $( '<li id="myItem' + data[i].id + '">' );
label = $( "<strong>" + data[i].label + "</strong>").appendTo( item );
$( "#programmatically-generated-list-items" ).append( item );
}
}
});
asyncTest( "Corner styling on programmatically created list items", function() {
// https://github.com/jquery/jquery-mobile/issues/1470
$.testHelper.pageSequence([
function() {
$.testHelper.openPage( "#programmatically-generated-list" );
},
function() {
ok(!$( "#programmatically-generated-list-items li:first-child" ).hasClass( "ui-corner-bottom" ), "First list item should not have class ui-corner-bottom" );
start();
}
]);
});
module("Programmatic list items manipulation");
asyncTest("Removing list items", 4, function() {
$.testHelper.pageSequence([
function() {
$.testHelper.openPage("#removing-items-from-list-test");
},
function() {
var ul = $('#removing-items-from-list-test ul');
ul.find("li").first().remove();
equal(ul.find("li").length, 3, "There should be only 3 list items left");
@ -414,6 +459,6 @@
start();
}
]);
});
});
})(jQuery);