wire/modules/AdminTheme/AdminThemeUikit/scripts/main.js
// this is called when an Inputfield is shown or hidden
this is called when an Inputfield is shown or hidden
this is called when an Inputfield is shown or hidden
function updateInputfieldRow($inputfield) {
			if(!$inputfield) return;
			var $inputfields = $inputfield.parent().children('.Inputfield');
			var $lastInputfield = null; 
			var width = 0; 
			var widthHidden = 0; 
			var w = 0; 
			var lastW = 0; 
			var debug = false; 
			function consoleLog(msg, $in) {
				if(!debug) return;
				if(typeof $in == "undefined") $in = $inputfield;	
				var id = $in.attr('id');
				id = id.replace('wrap_Inputfield_', '');
				console.log(id + ' (combined width=' + width + ', w=' + w + '): ' + msg);	
			}
			function expandLastInputfield($in) {
				if(typeof $in == "undefined") $in = $lastInputfield;
				if($in) {
					if(noGrid) {
						$in.addClass('InputfieldColumnWidthLast'); 
					} else {
						ukGridClass('InputfieldColumnWidthLast uk-width-expand', $in);
					}
				}
			}
			function applyHiddenInputfield() {
				if(debug) consoleLog('A: hidden', $inputfield);
				lastW += w;
				width += w;
				if($lastInputfield && width >= 95) {
					if(debug) consoleLog('Updating last visible Inputfield to width=' + lastW, $lastInputfield);
					ukGridClass(lastW, $lastInputfield);
					width = 0;
					lastW = 0;
					widthHidden = 0;
					$lastInputfield = null;
				} else {
					widthHidden += w;
				}
			}
			function applyFullWidthInputfield() {
				if(debug) consoleLog("Skipping because full-width", $inputfield);
				if(width < 100 && $lastInputfield) expandLastInputfield($lastInputfield);
				$lastInputfield = null;
				widthHidden = 0;
				lastW = 0;
				width = 0;
			}
			$inputfields.each(function() {
				$inputfield = $(this);
				var isLastColumn = false;
				var isFirstColumn = false;
				var hasWidth = $inputfield.hasClass('InputfieldColumnWidth'); 
				var isNewRow = !hasWidth || $inputfield.hasClass('InputfieldColumnWidthFirst');
				if(isNewRow && $lastInputfield && width < 100) {
					expandLastInputfield($lastInputfield);
				}
				w = hasWidth ? parseInt($inputfield.attr('data-colwidth')) : 0;
				if(!w || w >= 95) {
					applyFullWidthInputfield();
					return;
				}
				if($inputfield.hasClass('InputfieldStateHidden')) {
					applyHiddenInputfield();
					return;
				}
				if(!width || width >= 100) {
					width = 0;
					isFirstColumn = true;
					isLastColumn = false;
					if(debug) consoleLog('B: starting new row', $inputfield);
				} else if(width + w > 100) {
					if($lastInputfield) expandLastInputfield($lastInputfield); 
					width = 0;
					isFirstColumn = true;
					if(debug) consoleLog('C: start new row because width would exceed 100%', $inputfield);
				} else if(width + w == 100) {
					isLastColumn = true; 
					if(debug) consoleLog('D: width is exactly 100%, so this is the last column', $inputfield);
				} else if(width + w >= 95) {
					isLastColumn = true;
					w = 100 - width;
					if(debug) consoleLog('D2: width is close enough to 100%, so this is the last column', $inputfield);
				} else {
					if(debug) consoleLog('E: not first or last column', $inputfield);
				}
				if(isLastColumn) {
					$inputfield.addClass('InputfieldColumnWidthLast');
				} else {
					$inputfield.removeClass('InputfieldColumnWidthLast');
				}
				if(isFirstColumn) {
					$inputfield.addClass('InputfieldColumnWidthFirst');
					widthHidden = 0;
				} else {
					$inputfield.removeClass('InputfieldColumnWidthFirst');
				}
				if(isLastColumn) {
					$lastInputfield = null;
					width = 0;
					lastW = 0;
					if(widthHidden) w += widthHidden;
					widthHidden = 0;
				} else {
					$lastInputfield = $inputfield;
					width += w;
					lastW = w;
				}
				ukGridClass(w, $inputfield);
			});
			if(width < 100 && $lastInputfield) expandLastInputfield($lastInputfield);
		} 
