]> source.dussan.org Git - jquery-ui.git/commitdiff
Accordion: Move code for deprecated height options into an extension at the bottom...
authorScott González <scott.gonzalez@gmail.com>
Sun, 19 Dec 2010 21:38:15 +0000 (16:38 -0500)
committerScott González <scott.gonzalez@gmail.com>
Sun, 19 Dec 2010 21:38:15 +0000 (16:38 -0500)
tests/unit/accordion/accordion_defaults.js
ui/jquery.ui.accordion.js

index e472734bc61975c9c80193558da19353e727501f..bf5725f3002b5f5a9eaa3f58e6f51e6b07fac457 100644 (file)
@@ -12,6 +12,7 @@ var accordion_defaults = {
        event: "click",
        fillSpace: false,
        header: "> li > :first-child,> :not(li):even",
+       heightStyle: null,
        icons: { "header": "ui-icon-triangle-1-e", "headerSelected": "ui-icon-triangle-1-s" },
        navigation: false,
        navigationFilter: function() {}
index aed10168ab0b4de548147a3399d252c0114e681e..76be0095f5e7d65e4af75503f1f69b24512ca3a3 100644 (file)
@@ -17,13 +17,11 @@ $.widget( "ui.accordion", {
        options: {
                active: 0,
                animated: "slide",
-               autoHeight: true, //DEPRECATED - use heightStyle: "auto"
-               clearStyle: false, //DEPRECATED - use heightStyle: "content"
                collapsible: false,
                event: "click",
-               fillSpace: false, //DEPRECATED - use heightStyle: "fill"
-               //heightStyle: "auto",
                header: "> li > :first-child,> :not(li):even",
+               // TODO: set to "auto" in 2.0 (#5868, #5872)
+               heightStyle: null, // "auto"
                icons: {
                        header: "ui-icon-triangle-1-e",
                        headerSelected: "ui-icon-triangle-1-s"
@@ -34,9 +32,6 @@ $.widget( "ui.accordion", {
                var self = this,
                        options = self.options;
 
-               //Merge autoheight, fillSpace and clearStyle
-               options.heightStyle = options.heightStyle || self._mergeHeightStyle();  
-
                self.running = 0;
 
                self.element
@@ -176,30 +171,9 @@ $.widget( "ui.accordion", {
                return $.Widget.prototype.destroy.call( this );
        },
 
-       _mergeHeightStyle: function() {
-               var options = this.options;
-
-               if ( options.fillSpace ) {
-                       return "fill";
-               }
-
-               if ( options.clearStyle ) {
-                       return "content";
-               }
-
-               if ( options.autoHeight ) {
-                       return "auto";
-               }
-       },
-
        _setOption: function( key, value ) {
                $.Widget.prototype._setOption.apply( this, arguments );
                
-               // handle deprecated options
-               // TODO: remove in 2.0
-               if ( key === "autoHeight" || key === "clearStyle" || key === "fillSpace" ) {
-                       this.options.heightStyle = this._mergeHeightStyle();
-               }
                if ( key == "active" ) {
                        this.activate( value );
                }
@@ -626,7 +600,7 @@ $.extend( $.ui.accordion, {
                        return this.href.toLowerCase() === location.href.toLowerCase();
                }
        });
-       
+
        var _create = prototype._create;
        prototype._create = function() {
                if ( this.options.navigation ) {
@@ -648,6 +622,48 @@ $.extend( $.ui.accordion, {
                }
                _create.call( this );
        };
-}( jQuery, jQuery.ui.accordion.prototype ));
+}( jQuery, jQuery.ui.accordion.prototype ) );
+
+(function( $, prototype ) {
+       $.extend( prototype.options, {
+               autoHeight: true, // use heightStyle: "auto"
+               clearStyle: false, // use heightStyle: "content"
+               fillSpace: false // use heightStyle: "fill"
+       });
+
+       var _create = prototype._create,
+               _setOption = prototype._setOption;
+
+       $.extend( prototype, {
+               _create: function() {
+                       this.options.heightStyle = this.options.heightStyle ||
+                               this._mergeHeightStyle();
+                       _create.call( this );
+               },
+
+               _setOption: function( key, value ) {
+                       if ( key === "autoHeight" || key === "clearStyle" || key === "fillSpace" ) {
+                               this.options.heightStyle = this._mergeHeightStyle();
+                       }
+                       _setOption.apply( this, arguments );
+               },
+
+               _mergeHeightStyle: function() {
+                       var options = this.options;
+
+                       if ( options.fillSpace ) {
+                               return "fill";
+                       }
+
+                       if ( options.clearStyle ) {
+                               return "content";
+                       }
+
+                       if ( options.autoHeight ) {
+                               return "auto";
+                       }
+               }
+       });
+}( jQuery, jQuery.ui.accordion.prototype ) );
 
 })( jQuery );