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() { public static function getModuleInfo() {
return array( return array(
'title' => 'Uikit', 'title' => 'Uikit',
'version' => 24, 'version' => 25,
'summary' => 'Uikit v3 admin theme', 'summary' => 'Uikit v3 admin theme',
'autoload' => 'template=admin', 'autoload' => 'template=admin',
'requires' => 'ProcessWire>=3.0.94' 'requires' => 'ProcessWire>=3.0.94'

View File

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

View File

@@ -543,6 +543,7 @@ var ProcessWireAdminTheme = {
} while($in.hasClass('InputfieldColumnWidth')); } while($in.hasClass('InputfieldColumnWidth'));
} }
var ukGridClassCache = [];
// get or set uk-width class // get or set uk-width class
// width: may be integer of width, or classes you want to set (if $in is also provided) // 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 // $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) { } else if(!width || width >= 100) {
// full width // full width
ukGridClass = ukGridClassDefault; ukGridClass = ukGridClassDefault;
} else if(typeof ukGridClassCache[width] != "undefined") {
// use previously cached value
ukGridClass = 'uk-width-' + ukGridClassCache[width];
} else { } else {
// determine width from predefined setting // determine width from predefined setting
for(var pct in ProcessWire.config.ukGridWidths) { for(var pct in ProcessWire.config.ukGridWidths) {
var cn = ProcessWire.config.ukGridWidths[pct]; var cn = ProcessWire.config.ukGridWidths[pct];
pct = parseInt(pct); pct = parseInt(pct);
if(width >= pct) { if(width >= pct) {
ukGridClass = 'uk-width-' + cn; ukGridClass = cn;
// ukGrid = cn.split('-');
break; break;
} }
} }
ukGridClassCache[width] = ukGridClass;
ukGridClass = 'uk-width-' + ukGridClass;
} }
if(!widthIsClass && ukGridClass != ukGridClassDefault) { if(!widthIsClass && ukGridClass != ukGridClassDefault) {
@@ -596,7 +601,7 @@ var ProcessWireAdminTheme = {
str = $in.attr('class'); str = $in.attr('class');
} }
if(str.indexOf('uk-width-') > -1) { 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); if($in !== null) $in.attr('class', cls);
} }
return str; return str;
@@ -633,7 +638,7 @@ var ProcessWireAdminTheme = {
if(debug) consoleLog('A: hidden', $inputfield); if(debug) consoleLog('A: hidden', $inputfield);
lastW += w; lastW += w;
width += 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 // finishing out row, update last visible column to include the width of the hidden column
lastW += widthHidden; lastW += widthHidden;
if(debug) consoleLog('Updating last visible Inputfield to width=' + lastW, $lastInputfield); 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 // if column has width defined, pull from its data-colwidth property
w = hasWidth ? parseInt($inputfield.attr('data-colwidth')) : 0; w = hasWidth ? parseInt($inputfield.attr('data-colwidth')) : 0;
if(!w || w >= 100) { if(!w || w >= 95) {
// full-width // full-width
applyFullWidthInputfield(); applyFullWidthInputfield();
return; return;
@@ -702,6 +707,11 @@ var ProcessWireAdminTheme = {
// width comes to exactly 100% so make this the last column in the row // width comes to exactly 100% so make this the last column in the row
isLastColumn = true; isLastColumn = true;
if(debug) consoleLog('D: width is exactly 100%, so this is the last column', $inputfield); 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 { } else {
// column that isn't first or last column // column that isn't first or last column
if(debug) consoleLog('E: not first or last column', $inputfield); 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) {
if($value instanceof Page) $value = array($value); if($value instanceof Page) $value = array($value);
foreach($value as $item) { foreach($value as $item) {
/** @var Page $item */
if($item->hasStatus(Page::statusUnpublished) if($item->hasStatus(Page::statusUnpublished)
&& $item->hasStatus(Page::statusHidden) && $item->hasStatus(Page::statusHidden)
&& $item->id && $item->id