GridBase.php in GridStack 8.2
File
src/Plugin/gridstack/engine/GridBase.php
View source
<?php
namespace Drupal\gridstack\Plugin\gridstack\engine;
use Drupal\gridstack\GridStackEnginePluginBase;
abstract class GridBase extends GridStackEnginePluginBase {
protected $colors;
protected $setClassOptions;
protected $setRowClassOptions;
public function containerAttributes(array &$attributes, array &$settings) {
parent::containerAttributes($attributes, $settings);
if ($vm = $this
->getSetting('vm')) {
$attributes['class'][] = 'is-vm vm-' . $vm;
unset($settings['vm']);
}
}
protected function optimizeClasses(array $settings, array $breakpoints = []) {
$root = isset($settings['_root']) ? $settings['_root'] : 'grids';
$delta = isset($settings['delta']) ? $settings['delta'] : 0;
$nid = isset($settings['nested_delta']) ? $settings['nested_delta'] : -1;
$breakpoints = $breakpoints ?: $this->breakpoints;
$unique = $region = [];
foreach (array_keys($this->sizes) as $id) {
$item = isset($breakpoints[$id], $breakpoints[$id][$root][$delta]) ? $breakpoints[$id][$root][$delta] : '';
if (empty($item)) {
continue;
}
$data = isset($item[$nid]) ? $item[$nid] : [];
$data = $root == 'nested' ? $data : $item;
if (!empty($data[2])) {
$unique[$id] = (int) $data[2];
}
if (!empty($data[4])) {
$region[] = $data[4];
}
}
$optimized = $this
->unique($unique, 2);
$optimized = $this
->unique($optimized, 3);
$column = empty($settings['optimized']) ? $unique : $optimized;
return [
'column' => $column,
'region' => $region,
];
}
protected function unique(array $items = [], $visible = 2) {
$items = array_chunk($items, $visible, TRUE);
$columns = [];
foreach ($items as $value) {
$columns = array_merge($columns, array_unique($value));
}
return $columns;
}
public function previewOptions() {
return [
'background',
'gradient',
'rounded',
'text_color',
'text_transform',
];
}
}
Classes
Name |
Description |
GridBase |
Provides the base class for one-dimensional layout engines. |