public function BackgroundImageForm::buildSettings in Background Image 8
Same name and namespace in other branches
- 2.x src/Form/BackgroundImageForm.php \Drupal\background_image\Form\BackgroundImageForm::buildSettings()
- 2.0.x src/Form/BackgroundImageForm.php \Drupal\background_image\Form\BackgroundImageForm::buildSettings()
Builds the "Settings" group.
1 call to BackgroundImageForm::buildSettings()
- BackgroundImageForm::build in src/
Form/ BackgroundImageForm.php - Builds the Background Image form.
File
- src/
Form/ BackgroundImageForm.php, line 479
Class
Namespace
Drupal\background_image\FormCode
public function buildSettings() {
$this
->createGroup('settings', $this->subform, [
'#type' => 'container',
'#weight' => 11,
]);
$this
->buildSetting('full_viewport', [
'#type' => 'checkbox',
'#title' => $this
->t('Full Viewport'),
'#description' => $this
->t('If enabled, the class "@base_class-full-viewport" will be added to the BODY element so the background image will take up the full height of the viewport. This should push any content after it out of the way so it appears below the background image. Enabling this will require the user to scroll to view the main content of the page.', [
'@base_class' => static::getBackgroundImageManager()
->getBaseClass(),
]),
]);
$blur_type = [
'#type' => 'select',
'#title' => $this
->t('Type'),
'#description' => $this
->t('Determines when the background should be blurred.'),
'#default_value' => $this
->getSettingValue('blur.type'),
'#options' => [
BackgroundImageInterface::BLUR_NONE => 'None',
BackgroundImageInterface::BLUR_SCROLL => 'Scrolling',
BackgroundImageInterface::BLUR_SCROLL_FULL_VIEWPORT => 'Scrolling (Full Viewport)',
BackgroundImageInterface::BLUR_PERSISTENT => 'Persistent',
],
];
$blur_radius = [
'#type' => 'number',
'#title' => $this
->t('Radius'),
'#description' => $this
->t('Maximum blur radius, in pixels, that will be applied to the background image.'),
'#default_value' => $this
->getSettingValue('blur.radius'),
'#min' => 0,
'#max' => 100,
];
self::addState($blur_radius, 'invisible', $blur_type, [
'*' => [
'value' => BackgroundImageInterface::BLUR_NONE,
],
]);
$blur_speed = [
'#type' => 'number',
'#title' => $this
->t('Speed'),
'#description' => $this
->t('The speed in which the background image is blurred when scrolled.'),
'#default_value' => $this
->getSettingValue('blur.speed'),
'#min' => 1,
'#max' => 10,
];
self::addState($blur_speed, 'invisible', $blur_type, [
[
'*' => [
'value' => BackgroundImageInterface::BLUR_NONE,
],
],
[
'*' => [
[
'value' => BackgroundImageInterface::BLUR_SCROLL,
],
[
'!value' => BackgroundImageInterface::BLUR_SCROLL_FULL_VIEWPORT,
],
],
],
]);
$this
->buildSetting('blur', [
'#title' => $this
->t('Blur'),
'type' => &$blur_type,
'radius' => &$blur_radius,
'speed' => &$blur_speed,
]);
$text =& $this
->buildSetting('text', [
'#type' => 'text_format',
'#title' => $this
->t('Overlay Text'),
'#description' => $this
->t(''),
'#format' => $this
->getSettingValue('text.format'),
'#default_value' => $this
->getSettingValue('text.value'),
]);
self::addTokenBrowser($text['container'], $this->inlineEntity);
}