Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
Milan
diaspora
Commits
6e25189a
Unverified
Commit
6e25189a
authored
Aug 21, 2016
by
Dennis Schubert
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #7012 from svbergerem/fix-stream-shortcuts-small-screens
Fix stream shortcuts on small screens
parents
003672f0
002a7ff9
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
31 additions
and
18 deletions
+31
-18
app/assets/javascripts/app/views/stream/shortcuts.js
app/assets/javascripts/app/views/stream/shortcuts.js
+14
-14
features/desktop/keyboard_navigation.feature
features/desktop/keyboard_navigation.feature
+15
-0
features/step_definitions/custom_web_steps.rb
features/step_definitions/custom_web_steps.rb
+1
-3
features/step_definitions/keyboard_navigation_steps.rb
features/step_definitions/keyboard_navigation_steps.rb
+1
-1
No files found.
app/assets/javascripts/app/views/stream/shortcuts.js
View file @
6e25189a
// @license magnet:?xt=urn:btih:0b31508aeb0634b347b8270c7bee4d411b5d4109&dn=agpl-3.0.txt AGPL-v3-or-Later
app
.
views
.
StreamShortcuts
=
Backbone
.
View
.
extend
({
_headerSize
:
5
0
,
_headerSize
:
6
0
,
events
:
{
"
keydown
"
:
"
_onHotkeyDown
"
,
...
...
@@ -57,35 +57,35 @@ app.views.StreamShortcuts = Backbone.View.extend({
gotoNext
:
function
()
{
// select next post: take the first post under the header
var
stream
_e
lements
=
this
.
$
(
'
div.stream_element.loaded
'
);
var
stream
E
lements
=
this
.
$
(
"
div.stream_element.loaded
"
);
var
posUser
=
window
.
pageYOffset
;
for
(
var
i
=
0
;
i
<
stream
_e
lements
.
length
;
i
++
)
{
if
(
stream
_e
lements
[
i
].
offset
Top
>
posUser
+
this
.
_headerSize
){
this
.
selectPost
(
stream
_e
lements
[
i
]);
for
(
var
i
=
0
;
i
<
stream
E
lements
.
length
;
i
++
)
{
if
(
Math
.
round
(
$
(
stream
E
lements
[
i
]
)
.
offset
().
top
)
>
posUser
+
this
.
_headerSize
)
{
this
.
selectPost
(
stream
E
lements
[
i
]);
return
;
}
}
// standard: last post
if
(
stream
_e
lements
[
stream
_e
lements
.
length
-
1
]){
this
.
selectPost
(
stream
_e
lements
[
stream
_e
lements
.
length
-
1
]);
if
(
stream
E
lements
[
stream
E
lements
.
length
-
1
])
{
this
.
selectPost
(
stream
E
lements
[
stream
E
lements
.
length
-
1
]);
}
},
gotoPrev
:
function
()
{
// select previous post: take the first post above the header
var
stream
_e
lements
=
this
.
$
(
'
div.stream_element.loaded
'
);
var
stream
E
lements
=
this
.
$
(
"
div.stream_element.loaded
"
);
var
posUser
=
window
.
pageYOffset
;
for
(
var
i
=
stream
_e
lements
.
length
-
1
;
i
>=
0
;
i
--
)
{
if
(
stream
_e
lements
[
i
].
offset
Top
<
posUser
+
this
.
_headerSize
){
this
.
selectPost
(
stream
_e
lements
[
i
]);
for
(
var
i
=
stream
E
lements
.
length
-
1
;
i
>=
0
;
i
--
)
{
if
(
Math
.
round
(
$
(
stream
E
lements
[
i
]
)
.
offset
().
top
)
<
posUser
+
this
.
_headerSize
)
{
this
.
selectPost
(
stream
E
lements
[
i
]);
return
;
}
}
// standard: first post
if
(
stream
_e
lements
[
0
]){
this
.
selectPost
(
stream
_e
lements
[
0
]);
if
(
stream
E
lements
[
0
])
{
this
.
selectPost
(
stream
E
lements
[
0
]);
}
},
...
...
@@ -118,7 +118,7 @@ app.views.StreamShortcuts = Backbone.View.extend({
var
selected
=
this
.
$
(
'
div.stream_element.loaded.shortcut_selected
'
);
selected
.
removeClass
(
'
shortcut_selected
'
).
removeClass
(
'
highlighted
'
);
//move to new post
window
.
scrollTo
(
window
.
pageXOffset
,
element
.
offset
Top
-
this
.
_headerSize
);
window
.
scrollTo
(
window
.
pageXOffset
,
Math
.
round
(
$
(
element
)
.
offset
().
top
-
this
.
_headerSize
)
)
;
//add the selection and selected-class to new post
element
.
className
+=
"
shortcut_selected highlighted
"
;
},
...
...
features/desktop/keyboard_navigation.feature
View file @
6e25189a
...
...
@@ -60,3 +60,18 @@ Feature: Keyboard navigation
When
I press the
"J"
key somewhere
Then
post 2 should be highlighted
And
I should have navigated to the highlighted post
Scenario
:
navigate downwards on a small screen
When
I resize my window to 800x600
And
I press the
"J"
key somewhere
Then
post 1 should be highlighted
And
I should have navigated to the highlighted post
When
I press the
"J"
key somewhere
Then
post 2 should be highlighted
And
I should have navigated to the highlighted post
Given
I expand the publisher
When
I press the
"J"
key in the publisher
Then
post 2 should be highlighted
And
I close the publisher
features/step_definitions/custom_web_steps.rb
View file @
6e25189a
...
...
@@ -241,9 +241,7 @@ And "I wait for notifications to load" do
end
When
/^I resize my window to 800x600$/
do
page
.
execute_script
<<-
JS
window.resizeTo(800,600);
JS
page
.
driver
.
resize
(
800
,
600
)
end
Then
'I should see an image attached to the post'
do
...
...
features/step_definitions/keyboard_navigation_steps.rb
View file @
6e25189a
...
...
@@ -13,5 +13,5 @@ Then /^post (\d+) should be highlighted$/ do |position|
end
And
/^I should have navigated to the highlighted post$/
do
find
(
".shortcut_selected"
)[
"offsetTop"
].
to_i
.
should
==
page
.
evaluate_script
(
"window.pageYOffset + 50"
).
to_i
expect
(
page
.
evaluate_script
(
"window.pageYOffset + 60 - $('.shortcut_selected').offset().top"
).
to_i
).
to
be
(
0
)
end
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