Skip to content
Snippets Groups Projects
Commit 416aa9b1 authored by Serhii Myronets's avatar Serhii Myronets
Browse files

Issue #3392441 by agami4: Improve twig code, js library and php dependency

parent f909979c
No related branches found
Tags 2.5.9
1 merge request!184Issue #3392441 by agami4: Improve twig code, js library and php dependency
Showing
with 89 additions and 86 deletions
(function ($) {
(function (Drupal, $, once) {
Drupal.behaviors.textareaAutogrow = {
attach: function attach(context, settings) {
// Attach autosize listener.
$(".form-control--autogrow", context).once("textareaAutogrow").each(function () {
$(once('textareaAutogrow', ".form-control--autogrow", context)).each(function () {
autosize.destroy($('.form-control--autogrow'));
autosize($('.form-control--autogrow'));
autosize.update($('.form-control--autogrow'));
......@@ -19,4 +19,4 @@
});
}
};
})(jQuery);
\ No newline at end of file
})(Drupal, jQuery, once);
\ No newline at end of file
(function ($) {
(function (Drupal, $, once) {
Drupal.behaviors.navbarCollapse = {
attach: function attach(context, settings) {
// Delegate the event to body to prevent screenreaders from thinking
// teasers are clickable.
var $body = $('body');
$body.once('navbarCollapse').on('click', '.dropdown-toggle, #content', function () {
var $body = $(once('navbarCollapse', 'body'));
$body.on('click', '.dropdown-toggle, #content', function () {
$('.navbar-collapse').collapse('hide');
var headerDropDown = $('.navbar-default .dropdown');
setTimeout(function () {
......@@ -17,4 +18,4 @@
});
}
};
})(jQuery);
\ No newline at end of file
})(Drupal, jQuery, once);
\ No newline at end of file
......@@ -2,27 +2,30 @@
* @file
* Add SVG as sanitized option to popover.
*/
(function ($, Drupal) {
(function ($, Drupal, once) {
'use strict';
/**
* @type {Drupal~behavior}
*/
Drupal.behaviors.social_popover = {
attach: function attach(context, settings) {
if (!$.fn.popover) throw new Error('Popover requires tooltip.js');
$('body').once('social_popover').each(function () {
var myDefaultWhiteList = []; // Allow table elements
$(once('social_popover', 'body')).each(function () {
var myDefaultWhiteList = [];
// Allow table elements
myDefaultWhiteList.table = [];
myDefaultWhiteList.td = [];
myDefaultWhiteList.th = []; // Allow SVG's and use options
myDefaultWhiteList.th = [];
// Allow SVG's and use options
myDefaultWhiteList.svg = ['viewBox'];
myDefaultWhiteList.use = ['xlink:href', 'href', 'xlink']; // Extend the popover defaults so we can add the above to the popover.
myDefaultWhiteList.use = ['xlink:href', 'href', 'xlink'];
// Extend the popover defaults so we can add the above to the popover.
$.extend($.fn.popover.Constructor.DEFAULTS.whiteList, myDefaultWhiteList);
});
}
};
})(jQuery, Drupal);
\ No newline at end of file
})(jQuery, Drupal, once);
\ No newline at end of file
(function ($) {
(function (Drupal, $, once) {
Drupal.behaviors.textareaAutogrow = {
attach: function (context, settings) {
// Attach autosize listener.
$(".form-control--autogrow", context).once("textareaAutogrow").each(function () {
$(once('textareaAutogrow', ".form-control--autogrow", context)).each(function () {
autosize.destroy($('.form-control--autogrow'));
autosize($('.form-control--autogrow'));
autosize.update($('.form-control--autogrow'));
......@@ -24,4 +24,4 @@
}
}
})(jQuery);
})(Drupal, jQuery, once);
(function ($) {
(function (Drupal, $, once) {
Drupal.behaviors.navbarCollapse = {
attach: function (context, settings) {
......@@ -6,9 +6,9 @@
// Delegate the event to body to prevent screenreaders from thinking
// teasers are clickable.
var $body = $('body');
var $body = $(once('navbarCollapse', 'body'));
$body.once('navbarCollapse').on('click', '.dropdown-toggle, #content', function() {
$body.on('click', '.dropdown-toggle, #content', function() {
$('.navbar-collapse').collapse('hide');
var headerDropDown = $('.navbar-default .dropdown');
......@@ -26,4 +26,4 @@
};
})(jQuery);
})(Drupal, jQuery, once);
......@@ -3,7 +3,7 @@
* Add SVG as sanitized option to popover.
*/
(function ($, Drupal) {
(function ($, Drupal, once) {
'use strict';
......@@ -15,7 +15,7 @@
if (!$.fn.popover) throw new Error('Popover requires tooltip.js')
$('body').once('social_popover').each(function () {
$(once('social_popover', 'body')).each(function () {
var myDefaultWhiteList = [];
// Allow table elements
myDefaultWhiteList.table = [];
......@@ -32,4 +32,4 @@
}
};
})(jQuery, Drupal);
})(jQuery, Drupal, once);
......@@ -28,7 +28,7 @@ base theme: bootstrap
# The supported Drupal version.
core_version_requirement: ^8.8 || ^9
core_version_requirement: ^8.8 || ^9 || ^10
# Libraries-extend is used to attach libraries to other libraries. If the
# original library is conditionally included, the library it is extended with
......@@ -65,33 +65,12 @@ stylesheets-remove:
libraries-override:
# The library name.
core/normalize: false
# Remove jQuery UI styles
core/jquery.ui:
css:
component:
assets/vendor/jquery.ui/themes/base/core.css: false
theme:
assets/vendor/jquery.ui/themes/base/theme.css: false
core/jquery.ui.button:
css:
component:
assets/vendor/jquery.ui/themes/base/button.css: false
core/jquery.ui.dialog:
css:
component:
assets/vendor/jquery.ui/themes/base/dialog.css: false
core/jquery.ui.menu:
css:
component:
assets/vendor/jquery.ui/themes/base/menu.css: false
system/base: false
views/views.module: false
classy/file: false
like_and_dislike/behavior:
js:
js/like_and_dislike_service.js: false
like_and_dislike/icons: false
private_message/inbox_block: false
# Libraries contain CSS and JavaScript files. The libraries setting is used to
# globally add libraries, which means they will appear on every page. Libraries
......
......@@ -9,7 +9,7 @@ base:
dependencies:
- core/drupal
- core/jquery
- core/jquery.once
- core/once
print:
css:
......@@ -50,6 +50,9 @@ form-controls:
assets/js/autosize.init.min.js: { minified: true }
dependencies:
- core/drupal.form
- core/drupal
- core/jquery
- core/once
fitframe:
css:
......@@ -180,6 +183,10 @@ navbar:
assets/js/navbar-resize.min.js: { minified: true }
assets/js/navbar-search.min.js: { minified: true }
assets/js/navbar-main-menu.min.js: { minified: true }
dependencies:
- core/drupal
- core/jquery
- core/once
pagination:
css:
......@@ -199,6 +206,10 @@ popover:
/libraries/bootstrap/js/tooltip.js: { weight: -2 }
/libraries/bootstrap/js/popover.js: { weight: -1 }
assets/js/popover_svg.min.js: { }
dependencies:
- core/drupal
- core/jquery
- core/once
select2:
css:
......
......@@ -4,7 +4,7 @@ namespace Drupal\socialbase\Plugin\Preprocess;
use Drupal\bootstrap\Plugin\Preprocess\PreprocessBase;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use Symfony\Cmf\Component\Routing\RouteObjectInterface;
use Drupal\Core\Routing\RouteObjectInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\HttpFoundation\Request;
......
......@@ -51,31 +51,35 @@
</svg>
</button>
<ul{{ attributes.addClass('dropdown-menu') }}>
{%- for key, item in links|reverse if key != "comment-reply" -%}
<li{{ item.attributes.addClass(key|clean_class) }}>
{%- if item.link -%}
{{ item.link }}
{%- elseif item.text_attributes -%}
<span{{ item.text_attributes }}>{{ item.text }}</span>
{%- else -%}
{{ item.text }}
{%- endif -%}
</li>
{%- for key, item in links|reverse -%}
{%- if key != "comment-reply" -%}
<li{{ item.attributes.addClass(key|clean_class) }}>
{%- if item.link -%}
{{ item.link }}
{%- elseif item.text_attributes -%}
<span{{ item.text_attributes }}>{{ item.text }}</span>
{%- else -%}
{{ item.text }}
{%- endif -%}
</li>
{%- endif -%}
{%- endfor -%}
</ul>
</div>
{% else %}
{%- for key, item in links if key != "comment-reply" -%}
<li{{ item.attributes.addClass(key|clean_class) }}>
{%- if item.link -%}
{{ item.link }}
{%- elseif item.text_attributes -%}
<span{{ item.text_attributes }}>{{ item.text }}</span>
{%- else -%}
{{ item.text }}
{%- endif -%}
</li>
{%- for key, item in links -%}
{%- if key != "comment-reply" -%}
<li{{ item.attributes.addClass(key|clean_class) }}>
{%- if item.link -%}
{{ item.link }}
{%- elseif item.text_attributes -%}
<span{{ item.text_attributes }}>{{ item.text }}</span>
{%- else -%}
{{ item.text }}
{%- endif -%}
</li>
{%- endif -%}
{%- endfor -%}
{% endif %}
......@@ -85,13 +89,15 @@
{% if links['comment-reply'] %}
<div class="btn comment__reply-btn">
{%- for key, item in links|reverse if key == "comment-reply" -%}
{%- if item.link -%}
{{ item.link }}
{%- elseif item.text_attributes -%}
<span{{ item.text_attributes }}>{{ item.text }}</span>
{%- else -%}
{{ item.text }}
{%- for key, item in links|reverse -%}
{%- if key == "comment-reply" -%}
{%- if item.link -%}
{{ item.link }}
{%- elseif item.text_attributes -%}
<span{{ item.text_attributes }}>{{ item.text }}</span>
{%- else -%}
{{ item.text }}
{%- endif -%}
{%- endif -%}
{%- endfor -%}
</div>
......
......@@ -14,7 +14,7 @@
*/
#}
{{ attach_library('socialbase/file') }}
{% spaceless %}
{% apply spaceless %}
<span{{ attributes }}>
{% if icon_only %}
......@@ -32,4 +32,4 @@
</span>
{% endspaceless %}
{% endapply %}
......@@ -23,7 +23,7 @@
*/
#}
{% block input %}
{% spaceless %}
{% apply spaceless %}
{% if icon_only %}
<button{{ attributes.addClass(classes, 'icon-only') }}>
<span class="sr-only">{{ label }}</span>
......@@ -45,5 +45,5 @@
</span>
{% endif %}
{{ children }}
{% endspaceless %}
{% endapply %}
{% endblock %}
......@@ -66,7 +66,8 @@
depth this forum resides at. This will allow us to use CSS
left-margin for indenting.
#}
{% for i in 1..forum.depth if forum.depth > 0 %}<div class="indent">{% endfor %}
{% for i in 1..forum.depth|filter(forum.depth > 0) %}<div class="indent">{% endfor %}
<div title="{{ forum.icon_title }}">
<span class="visually-hidden">{{ forum.icon_title }}</span>
</div>
......@@ -74,7 +75,8 @@
{% if forum.description.value %}
<div>{{ forum.description.value }}</div>
{% endif %}
{% for i in 1..forum.depth if forum.depth > 0 %}</div>{% endfor %}
{% for i in 1..forum.depth|filter(forum.depth > 0) %}</div>{% endfor %}
</td>
{% if forum.is_container == false %}
<td>
......
{% extends "node--full.html.twig" %}
{% if display_submitted %}
{% block metainfo %}
{% block metainfo %}
{% if display_submitted %}
<header class="metainfo">
<div class="metainfo__avatar">
......@@ -27,8 +28,8 @@
{{ content.links.moderation }}
</header>
{% endblock %}
{% endif %}
{% endif %}
{% endblock %}
{# add specific fields to body for events only #}
{% block nodefull_specialfields %}
......
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