Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
gitlab-ce
Commits
34a1e3dc
Commit
34a1e3dc
authored
Jan 24, 2017
by
Eric Eastwood
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix permalink discussion note being collapsed
parent
04bafeb8
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
49 additions
and
10 deletions
+49
-10
app/assets/javascripts/behaviors/toggler_behavior.js
app/assets/javascripts/behaviors/toggler_behavior.js
+16
-10
changelogs/unreleased/27089-26860-27151-fix-discussion-note-permalink-collapsed.yml
...9-26860-27151-fix-discussion-note-permalink-collapsed.yml
+4
-0
spec/features/merge_requests/toggler_behavior_spec.rb
spec/features/merge_requests/toggler_behavior_spec.rb
+29
-0
No files found.
app/assets/javascripts/behaviors/toggler_behavior.js
View file @
34a1e3dc
/* eslint-disable wrap-iife, func-names, space-before-function-paren, prefer-arrow-callback, vars-on-top, no-var, max-len */
(
function
(
w
)
{
$
(
function
()
{
var
toggleContainer
=
function
(
container
,
/* optional */
toggleState
)
{
var
$container
=
$
(
container
);
$container
.
find
(
'
.js-toggle-button .fa
'
)
.
toggleClass
(
'
fa-chevron-up
'
,
toggleState
)
.
toggleClass
(
'
fa-chevron-down
'
,
toggleState
!==
undefined
?
!
toggleState
:
undefined
);
$container
.
find
(
'
.js-toggle-content
'
)
.
toggle
(
toggleState
);
};
// Toggle button. Show/hide content inside parent container.
// Button does not change visibility. If button has icon - it changes chevron style.
//
...
...
@@ -10,14 +23,7 @@
//
$
(
'
body
'
).
on
(
'
click
'
,
'
.js-toggle-button
'
,
function
(
e
)
{
e
.
preventDefault
();
$
(
this
)
.
find
(
'
.fa
'
)
.
toggleClass
(
'
fa-chevron-down fa-chevron-up
'
)
.
end
()
.
closest
(
'
.js-toggle-container
'
)
.
find
(
'
.js-toggle-content
'
)
.
toggle
()
;
toggleContainer
(
$
(
this
).
closest
(
'
.js-toggle-container
'
));
});
// If we're accessing a permalink, ensure it is not inside a
...
...
@@ -26,8 +32,8 @@
var
anchor
=
hash
&&
document
.
getElementById
(
hash
);
var
container
=
anchor
&&
$
(
anchor
).
closest
(
'
.js-toggle-container
'
);
if
(
container
&&
container
.
find
(
'
.js-toggle-content
'
).
is
(
'
:hidden
'
)
)
{
container
.
find
(
'
.js-toggle-button
'
).
trigger
(
'
click
'
);
if
(
container
)
{
toggleContainer
(
container
,
true
);
anchor
.
scrollIntoView
();
}
});
...
...
changelogs/unreleased/27089-26860-27151-fix-discussion-note-permalink-collapsed.yml
0 → 100644
View file @
34a1e3dc
---
title
:
Fix permalink discussion note being collapsed
merge_request
:
author
:
spec/features/merge_requests/toggler_behavior_spec.rb
0 → 100644
View file @
34a1e3dc
require
'spec_helper'
feature
'toggler_behavior'
,
js:
true
,
feature:
true
do
let
(
:user
)
{
create
(
:user
)
}
let
(
:project
)
{
create
(
:project
)
}
let
(
:merge_request
)
{
create
(
:merge_request
,
source_project:
project
,
author:
user
)
}
let
(
:note
)
{
create
(
:diff_note_on_merge_request
,
noteable:
merge_request
,
project:
project
)
}
let
(
:fragment_id
)
{
"#note_
#{
note
.
id
}
"
}
before
do
login_as
:admin
project
=
merge_request
.
source_project
visit
"
#{
namespace_project_merge_request_path
(
project
.
namespace
,
project
,
merge_request
)
}#{
fragment_id
}
"
page
.
current_window
.
resize_to
(
1000
,
300
)
end
describe
'scroll position'
do
it
'should be scrolled down to fragment'
do
page_height
=
page
.
current_window
.
size
[
1
]
page_scroll_y
=
page
.
evaluate_script
(
"window.scrollY"
)
fragment_position_top
=
page
.
evaluate_script
(
"document.querySelector('
#{
fragment_id
}
').getBoundingClientRect().top"
)
expect
(
find
(
'.js-toggle-content'
).
visible?
).
to
eq
true
expect
(
find
(
fragment_id
).
visible?
).
to
eq
true
expect
(
fragment_position_top
).
to
be
>
page_scroll_y
expect
(
fragment_position_top
).
to
be
<
(
page_scroll_y
+
page_height
)
end
end
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