Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
H
hypha
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ots
hypha
Commits
3ffff58a
Commit
3ffff58a
authored
6 years ago
by
Chris Lawton
Browse files
Options
Downloads
Patches
Plain Diff
move filters logic into submission filter js file
parent
3614645f
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
opentech/static_src/src/javascript/apply/submission-filters.js
+52
-0
52 additions, 0 deletions
...ech/static_src/src/javascript/apply/submission-filters.js
opentech/static_src/src/javascript/main.js
+1
-47
1 addition, 47 deletions
opentech/static_src/src/javascript/main.js
with
53 additions
and
47 deletions
opentech/static_src/src/javascript/apply/submission-filters.js
+
52
−
0
View file @
3ffff58a
...
...
@@ -2,6 +2,7 @@
'
use strict
'
;
// Variables
const
$body
=
$
(
'
body
'
);
const
$toggleButton
=
$
(
'
.js-toggle-filters
'
);
const
$closeButton
=
$
(
'
.js-close-filters
'
);
...
...
@@ -73,6 +74,41 @@
}
}
// corrects spacing of dropdowns when toggled on mobile
function
mobileFilterPadding
(
element
)
{
const
expanded
=
'
expanded-filter-element
'
;
const
dropdown
=
$
(
element
).
closest
(
'
.select2
'
);
const
openDropdown
=
$
(
'
.select2 .
'
+
expanded
);
let
dropdownMargin
=
0
;
if
(
openDropdown
.
length
>
0
&&
!
openDropdown
.
hasClass
(
'
select2-container--open
'
))
{
// reset the margin of the select we previously worked
openDropdown
.
removeClass
(
expanded
);
// store the offset to adjust the new select box (elements above the old dropdown unaffected)
if
(
dropdown
.
position
().
top
>
openDropdown
.
position
().
top
)
{
dropdownMargin
=
parseInt
(
openDropdown
.
css
(
'
marginBottom
'
));
}
openDropdown
.
css
(
'
margin-bottom
'
,
'
0px
'
);
}
if
(
dropdown
.
hasClass
(
'
select2-container--open
'
))
{
dropdown
.
addClass
(
expanded
);
const
dropdownID
=
$
(
element
).
closest
(
'
.select2-selection
'
).
attr
(
'
aria-owns
'
);
// Element which has the height of the select dropdown
const
match
=
$
(
`ul#
${
dropdownID
}
`
);
const
dropdownHeight
=
match
.
outerHeight
(
true
);
// Element which has the position of the dropdown
const
positionalMatch
=
match
.
closest
(
'
.select2-container
'
);
// Pad the bottom of the select box
dropdown
.
css
(
'
margin-bottom
'
,
`
${
dropdownHeight
}
px`
);
// bump up the dropdown options by height of closed elements
positionalMatch
.
css
(
'
top
'
,
positionalMatch
.
position
().
top
-
dropdownMargin
);
}
}
// clear all filters
$clearButton
.
on
(
'
click
'
,
()
=>
{
const
dropdowns
=
document
.
querySelectorAll
(
'
.form__filters select
'
);
...
...
@@ -91,5 +127,21 @@
});
});
// reset mobile filters if they're open past the tablet breakpoint
$
(
window
).
resize
(
function
resize
()
{
if
(
$
(
window
).
width
()
<
1024
)
{
// close the filters if open when reducing the window size
$
(
'
body
'
).
removeClass
(
'
filters-open
'
);
// update filter button text
$
(
'
.js-toggle-filters
'
).
text
(
'
Filters
'
);
// Correct spacing of dropdowns when toggled
$
(
'
.select2
'
).
on
(
'
click
'
,
(
e
)
=>
{
mobileFilterPadding
(
e
.
target
);
});
}
}).
trigger
(
'
resize
'
);
})(
jQuery
);
This diff is collapsed.
Click to expand it.
opentech/static_src/src/javascript/main.js
+
1
−
47
View file @
3ffff58a
...
...
@@ -128,59 +128,13 @@
// reset mobile filters if they're open past the tablet breakpoint
$
(
window
).
resize
(
function
resize
()
{
if
(
$
(
window
).
width
()
<
1024
)
{
// close the filters if open when reducing the window size
$
(
'
body
'
).
removeClass
(
'
filters-open
'
);
// update filter button text
$
(
'
.js-toggle-filters
'
).
text
(
'
Filters
'
);
$
(
'
.select2
'
).
on
(
'
click
'
,
(
e
)
=>
{
mobileFilterPadding
(
e
.
target
);
});
}
else
{
if
(
$
(
window
).
width
()
>
1024
)
{
$
(
'
.js-actions-toggle
'
).
removeClass
(
'
is-active
'
);
$
(
'
.js-actions-sidebar
'
).
removeClass
(
'
is-visible
'
);
$
(
'
.tr--parent.is-expanded
'
).
removeClass
(
'
is-expanded
'
);
}
}).
trigger
(
'
resize
'
);
function
mobileFilterPadding
(
element
)
{
const
expanded
=
'
expanded-filter-element
'
;
const
dropdown
=
$
(
element
).
closest
(
'
.select2
'
);
const
openDropdown
=
$
(
'
.select2 .
'
+
expanded
);
let
dropdownMargin
=
0
;
if
(
openDropdown
.
length
>
0
&&
!
openDropdown
.
hasClass
(
'
select2-container--open
'
))
{
// reset the margin of the select we previously worked
openDropdown
.
removeClass
(
expanded
);
// store the offset to adjust the new select box (elements above the old dropdown unaffected)
if
(
dropdown
.
position
().
top
>
openDropdown
.
position
().
top
)
{
dropdownMargin
=
parseInt
(
openDropdown
.
css
(
'
marginBottom
'
));
}
openDropdown
.
css
(
'
margin-bottom
'
,
'
0px
'
);
}
if
(
dropdown
.
hasClass
(
'
select2-container--open
'
))
{
dropdown
.
addClass
(
expanded
);
const
dropdownID
=
$
(
element
).
closest
(
'
.select2-selection
'
).
attr
(
'
aria-owns
'
);
// Element which has the height of the select dropdown
const
match
=
$
(
`ul#
${
dropdownID
}
`
);
const
dropdownHeight
=
match
.
outerHeight
(
true
);
// Element which has the position of the dropdown
const
positionalMatch
=
match
.
closest
(
'
.select2-container
'
);
// Pad the bottom of the select box
dropdown
.
css
(
'
margin-bottom
'
,
`
${
dropdownHeight
}
px`
);
// bump up the dropdown options by height of closed elements
positionalMatch
.
css
(
'
top
'
,
positionalMatch
.
position
().
top
-
dropdownMargin
);
}
}
$
(
'
form
'
).
filter
(
'
.form__comments
'
).
submit
(
function
(
e
)
{
var
$form
=
$
(
this
);
var
formValues
=
$form
.
serialize
();
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment