<commit_before>//>>excludeStart("jqmBuildExclude", pragmas.jqmBuildExclude);
//>>description: For creating grouped collapsible content areas.
//>>label: Collapsible Sets (Accordions)
//>>group: Widgets
//>>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 ) {
//>>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,
			classes = "ui-collapsible-set";

		if ( !o.theme ) {
			o.theme = $el.jqmData( "theme" );
		}
		if ( o.theme ) {
			classes += " ui-group-theme-" + o.theme;
		}

		if ( !o.contentTheme ) {
			o.contentTheme = $el.jqmData( "content-theme" );
		}

		if ( !o.corners ) {
			o.corners = $el.jqmData( "corners" );
		}

		if ( $el.jqmData( "inset" ) !== undefined ) {
			o.inset = $el.jqmData( "inset" );
		}
		o.inset = o.inset !== undefined ? o.inset : true;
		o.corners = o.corners !== undefined ? o.corners : true;

		if ( !!o.corners && !!o.inset ) {
			classes += " ui-corner-all";
		}

		$el.addClass( classes );

		// Initialize the collapsible set if it's not already initialized
		if ( !$el.jqmData( "collapsiblebound" ) ) {
			$el
				.jqmData( "collapsiblebound", true )
				.bind( "collapsibleexpand", function( event ) {
					var closestCollapsible = $( event.target ).closest( ".ui-collapsible" );

					if ( closestCollapsible.parent().is( ":mobile-collapsibleset, :jqmData(role='collapsible-set')" ) ) {
						closestCollapsible
							.siblings( ".ui-collapsible:not(.ui-collapsible-collapsed)" )
							.collapsible( "collapse" );
					}
				});
		}
	},

	_init: function() {
		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
		this.element
			.children( childCollapsiblesSelector )
			.filter( ":jqmData(collapsed='false')" )
			.collapsible( "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( childCollapsiblesSelector );

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

		this._addFirstLastClasses( collapsiblesInSet, this._getVisibles( collapsiblesInSet, create ), create );
	},

	refresh: function() {
		this._refresh( false );
	}
}, $.mobile.behaviors.addFirstLastClasses ) );
<commit_msg>Collapsible set: Reflect options that affect the collapsibleSet instead of merely forwarding them all to the children.<commit_after>//>>excludeStart("jqmBuildExclude", pragmas.jqmBuildExclude);
//>>description: For creating grouped collapsible content areas.
//>>label: Collapsible Sets (Accordions)
//>>group: Widgets
//>>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 ) {
//>>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.addClass( "ui-collapsible-set" );

		$.extend( this, {
			_classes: ""
		});

		this._updateClasses( this.options );

		// Initialize the collapsible set if it's not already initialized
		if ( !$el.jqmData( "collapsiblebound" ) ) {
			$el
				.jqmData( "collapsiblebound", true )
				.bind( "collapsibleexpand", function( event ) {
					var closestCollapsible = $( event.target ).closest( ".ui-collapsible" );

					if ( closestCollapsible.parent().is( ":mobile-collapsibleset, :jqmData(role='collapsible-set')" ) ) {
						closestCollapsible
							.siblings( ".ui-collapsible:not(.ui-collapsible-collapsed)" )
							.collapsible( "collapse" );
					}
				});
		}
	},

	_init: function() {
		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
		this.element
			.children( childCollapsiblesSelector )
			.filter( ":jqmData(collapsed='false')" )
			.collapsible( "expand" );
	},

	_updateClasses: function( options ) {
		var opts = {
				theme: options.theme || this.options.theme,
				corners: options.corners || this.options.corners,
				inset: options.inset || this.options.inset
			},
			classes = "";

		if ( opts.theme && opts.theme !== "none" ) {
			classes += " ui-group-theme-" + opts.theme;
		}

		if ( opts.corners && opts.inset ) {
			classes += " ui-corner-all";
		}

		this._toggleClasses( this.element, "_classes", classes );
	},

	_setOptions: function( options ) {
		var ret = this._super( options );

		this._updateClasses( options );
		this.element.children( ":mobile-collapsible" ).collapsible( "refresh" );
		return ret;
	},

	_refresh: function( create ) {
		var collapsiblesInSet = this.element.children( childCollapsiblesSelector );

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

		this._addFirstLastClasses( collapsiblesInSet, this._getVisibles( collapsiblesInSet, create ), create );
	},

	refresh: function() {
		this._refresh( false );
	}
}, $.mobile.behaviors.addFirstLastClasses ) );

{'fraction_non_alphanumeric': 0.16700473292765383, 'fraction_numerical': 0.001352265043948614, 'mean_word_length': 3.7564308681672025, 'pattern_counts': {'":': 8, '<': 3, '<?xml version=': 0, '>': 31, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3488936', 'n_tokens_mistral': 2249, 'n_tokens_neox': 1967, 'n_words': 389}