1
0
mirror of https://github.com/processwire/processwire.git synced 2025-08-26 16:14:35 +02:00

Further updates to AdminThemeUikit Inputfield width adjustments per processwire/processwire-issues#480

This commit is contained in:
Ryan Cramer
2018-04-13 08:31:17 -04:00
parent ae5b955ec8
commit 6b3b0b7782
5 changed files with 29 additions and 22 deletions

View File

@@ -24,7 +24,7 @@ class AdminThemeUikit extends AdminThemeFramework implements Module, Configurabl
public static function getModuleInfo() {
return array(
'title' => 'Uikit',
'version' => 24,
'version' => 25,
'summary' => 'Uikit v3 admin theme',
'autoload' => 'template=admin',
'requires' => 'ProcessWire>=3.0.94'

View File

@@ -20,21 +20,17 @@ if(!defined("PROCESSWIRE")) die();
// uk class => width %
$ukGridWidths = array(
'80%' => '4-5',
'75%' => '3-4',
'70%' => '2-3',
'64%' => '2-3',
'60%' => '3-5',
'50%' => '1-2',
'45%' => '1-2',
'40%' => '2-5',
'34%' => '1-3',
'33%' => '1-3',
'32%' => '1-3',
'30%' => '1-3',
'25%' => '1-4',
'20%' => '1-5',
'16%' => '1-6',
'85%' => '5-6', // 85%-94%
'80%' => '4-5', // 80%-84%
'75%' => '3-4', // 75%-79%
'64%' => '2-3', // 64%-74%
'60%' => '3-5', // 60%-63%
'45%' => '1-2', // 45%-59%
'36%' => '2-5', // 36%-44%
'27%' => '1-3', // 27%-35%
'25%' => '1-4', // 25%-26%
'18%' => '1-5', // 18%-24%
'11%' => '1-6', // 11%-17%
);
$config->set('inputfieldColumnWidthSpacing', 0);

View File

@@ -543,6 +543,7 @@ var ProcessWireAdminTheme = {
} while($in.hasClass('InputfieldColumnWidth'));
}
var ukGridClassCache = [];
// get or set uk-width class
// width: may be integer of width, or classes you want to set (if $in is also provided)
// $in: An optional Inputfield that you want to populate given or auto-determined classes to
@@ -559,17 +560,21 @@ var ProcessWireAdminTheme = {
} else if(!width || width >= 100) {
// full width
ukGridClass = ukGridClassDefault;
} else if(typeof ukGridClassCache[width] != "undefined") {
// use previously cached value
ukGridClass = 'uk-width-' + ukGridClassCache[width];
} else {
// determine width from predefined setting
for(var pct in ProcessWire.config.ukGridWidths) {
var cn = ProcessWire.config.ukGridWidths[pct];
pct = parseInt(pct);
if(width >= pct) {
ukGridClass = 'uk-width-' + cn;
// ukGrid = cn.split('-');
ukGridClass = cn;
break;
}
}
ukGridClassCache[width] = ukGridClass;
ukGridClass = 'uk-width-' + ukGridClass;
}
if(!widthIsClass && ukGridClass != ukGridClassDefault) {
@@ -596,7 +601,7 @@ var ProcessWireAdminTheme = {
str = $in.attr('class');
}
if(str.indexOf('uk-width-') > -1) {
var cls = str.replace(/uk-width-(\d-\d@m|\d-\d|expand)\s*/g, '');
var cls = str.replace(/uk-width-(\d-\d|expand)[@smxl]*\s*/g, '');
if($in !== null) $in.attr('class', cls);
}
return str;
@@ -633,7 +638,7 @@ var ProcessWireAdminTheme = {
if(debug) consoleLog('A: hidden', $inputfield);
lastW += w;
width += w;
if($lastInputfield && width >= 100) {
if($lastInputfield && width >= 95) {
// finishing out row, update last visible column to include the width of the hidden column
lastW += widthHidden;
if(debug) consoleLog('Updating last visible Inputfield to width=' + lastW, $lastInputfield);
@@ -674,7 +679,7 @@ var ProcessWireAdminTheme = {
// if column has width defined, pull from its data-colwidth property
w = hasWidth ? parseInt($inputfield.attr('data-colwidth')) : 0;
if(!w || w >= 100) {
if(!w || w >= 95) {
// full-width
applyFullWidthInputfield();
return;
@@ -702,6 +707,11 @@ var ProcessWireAdminTheme = {
// width comes to exactly 100% so make this the last column in the row
isLastColumn = true;
if(debug) consoleLog('D: width is exactly 100%, so this is the last column', $inputfield);
} else if(width + w >= 95) {
// width is close enough to 100% so treat it the same
isLastColumn = true;
w = 100 - width;
if(debug) consoleLog('D2: width is close enough to 100%, so this is the last column', $inputfield);
} else {
// column that isn't first or last column
if(debug) consoleLog('E: not first or last column', $inputfield);

File diff suppressed because one or more lines are too long

View File

@@ -609,6 +609,7 @@ class FieldtypeRepeater extends Fieldtype implements ConfigurableModule {
if($value) {
if($value instanceof Page) $value = array($value);
foreach($value as $item) {
/** @var Page $item */
if($item->hasStatus(Page::statusUnpublished)
&& $item->hasStatus(Page::statusHidden)
&& $item->id