<commit_before>﻿/**
	_enyo.FittableLayout_ provides the base positioning and boundary logic for
	the fittable layout strategy. The fittable layout strategy is based on
	laying out items in either a set of rows or a set of columns, with most of
	the items having natural size, but one item expanding to fill the remaining
	space. The item that expands is labeled with the attribute _fit: true_.

	The subkinds [enyo.FittableColumnsLayout](#enyo.FittableColumnsLayout) and
	[enyo.FittableRowsLayout](#enyo.FittableRowsLayout) (or _their_ subkinds)
	are used for layout rather than _enyo.FittableLayout_ because they specify
	properties that the framework expects to be available when laying items out.

	When available on the platform, _enyo.FittableLayout_ will use CSS flexible
	box (flexbox) to implement fitting behavior on the platform for better 
	performance, and will fall back to JS-based layout on older platforms.
	There are three subtle differences between the flexbox and JS implementations
	that should be noted:

	* When using flexbox, vertical margins (`margin-top`, `margin-bottom`) will
		not collapse; when using JS layout, vertical margin will collapse according
		to static layout rules.
	* When using flexbox, non-fitting children of the Fittable must not be sized
		using percentages of the container (even if set to `position: relative`);
		this is explicitly not supported by the flexbox 2013 spec.
	* The flexbox-based Fittable implementation will respect multiple children
		with `fit: true` (the fitting space will be divided equally between them).
		This is NOT supported by the JS implementation, and should not be relied
		on if deploying to platforms without flexbox support.

	The flexbox implementation was added to Enyo 2.5.0 as a performance optimization;
	to opt-out of this optimization (and avoid the subtle differences between the
	flexbox and JS implementations listed above), set `useFlex: false` on the
	Fittable container, which will result in the legacy JS implementation for all
	platforms.

	For more information, see the documentation on
	[Fittables](building-apps/layout/fittables.html) in the Enyo Developer Guide.
*/

enyo.kind({
	name: 'enyo.FittableLayout',
	kind: 'Layout',
	noDefer: true,

	//* @protected
	constructor: enyo.inherit(function (sup) {
		return function () {
			sup.apply(this, arguments);
			
			// Add the force-ltr class if we're in RTL mode, but this control is set explicitly to NOT be in RTL mode.
			this.container.addRemoveClass("force-left-to-right", (enyo.Control.prototype.rtl && !this.container.get("rtl")) );

			// Flexbox optimization is determined by global flexAvailable and per-instance opt-out useFlex flag
			this.useFlex = enyo.FittableLayout.flexAvailable && (this.container.useFlex !== false);
			if (this.useFlex) {
				this.container.addClass(this.flexLayoutClass);
			} else {
				this.container.addClass(this.fitLayoutClass);
			}
		};
	}),
	calcFitIndex: function() {
		var aChildren = this.container.children,
			oChild,
			n;

		for (n=0; n<aChildren.length; n++) {
			oChild = aChildren[n];
			if (oChild.fit && oChild.showing) {
				return n;
			}
		}
	},

	getFitControl: function() {
		var aChildren = this.container.children,
			oFitChild = aChildren[this.fitIndex];

		if (!(oFitChild && oFitChild.fit && oFitChild.showing)) {
			this.fitIndex = this.calcFitIndex();
			oFitChild = aChildren[this.fitIndex];
		}
		return oFitChild;
	},<commit_msg>need to temporarily switch this to be opt-in<commit_after>﻿/**
	_enyo.FittableLayout_ provides the base positioning and boundary logic for
	the fittable layout strategy. The fittable layout strategy is based on
	laying out items in either a set of rows or a set of columns, with most of
	the items having natural size, but one item expanding to fill the remaining
	space. The item that expands is labeled with the attribute _fit: true_.

	The subkinds [enyo.FittableColumnsLayout](#enyo.FittableColumnsLayout) and
	[enyo.FittableRowsLayout](#enyo.FittableRowsLayout) (or _their_ subkinds)
	are used for layout rather than _enyo.FittableLayout_ because they specify
	properties that the framework expects to be available when laying items out.

	When available on the platform, you can opt-in to have _enyo.FittableLayout_ use CSS
	flexible box (flexbox) to implement fitting behavior on the platform for better 
	performance, and will fall back to JS-based layout on older platforms.
	There are three subtle differences between the flexbox and JS implementations
	that should be noted:

	* When using flexbox, vertical margins (`margin-top`, `margin-bottom`) will
		not collapse; when using JS layout, vertical margin will collapse according
		to static layout rules.
	* When using flexbox, non-fitting children of the Fittable must not be sized
		using percentages of the container (even if set to `position: relative`);
		this is explicitly not supported by the flexbox 2013 spec.
	* The flexbox-based Fittable implementation will respect multiple children
		with `fit: true` (the fitting space will be divided equally between them).
		This is NOT supported by the JS implementation, and should not be relied
		on if deploying to platforms without flexbox support.

	The flexbox implementation was added to Enyo 2.5.0 as a performance optimization;
	to opt-in to this optimization set `useFlex: true` on the
	Fittable container, which will result in the use of flexbox when possible - noting the
	subtle differences between the JS fittables implementation and flexbox.

	For more information, see the documentation on
	[Fittables](building-apps/layout/fittables.html) in the Enyo Developer Guide.
*/

enyo.kind({
	name: 'enyo.FittableLayout',
	kind: 'Layout',
	noDefer: true,

	//* @protected
	constructor: enyo.inherit(function (sup) {
		return function () {
			sup.apply(this, arguments);
			
			// Add the force-ltr class if we're in RTL mode, but this control is set explicitly to NOT be in RTL mode.
			this.container.addRemoveClass("force-left-to-right", (enyo.Control.prototype.rtl && !this.container.get("rtl")) );

			// Flexbox optimization is determined by global flexAvailable and per-instance opt-out useFlex flag
			this.useFlex = enyo.FittableLayout.flexAvailable && (this.container.useFlex === true);
			if (this.useFlex) {
				this.container.addClass(this.flexLayoutClass);
			} else {
				this.container.addClass(this.fitLayoutClass);
			}
		};
	}),
	calcFitIndex: function() {
		var aChildren = this.container.children,
			oChild,
			n;

		for (n=0; n<aChildren.length; n++) {
			oChild = aChildren[n];
			if (oChild.fit && oChild.showing) {
				return n;
			}
		}
	},

	getFitControl: function() {
		var aChildren = this.container.children,
			oFitChild = aChildren[this.fitIndex];

		if (!(oFitChild && oFitChild.fit && oFitChild.showing)) {
			this.fitIndex = this.calcFitIndex();
			oFitChild = aChildren[this.fitIndex];
		}
		return oFitChild;
	},
{'fraction_non_alphanumeric': 0.08060089556550629, 'fraction_numerical': 0.0023111367904087824, 'mean_word_length': 4.237518910741301, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5608269', 'n_tokens_mistral': 2177, 'n_tokens_neox': 1959, 'n_words': 794}