Skip to content

Commit

Permalink
Merge pull request #475 from droptica/develop
Browse files Browse the repository at this point in the history
RC2 Changes
  • Loading branch information
grzegorz-pietrzak-droptica committed Apr 27, 2020
2 parents a87fadb + 90ad5a6 commit 5ce1db3
Show file tree
Hide file tree
Showing 24 changed files with 177 additions and 59 deletions.
1 change: 0 additions & 1 deletion composer.json
Expand Up @@ -56,7 +56,6 @@
"drupal/schema_metatag": "^1.4",
"npm-asset/countup": "^1.9",
"npm-asset/in-viewport": "^3.6",
"npm-asset/jquery-backstretch": "^2.1",
"npm-asset/select2": "^4.0.4",
"npm-asset/slick-carousel": "^1.8",
"npm-asset/object-fit-images": "^3.2.4"
Expand Down
11 changes: 0 additions & 11 deletions modules/custom/d_demo/blocks/d_social_media_header.yml

This file was deleted.

1 change: 0 additions & 1 deletion modules/custom/d_demo/d_demo.module
Expand Up @@ -88,7 +88,6 @@ function d_demo_block_structure_alter(&$structure, $context) {
$structure['footer_services'] = ['file' => "$path/footer_services.yml"];
$structure['footer_others'] = ['file' => "$path/footer_others.yml"];
$structure['footer_secondary_menu'] = ['file' => "$path/footer_secondary_menu.yml"];
$structure['d_social_media_header'] = ['file' => "$path/d_social_media_header.yml"];
$structure['d_social_media_footer'] = ['file' => "$path/d_social_media_footer.yml"];
$structure['header_search_link'] = ['file' => "$path/header_search_link.yml"];
$structure['secondary_menu'] = ['file' => "$path/secondary_menu.yml"];
Expand Down
4 changes: 2 additions & 2 deletions modules/custom/d_demo/pages/invest.yml
Expand Up @@ -186,9 +186,9 @@ field_page_section:
field_d_long_text:
type: text_long
data:
<p>John Smith</p>
'<p>John Smith</p>
<p>ul. Duńska 9<br>54-427 Wrocław</p>
<p>Mobile: +48 333 444 222</p>
<p>Mobile: +48 333 444 222</p>'
field_d_background_color:
type: text
data: '#fff'
Expand Down
2 changes: 1 addition & 1 deletion modules/custom/d_geysir/d_geysir.module
Expand Up @@ -16,7 +16,7 @@ function d_geysir_form_alter(&$form, FormStateInterface $form_state, $form_id) {
switch ($form_id) {
case 'geysir.modal.add_select_type_form':
$root_path = DRUPAL_ROOT;
$base_url = \Drupal::service('router.request_context')->getBaseUrl;
$base_url = \Drupal::service('router.request_context')->getBaseUrl();
$module_path = drupal_get_path('module', 'd_p');
foreach ($form['description'] as $paragraph_name => $attributes) {
$file_server_path = $root_path . '/' . $module_path . '/images/' . $paragraph_name . '.png';
Expand Down
21 changes: 21 additions & 0 deletions modules/custom/d_geysir/js/d_geysir.js
Expand Up @@ -20,4 +20,25 @@
Drupal.AjaxCommands.prototype.d_geysir_reattach_behaviors = function(ajax, response, status) {
Drupal.attachBehaviors($('[data-geysir-field-paragraph-field-wrapper]').get(0));
};

/**
* Binds "use-ajax" links.
*
* After closing Drupal modal, none of the behaviors
* nor any of the Drupal ajax commands is executed.
* Because of this reason we have to register newly
* added links containing "use-ajax" css class
* by passing the geysir paragraph wrapper element
* to bindAjaxLinks method so it could collect it properly.
*
* @type {{attach: Drupal.behaviors.d_geysir_bind_ajax_links}}
*/
Drupal.behaviors.d_geysir_bind_ajax_links = {
attach: function (context, settings) {
$(window).on('dialog:afterclose', function (dialog, $element) {
Drupal.ajax.bindAjaxLinks('[data-geysir-field-paragraph-field-wrapper]');
});
}
}

})(jQuery, Drupal);
17 changes: 17 additions & 0 deletions modules/custom/d_p/d_p.api.php
@@ -0,0 +1,17 @@
<?php

/**
* @file
* Paragraphs features API documentation.
*/

/**
* Collects paragraph types to center its ckeditor content.
*
* @param array $paragraph_types
* Array of the paragraph types for which ckeditor content should be centered
* by default.
*/
function hook_d_p_centered_ckeditor_widget_paragraphs(array &$paragraph_types) {
$paragraph_types[] = 'my_paragraph_type';
}
41 changes: 41 additions & 0 deletions modules/custom/d_p/d_p.module
Expand Up @@ -10,6 +10,7 @@ use Drupal\Core\Template\Attribute;
use Drupal\Core\Form\FormStateInterface;
use Drupal\field\Entity\FieldConfig;
use Drupal\d_p\Helper\ParagraphModifiersHelper;
use Drupal\text\Plugin\Field\FieldWidget\TextareaWidget;

/**
* Implements hook_theme().
Expand Down Expand Up @@ -232,6 +233,10 @@ function d_p_field_widget_form_alter(&$element, FormStateInterface $form_state,
unset($element['#options']['full']);
}

// Make the content of the CKEditor centred by default for the specified
// paragraph types.
d_p_centered_ckeditor_widget_content($element, $form_state, $context, $bundle);

// Hide options "Left (wide)" and "Right (wide)" on given paragraphs.
if (in_array($bundle, ['d_p_side_embed', 'd_p_side_tiles'])) {
unset($element['#options']['left-wide']);
Expand All @@ -253,3 +258,39 @@ function d_p_preprocess_field(&$variables) {
}
}
}

/**
* Make the content of the CKEditor centred for the specified paragraph types.
*
* @param array $element
* The field widget form element.
* @param \Drupal\Core\Form\FormStateInterface $form_state
* The current state of the form.
* @param array $context
* An associative array containing widget attributes.
* @param string $paragraph_type
* Type of the processing paragraph.
*
* @see: d_p_preprocess_textarea();
*/
function d_p_centered_ckeditor_widget_content(&$element, FormStateInterface $form_state, $context, $paragraph_type) {
if ($context['widget'] instanceof TextareaWidget) {
$paragraph_types = [];
\Drupal::moduleHandler()->invokeAll('d_p_centered_ckeditor_widget_paragraphs', [&$paragraph_types]);
if (in_array($paragraph_type, $paragraph_types)) {
$element['#d_p_ckeditor_centered'] = TRUE;
}
}
}

/**
* Implements hook_preprocess_HOOK().
*
* Make the content of the CKEditor centred for the specified paragraph types.
* @see: d_p_centered_ckeditor_widget_content();
*/
function d_p_preprocess_textarea(&$variables) {
if ($variables['element']['#d_p_ckeditor_centered'] ?? FALSE) {
$variables['wrapper_attributes']->addClass('d_p_ckeditor_centered');
}
}
47 changes: 12 additions & 35 deletions modules/custom/d_p/js/d_p_ckeditor.js
Expand Up @@ -4,35 +4,9 @@
attach: function (context, settings) {

$(context).ready(function() {
d_p_ckeditor(true);
d_p_ckeditor();
});

function d_p_ckeditor_geysir() {
if (typeof CKEDITOR.instances[Object.keys(CKEDITOR.instances)[0]].element.$.parentElement.offsetParent.offsetParent.children['geysir-modal-form'] !== 'undefined') {
if (typeof CKEDITOR.instances[Object.keys(CKEDITOR.instances)[0]].document !== 'undefined') {
var doc = CKEDITOR.instances[Object.keys(CKEDITOR.instances)[0]].document.$;
d_p_ckeditor_add_js(doc);
} else {
setTimeout(d_p_ckeditor_geysir, 500);
}
}
}

function d_p_ckeditor_notgeysir() {
for (var instanceName in CKEDITOR.instances) {
var element = CKEDITOR.instances[instanceName].element.$.parentElement.offsetParent.parentElement.classList;
// check if it is group of text-block from block-text-paragraph
if (!(element.contains('paragraph-type--d-p-single-text-block'))) {
if (typeof CKEDITOR.instances[Object.keys(CKEDITOR.instances)[0]].document !== 'undefined') {
var doc = CKEDITOR.instances[Object.keys(CKEDITOR.instances)[0]].document.$; //get CKE doc!
d_p_ckeditor_add_js(doc);
} else {
setTimeout(d_p_ckeditor_notgeysir, 500);
}
}
}
}

function d_p_ckeditor_add_js(doc) {
var cssId = 'd_p_ckeditor';
if (!doc.getElementById(cssId)) {
Expand All @@ -47,15 +21,18 @@
}
}

function d_p_ckeditor(fade_in) {
fade_in = (fade_in == true) ? 500 : 0;
function d_p_ckeditor() {
if (typeof CKEDITOR !== "undefined") {
// Check if it is a geysir paragraph editor
if (document.getElementById('geysir-modal')) {
d_p_ckeditor_geysir();
} else if (typeof CKEDITOR.instances !== "undefined") {
// For editor paragraph check every instance of ckeditor
d_p_ckeditor_notgeysir();
for (let instanceName in CKEDITOR.instances) {
if (CKEDITOR.instances[instanceName].element.$.parentElement.classList.contains('d_p_ckeditor_centered')) {
if (typeof CKEDITOR.instances[instanceName].document !== 'undefined') {
d_p_ckeditor_add_js(CKEDITOR.instances[instanceName].document.$);
} else {
setTimeout(function () {
d_p_ckeditor_add_js(CKEDITOR.instances[instanceName].document.$);
}, 500);
}
}
}
} else {
window.setTimeout(d_p_ckeditor, 500);
Expand Down
8 changes: 8 additions & 0 deletions modules/custom/d_p_carousel/d_p_carousel.module
Expand Up @@ -115,3 +115,11 @@ function d_p_carousel_preprocess_paragraph(&$variables) {
break;
}
}

/**
* Implements hook_d_p_centered_ckeditor_widget_paragraphs().
*/
function d_p_carousel_d_p_centered_ckeditor_widget_paragraphs(array &$paragraph_types) {
$paragraph_types[] = 'd_p_carousel';
$paragraph_types[] = 'd_p_carousel_item';
}
7 changes: 7 additions & 0 deletions modules/custom/d_p_gallery/d_p_gallery.module
Expand Up @@ -18,3 +18,10 @@ function d_p_gallery_theme($existing, $type, $theme, $path) {
],
];
}

/**
* Implements hook_d_p_centered_ckeditor_widget_paragraphs().
*/
function d_p_gallery_d_p_centered_ckeditor_widget_paragraphs(array &$paragraph_types) {
$paragraph_types[] = 'd_p_gallery';
}
7 changes: 7 additions & 0 deletions modules/custom/d_p_subscribe_file/d_p_subscribe_file.module
Expand Up @@ -92,3 +92,10 @@ function d_p_subscribe_file_mail($key, &$message, $params) {
break;
}
}

/**
* Implements hook_d_p_centered_ckeditor_widget_paragraphs().
*/
function d_p_subscribe_file_d_p_centered_ckeditor_widget_paragraphs(array &$paragraph_types) {
$paragraph_types[] = 'd_p_subscribe_file';
}
7 changes: 7 additions & 0 deletions modules/custom/d_p_text_blocks/d_p_text_blocks.module
Expand Up @@ -86,3 +86,10 @@ function d_p_text_blocks_preprocess_paragraph(&$variables) {
break;
}
}

/**
* Implements hook_d_p_centered_ckeditor_widget_paragraphs().
*/
function d_p_text_blocks_d_p_centered_ckeditor_widget_paragraphs(array &$paragraph_types) {
$paragraph_types[] = 'd_p_group_of_text_blocks';
}
7 changes: 7 additions & 0 deletions modules/custom/d_p_text_paged/d_p_text_paged.module
Expand Up @@ -15,3 +15,10 @@ function d_p_text_paged_theme($existing, $type, $theme, $path) {
],
];
}

