Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
B
bootstrap-multiselect
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
bootstrap-multiselect
Commits
c6ed1dc1
Commit
c6ed1dc1
authored
May 23, 2014
by
David Stutz
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #314 from Tyf0x/select-all_fix
** Removed the mirroring on the "Select All" option. **
parents
7f31ccbc
4f22e998
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
62 additions
and
45 deletions
+62
-45
bootstrap-multiselect.js
js/bootstrap-multiselect.js
+62
-45
No files found.
js/bootstrap-multiselect.js
View file @
c6ed1dc1
...
...
@@ -106,8 +106,8 @@
// Build select all if enabled.
this
.
buildContainer
();
this
.
buildButton
();
this
.
buildSelectAll
();
this
.
buildDropdown
();
this
.
buildSelectAll
();
this
.
buildDropdownOptions
();
this
.
buildFilter
();
...
...
@@ -362,33 +362,35 @@
}
}
if
(
checked
)
{
$option
.
prop
(
'
selected
'
,
true
);
if
(
this
.
options
.
multiple
)
{
// Simply select additional option.
if
(
!
isSelectAllOption
){
if
(
checked
)
{
$option
.
prop
(
'
selected
'
,
true
);
}
else
{
// Unselect all other options and corresponding checkboxes.
if
(
this
.
options
.
selectedClass
)
{
$
(
$checkboxesNotThis
).
parents
(
'
li
'
).
removeClass
(
this
.
options
.
selectedClass
);
if
(
this
.
options
.
multiple
)
{
// Simply select additional option.
$option
.
prop
(
'
selected
'
,
true
);
}
else
{
// Unselect all other options and corresponding checkboxes.
if
(
this
.
options
.
selectedClass
)
{
$
(
$checkboxesNotThis
).
parents
(
'
li
'
).
removeClass
(
this
.
options
.
selectedClass
);
}
$
(
$checkboxesNotThis
).
prop
(
'
checked
'
,
false
);
$optionsNotThis
.
prop
(
'
selected
'
,
false
);
$
(
$checkboxesNotThis
).
prop
(
'
checked
'
,
false
);
$optionsNotThis
.
prop
(
'
selected
'
,
false
);
// It's a single selection, so close.
this
.
$button
.
click
();
}
// It's a single selection, so close.
this
.
$button
.
click
();
}
if
(
this
.
options
.
selectedClass
===
"
active
"
)
{
$optionsNotThis
.
parents
(
"
a
"
).
css
(
"
outline
"
,
""
);
if
(
this
.
options
.
selectedClass
===
"
active
"
)
{
$optionsNotThis
.
parents
(
"
a
"
).
css
(
"
outline
"
,
""
);
}
}
else
{
// Unselect option.
$option
.
prop
(
'
selected
'
,
false
);
}
}
else
{
// Unselect option.
$option
.
prop
(
'
selected
'
,
false
);
}
this
.
$select
.
change
();
...
...
@@ -573,20 +575,35 @@
/**
* Build the selct all.
* Checks if a select all
ah
s already been created.
* Checks if a select all
ha
s already been created.
*/
buildSelectAll
:
function
()
{
var
alreadyHasSelectAll
=
this
.
hasSelectAll
();
if
(
!
alreadyHasSelectAll
&&
this
.
options
.
includeSelectAllOption
&&
this
.
options
.
multiple
&&
$
(
'
option
[data-role!="divider"]
'
,
this
.
$select
).
length
>
this
.
options
.
includeSelectAllIfMoreThan
)
{
&&
$
(
'
option
'
,
this
.
$select
).
length
>
this
.
options
.
includeSelectAllIfMoreThan
)
{
// Check whether to add a divider after the select all.
if
(
this
.
options
.
includeSelectAllDivider
)
{
this
.
$
select
.
prepend
(
'
<option value="" disabled="disabled" data-role="divider">
'
);
this
.
$
ul
.
prepend
(
$
(
this
.
options
.
templates
.
divider
)
);
}
this
.
$select
.
prepend
(
'
<option value="
'
+
this
.
options
.
selectAllValue
+
'
">
'
+
this
.
options
.
selectAllText
+
'
</option>
'
);
var
$li
=
$
(
this
.
options
.
templates
.
li
);
$
(
'
label
'
,
$li
).
addClass
(
"
checkbox
"
);
$
(
'
label
'
,
$li
).
append
(
'
<input type="checkbox" name="
'
+
this
.
options
.
checkboxName
+
'
" />
'
);
var
$checkbox
=
$
(
'
input
'
,
$li
);
$checkbox
.
val
(
this
.
options
.
selectAllValue
);
$li
.
addClass
(
"
multiselect-item multiselect-all
"
);
$checkbox
.
parent
().
parent
()
.
addClass
(
'
multiselect-all
'
);
$
(
'
label
'
,
$li
).
append
(
"
"
+
this
.
options
.
selectAllText
);
this
.
$ul
.
prepend
(
$li
);
$checkbox
.
prop
(
'
checked
'
,
false
);
}
},
...
...
@@ -644,10 +661,10 @@
}
if
(
showElement
)
{
$
(
element
).
show
();
$
(
element
).
show
()
.
removeClass
(
"
filter-hidden
"
)
;
}
else
{
$
(
element
).
hide
();
$
(
element
).
hide
()
.
addClass
(
"
filter-hidden
"
)
;
}
}
},
this
));
...
...
@@ -793,11 +810,11 @@
$
(
"
li:not(.divider):not(.disabled)
"
,
this
.
$ul
).
filter
(
"
:visible
"
).
addClass
(
this
.
options
.
selectedClass
);
if
(
allCheckboxesCount
===
visibleCheckboxesCount
)
{
$
(
"
option:enabled
:not([data-role='divider'])
"
,
this
.
$select
).
prop
(
'
selected
'
,
true
);
$
(
"
option:enabled
"
,
this
.
$select
).
prop
(
'
selected
'
,
true
);
}
else
{
var
values
=
visibleCheckboxes
.
map
(
function
()
{
return
$
(
this
).
val
()
}).
get
();
$
(
"
option:enabled
:not([data-role='divider'])
"
,
this
.
$select
).
filter
(
function
(
index
){
return
$
.
inArray
(
$
(
this
).
val
(),
values
)
!==
-
1
;
}).
prop
(
'
selected
'
,
true
);
$
(
"
option:enabled
"
,
this
.
$select
).
filter
(
function
(
index
){
return
$
.
inArray
(
$
(
this
).
val
(),
values
)
!==
-
1
;
}).
prop
(
'
selected
'
,
true
);
}
},
...
...
@@ -819,13 +836,13 @@
values
=
visibleCheckboxes
.
map
(
function
()
{
return
$
(
this
).
val
()
}).
get
();
$
(
"
option:enabled
:not([data-role='divider'])
"
,
this
.
$select
).
filter
(
function
(
index
){
return
$
.
inArray
(
$
(
this
).
val
(),
values
)
!==
-
1
;
}).
prop
(
'
selected
'
,
false
);
$
(
"
option:enabled
"
,
this
.
$select
).
filter
(
function
(
index
){
return
$
.
inArray
(
$
(
this
).
val
(),
values
)
!==
-
1
;
}).
prop
(
'
selected
'
,
false
);
$
(
"
li:not(.divider):not(.disabled)
"
,
this
.
$ul
).
filter
(
"
:visible
"
).
removeClass
(
this
.
options
.
selectedClass
);
}
else
{
allCheckboxes
.
prop
(
'
checked
'
,
false
);
$
(
"
option:enabled
:not([data-role='divider'])
"
,
this
.
$select
).
prop
(
'
selected
'
,
false
);
$
(
"
option:enabled
"
,
this
.
$select
).
prop
(
'
selected
'
,
false
);
$
(
"
li:not(.divider):not(.disabled)
"
,
this
.
$ul
).
removeClass
(
this
.
options
.
selectedClass
);
}
},
...
...
@@ -837,10 +854,6 @@
rebuild
:
function
()
{
this
.
$ul
.
html
(
''
);
// Remove select all option in select.
$
(
'
option[value="
'
+
this
.
options
.
selectAllValue
+
'
"]
'
,
this
.
$select
).
remove
();
$
(
'
option[data-role="divider"]
'
,
this
.
$select
).
remove
();
// Important to distinguish between radios and checkboxes.
this
.
options
.
multiple
=
this
.
$select
.
attr
(
'
multiple
'
)
===
"
multiple
"
;
...
...
@@ -905,28 +918,32 @@
},
/**
* Checks whether a select all
option
is present.
* Checks whether a select all
checkbox
is present.
*
* @returns {Boolean}
*/
hasSelectAll
:
function
()
{
return
$
(
'
option[value="
'
+
this
.
options
.
selectAllValue
+
'
"]
'
,
this
.
$select
).
length
>
0
;
return
$
(
'
li.
'
+
this
.
options
.
selectAllValue
,
this
.
$ul
).
length
>
0
;
},
/**
* Updates the select all
option
based on the currently displayed and selected checkboxes.
* Updates the select all
checkbox
based on the currently displayed and selected checkboxes.
*/
updateSelectAll
:
function
()
{
if
(
this
.
hasSelectAll
())
{
var
allBoxes
=
$
(
"
li:not(.multiselect-item)
input:enabled
"
,
this
.
$ul
).
filter
(
"
:visible
"
),
var
allBoxes
=
$
(
"
li:not(.multiselect-item)
:not(.filter-hidden) input:enabled
"
,
this
.
$ul
),
allBoxesLength
=
allBoxes
.
length
,
checkedBoxesLength
=
allBoxes
.
filter
(
"
:checked
"
).
length
;
checkedBoxesLength
=
allBoxes
.
filter
(
"
:checked
"
).
length
,
selectAllLi
=
$
(
"
li.
"
+
this
.
options
.
selectAllValue
,
this
.
$ul
),
selectAllInput
=
selectAllLi
.
find
(
"
input
"
);
if
(
checkedBoxesLength
>
0
&&
checkedBoxesLength
===
allBoxesLength
)
{
this
.
select
(
this
.
options
.
selectAllValue
);
selectAllInput
.
prop
(
"
checked
"
,
true
);
selectAllLi
.
addClass
(
this
.
options
.
selectedClass
);
}
else
{
this
.
deselect
(
this
.
options
.
selectAllValue
);
selectAllInput
.
prop
(
"
checked
"
,
false
);
selectAllLi
.
removeClass
(
this
.
options
.
selectedClass
);
}
}
},
...
...
@@ -951,7 +968,7 @@
* @returns {jQUery}
*/
getSelected
:
function
()
{
return
$
(
'
option
:not([value="
'
+
this
.
options
.
selectAllValue
+
'
"])
'
,
this
.
$select
).
filter
(
"
:selected
"
);
return
$
(
'
option
'
,
this
.
$select
).
filter
(
"
:selected
"
);
},
/**
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment