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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
99193d82
Commit
99193d82
authored
Jul 19, 2017
by
Luke "Jared" Bennett
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added scroll_helper tests
parent
929c66d6
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
42 additions
and
23 deletions
+42
-23
app/assets/javascripts/dispatcher.js
app/assets/javascripts/dispatcher.js
+2
-2
app/assets/javascripts/helpers/scroll_helper.js
app/assets/javascripts/helpers/scroll_helper.js
+22
-21
spec/javascripts/helpers/scroll_helper_spec.js
spec/javascripts/helpers/scroll_helper_spec.js
+18
-0
No files found.
app/assets/javascripts/dispatcher.js
View file @
99193d82
...
...
@@ -54,7 +54,7 @@ import RefSelectDropdown from './ref_select_dropdown';
import
GfmAutoComplete
from
'
./gfm_auto_complete
'
;
import
ShortcutsBlob
from
'
./shortcuts_blob
'
;
import
initSettingsPanels
from
'
./settings_panels
'
;
import
{
setScrollWidth
}
from
'
./helpers/scroll_helper
'
;
import
ScrollHelper
from
'
./helpers/scroll_helper
'
;
(
function
()
{
var
Dispatcher
;
...
...
@@ -77,7 +77,7 @@ import { setScrollWidth } from './helpers/scroll_helper';
return
false
;
}
setScrollWidth
();
ScrollHelper
.
setScrollWidth
();
path
=
page
.
split
(
'
:
'
);
shortcut_handler
=
null
;
...
...
app/assets/javascripts/helpers/scroll_helper.js
View file @
99193d82
function
getScrollWidth
()
{
const
$rulerContainer
=
$
(
'
<div>
'
).
css
({
visibility
:
'
hidden
'
,
width
:
100
,
overflow
:
'
scroll
'
,
});
import
$
from
'
jquery
'
;
const
$ruler
=
$
(
'
<div>
'
).
css
({
width
:
'
100%
'
,
});
const
ScrollHelper
=
{
getScrollWidth
()
{
const
$rulerContainer
=
$
(
'
<div>
'
).
css
({
visibility
:
'
hidden
'
,
width
:
100
,
overflow
:
'
scroll
'
,
});
$ruler
.
appendTo
(
$rulerContainer
);
$rulerContainer
.
appendTo
(
'
body
'
);
const
$ruler
=
$
(
'
<div>
'
).
css
({
width
:
'
100%
'
,
});
const
scrollWidth
=
$ruler
.
outerWidth
();
$ruler
.
appendTo
(
$rulerContainer
);
$rulerContainer
.
appendTo
(
'
body
'
);
$rulerContainer
.
remove
();
const
scrollWidth
=
$ruler
.
outerWidth
();
return
100
-
scrollWidth
;
}
$rulerContainer
.
remove
();
function
setScrollWidth
()
{
$
(
'
body
'
).
attr
(
'
data-scroll-width
'
,
getScrollWidth
());
}
return
100
-
scrollWidth
;
},
export
{
getScrollWidth
,
setScrollWidth
,
setScrollWidth
()
{
$
(
'
body
'
).
attr
(
'
data-scroll-width
'
,
ScrollHelper
.
getScrollWidth
());
}
,
};
export
default
ScrollHelper
;
spec/javascripts/helpers/scroll_helper_spec.js
0 → 100644
View file @
99193d82
import
$
from
'
jquery
'
;
import
ScrollHelper
from
'
~/helpers/scroll_helper
'
;
describe
(
'
ScrollHelper
'
,
()
=>
{
describe
(
'
setScrollWidth
'
,
()
=>
{
it
(
'
calls getScrollWidth and sets data-scroll-width
'
,
()
=>
{
const
width
=
10
;
spyOn
(
$
.
fn
,
'
attr
'
);
spyOn
(
ScrollHelper
,
'
getScrollWidth
'
).
and
.
returnValue
(
width
);
ScrollHelper
.
setScrollWidth
();
expect
(
ScrollHelper
.
getScrollWidth
).
toHaveBeenCalled
();
expect
(
$
.
fn
.
attr
).
toHaveBeenCalledWith
(
'
data-scroll-width
'
,
width
);
});
});
});
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