function updateInputfieldRow ( $inputfield ) { if ( ! $inputfield ) return ; var $inputfields = $inputfield . parent ( ) . children ( '.Inputfield' ) ; var $lastInputfield = null ; var width = 0 ; var widthHidden = 0 ; var w = 0 ; var lastW = 0 ; var debug = false ; function consoleLog ( msg , $in ) { if ( ! debug ) return ; if ( typeof $in == "undefined" ) $in = $inputfield ; var id = $in . attr ( 'id' ) ; id = id . replace ( 'wrap_Inputfield_' , '' ) ; console . log ( id + ' (combined width=' + width + ', w=' + w + '): ' + msg ) ; } function expandLastInputfield ( $in ) { if ( typeof $in == "undefined" ) $in = $lastInputfield ; if ( $in ) { if ( noGrid ) { $in . addClass ( 'InputfieldColumnWidthLast' ) ; } else { ukGridClass ( 'InputfieldColumnWidthLast uk-width-expand' , $in ) ; } } } function applyHiddenInputfield ( ) { if ( debug ) consoleLog ( 'A: hidden' , $inputfield ) ; lastW += w ; width += w ; if ( $lastInputfield && width >= 95 ) { if ( debug ) consoleLog ( 'Updating last visible Inputfield to width=' + lastW , $lastInputfield ) ; ukGridClass ( lastW , $lastInputfield ) ; width = 0 ; lastW = 0 ; widthHidden = 0 ; $lastInputfield = null ; } else { widthHidden += w ; } } function applyFullWidthInputfield ( ) { if ( debug ) consoleLog ( "Skipping because full-width" , $inputfield ) ; if ( width < 100 && $lastInputfield ) expandLastInputfield ( $lastInputfield ) ; $lastInputfield = null ; widthHidden = 0 ; lastW = 0 ; width = 0 ; } $inputfields . each ( function ( ) { $inputfield = $ ( this ) ; var isLastColumn = false ; var isFirstColumn = false ; var hasWidth = $inputfield . hasClass ( 'InputfieldColumnWidth' ) ; var isNewRow = ! hasWidth || $inputfield . hasClass ( 'InputfieldColumnWidthFirst' ) ; if ( isNewRow && $lastInputfield && width < 100 ) { expandLastInputfield ( $lastInputfield ) ; } w = hasWidth ? parseInt ( $inputfield . attr ( 'data-colwidth' ) ) : 0 ; if ( ! w || w >= 95 ) { applyFullWidthInputfield ( ) ; return ; } if ( $inputfield . hasClass ( 'InputfieldStateHidden' ) ) { applyHiddenInputfield ( ) ; return ; } if ( ! width || width >= 100 ) { width = 0 ; isFirstColumn = true ; isLastColumn = false ; if ( debug ) consoleLog ( 'B: starting new row' , $inputfield ) ; } else if ( width + w > 100 ) { if ( $lastInputfield ) expandLastInputfield ( $lastInputfield ) ; width = 0 ; isFirstColumn = true ; if ( debug ) consoleLog ( 'C: start new row because width would exceed 100%' , $inputfield ) ; } else if ( width + w == 100 ) { isLastColumn = true ; if ( debug ) consoleLog ( 'D: width is exactly 100%, so this is the last column' , $inputfield ) ; } else if ( width + w >= 95 ) { isLastColumn = true ; w = 100 - width ; if ( debug ) consoleLog ( 'D2: width is close enough to 100%, so this is the last column' , $inputfield ) ; } else { if ( debug ) consoleLog ( 'E: not first or last column' , $inputfield ) ; } if ( isLastColumn ) { $inputfield . addClass ( 'InputfieldColumnWidthLast' ) ; } else { $inputfield . removeClass ( 'InputfieldColumnWidthLast' ) ; } if ( isFirstColumn ) { $inputfield . addClass ( 'InputfieldColumnWidthFirst' ) ; widthHidden = 0 ; } else { $inputfield . removeClass ( 'InputfieldColumnWidthFirst' ) ; } if ( isLastColumn ) { $lastInputfield = null ; width = 0 ; lastW = 0 ; if ( widthHidden ) w += widthHidden ; widthHidden = 0 ; } else { $lastInputfield = $inputfield ; width += w ; lastW = w ; } ukGridClass ( w , $inputfield ) ; } ) ; if ( width < 100 && $lastInputfield ) expandLastInputfield ( $lastInputfield ) ; }
this is called when an Inputfield is shown or hidden
this is called when an Inputfield is shown or hidden
// last non-hidden Inputfield // current combined width of all Inputfields in row // amount of width in row occupied by hidden field(s) // current Inputfield width // last Inputfield non-hidden Inputfield width // verbose console.log messages // hidden column, reserve space even though its hidden // finishing out row, update last visible column to include the width of the hidden column // lastW += widthHidden; // full width column consumes its own row, so we can reset everything here and exit // finish out the previous row, letting width expand to 100% // if column has width defined, pull from its data-colwidth property // full-width // hidden  // starting a new row // start new row and update width for last column // width comes to exactly 100% so make this the last column in the row // width is close enough to 100% so treat it the same // column that isn't first or last column // last column in this row, reset for new row // if there was any width from previous hidden fields in same row, add it to this field // $inputfields.find('.InputfieldColumnWidthLast').removeClass('InputfieldColumnWidthLast'); // function updateInputfieldRow