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
Tatuya Kamada
gitlab-ce
Commits
f50cb7fc
Commit
f50cb7fc
authored
Jun 26, 2013
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add keyboard nav for tree view. Refactor tree-view coffee
parent
1dd80d22
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
75 additions
and
25 deletions
+75
-25
app/assets/javascripts/blob.js.coffee
app/assets/javascripts/blob.js.coffee
+24
-0
app/assets/javascripts/dispatcher.js.coffee
app/assets/javascripts/dispatcher.js.coffee
+4
-0
app/assets/javascripts/tree.js.coffee
app/assets/javascripts/tree.js.coffee
+39
-25
app/assets/stylesheets/sections/tree.scss
app/assets/stylesheets/sections/tree.scss
+8
-0
No files found.
app/assets/javascripts/blob.js.coffee
0 → 100644
View file @
f50cb7fc
class
BlobView
constructor
:
->
# See if there are lines selected
# "#L12" and "#L34-56" supported
highlightBlobLines
=
->
if
window
.
location
.
hash
isnt
""
matches
=
window
.
location
.
hash
.
match
(
/\#L(\d+)(\-(\d+))?/
)
first_line
=
parseInt
(
matches
?
[
1
])
last_line
=
parseInt
(
matches
?
[
3
])
unless
isNaN
first_line
last_line
=
first_line
if
isNaN
(
last_line
)
$
(
"#tree-content-holder .highlight .line"
).
removeClass
(
"hll"
)
$
(
"#LC
#{
line
}
"
).
addClass
(
"hll"
)
for
line
in
[
first_line
..
last_line
]
$
(
"#L
#{
first_line
}
"
).
ScrollTo
()
# Highlight the correct lines on load
highlightBlobLines
()
# Highlight the correct lines when the hash part of the URL changes
$
(
window
).
on
'hashchange'
,
highlightBlobLines
@
BlobView
=
BlobView
app/assets/javascripts/dispatcher.js.coffee
View file @
f50cb7fc
...
@@ -32,6 +32,10 @@ class Dispatcher
...
@@ -32,6 +32,10 @@ class Dispatcher
new
TeamMembers
()
new
TeamMembers
()
when
'groups:people'
when
'groups:people'
new
GroupMembers
()
new
GroupMembers
()
when
'projects:tree:show'
new
TreeView
()
when
'projects:blob:show'
new
BlobView
()
switch
path
.
first
()
switch
path
.
first
()
when
'admin'
then
new
Admin
()
when
'admin'
then
new
Admin
()
...
...
app/assets/javascripts/tree.js.coffee
View file @
f50cb7fc
# Code browser tree slider
class
TreeView
# Make the entire tree-item row clickable, but not if clicking another link (like a commit message)
constructor
:
->
$
(
".tree-content-holder .tree-item"
).
live
'click'
,
(
e
)
->
@
initKeyNav
()
if
(
e
.
target
.
nodeName
!=
"A"
)
path
=
$
(
'.tree-item-file-name a'
,
this
).
attr
(
'href'
)
Turbolinks
.
visit
(
path
)
$
->
# Code browser tree slider
# Show the "Loading commit data" for only the first element
# Make the entire tree-item row clickable, but not if clicking another link (like a commit message)
$
(
'span.log_loading:first'
).
removeClass
(
'hide'
)
$
(
".tree-content-holder .tree-item"
).
on
'click'
,
(
e
)
->
if
(
e
.
target
.
nodeName
!=
"A"
)
path
=
$
(
'.tree-item-file-name a'
,
this
).
attr
(
'href'
)
Turbolinks
.
visit
(
path
)
# See if there are lines selected
# Show the "Loading commit data" for only the first element
# "#L12" and "#L34-56" supported
$
(
'span.log_loading:first'
).
removeClass
(
'hide'
)
highlightBlobLines
=
->
if
window
.
location
.
hash
isnt
""
matches
=
window
.
location
.
hash
.
match
(
/\#L(\d+)(\-(\d+))?/
)
first_line
=
parseInt
(
matches
?
[
1
])
last_line
=
parseInt
(
matches
?
[
3
])
unless
isNaN
first_line
initKeyNav
:
->
last_line
=
first_line
if
isNaN
(
last_line
)
li
=
$
(
"tr.tree-item"
)
$
(
"#tree-content-holder .highlight .line"
).
removeClass
(
"hll"
)
liSelected
=
null
$
(
"#LC
#{
line
}
"
).
addClass
(
"hll"
)
for
line
in
[
first_line
..
last_line
]
$
(
'body'
).
keydown
(
e
)
->
$
(
"#L
#{
first_line
}
"
).
ScrollTo
()
if
e
.
which
is
40
if
liSelected
next
=
liSelected
.
next
()
if
next
.
length
>
0
liSelected
.
removeClass
"selected"
liSelected
=
next
.
addClass
(
"selected"
)
else
liSelected
=
li
.
eq
(
0
).
addClass
(
"selected"
)
# Highlight the correct lines on load
$
(
liSelected
).
focus
()
highlightBlobLines
()
else
if
e
.
which
is
38
# Highlight the correct lines when the hash part of the URL changes
if
liSelected
$
(
window
).
on
'hashchange'
,
highlightBlobLines
next
=
liSelected
.
prev
()
if
next
.
length
>
0
liSelected
.
removeClass
"selected"
liSelected
=
next
.
addClass
(
"selected"
)
else
liSelected
=
li
.
last
().
addClass
(
"selected"
)
$
(
liSelected
).
focus
()
else
if
e
.
which
is
13
path
=
$
(
'.tree-item.selected .tree-item-file-name a'
).
attr
(
'href'
)
Turbolinks
.
visit
(
path
)
@
TreeView
=
TreeView
app/assets/stylesheets/sections/tree.scss
View file @
f50cb7fc
...
@@ -23,6 +23,14 @@
...
@@ -23,6 +23,14 @@
}
}
cursor
:
pointer
;
cursor
:
pointer
;
}
}
&
.selected
{
td
{
background
:
$hover
;
border-top
:
1px
solid
#ADF
;
border-bottom
:
1px
solid
#ADF
;
}
}
}
}
}
}
...
...
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