You are here

public function GridStackJs::attach in GridStack 8.2

Provides gridstack skins and libraries.

Overrides GridStackBase::attach

File

src/Plugin/gridstack/engine/GridStackJs.php, line 31

Class

GridStackJs
Provides a GridStack JS layout engine.

Namespace

Drupal\gridstack\Plugin\gridstack\engine

Code

public function attach(array &$load, array $attach = []) {
  parent::attach($load, $attach);

  // Allows to not use GridStack libraries, yet still re-use the same markups.
  if ($this
    ->getSetting('_gridstack')) {
    $load['library'][] = 'gridstack/load';
    $column = $this
      ->getSetting('column');
    if ($column && $column < 12) {
      $load['library'][] = 'gridstack/gridstack.' . $column;
    }

    // Breakpoints: xs sm md lg xl requires separate CSS files.
    if ($columns = array_unique(array_values($this->columns))) {
      foreach ($columns as $column) {
        if ($column < 12) {
          $load['library'][] = 'gridstack/gridstack.' . $column;
        }
      }
    }
  }
}