Skip to content
Snippets Groups Projects
Commit db58502e authored by Tyler Struyk's avatar Tyler Struyk
Browse files

Merge branch 'feature/ISTWCMS-6313-ebremner-page-title-big-text' into '1.1.x'

Feature/istwcms 6313 ebremner page title big text

See merge request !335
parents f15968a8 dd896e8b
No related branches found
No related tags found
1 merge request!335Feature/istwcms 6313 ebremner page title big text
langcode: en
status: true
dependencies:
module:
- node
- options
id: node.field_uw_page_title_big_text
field_name: field_uw_page_title_big_text
entity_type: node
type: list_string
settings:
allowed_values:
-
value: '1'
label: 'Yes'
-
value: '0'
label: 'No'
allowed_values_function: ''
module: options
locked: false
cardinality: 1
translatable: true
indexes: { }
persist_with_no_fields: false
custom_storage: false
/**
* @file
* Javascript for uw_cfg_common.
*/
(function ($, Drupal, drupalSettings) {
'use strict';
Drupal.behaviors.uw_cfg_common = {
attach: function (context, drupalSettings) {
// On document ready, check if the page has the page title
// as big text and if so enable/disable the big text
// in the banner image.
$(document).ready(function () {
setBigText();
});
// When the big text in banner images is ready, check if it
// needs to be able enable/disabled based on page title.
$('input[name*="[subform][field_uw_ban_big_text]"]').ready(function () {
setBigText();
});
// When the page title option has been changed set the big text
// in banner based on inputs.
$('#edit-field-uw-page-title-big-text').change(function () {
setBigText();
});
// When the text overlay option has been changed set the big text
// in banner based on inputs.
$('#edit-field-uw-text-overlay-style').change(function () {
setBigText();
});
// Function to set big text in banner image.
function setBigText() {
// If not single page style banner and page title big text
// then disable big text in banner and set value to blank.
// Otherwise enable big text in banner.
if (
$('#edit-field-uw-text-overlay-style').val() !== 'split' &&
$('#edit-field-uw-page-title-big-text').val() == 1
) {
$('input[name*="[subform][field_uw_ban_big_text]"]').each(function () {
$(this).prop("disabled", true);
$(this).val('');
});
}
else {
$('input[name*="[subform][field_uw_ban_big_text]"]').each(function () {
$(this).prop("disabled", false);
});
}
}
}
}
})(jQuery, Drupal, drupalSettings);
......@@ -262,6 +262,15 @@ class UwNodeFieldValue {
$media_width_classes = $layout_builder_style->getClasses();
}
// Flag to use page title as big text.
$use_page_title_big_text_flag = FALSE;
if ($node->hasField('field_uw_page_title_big_text')) {
if ($node->field_uw_page_title_big_text->value) {
$use_page_title_big_text_flag = TRUE;
}
}
// Process banner images.
foreach ($node->$field_name as $banner_item) {
......@@ -270,7 +279,7 @@ class UwNodeFieldValue {
$banner = [
'type' => $type,
'big_text' => $banner_para->field_uw_ban_big_text->value,
'big_text' => $use_page_title_big_text_flag ? $node->label() : $banner_para->field_uw_ban_big_text->value,
'small_text' => $banner_para->field_uw_ban_small_text->value,
];
......@@ -317,6 +326,8 @@ class UwNodeFieldValue {
'style' => $node->field_uw_text_overlay_style->value,
'transition_speed' => $node->field_uw_transition_speed->value,
'media_width' => $media_width_classes ?? NULL,
'text_overlay' => $node->field_uw_text_overlay_style->value,
'use_page_title_big_text' => $use_page_title_big_text_flag,
'bundle' => $node->getType(),
'uuid' => uniqid(),
];
......
uw_mathjax:
js:
https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.7/MathJax.js?config=TeX-AMS_HTML: { type: external, minified: true }
uw_cfg_common:
version: 1.x
js:
js/uw_cfg_common.js: { }
......@@ -1074,7 +1074,6 @@ function uw_cfg_common_form_alter(array &$form, FormStateInterface $form_state,
// Hide elements under Twitter settings.
$form['field_uw_meta_tags']['widget'][0]['twitter_cards']['twitter_cards_page_url']['#access'] = FALSE;
$form['field_uw_meta_tags']['widget'][0]['twitter_cards']['twitter_cards_page_url']['#access'] = FALSE;
}
}
......@@ -1127,6 +1126,17 @@ function uw_cfg_common_form_alter(array &$form, FormStateInterface $form_state,
],
];
// Set the states for the banner settings.
$form['field_uw_text_overlay_style']['#states'] = [
'visible' => [
[
'select[name="field_uw_type_of_media"]' => [
['value' => 'banner'],
],
],
],
];
// Set the states for the banner settings.
$form['field_uw_media_width']['#states'] = [
'visible' => [
......@@ -1141,6 +1151,38 @@ function uw_cfg_common_form_alter(array &$form, FormStateInterface $form_state,
],
];
// Set the states for the banner settings, if it exists.
if (isset($form['field_uw_page_title_big_text'])) {
// ISTWCMS-6313.
// The next two are for existing content types that do not have
// the default values and options set for page title big text.
if (empty($form['field_uw_page_title_big_text']['widget']['#default_value'])) {
$form['field_uw_page_title_big_text']['widget']['#default_value'][0] = 0;
}
if (isset($form['field_uw_page_title_big_text']['widget']['#options']['_none'])) {
unset($form['field_uw_page_title_big_text']['widget']['#options']['_none']);
}
// The form state for page title as big text.
$form['field_uw_page_title_big_text']['#states'] = [
'visible' => [
[
'select[name="field_uw_type_of_media"]' => [
['value' => 'banner'],
],
'select[name="field_uw_text_overlay_style"]' => [
['!value' => 'split'],
],
],
],
];
}
// ISTWCMS-6313: adding the JS on the node add/edit page,
// that will check for enable/disable big text in banner image.
$form['#attached']['library'][] = 'uw_cfg_common/uw_cfg_common';
// Add our custom validation for banners.
$form['#validate'][] = '_uw_cfg_common_banner_validate';
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment