Skip to content
This repository has been archived by the owner on Oct 8, 2021. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
Collapsible set: Declare the same options as collapsible, and update …
…child collapsibles when any of those options change.
  • Loading branch information
Gabriel Schulhof committed Jul 9, 2013
1 parent f380d2a commit c12d10f
Showing 1 changed file with 21 additions and 6 deletions.
27 changes: 21 additions & 6 deletions js/widgets/collapsibleSet.js
Expand Up @@ -5,11 +5,20 @@
//>>css.structure: ../css/structure/jquery.mobile.collapsible.css
//>>css.theme: ../css/themes/default/jquery.mobile.theme.css

define( [ "jquery", "../jquery.mobile.widget", "./collapsible", "./addFirstLastClasses", "../jquery.mobile.registry" ], function( jQuery ) {
define( [
"jquery",
"../jquery.mobile.widget",
"./collapsible",
"./addFirstLastClasses",
"../jquery.mobile.registry" ], function( jQuery ) {
//>>excludeEnd("jqmBuildExclude");
(function( $, undefined ) {

var childCollapsiblesSelector = ":mobile-collapsible, :jqmData(role='collapsible')";

$.widget( "mobile.collapsibleset", $.extend( {
options: $.extend( {}, $.mobile.collapsible.defaults ),

_create: function() {
var $el = this.element,
o = this.options,
Expand Down Expand Up @@ -59,18 +68,24 @@ $.widget( "mobile.collapsibleset", $.extend( {
},

_init: function() {
var $el = this.element,
collapsiblesInSet = $el.children( ":mobile-collapsible, :jqmData(role='collapsible')" ),
expanded = collapsiblesInSet.filter( ":jqmData(collapsed='false')" );
this._refresh( "true" );

// Because the corners are handled by the collapsible itself and the default state is collapsed
// That was causing https://github.com/jquery/jquery-mobile/issues/4116
expanded.trigger( "expand" );
this.element
.children( childCollapsiblesSelector )
.filter( ":jqmData(collapsed='false')" )
.trigger( "expand" );
},

_setOptions: function( options ) {
var ret = this._super( options );
this.element.children( ":mobile-collapsible" ).collapsible( "refresh" );
return ret;
},

_refresh: function( create ) {
var collapsiblesInSet = this.element.children( ":mobile-collapsible, :jqmData(role='collapsible')" );
var collapsiblesInSet = this.element.children( childCollapsiblesSelector );

$.mobile.collapsible.prototype.enhance( collapsiblesInSet.not( ".ui-collapsible" ) );

Expand Down

0 comments on commit c12d10f

Please sign in to comment.