mirror of
https://github.com/processwire/processwire.git
synced 2025-08-20 21:42:23 +02:00
Update for processwire/processwire-issues#480
This commit is contained in:
@@ -266,6 +266,7 @@ function AdminThemeUikitConfig(AdminTheme $adminTheme, InputfieldWrapper $inputf
|
||||
$fieldset->add($f);
|
||||
*/
|
||||
|
||||
/*
|
||||
// The following is just for development/testing
|
||||
$f = $modules->get('InputfieldRadios');
|
||||
$f->attr('name', 'test_radios');
|
||||
@@ -276,7 +277,6 @@ function AdminThemeUikitConfig(AdminTheme $adminTheme, InputfieldWrapper $inputf
|
||||
$f->columnWidth = 30;
|
||||
$inputfields->add($f);
|
||||
|
||||
/*
|
||||
$f = $modules->get('InputfieldText');
|
||||
$f->attr('name', 'test_text1');
|
||||
$f->label = 'Test text 1';
|
||||
|
@@ -25,6 +25,7 @@ $ukGridWidths = array(
|
||||
'64%' => '2-3',
|
||||
'60%' => '3-5',
|
||||
'50%' => '1-2',
|
||||
'45%' => '1-2',
|
||||
'40%' => '2-5',
|
||||
'34%' => '1-3',
|
||||
'33%' => '1-3',
|
||||
|
@@ -609,6 +609,7 @@ var ProcessWireAdminTheme = {
|
||||
var $inputfields = $inputfield.parent().children('.Inputfield');
|
||||
var $lastInputfield = null; // last non-hidden Inputfield
|
||||
var width = 0; // current combined width of all Inputfields in row
|
||||
var widthHidden = 0; // amount of width in row occupied by hidden field(s)
|
||||
var w = 0; // current Inputfield width
|
||||
var lastW = 0; // last Inputfield non-hidden Inputfield width
|
||||
var debug = false; // verbose console.log messages
|
||||
@@ -621,30 +622,33 @@ var ProcessWireAdminTheme = {
|
||||
console.log(id + ' (combined width=' + width + ', w=' + w + '): ' + msg);
|
||||
}
|
||||
|
||||
function expandLastInputfield($in) {
|
||||
if(typeof $in == "undefined") $in = $lastInputfield;
|
||||
if($in) ukGridClass('InputfieldColumnWidthLast uk-width-expand', $in);
|
||||
}
|
||||
|
||||
$inputfields.each(function() {
|
||||
|
||||
$inputfield = $(this);
|
||||
|
||||
var isLastColumn = false;
|
||||
var isFirstColumn = false;
|
||||
var isNewRow = $inputfield.hasClass('InputfieldColumnWidthFirst') || !$inputfield.hasClass('InputfieldColumnWidth');
|
||||
var hasWidth = $inputfield.hasClass('InputfieldColumnWidth');
|
||||
var isNewRow = !hasWidth || $inputfield.hasClass('InputfieldColumnWidthFirst');
|
||||
|
||||
if(isNewRow && $lastInputfield && width < 100) {
|
||||
// finish out the previous row, letting width expand to 100%
|
||||
ukGridClass('InputfieldColumnWidthLast uk-width-expand', $lastInputfield);
|
||||
expandLastInputfield($lastInputfield);
|
||||
}
|
||||
|
||||
if($inputfield.hasClass('InputfieldColumnWidth')) {
|
||||
// column having width
|
||||
w = parseInt($inputfield.attr('data-colwidth'));
|
||||
} else {
|
||||
// full width column
|
||||
w = 0;
|
||||
}
|
||||
// if column has width defined, pull from its data-colwidth property
|
||||
w = hasWidth ? parseInt($inputfield.attr('data-colwidth')) : 0;
|
||||
|
||||
if(!w || w >= 100) {
|
||||
// full width column consumes its own row, so we can reset everything here and exit
|
||||
if(width < 100) expandLastInputfield($lastInputfield);
|
||||
$lastInputfield = null;
|
||||
widthHidden = 0;
|
||||
lastW = 0;
|
||||
width = 0;
|
||||
if(debug) consoleLog("Skipping because full-width", $inputfield);
|
||||
@@ -656,10 +660,12 @@ var ProcessWireAdminTheme = {
|
||||
if(debug) consoleLog('A: hidden', $inputfield);
|
||||
lastW += w;
|
||||
width += w;
|
||||
if($lastInputfield) {
|
||||
if($lastInputfield && width >= 100) {
|
||||
// update previous visible column to include the width of the hidden column
|
||||
if(debug) consoleLog('Updating this to width=' + lastW, $lastInputfield);
|
||||
ukGridClass(lastW, $lastInputfield);
|
||||
} else {
|
||||
widthHidden += w;
|
||||
}
|
||||
return;
|
||||
}
|
||||
@@ -672,7 +678,7 @@ var ProcessWireAdminTheme = {
|
||||
if(debug) consoleLog('B: starting new row', $inputfield);
|
||||
} else if(width + w > 100) {
|
||||
// start new row and update width for last column
|
||||
if($lastInputfield) ukGridClass('InputfieldColumnWidthLast uk-width-expand', $lastInputfield);
|
||||
expandLastInputfield($lastInputfield);
|
||||
width = 0;
|
||||
isFirstColumn = true;
|
||||
if(debug) consoleLog('C: start new row because width would exceed 100%', $inputfield);
|
||||
@@ -692,21 +698,27 @@ var ProcessWireAdminTheme = {
|
||||
}
|
||||
if(isFirstColumn) {
|
||||
$inputfield.addClass('InputfieldColumnWidthFirst');
|
||||
widthHidden = 0;
|
||||
} else {
|
||||
$inputfield.removeClass('InputfieldColumnWidthFirst');
|
||||
}
|
||||
|
||||
if(widthHidden) {
|
||||
// if there was any width from previous hidden fields in same row, add it to this field
|
||||
w += widthHidden;
|
||||
width -= widthHidden;
|
||||
widthHidden = 0;
|
||||
}
|
||||
|
||||
width += w;
|
||||
lastW = w;
|
||||
$lastInputfield = $inputfield;
|
||||
ukGridClass(w, $inputfield);
|
||||
});
|
||||
|
||||
//$inputfields.find('.InputfieldColumnWidthLast').removeClass('InputfieldColumnWidthLast');
|
||||
if(width < 100 && $lastInputfield) expandLastInputfield($lastInputfield);
|
||||
|
||||
if(width < 100 && $lastInputfield) {
|
||||
ukGridClass('InputfieldColumnWidthLast uk-width-expand', $lastInputfield);
|
||||
}
|
||||
// $inputfields.find('.InputfieldColumnWidthLast').removeClass('InputfieldColumnWidthLast');
|
||||
} // function updateInputfieldRow
|
||||
|
||||
var showHideInputfieldTimer = null;
|
||||
|
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user