Sha256: 13cd35be9029e2993a791ffcce1de1d11811f574ed6c0abc107fcf31806343ff

Contents?: true

Size: 1.92 KB

Versions: 28

Compression:

Stored size: 1.92 KB

Contents

// DATA_TEMPLATE: js_data
oTest.fnStart( "aoColumns.sWidth" );

/* NOTE - we need to disable the auto width for the majority of these test in order to preform 
 * these tests as the auto width will convert the width to a px value. We can do 'non-exact' tests
 * with auto width enabled however to ensure it scales columns as required
 */

$(document).ready( function () {
	/* Check the default */
	var oTable = $('#example').dataTable( {
		"aaData": gaaData,
		"bAutoWidth": false,
		"aoColumns": [
			null,
			{ "sWidth": '40%' },
			null,
			null,
			null
		]
	} );
	var oSettings = oTable.fnSettings();
	
	oTest.fnTest( 
		"With auto width disabled the width for one column is appled",
		null,
		function () { return $('#example thead th:eq(1)')[0].style.width == "40%"; }
	);
	
	oTest.fnTest( 
		"With auto width disabled the width for one column is appled",
		function () {
			oSession.fnRestore();
			oTable = $('#example').dataTable( {
				"aaData": gaaData,
				"bAutoWidth": false,
				"aoColumns": [
					null,
					null,
					{ "sWidth": '20%' },
					{ "sWidth": '30%' },
					null
				]
			} );
		},
		function () {
			var bReturn =
				$('#example thead th:eq(2)')[0].style.width == "20%" &&
				$('#example thead th:eq(3)')[0].style.width == "30%";
			return bReturn;
		}
	);
	
	
	oTest.fnTest( 
		"With auto width, it will make the smallest column the largest with percentage width given",
		function () {
			oSession.fnRestore();
			oTable = $('#example').dataTable( {
				"aaData": gaaData,
				"aoColumns": [
					null,
					null,
					null,
					{ "sWidth": '40%' },
					null
				]
			} );
		},
		function () {
			var anThs = $('#example thead th');
			var a0 = anThs[0].offsetWidth;
			var a1 = anThs[1].offsetWidth;
			var a2 = anThs[2].offsetWidth;
			var a3 = anThs[3].offsetWidth;
			var a4 = anThs[4].offsetWidth;
			
			if ( a3>a0 && a3>a1 && a3>a2 && a3>a4 )
				return true;
			else
				return false;
		}
	);
	
	
	oTest.fnComplete();
} );

Version data entries

28 entries across 28 versions & 1 rubygems

Version Path
classiccms-0.7.5 lib/classiccms/public/admin/datatables/unit_testing/tests_onhold/2_js/aoColumns.sWidth.js
classiccms-0.7.4 lib/classiccms/public/admin/datatables/unit_testing/tests_onhold/2_js/aoColumns.sWidth.js
classiccms-0.7.3 lib/classiccms/public/admin/datatables/unit_testing/tests_onhold/2_js/aoColumns.sWidth.js
classiccms-0.7.2 lib/classiccms/public/admin/datatables/unit_testing/tests_onhold/2_js/aoColumns.sWidth.js
classiccms-0.7.1 lib/classiccms/public/admin/datatables/unit_testing/tests_onhold/2_js/aoColumns.sWidth.js
classiccms-0.7.0 lib/classiccms/public/admin/datatables/unit_testing/tests_onhold/2_js/aoColumns.sWidth.js
classiccms-0.6.9 lib/classiccms/public/admin/datatables/unit_testing/tests_onhold/2_js/aoColumns.sWidth.js
classiccms-0.6.8 lib/classiccms/public/admin/datatables/unit_testing/tests_onhold/2_js/aoColumns.sWidth.js
classiccms-0.6.7 lib/classiccms/public/admin/datatables/unit_testing/tests_onhold/2_js/aoColumns.sWidth.js
classiccms-0.6.6 lib/classiccms/public/admin/datatables/unit_testing/tests_onhold/2_js/aoColumns.sWidth.js
classiccms-0.6.5 lib/classiccms/public/admin/datatables/unit_testing/tests_onhold/2_js/aoColumns.sWidth.js
classiccms-0.6.4 lib/classiccms/public/admin/datatables/unit_testing/tests_onhold/2_js/aoColumns.sWidth.js
classiccms-0.6.3 lib/classiccms/public/admin/datatables/unit_testing/tests_onhold/2_js/aoColumns.sWidth.js
classiccms-0.6.2 lib/classiccms/public/admin/datatables/unit_testing/tests_onhold/2_js/aoColumns.sWidth.js
classiccms-0.6.1 lib/classiccms/public/admin/datatables/unit_testing/tests_onhold/2_js/aoColumns.sWidth.js
classiccms-0.6.0 lib/classiccms/public/admin/datatables/unit_testing/tests_onhold/2_js/aoColumns.sWidth.js
classiccms-0.5.17 lib/classiccms/public/admin/datatables/unit_testing/tests_onhold/2_js/aoColumns.sWidth.js
classiccms-0.5.16 lib/classiccms/public/admin/datatables/unit_testing/tests_onhold/2_js/aoColumns.sWidth.js
classiccms-0.5.15 lib/classiccms/public/admin/datatables/unit_testing/tests_onhold/2_js/aoColumns.sWidth.js
classiccms-0.5.14 lib/classiccms/public/admin/datatables/unit_testing/tests_onhold/2_js/aoColumns.sWidth.js