/**
* Implements hook_d_p_centered_ckeditor_widget_paragraphs().
*/
function d_p_text_paged_d_p_centered_ckeditor_widget_paragraphs(array &$paragraph_types) {
$paragraph_types[] = 'd_p_text_paged';
}
7 changes: 7 additions & 0 deletions modules/custom/d_p_text_with_bckg/d_p_text_with_bckg.module
Expand Up @@ -15,3 +15,10 @@ function d_p_text_with_bckg_theme($existing, $type, $theme, $path) {
],
];
}

/**
* Implements hook_d_p_centered_ckeditor_widget_paragraphs().
*/
function d_p_text_with_bckg_d_p_centered_ckeditor_widget_paragraphs(array &$paragraph_types) {
$paragraph_types[] = 'd_p_text_with_bckg';
}
7 changes: 7 additions & 0 deletions modules/custom/d_p_tiles/d_p_tiles.module
Expand Up @@ -94,3 +94,10 @@ function d_p_tiles_preprocess_colorbox_formatter(&$variables) {
$variables['attributes']['data-cbox-title'] = $alt;
}
}

/**
* Implements hook_d_p_centered_ckeditor_widget_paragraphs().
*/
function d_p_tiles_d_p_centered_ckeditor_widget_paragraphs(array &$paragraph_types) {
$paragraph_types[] = 'd_p_tiles';
}
4 changes: 2 additions & 2 deletions modules/custom/d_product/d_product.module
Expand Up @@ -113,8 +113,8 @@ function d_product_form_alter(&$form, FormStateInterface $form_state, $form_id)
function d_product_preprocess_page(&$variables) {
$route_name = \Drupal::routeMatch()->getRouteName();
if (stripos($route_name, 'view.products_list') !== FALSE) {
global $pager_total_items;
$variables['pager_total_items'] = reset($pager_total_items);
$pager_manager = \Drupal::service('pager.manager');
$variables['pager_total_items'] = $pager_manager->getPager(0)->getTotalItems();
$variables['#attached']['library'][] = 'd_product/d_product_select';
$variables['#attached']['library'][] = 'd_product/d_product_searches';
}
Expand Down
8 changes: 8 additions & 0 deletions themes/custom/droopler_theme/scss/components/_alerts.scss
@@ -0,0 +1,8 @@
#main-wrapper {
& > .container {
.alert {
margin-left: -($grid-gutter-width/2);
margin-right: -($grid-gutter-width/2);
}
}
}
Expand Up @@ -7,7 +7,6 @@ Styleguide 2.2
// Colour variables used in this component.
$lang-dropdown-header-color: $menu-main-link-color !default; // Color of language link in main menu
$lang-dropdown-toggle-color: $menu-main-link-dropdown !default; // Color of language dropdown toggle icon
$lang-dropdown-submenu-color: $submenu-link-color !default; // Color of link in language menu
$lang-dropdown-submenu-hover-color: $submenu-link-hover-color !default; // Color of hover link in language submenu
$lang-dropdown-submenu-hover-background: $submenu-link-hover-background !default; // Color of hover bg in language submenu
$lang-dropdown-submenu-active-color: $menu-main-link-active-color !default; // Color of active link in language submenu
Expand All @@ -29,6 +28,7 @@ $lang-dropdown-dropdown-width: $menu-dropdown-width !default; // Width of deskt
$lang-dropdown-submenu-link-height: $submenu-link-height !default;
$lang-dropdown-mobile-link-padding: 0.625rem !default;
$lang-dropdown-mobile-padding: 1.25rem !default;
$lang-dropdown-mobile-margin-top: 1.0625rem;

