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
13219440
Commit
13219440
authored
11 years ago
by
David Stutz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Some more modularity and tests.
parent
8d43ff18
Changes
3
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
485 additions
and
301 deletions
+485
-301
index.html
index.html
+100
-107
bootstrap-multiselect.js
js/bootstrap-multiselect.js
+233
-194
tests.html
tests.html
+152
-0
No files found.
index.html
View file @
13219440
This diff is collapsed.
Click to expand it.
js/bootstrap-multiselect.js
View file @
13219440
This diff is collapsed.
Click to expand it.
tests.html
View file @
13219440
...
...
@@ -67,6 +67,32 @@
</td>
<td>
Everything fine.
</td>
</tr>
<tr
id=
"test-build-select-all-tr"
class=
"success"
>
<th>
Test build with select all
</th>
<td>
<select
id=
"test-build-select-all-select"
multiple=
"multiple"
>
<option
value=
"1"
>
1
</option>
<option
value=
"2"
>
2
</option>
<option
value=
"3"
>
3
</option>
<option
value=
"4"
>
4
</option>
<option
value=
"5"
>
5
</option>
</select>
</td>
<td>
Everything fine.
</td>
</tr>
<tr
id=
"test-build-filter-tr"
class=
"success"
>
<th>
Test build with filter
</th>
<td>
<select
id=
"test-build-filter-select"
multiple=
"multiple"
>
<option
value=
"1"
>
1
</option>
<option
value=
"2"
>
2
</option>
<option
value=
"3"
>
3
</option>
<option
value=
"4"
>
4
</option>
<option
value=
"5"
>
5
</option>
</select>
</td>
<td>
Everything fine.
</td>
</tr>
<tr
id=
"test-select-tr"
class=
"success"
>
<th>
Test select
</th>
<td>
...
...
@@ -93,6 +119,40 @@
</td>
<td>
Everything fine.
</td>
</tr>
<tr
id=
"test-max-height-tr"
class=
"success"
>
<th>
Test max height
</th>
<td>
<select
id=
"test-max-height-select"
multiple=
"multiple"
>
<option
value=
"1"
>
1
</option>
<option
value=
"2"
>
2
</option>
<option
value=
"3"
>
3
</option>
<option
value=
"4"
>
4
</option>
<option
value=
"5"
>
5
</option>
<option
value=
"6"
>
6
</option>
<option
value=
"7"
>
7
</option>
<option
value=
"8"
>
8
</option>
<option
value=
"9"
>
9
</option>
<option
value=
"10"
>
10
</option>
<option
value=
"11"
>
11
</option>
<option
value=
"12"
>
12
</option>
<option
value=
"13"
>
13
</option>
</select>
</td>
<td>
Everything fine.
</td>
</tr>
<tr
id=
"test-select-all-tr"
class=
"success"
>
<th>
Test select all
</th>
<td>
<select
id=
"test-select-all-select"
multiple=
"multiple"
>
<option
value=
"1"
>
1
</option>
<option
value=
"2"
>
2
</option>
<option
value=
"3"
>
3
</option>
<option
value=
"4"
>
4
</option>
<option
value=
"5"
>
5
</option>
</select>
</td>
<td>
Everything fine.
</td>
</tr>
</tbody>
</table>
</div>
...
...
@@ -174,6 +234,8 @@
if
(
$
(
secondLabel
).
text
()
!=
$
(
second
).
prop
(
'
label
'
))
{
return
'
Second group labeled incorrectly.
'
;
}
return
false
;
}(
$
(
'
#test-build-optgroups-select
'
),
$
(
'
#test-build-optgroups-tr
'
));
if
(
buildOptgroups
)
{
...
...
@@ -200,6 +262,41 @@
$
(
'
#test-build-selected-tr td
'
).
last
().
html
(
buildSelected
);
}
var
buildSelectAll
=
function
(
select
,
tr
)
{
var
value
=
'
multiselect-select-all
'
;
select
.
multiselect
({
includeSelectAllOption
:
true
,
selectAllValue
:
value
});
if
(
$
(
'
.multiselect-container input[value="
'
+
value
+
'
"]
'
,
tr
).
length
!=
1
)
{
return
'
Expected exactly one input with value
'
+
value
+
'
as select all option.
'
;
}
return
false
;
}(
$
(
'
#test-build-select-all-select
'
),
$
(
'
#test-build-select-all-tr
'
));
if
(
buildSelectAll
)
{
$
(
'
#test-build-select-all-tr
'
).
removeClass
(
'
success
'
).
addClass
(
'
danger
'
);
$
(
'
#test-build-select-all-tr td
'
).
last
().
html
(
buildSelectAll
);
}
var
buildFilter
=
function
(
select
,
tr
)
{
select
.
multiselect
({
enableFiltering
:
true
});
if
(
$
(
'
.multiselect-search
'
,
tr
).
length
!=
1
)
{
return
'
No search input present.
'
;
}
}(
$
(
'
#test-build-filter-select
'
),
$
(
'
#test-build-filter-tr
'
));
if
(
buildFilter
)
{
$
(
'
#test-build-filter-tr
'
).
removeClass
(
'
success
'
).
addClass
(
'
danger
'
);
$
(
'
#test-build-filter-tr td
'
).
last
().
html
(
buildFilter
);
}
// Test select.
var
select
=
function
(
select
,
tr
)
{
select
.
multiselect
();
...
...
@@ -251,6 +348,8 @@
if
(
$
(
second
).
val
()
!=
2
||
$
(
third
).
val
()
!=
3
)
{
return
'
Wrong options selected.
'
;
}
return
false
;
}(
$
(
'
#test-select-select
'
),
$
(
'
#test-select-tr
'
));
if
(
select
)
{
...
...
@@ -294,12 +393,65 @@
if
(
$
(
'
ul.multiselect-container li.active
'
,
tr
).
length
>
0
)
{
return
'
Just deselected two additional options - list items not set unactive.
'
;
}
return
false
;
}(
$
(
'
#test-deselect-select
'
),
$
(
'
#test-deselect-tr
'
));
if
(
deselect
)
{
$
(
'
#test-deselect-tr
'
).
removeClass
(
'
success
'
).
addClass
(
'
danger
'
);
$
(
'
#test-deselect-tr td
'
).
last
().
html
(
deselect
);
}
var
maxHeight
=
function
(
select
,
tr
)
{
select
.
multiselect
({
maxHeight
:
100
,
});
var
height
=
$
(
'
.multiselect-container
'
,
tr
).
css
(
'
max-height
'
);
if
(
height
!=
'
100px
'
)
{
return
'
Max height not set correctly (set:
'
+
height
+
'
).
'
;
}
return
false
;
}(
$
(
'
#test-max-height-select
'
),
$
(
'
#test-max-height-tr
'
));
if
(
maxHeight
)
{
$
(
'
#test-max-height-tr
'
).
removeClass
(
'
success
'
).
addClass
(
'
danger
'
);
$
(
'
#test-max-height-tr td
'
).
last
().
html
(
maxHeight
);
}
var
selectAll
=
function
(
select
,
tr
)
{
var
value
=
'
multiselect-select-all
'
;
select
.
multiselect
({
includeSelectAllOption
:
true
,
selectAllValue
:
value
});
if
(
$
(
'
option:selected
'
,
select
).
length
>
0
)
{
return
'
Test expected 0 selected options as initial state (found
'
+
$
(
'
option:selected
'
,
select
).
length
+
'
).
'
;
}
// Trigger select all.
$
(
'
.multiselect-container input[value="
'
+
value
+
'
"]
'
,
tr
).
click
();
if
(
$
(
'
option:selected
'
,
select
).
length
!=
$
(
'
option
'
,
select
).
length
)
{
return
'
Not all options selected.
'
;
}
$
(
'
.multiselect-container input[value="
'
+
value
+
'
"]
'
,
tr
).
click
();
if
(
$
(
'
option:selected
'
,
select
).
length
>
0
)
{
return
'
There is some option selected (0 expected).
'
;
}
return
false
;
}(
$
(
'
#test-select-all-select
'
),
$
(
'
#test-select-all-tr
'
));
if
(
selectAll
)
{
$
(
'
#test-select-all-tr
'
).
removeClass
(
'
success
'
).
addClass
(
'
danger
'
);
$
(
'
#test-select-all-tr td
'
).
last
().
html
(
selectAll
);
}
});
</script>
</body>
...
...
This diff is collapsed.
Click to expand it.
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