Skip to content

Commit

Permalink
Accordion: Fixed destroy method with new markup.
Browse files Browse the repository at this point in the history
  • Loading branch information
scottgonzalez committed Jan 30, 2009
1 parent 902c191 commit 967d659
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 57 deletions.
72 changes: 33 additions & 39 deletions tests/unit/accordion/accordion.html
Expand Up @@ -19,47 +19,41 @@
<div id="main"> <div id="main">


<div id="list1"> <div id="list1">
<div> <a>There is one obvious advantage:</a>
<a>There is one obvious advantage:</a> <div>
<div> <p>
<p> You've seen it coming!
You've seen it coming! <br/>
<br/> Buy now and get nothing for free!
Buy now and get nothing for free! <br/>
<br/> Well, at least no free beer. Perhaps a bear, if you can afford it.
Well, at least no free beer. Perhaps a bear, if you can afford it. </p>
</p> </div>
</div> <a>Now that you've got...</a>
</div> <div>
<div> <p>
<a>Now that you've got...</a> your bear, you have to admit it!
<div> <br/>
<p> No, we aren't selling bears.
your bear, you have to admit it! </p>
<br/> <p>
No, we aren't selling bears. We could talk about renting one.
</p> </p>
<p> </div>
We could talk about renting one. <a>Rent one bear, ...</a>
</p> <div>
</div> <p>
</div> get two for three beer.
<div> </p>
<a>Rent one bear, ...</a> <p>
<div> And now, for something completely different.
<p> </p>
get two for three beer. </div>
</p>
<p>
And now, for something completely different.
</p>
</div>
</div>
</div> </div>


<ul id="navigation"> <ul id="navigation">
<li><a href="?p=1.1.1">Guitar</a></li>
<li> <li>
<a href="?p=1.1.1">Guitar</a>
<ul> <ul>
<li><a href="?p=1.1.1.1">Electric</a></li> <li><a href="?p=1.1.1.1">Electric</a></li>
<li><a href="?p=1.1.1.2">Acoustic</a></li> <li><a href="?p=1.1.1.2">Acoustic</a></li>
Expand All @@ -68,8 +62,8 @@
<li><a href="?p=1.1.1.5">Accessories</a></li> <li><a href="?p=1.1.1.5">Accessories</a></li>
</ul> </ul>
</li> </li>
<li><a href="?p=1.1.2"><span>Bass</span></a></li>
<li> <li>
<a href="?p=1.1.2"><span>Bass</span></a>
<ul> <ul>
<li><a href="?p=1.1.2.1">Electric</a></li> <li><a href="?p=1.1.2.1">Electric</a></li>
<li><a href="?p=1.1.2.2">Acoustic</a></li> <li><a href="?p=1.1.2.2">Acoustic</a></li>
Expand All @@ -80,8 +74,8 @@
<li><a href="?p=1.1.2.5">Accessories</a></li> <li><a href="?p=1.1.2.5">Accessories</a></li>
</ul> </ul>
</li> </li>
<li><a href="?p=1.1.3">Drums</a></li>
<li> <li>
<a href="?p=1.1.3">Drums</a>
<ul> <ul>
<li><a href="?p=1.1.3.2">Acoustic Drums</a></li> <li><a href="?p=1.1.3.2">Acoustic Drums</a></li>
<li><a href="?p=1.1.3.3">Electronic Drums</a></li> <li><a href="?p=1.1.3.3">Electronic Drums</a></li>
Expand Down
30 changes: 15 additions & 15 deletions tests/unit/accordion/accordion.js
Expand Up @@ -24,13 +24,13 @@ test("basics", function() {


test("autoHeight", function() { test("autoHeight", function() {
$('#navigation').accordion({ autoHeight: false }); $('#navigation').accordion({ autoHeight: false });
equals( 90, $('#navigation div:first').height() ); equals( $('#navigation > li:eq(1)').height(), 90 );
equals( 126, $('#navigation div:eq(1)').height() ); equals( $('#navigation > li:eq(3)').height(), 126 );
equals( 54, $('#navigation div:last').height() ); equals( $('#navigation > li:eq(5)').height(), 54 );
$('#navigation').accordion("destroy").accordion({ autoHeight: true }); $('#navigation').accordion("destroy").accordion({ autoHeight: true });
equals( 126, $('#navigation div:first').height() ); equals( $('#navigation > li:eq(1)').height(), 126 );
equals( 126, $('#navigation div:eq(1)').height() ); equals( $('#navigation > li:eq(3)').height(), 126 );
equals( 126, $('#navigation div:last').height() ); equals( $('#navigation > li:eq(5)').height(), 126 );
}); });


test("activate, numeric", function() { test("activate, numeric", function() {
Expand Down Expand Up @@ -94,7 +94,7 @@ function state2(accordion) {
} }


test("handle click on header-descendant", function() { test("handle click on header-descendant", function() {
var ac = $('#navigation').accordion({ autoHeight: false }) var ac = $('#navigation').accordion({ autoHeight: false });
ac.triggerEvent("click", $('#navigation span:contains(Bass)')[0]); ac.triggerEvent("click", $('#navigation span:contains(Bass)')[0]);
state2(ac, 0, 1, 0); state2(ac, 0, 1, 0);
}); });
Expand All @@ -114,17 +114,17 @@ test("accordionchange event, open closed and close again", function() {
alwaysOpen: false alwaysOpen: false
}) })
.one("accordionchange", function(event, ui) { .one("accordionchange", function(event, ui) {
equals( ui.oldHeader.size(), 0 ) equals( ui.oldHeader.size(), 0 );
equals( ui.oldContent.size(), 0 ) equals( ui.oldContent.size(), 0 );
equals( ui.newHeader.size(), 1 ) equals( ui.newHeader.size(), 1 );
equals( ui.newContent.size(), 1 ) equals( ui.newContent.size(), 1 );
}) })
.accordion("activate", 0) .accordion("activate", 0)
.one("accordionchange", function(event, ui) { .one("accordionchange", function(event, ui) {
equals( ui.oldHeader.size(), 1 ) equals( ui.oldHeader.size(), 1 );
equals( ui.oldContent.size(), 1 ) equals( ui.oldContent.size(), 1 );
equals( ui.newHeader.size(), 0 ) equals( ui.newHeader.size(), 0 );
equals( ui.newContent.size(), 0 ) equals( ui.newContent.size(), 0 );
}) })
.accordion("activate", 0); .accordion("activate", 0);
}); });
Expand Down
4 changes: 1 addition & 3 deletions ui/ui.accordion.js
Expand Up @@ -105,9 +105,7 @@ $.widget("ui.accordion", {


this.headers.find("a").removeAttr("tabindex"); this.headers.find("a").removeAttr("tabindex");
this.headers.children(".ui-icon").remove(); this.headers.children(".ui-icon").remove();
this.headers.next().removeClass("ui-accordion-content ui-accordion-content-active").each(function() { this.headers.next().removeClass("ui-accordion-content ui-accordion-content-active");
$(this).parent().replaceWith(this);
});


}, },


Expand Down

0 comments on commit 967d659

Please sign in to comment.