You are here

class GridStackDefault in GridStack 8.2

Same name and namespace in other branches
  1. 8 src/GridStackDefault.php \Drupal\gridstack\GridStackDefault

Defines shared plugin default settings for field formatter and Views style.

@todo move style stuffs into plugins.

Hierarchy

Expanded class hierarchy of GridStackDefault

See also

FormatterBase::defaultSettings()

StylePluginBase::defineOptions()

27 files declare their use of GridStackDefault
Bootstrap3.php in src/Plugin/gridstack/engine/Bootstrap3.php
Builder.php in src/Plugin/gridstack/stylizer/Builder.php
Classes.php in src/Plugin/gridstack/stylizer/Classes.php
Color.php in src/Plugin/gridstack/stylizer/Color.php
Extras.php in src/Plugin/gridstack/stylizer/Extras.php

... See full list

File

src/GridStackDefault.php, line 15

Namespace

Drupal\gridstack
View source
class GridStackDefault extends BlazyDefault {

  /**
   * Defines root level.
   */
  const LEVEL_ROOT = 0;

  /**
   * Defines root item level.
   */
  const LEVEL_ROOT_ITEM = 1;

  /**
   * Defines nested level.
   */
  const LEVEL_NESTED = 2;

  /**
   * Defines nested item level.
   */
  const LEVEL_NESTED_ITEM = 3;

  /**
   * Defines dummy root selector.
   */
  const ROOT = ':root';

  /**
   * Defines dummy nested selector.
   */
  const NESTED = ':nested';

  /**
   * Defines a container.
   */
  const CONTAINER = 'Container';

  /**
   * Defines a region.
   */
  const REGION = 'Region';

  /**
   * Returns common settings across plugins.
   */
  public static function commonSettings() {
    return [
      'gridnative' => FALSE,
      'skin' => '',
    ];
  }

  /**
   * {@inheritdoc}
   */
  public static function baseSettings() {
    return [
      'optionset' => 'default',
      'vanilla' => FALSE,
    ] + self::commonSettings() + parent::baseSettings();
  }

  /**
   * {@inheritdoc}
   */
  public static function imageSettings() {
    return [
      'background' => TRUE,
      'category' => '',
      'stamp' => '',
      'stamp_index' => 0,
    ] + parent::imageSettings() + self::baseSettings();
  }

  /**
   * {@inheritdoc}
   */
  public static function extendedSettings() {
    return self::imageSettings() + parent::extendedSettings();
  }

  /**
   * Returns view fields options for Views UI.
   */
  public static function viewFieldOptions() {
    return [
      'captions',
      'layouts',
      'images',
      'links',
      'titles',
      'classes',
      'overlays',
    ];
  }

  /**
   * Returns fixed settings not configurable via UI.
   */
  public static function fixedSettings() {
    return [
      'item_id' => 'box',
      'nameshort' => 'gs',
      'namespace' => 'gridstack',
      'ratio' => '',
      'blazy' => TRUE,
      'lazy' => 'blazy',
    ];
  }

  /**
   * Returns shared global form settings which should be consumed at formatters.
   */
  public static function cleanUiSettings() {
    return [
      'debug' => FALSE,
      'dev' => FALSE,
      'framework' => '',
      'no_classes' => FALSE,
      'library' => '',
      'optimized' => FALSE,
      'html5_ac' => FALSE,
      'gridstatic' => FALSE,
    ];
  }

  /**
   * Returns shared global form settings which should be consumed at formatters.
   */
  public static function uiSettings() {
    return [
      'animationless' => FALSE,
      'editor_pos' => '',
      'excludes' => '',
      'fw_classes' => '',
      'helpless' => FALSE,
      'palettes' => '',
      'palettes_pos' => '',
      'skinless' => FALSE,
    ] + self::cleanUiSettings();
  }

  /**
   * Returns style settings.
   */
  public static function styleSettings() {
    return [
      'responsive_image_style' => '',
      'alpha' => '',
      'opacity' => '',
      'animations' => [],
      'colors' => [],
      'extras' => [],
    ];
  }

  /**
   * Returns background color settings.
   */
  public static function rangeElements() {

    // @todo height sm-height md-height lg-height
    return [
      'opacity',
      'alpha',
    ];
  }

  /**
   * Returns background color settings.
   */
  public static function bgElements() {
    return array_merge(self::rangeElements(), [
      'rgba',
      'bg',
    ]);
  }

  /**
   * Returns color settings.
   */
  public static function textElements() {
    return [
      'text',
      'a',
      'a:hover',
      'h2',
      'h3',
    ];
  }

  /**
   * Returns color settings.
   */
  public static function colorElements() {
    return array_merge([
      'rgba',
      'bg',
    ], self::textElements());
  }

  /**
   * Returns style settings.
   */
  public static function styleElements() {
    return array_merge(self::bgElements(), self::textElements());
  }

  /**
   * Returns the region layout settings.
   */
  public static function regionSettings() {
    return [
      'attributes' => '',
      'styles' => [],
      'target_id' => '',
      'wrapper' => '',
      'wrapper_classes' => '',
      'row_classes' => '',
      '_fullwidth' => FALSE,
    ];
  }

