Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
ui_suite_bootstrap
Manage
Activity
Members
Labels
Plan
Wiki
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
project
ui_suite_bootstrap
Merge requests
!120
Issue
#3367100
: Style 'edit summary' on formatted text with summary
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Issue
#3367100
: Style 'edit summary' on formatted text with summary
issue/ui_suite_bootstrap-3367100:3367100-style-edit-summary
into
5.0.x
Overview
4
Commits
3
Pipelines
0
Changes
4
All threads resolved!
Hide all comments
Merged
Florent Torregrosa
requested to merge
issue/ui_suite_bootstrap-3367100:3367100-style-edit-summary
into
5.0.x
1 year ago
Overview
4
Commits
3
Pipelines
0
Changes
4
All threads resolved!
Hide all comments
Expand
0
0
Merge request reports
Compare
5.0.x
version 1
77048ecd
1 year ago
5.0.x (base)
and
latest version
latest version
f43d2f01
3 commits,
1 year ago
version 1
77048ecd
1 commit,
1 year ago
4 files
+
82
−
0
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
4
Search (e.g. *.vue) (Ctrl+P)
assets/js/text/text.es6.js
0 → 100644
+
72
−
0
Options
/**
* @file
* Text behaviors.
*/
((
$
,
Drupal
,
once
)
=>
{
/**
* Auto-hide summary textarea if empty and show hide and unhide links.
*
* @type {Drupal~behavior}
*
* @prop {Drupal~behaviorAttach} attach
* Attaches auto-hide behavior on `text-summary` events.
*/
Drupal
.
behaviors
.
textSummary
=
{
attach
(
context
)
{
once
(
"
text-summary
"
,
"
.js-text-summary
"
,
context
).
forEach
((
summary
)
=>
{
const
$widget
=
$
(
summary
).
closest
(
"
.js-text-format-wrapper
"
);
const
$summary
=
$widget
.
find
(
"
.js-text-summary-wrapper
"
);
const
$summaryLabel
=
$summary
.
find
(
"
label
"
).
eq
(
0
);
const
$full
=
$widget
.
children
(
"
.js-form-type-textarea
"
);
let
$fullLabel
=
$full
.
find
(
"
label
"
).
eq
(
0
);
// Create a placeholder label when the field cardinality is greater
// than 1.
if
(
$fullLabel
.
length
===
0
)
{
$fullLabel
=
$
(
"
<label></label>
"
).
prependTo
(
$full
);
}
// To ensure the summary toggle is shown in case the label is hidden
// (in multivalue fields in particular), show the label but hide
// the original text of the label.
if
(
$fullLabel
.
hasClass
(
"
visually-hidden
"
))
{
$fullLabel
.
html
(
(
index
,
oldHtml
)
=>
`<span class="visually-hidden">
${
oldHtml
}
</span>`
);
$fullLabel
.
removeClass
(
"
visually-hidden
"
);
}
// Set up the edit/hide summary link.
const
$link
=
$
(
`<span class="field-edit-link"><button type="button" class="link link-edit-summary btn btn-outline-dark btn-sm float-end">
${
Drupal
.
t
(
"
Hide summary
"
)}
</button></span>`
);
const
$button
=
$link
.
find
(
"
button
"
);
let
toggleClick
=
true
;
$link
.
on
(
"
click
"
,
(
e
)
=>
{
if
(
toggleClick
)
{
$summary
.
hide
();
$button
.
html
(
Drupal
.
t
(
"
Edit summary
"
));
$fullLabel
.
before
(
$link
);
}
else
{
$summary
.
show
();
$button
.
html
(
Drupal
.
t
(
"
Hide summary
"
));
$summaryLabel
.
before
(
$link
);
}
e
.
preventDefault
();
toggleClick
=
!
toggleClick
;
});
$summaryLabel
.
before
(
$link
);
// If no summary is set, hide the summary field.
if
(
summary
.
value
===
""
)
{
$link
.
trigger
(
"
click
"
);
}
});
},
};
})(
jQuery
,
Drupal
,
once
);
Loading