Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
T
third-party
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
2
Merge Requests
2
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
cooperatic-foodcoops
third-party
Commits
56ef5527
Commit
56ef5527
authored
Nov 18, 2021
by
Damien Moulard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
on changing input with arrow keys, auto scroll to keep target in view
parent
115f8a60
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
1 deletions
+35
-1
oders_helper_style.css
orders/static/css/oders_helper_style.css
+7
-0
orders_helper.js
orders/static/js/orders_helper.js
+28
-1
No files found.
orders/static/css/oders_helper_style.css
View file @
56ef5527
...
...
@@ -382,4 +382,10 @@
background-color
:
#e7e9ed
;
width
:
100%
;
padding
:
15px
;
}
/* - Miscellaneous */
footer
{
display
:
none
;
}
\ No newline at end of file
orders/static/js/orders_helper.js
View file @
56ef5527
...
...
@@ -1606,10 +1606,37 @@ function display_products(params) {
$
(
this
).
focus
();
})
.
on
(
'keypress'
,
'tbody td .product_qty_input'
,
function
(
e
)
{
if
(
e
.
which
==
13
)
{
// Validate on Enter pressed
if
(
e
.
which
==
13
)
{
$
(
this
).
blur
();
}
})
.
on
(
'keydown'
,
'tbody td .product_qty_input'
,
function
(
e
)
{
if
(
e
.
which
==
38
)
{
e
.
preventDefault
();
// On arrow up pressed, focus next row input
let
next_input
=
$
(
this
).
closest
(
"tr"
).
prev
().
find
(
".product_qty_input"
);
next_input
.
focus
();
// Scroll to a position where the target input is not hidden by the sticky suppliers container
const
suppliers_container_top_offset
=
$
(
"#suppliers_container"
).
offset
().
top
-
$
(
window
).
scrollTop
()
+
$
(
"#suppliers_container"
).
outerHeight
();
const
next_input_top_offset
=
next_input
.
offset
().
top
-
$
(
window
).
scrollTop
();
if
(
next_input_top_offset
<
suppliers_container_top_offset
)
{
window
.
scrollTo
({
top
:
$
(
window
).
scrollTop
()
-
$
(
"#suppliers_container"
).
outerHeight
()
});
}
}
else
if
(
e
.
which
==
40
)
{
e
.
preventDefault
();
// On arrow down pressed, focus previous row input
$
(
this
).
closest
(
"tr"
).
next
().
find
(
".product_qty_input"
).
focus
();
}
});
// Associate product to supplier on click on 'X' in the table
...
...
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