  /**
   * Returns the main layout settings.
   */
  public static function layoutSettings() {
    return [
      'current_selection' => '',
      'regions' => [],
      'field_name' => '',
      'gid' => '',
      'metadata' => '',
      'vid' => '',
      'vm' => '',
    ] + self::commonSettings() + self::regionSettings();
  }

  /**
   * Returns the main wrapper Layout Builder select options.
   */
  public static function mainWrapperOptions() {
    return [
      'article' => 'Article',
      'aside' => 'Aside',
      'main' => 'Main',
      'footer' => 'Footer',
      'section' => 'Section',
    ];
  }

  /**
   * Returns wrapper Layout Builder select options.
   */
  public static function regionWrapperOptions() {
    return self::mainWrapperOptions() + [
      'figure' => 'Figure',
      'header' => 'Header',
    ];
  }

  /**
   * Returns HTML or layout related settings, none of JS to shutup notices.
   */
  public static function htmlSettings() {
    return [
      '_lb' => FALSE,
      '_lbux' => FALSE,
      '_panels' => FALSE,
      '_ipe' => FALSE,
      'column' => 12,
      'contentless' => FALSE,
      'debug' => FALSE,
      'ungridstack' => FALSE,
      'id' => '',
      'lightbox' => '',
      'nested' => FALSE,
      'rid' => NULL,
      'root' => TRUE,
      '_root' => 'grids',
      'use_framework' => FALSE,
      'use_js' => TRUE,
      'use_inner' => TRUE,
      'view_name' => '',
    ] + self::commonSettings() + self::imageSettings() + self::fixedSettings();
  }

  /**
   * Returns breakpoints.
   */
  public static function breakpoints() {
    return [
      'xs' => 'xsmall',
      'sm' => 'small',
      'md' => 'medium',
      'lg' => 'large',
      'xl' => 'xlarge',
    ];
  }

  /**
   * Returns region ID.
   */
  public static function regionId($id) {
    return 'gridstack_' . $id;
  }

  /**
   * Returns variant wrapper AJAX ID.
   */
  public static function variantWrapperId($id) {
    return 'gridstack-variant-wrapper-' . str_replace([
      '_',
      ':',
    ], '-', $id);
  }

  /**
   * Returns gridstack random id related to the each layout.
   */
  public static function gid($id) {
    return str_replace([
      '-',
      ':',
    ], '_', $id);
  }

  /**
   * Returns gridstack layout id.
   */
  public static function layoutId($id) {
    return 'gridstack_' . $id;
  }

  /**
   * Returns theme properties.
   */
  public static function themeProperties() {
    return [
      'items',
      'optionset',
      'aside',
      'bottom',
      'preface',
      'postscript',
      'settings',
      'content_attributes',
      'wrapper_attributes',
    ];
  }

}

Members

Namesort descending Modifiers Type Description Overrides
GridStackDefault::baseSettings public static function
GridStackDefault::bgElements public static function Returns background color settings.
GridStackDefault::breakpoints public static function Returns breakpoints.
GridStackDefault::cleanUiSettings public static function Returns shared global form settings which should be consumed at formatters.
GridStackDefault::colorElements public static function Returns color settings.
GridStackDefault::commonSettings public static function Returns common settings across plugins.
GridStackDefault::CONTAINER constant Defines a container.
GridStackDefault::extendedSettings public static function
GridStackDefault::fixedSettings public static function Returns fixed settings not configurable via UI.
GridStackDefault::gid public static function Returns gridstack random id related to the each layout.
GridStackDefault::htmlSettings public static function Returns HTML or layout related settings, none of JS to shutup notices.
GridStackDefault::imageSettings public static function
GridStackDefault::layoutId public static function Returns gridstack layout id.
GridStackDefault::layoutSettings public static function Returns the main layout settings.
GridStackDefault::LEVEL_NESTED constant Defines nested level.
GridStackDefault::LEVEL_NESTED_ITEM constant Defines nested item level.
GridStackDefault::LEVEL_ROOT constant Defines root level.
GridStackDefault::LEVEL_ROOT_ITEM constant Defines root item level.
GridStackDefault::mainWrapperOptions public static function Returns the main wrapper Layout Builder select options.
GridStackDefault::NESTED constant Defines dummy nested selector.
GridStackDefault::rangeElements public static function Returns background color settings.
GridStackDefault::REGION constant Defines a region.
GridStackDefault::regionId public static function Returns region ID.
GridStackDefault::regionSettings public static function Returns the region layout settings.
GridStackDefault::regionWrapperOptions public static function Returns wrapper Layout Builder select options.
GridStackDefault::ROOT constant Defines dummy root selector.
GridStackDefault::styleElements public static function Returns style settings.
GridStackDefault::styleSettings public static function Returns style settings.
GridStackDefault::textElements public static function Returns color settings.
GridStackDefault::themeProperties public static function Returns theme properties.
GridStackDefault::uiSettings public static function Returns shared global form settings which should be consumed at formatters.
GridStackDefault::variantWrapperId public static function Returns variant wrapper AJAX ID.
GridStackDefault::viewFieldOptions public static function Returns view fields options for Views UI.