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
1d17e957
Commit
1d17e957
authored
May 09, 2016
by
David Stutz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Started tests for filter.
parent
06549a01
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
359 additions
and
272 deletions
+359
-272
bootstrap-multiselect.js
dist/js/bootstrap-multiselect.js
+15
-4
bootstrap-multiselect.js
tests/spec/bootstrap-multiselect.js
+344
-268
No files found.
dist/js/bootstrap-multiselect.js
View file @
1d17e957
...
...
@@ -199,6 +199,7 @@
this
.
options
.
onDropdownShown
=
$
.
proxy
(
this
.
options
.
onDropdownShown
,
this
);
this
.
options
.
onDropdownHidden
=
$
.
proxy
(
this
.
options
.
onDropdownHidden
,
this
);
this
.
options
.
onInitialized
=
$
.
proxy
(
this
.
options
.
onInitialized
,
this
);
this
.
options
.
onFiltering
=
$
.
proxy
(
this
.
options
.
onFiltering
,
this
);
// Build select all if enabled.
this
.
buildContainer
();
...
...
@@ -377,6 +378,14 @@
*/
onInitialized
:
function
(
$select
,
$container
)
{
},
/**
* Triggered on filtering.
*
* @param {jQuery} $filter
*/
onFiltering
:
function
(
$filter
)
{
},
enableHTML
:
false
,
buttonClass
:
'
btn btn-default
'
,
...
...
@@ -796,7 +805,7 @@
var
visible
=
true
;
$inputs
.
each
(
function
()
{
visible
=
visible
&&
!
$
(
this
).
hasClass
(
'
multiselect-collapsible-hidden
'
);
visible
=
visible
&&
$
(
this
).
is
(
'
:visible
'
);
});
if
(
visible
)
{
...
...
@@ -1102,6 +1111,9 @@
if
(
this
.
options
.
enableClickableOptGroups
&&
this
.
options
.
multiple
)
{
this
.
updateOptGroups
();
}
this
.
options
.
onFiltering
(
event
.
target
);
},
this
),
300
,
this
);
},
this
));
}
...
...
@@ -1371,9 +1383,8 @@
if
(
this
.
options
.
enableClickableOptGroups
&&
this
.
options
.
multiple
)
{
this
.
updateOptGroups
();
}
console
.
log
(
'
test
'
)
if
(
triggerOnDeselectAll
)
{
console
.
log
(
'
test2
'
)
this
.
options
.
onDeselectAll
();
}
},
...
...
tests/spec/bootstrap-multiselect.js
View file @
1d17e957
...
...
@@ -1022,6 +1022,82 @@ describe('Bootstrap Multiselect "Select All".', function() {
});
});
describe
(
'
Bootstrap Multiselect "Filter".
'
,
function
()
{
function
beforeCreate
()
{
// Reset
$
(
'
#multiselect
'
).
multiselect
(
'
destroy
'
);
$
(
'
#multiselect
'
).
remove
();
var
$select
=
$
(
'
<select id="multiselect" multiple="multiple"></select>
'
);
for
(
var
i
=
1
;
i
<
100
;
i
++
)
{
$select
.
append
(
'
<option value="
'
+
i
+
'
">1</option>
'
);
}
$
(
'
body
'
).
append
(
$select
);
$select
.
multiselect
({
buttonContainer
:
'
<div id="multiselect-container"></div>
'
,
enableFiltering
:
true
});
}
function
beforeFilterElements
()
{
// Reset
$
(
'
#multiselect
'
).
multiselect
(
'
destroy
'
);
$
(
'
#multiselect
'
).
remove
();
var
$select
=
$
(
'
<select id="multiselect" multiple="multiple"></select>
'
);
for
(
var
i
=
1
;
i
<
100
;
i
++
)
{
$select
.
append
(
'
<option value="
'
+
i
+
'
">1</option>
'
);
}
$
(
'
body
'
).
append
(
$select
);
$select
.
multiselect
({
buttonContainer
:
'
<div id="multiselect-container"></div>
'
,
enableFiltering
:
true
,
onFiltering
:
function
(
$filter
)
{
var
val
=
$
(
$filter
).
val
();
$
(
'
#multiselect-container li input[value!="
'
+
val
+
'
"]
'
).
closest
(
'
li
'
).
each
(
function
()
{
expect
(
$
(
this
).
is
(
'
:visible
'
)).
toBe
(
false
);
expect
(
$
(
this
).
hasClass
(
'
multiselect-filter-hidden
'
)).
toBe
(
true
);
});
$
(
'
#multiselect-container li input[value="
'
+
val
+
'
"]
'
).
closest
(
'
li
'
).
each
(
function
()
{
expect
(
$
(
this
).
is
(
'
:visible
'
)).
toBe
(
true
);
expect
(
$
(
this
).
hasClass
(
'
multiselect-filter-hidden
'
)).
toBe
(
false
);
});
done
();
}
});
}
it
(
'
Should create filter.
'
,
function
()
{
beforeCreate
();
expect
(
$
(
'
#multiselect-container li.multiselect-filter
'
).
length
).
toBe
(
1
);
expect
(
$
(
'
#multiselect-container li.multiselect-filter input
'
).
length
).
toBe
(
1
);
});
it
(
'
Should filter elements.
'
,
function
()
{
beforeFilterElements
();
$
(
'
#multiselect-container li.multiselect-filter input
'
).
val
(
'
11
'
).
trigger
(
'
keydown
'
);
// Expectations are in onFiltering.
expect
(
true
).
toBe
(
true
);
});
afterEach
(
function
()
{
$
(
'
#multiselect
'
).
multiselect
(
'
destroy
'
);
$
(
'
#multiselect
'
).
remove
();
});
});
describe
(
'
Bootstrap Multiselect Specific Issues.
'
,
function
()
{
it
(
'
#393
'
,
function
()
{
...
...
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