Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
select2_multicheck
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
select2_multicheck
Merge requests
!5
Use placeholder if nothing selected.
Code
Review changes
Check out branch
Download
Patches
Plain diff
Open
Use placeholder if nothing selected.
issue/select2_multicheck-3474966:3474966-bef-placeholder-text
into
1.0.x
Overview
0
Commits
1
Pipelines
1
Changes
1
Open
Damien McKenna
requested to merge
issue/select2_multicheck-3474966:3474966-bef-placeholder-text
into
1.0.x
9 months ago
Overview
0
Commits
1
Pipelines
1
Changes
1
Expand
Closes
#3474966
0
0
Merge request reports
Compare
1.0.x
1.0.x (HEAD)
and
latest version
latest version
b306868b
1 commit,
9 months ago
1 file
+
38
−
20
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
js/select2-multi-check.js
+
38
−
20
Options
(
function
(
$
,
Drupal
,
drupalSettings
)
{
Drupal
.
behaviors
.
select2MultiCheckboxes
=
{
attach
:
function
(
context
)
{
$
(
"
.select2-multiple
"
).
select2MultiCheckboxes
({
templateSelection
:
function
(
selected
,
total
,
context
)
{
return
Drupal
.
t
(
"
Selected @selected of @total
"
,
{
"
@selected
"
:
selected
.
length
,
"
@total
"
:
total
});
},
$
(
"
.select2-multiple
"
).
each
(
function
()
{
let
$item
=
$
(
this
);
$item
.
select2MultiCheckboxes
({
templateSelection
:
function
(
selected
,
total
,
context
)
{
if
(
selected
.
length
===
0
)
{
return
$item
.
data
(
'
select2Config
'
).
placeholder
;
}
else
{
return
Drupal
.
t
(
"
Selected @selected of @total
"
,
{
"
@selected
"
:
selected
.
length
,
"
@total
"
:
total
});
}
}
});
// placeholder: this.attr('placeholder'),
});
$
(
"
.select2-single
"
).
select2MultiCheckboxes
({
templateSelection
:
function
(
selected
,
total
,
context
)
{
if
(
typeof
(
selected
)
==
"
object
"
)
{
return
Drupal
.
t
(
"
Selected @selected of @total
"
,
{
"
@selected
"
:
selected
.
length
,
"
@total
"
:
total
-
1
});
}
else
{
return
Drupal
.
t
(
"
Selected @selected of @total
"
,
{
"
@selected
"
:
1
,
"
@total
"
:
total
-
1
});
$
(
"
.select2-single
"
).
each
(
function
()
{
let
$item
=
$
(
this
);
$item
.
select2MultiCheckboxes
({
templateSelection
:
function
(
selected
,
total
,
context
)
{
if
(
typeof
(
selected
)
==
"
object
"
)
{
if
(
selected
.
length
===
0
)
{
return
$item
.
data
(
'
select2Config
'
).
placeholder
;
}
else
{
return
Drupal
.
t
(
"
Selected @selected of @total
"
,
{
"
@selected
"
:
selected
.
length
,
"
@total
"
:
total
-
1
});
}
}
else
{
return
Drupal
.
t
(
"
Selected @selected of @total
"
,
{
"
@selected
"
:
1
,
"
@total
"
:
total
-
1
});
}
}
}
,
}
);
});
// Get the widget width for elements with multiple selections.
$
(
"
.select2-multiple + .select2-container
"
).
each
(
function
(
index
){
Loading