mirror of
https://github.com/jquery/jquery-ui.git
synced 2025-01-07 20:34:24 +00:00
Accordion: API Redesign. Made style changes and changed 'fill' implementation to use $.siblings()
This commit is contained in:
parent
490792be6a
commit
94a1786d56
@ -129,6 +129,15 @@ test("{ fillSpace: true } with sibling", function() {
|
|||||||
equalHeights($('#navigation').accordion({ fillSpace: true}), 320, 332);
|
equalHeights($('#navigation').accordion({ fillSpace: true}), 320, 332);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test("{ fillSpace: true } with multiple siblings", function() {
|
||||||
|
$("#navigationWrapper").height(500);
|
||||||
|
var sibling = $("<p>Lorem Ipsum</p>");
|
||||||
|
$("#navigationWrapper").prepend( sibling.height(100) );
|
||||||
|
$("#navigationWrapper").prepend( sibling.clone().height(50) );
|
||||||
|
//sibling.outerHeight(true) == 126
|
||||||
|
equalHeights($('#navigation').accordion({ fillSpace: true}), 244, 256);
|
||||||
|
});
|
||||||
|
|
||||||
test("{ header: '> li > :first-child,> :not(li):even' }, default", function() {
|
test("{ header: '> li > :first-child,> :not(li):even' }, default", function() {
|
||||||
state($("#list1").accordion(), 1, 0, 0);
|
state($("#list1").accordion(), 1, 0, 0);
|
||||||
state($("#navigation").accordion(), 1, 0, 0);
|
state($("#navigation").accordion(), 1, 0, 0);
|
||||||
|
49
ui/jquery.ui.accordion.js
vendored
49
ui/jquery.ui.accordion.js
vendored
@ -17,11 +17,11 @@ $.widget( "ui.accordion", {
|
|||||||
options: {
|
options: {
|
||||||
active: 0,
|
active: 0,
|
||||||
animated: "slide",
|
animated: "slide",
|
||||||
autoHeight: true,
|
autoHeight: true, //DEPRECATED - use heightStyle: "auto"
|
||||||
clearStyle: false,
|
clearStyle: false, //DEPRECATED - use heightStyle: "content"
|
||||||
collapsible: false,
|
collapsible: false,
|
||||||
event: "click",
|
event: "click",
|
||||||
fillSpace: false,
|
fillSpace: false, //DEPRECATED - use heightStyle: "fill"
|
||||||
//heightStyle: "auto",
|
//heightStyle: "auto",
|
||||||
header: "> li > :first-child,> :not(li):even",
|
header: "> li > :first-child,> :not(li):even",
|
||||||
icons: {
|
icons: {
|
||||||
@ -30,19 +30,6 @@ $.widget( "ui.accordion", {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
_mergeHeightStyle: function() {
|
|
||||||
options = this.options;
|
|
||||||
|
|
||||||
if (options.fillSpace)
|
|
||||||
return "fill";
|
|
||||||
|
|
||||||
if (options.clearStyle)
|
|
||||||
return "content";
|
|
||||||
|
|
||||||
if (options.autoHeight)
|
|
||||||
return "auto";
|
|
||||||
},
|
|
||||||
|
|
||||||
_create: function() {
|
_create: function() {
|
||||||
var self = this,
|
var self = this,
|
||||||
options = self.options;
|
options = self.options;
|
||||||
@ -182,13 +169,29 @@ $.widget( "ui.accordion", {
|
|||||||
.css( "display", "" )
|
.css( "display", "" )
|
||||||
.removeAttr( "role" )
|
.removeAttr( "role" )
|
||||||
.removeClass( "ui-helper-reset ui-widget-content ui-corner-bottom ui-accordion-content ui-accordion-content-active ui-accordion-disabled ui-state-disabled" );
|
.removeClass( "ui-helper-reset ui-widget-content ui-corner-bottom ui-accordion-content ui-accordion-content-active ui-accordion-disabled ui-state-disabled" );
|
||||||
if ( options.heightStyle != "content" ) {
|
if ( options.heightStyle !== "content" ) {
|
||||||
contents.css( "height", "" );
|
contents.css( "height", "" );
|
||||||
}
|
}
|
||||||
|
|
||||||
return $.Widget.prototype.destroy.call( this );
|
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 ) {
|
_setOption: function( key, value ) {
|
||||||
$.Widget.prototype._setOption.apply( this, arguments );
|
$.Widget.prototype._setOption.apply( this, arguments );
|
||||||
|
|
||||||
@ -249,13 +252,15 @@ $.widget( "ui.accordion", {
|
|||||||
var options = this.options,
|
var options = this.options,
|
||||||
maxHeight;
|
maxHeight;
|
||||||
|
|
||||||
if ( options.heightStyle == "fill" ) {
|
if ( options.heightStyle === "fill" ) {
|
||||||
if ( $.browser.msie ) {
|
if ( $.browser.msie ) {
|
||||||
var defOverflow = this.element.parent().css( "overflow" );
|
var defOverflow = this.element.parent().css( "overflow" );
|
||||||
this.element.parent().css( "overflow", "hidden");
|
this.element.parent().css( "overflow", "hidden");
|
||||||
}
|
}
|
||||||
parent = this.element.parent();
|
maxHeight = this.element.parent().height();
|
||||||
maxHeight = parent.height() - parent.children(':visible').not(this.element).outerHeight(true);
|
this.element.siblings( ":visible" ).each(function() {
|
||||||
|
maxHeight -= $( this ).outerHeight( true );
|
||||||
|
});
|
||||||
if ($.browser.msie) {
|
if ($.browser.msie) {
|
||||||
this.element.parent().css( "overflow", defOverflow );
|
this.element.parent().css( "overflow", defOverflow );
|
||||||
}
|
}
|
||||||
@ -270,7 +275,7 @@ $.widget( "ui.accordion", {
|
|||||||
$( this ).innerHeight() + $( this ).height() ) );
|
$( this ).innerHeight() + $( this ).height() ) );
|
||||||
})
|
})
|
||||||
.css( "overflow", "auto" );
|
.css( "overflow", "auto" );
|
||||||
} else if ( options.heightStyle == "auto" ) {
|
} else if ( options.heightStyle === "auto" ) {
|
||||||
maxHeight = 0;
|
maxHeight = 0;
|
||||||
this.headers.next()
|
this.headers.next()
|
||||||
.each(function() {
|
.each(function() {
|
||||||
@ -493,7 +498,7 @@ $.widget( "ui.accordion", {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( this.options.heightStyle == "content" ) {
|
if ( this.options.heightStyle === "content" ) {
|
||||||
this.toShow.add( this.toHide ).css({
|
this.toShow.add( this.toHide ).css({
|
||||||
height: "",
|
height: "",
|
||||||
overflow: ""
|
overflow: ""
|
||||||
|
Loading…
Reference in New Issue
Block a user