r1952 - in trunk: demos/accordion tests/unit/accordion ui

r1952 - in trunk: demos/accordion tests/unit/accordion ui


Author: scott.gonzalez
Date: Sun Feb 1 18:29:31 2009
New Revision: 1952
Modified:
trunk/demos/accordion/collapsible.html
trunk/tests/unit/accordion/accordion.js
trunk/ui/ui.accordion.js
Log:
Accordion: Fixed #3969: Deprecated alwaysOpen for collapsible option; fixed
demos, tests, and using alwaysOpen on init.
Modified: trunk/demos/accordion/collapsible.html
==============================================================================
--- trunk/demos/accordion/collapsible.html    (original)
+++ trunk/demos/accordion/collapsible.html    Sun Feb 1 18:29:31 2009
@@ -10,7 +10,7 @@
    <script type="text/javascript">
    $(function() {
        $("#accordion").accordion({
-            alwaysOpen: false
+            collapsible: true
        });
    });
    </script>
@@ -49,7 +49,7 @@
<div class="demo-description">
-

By default, accordions always keep one section open. To allow for all
sections to be be collapsible, set the <code>alwaysOpen</code> option to
false. Click on the currently open section to collapse its content pane.


+

By default, accordions always keep one section open. To allow for all
sections to be be collapsible, set the <code>collapsible</code> option to
true. Click on the currently open section to collapse its content pane.


</div><!-- End demo-description -->
Modified: trunk/tests/unit/accordion/accordion.js
==============================================================================
--- trunk/tests/unit/accordion/accordion.js    (original)
+++ trunk/tests/unit/accordion/accordion.js    Sun Feb 1 18:29:31 2009
@@ -48,8 +48,8 @@
    state(ac, 0, 0, 1);
});
-test("activate, boolean and numeric, alwaysOpen:false", function() {
-    var ac = $('#list1').accordion({alwaysOpen: false}).accordion("activate",
2);
+test("activate, boolean and numeric, collapsible:true", function() {
+    var ac = $('#list1').accordion({collapsible: true}).accordion("activate",
2);
    state(ac, 0, 0, 1);
    ok("x", "----");
    ac.accordion("activate", 0);
@@ -59,7 +59,7 @@
    state(ac, 0, 0, 0);
});
-test("activate, boolean, alwaysOpen:true", function() {
+test("activate, boolean, collapsible:false", function() {
    var ac = $('#list1').accordion().accordion("activate", 2);
    state(ac, 0, 0, 1);
    ac.accordion("activate", -1);
@@ -102,7 +102,7 @@
test("active:false", function() {
    $("#list1").accordion({
        active: false,
-        alwaysOpen: false
+        collapsible: true
    });
    equals( $("#list1 a.selected").size(), 0, "no headers selected" );
});
@@ -111,7 +111,7 @@
    expect(8);
    $("#list1").accordion({
        active: false,
-        alwaysOpen: false
+        collapsible: true
    })
    .one("accordionchange", function(event, ui) {
        equals( ui.oldHeader.size(), 0 );
Modified: trunk/ui/ui.accordion.js
==============================================================================
--- trunk/ui/ui.accordion.js    (original)
+++ trunk/ui/ui.accordion.js    Sun Feb 1 18:29:31 2009
@@ -19,6 +19,14 @@
        var o = this.options, self = this;
        this.running = 0;
+        // if the user set the alwaysOpen option on init
+        // then we need to set the collapsible option
+        // if they set both on init, collapsible will take priority
+        if (o.collapsible == $.ui.accordion.defaults.collapsible &&
+            o.alwaysOpen != $.ui.accordion.defaults.alwaysOpen) {
+            o.collapsible = !o.alwaysOpen;
+        }
+
        if ( o.navigation ) {
            var current = this.element.find("a").filter(o.navigationFilter);
            if ( current.length ) {
@@ -377,9 +385,9 @@
        active: null,
        autoHeight: true,
        alwaysOpen: true, //deprecated, use collapsible
-        collapsible: false,
        animated: 'slide',
        clearStyle: false,
+        collapsible: false,
        event: "click",
        fillSpace: false,
        header: "> li > :first-child,> :not(li):even",