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