$secondary-menu-lang-dropdown-height: 2.4rem !default;

Expand Down Expand Up @@ -107,7 +107,6 @@ $secondary-menu-lang-dropdown-height: 2.4rem !default;
}
a {
font-size: $lang-dropdown-submenu-font-size;
color: $lang-dropdown-submenu-color;
text-transform: uppercase;
&:hover, &:focus {
color: $lang-dropdown-submenu-hover-color;
Expand All @@ -124,6 +123,9 @@ $secondary-menu-lang-dropdown-height: 2.4rem !default;

// Styling for mobile (<= MD)
@include media-breakpoint-down(md) {
width: 100%;
margin-top: $lang-dropdown-mobile-margin-top;

.active-lang-code {
display: none;
}
Expand Down
11 changes: 11 additions & 0 deletions themes/custom/droopler_theme/scss/components/_forms.scss
Expand Up @@ -27,6 +27,17 @@ input:-moz-placeholder { /* Firefox 18- */
font-weight: normal;
}

fieldset {
&.error {
.fieldset-wrapper {
border-color: $danger !important;
}
.media-library-widget-empty-text {
color: $color-achillies;
}
}
}

@mixin make-inline-form {
fieldset {
display: inline-block;
Expand Down
1 change: 1 addition & 0 deletions themes/custom/droopler_theme/scss/menu/_menu_design.scss
Expand Up @@ -111,6 +111,7 @@ $sidebar-animation-speed: 600ms !default;
left: -50%;
top: 0;
z-index: 0;
pointer-events: none;
}
&::after {
left: 50%;
Expand Down
6 changes: 4 additions & 2 deletions themes/custom/droopler_theme/scss/menu/_menu_layout.scss
Expand Up @@ -35,7 +35,8 @@ li.we-mega-menu-li {
}
}
}
.we-mega-menu-li {
.we-mega-menu-li,
.we-megamenu-nolink {
width: 100%;
display: flex;
justify-content: space-between;
Expand Down Expand Up @@ -323,7 +324,8 @@ li.we-mega-menu-li {
}

.we-mega-menu-li {
> a {
> a,
> span.we-megamenu-nolink {
padding: $menu-main-link-padding-desktop;
line-height: $submenu-link-height;
}
Expand Down

0 comments on commit 5ce1db3

Please sign in to comment.