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
Léo-Paul Géneau
gitlab-ce
Commits
a100c578
Commit
a100c578
authored
Oct 10, 2012
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1665 from tsigo/history_js
Fix forward/back while browsing Tree hierarchy
parents
679d0d6d
702133c0
Changes
7
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
28 additions
and
25 deletions
+28
-25
app/assets/javascripts/application.js
app/assets/javascripts/application.js
+1
-0
app/assets/javascripts/tree.js.coffee
app/assets/javascripts/tree.js.coffee
+21
-3
app/controllers/refs_controller.rb
app/controllers/refs_controller.rb
+0
-2
app/controllers/tree_controller.rb
app/controllers/tree_controller.rb
+2
-4
app/views/tree/_tree.html.haml
app/views/tree/_tree.html.haml
+2
-15
app/views/tree/_tree_item.html.haml
app/views/tree/_tree_item.html.haml
+1
-1
vendor/assets/javascripts/jquery.history.js
vendor/assets/javascripts/jquery.history.js
+1
-0
No files found.
app/assets/javascripts/application.js
View file @
a100c578
...
@@ -10,6 +10,7 @@
...
@@ -10,6 +10,7 @@
//= require jquery.cookie
//= require jquery.cookie
//= require jquery.endless-scroll
//= require jquery.endless-scroll
//= require jquery.highlight
//= require jquery.highlight
//= require jquery.history
//= require jquery.waitforimages
//= require jquery.waitforimages
//= require jquery.atwho
//= require jquery.atwho
//= require bootstrap
//= require bootstrap
...
...
app/assets/javascripts/tree.js.coffee
View file @
a100c578
...
@@ -8,9 +8,6 @@ $ ->
...
@@ -8,9 +8,6 @@ $ ->
$
(
'#tree-slider .tree-item-file-name a, .breadcrumb li > a'
).
live
"click"
,
->
$
(
'#tree-slider .tree-item-file-name a, .breadcrumb li > a'
).
live
"click"
,
->
$
(
"#tree-content-holder"
).
hide
(
"slide"
,
{
direction
:
"left"
},
150
)
$
(
"#tree-content-holder"
).
hide
(
"slide"
,
{
direction
:
"left"
},
150
)
$
(
'.project-refs-form'
).
live
"ajax:beforeSend"
:
->
$
(
"#tree-content-holder"
).
hide
(
"slide"
,
{
direction
:
"left"
},
150
)
# Make the entire tree-item row clickable, but not if clicking another link (like a commit message)
# Make the entire tree-item row clickable, but not if clicking another link (like a commit message)
$
(
"#tree-slider .tree-item"
).
live
'click'
,
(
e
)
->
$
(
"#tree-slider .tree-item"
).
live
'click'
,
(
e
)
->
$
(
'.tree-item-file-name a'
,
this
).
trigger
(
'click'
)
if
(
e
.
target
.
nodeName
!=
"A"
)
$
(
'.tree-item-file-name a'
,
this
).
trigger
(
'click'
)
if
(
e
.
target
.
nodeName
!=
"A"
)
...
@@ -19,3 +16,24 @@ $ ->
...
@@ -19,3 +16,24 @@ $ ->
$
(
'#tree-slider .tree-item-file-name a, .breadcrumb a, .project-refs-form'
).
live
$
(
'#tree-slider .tree-item-file-name a, .breadcrumb a, .project-refs-form'
).
live
"ajax:beforeSend"
:
->
$
(
'.tree_progress'
).
addClass
(
"loading"
)
"ajax:beforeSend"
:
->
$
(
'.tree_progress'
).
addClass
(
"loading"
)
"ajax:complete"
:
->
$
(
'.tree_progress'
).
removeClass
(
"loading"
)
"ajax:complete"
:
->
$
(
'.tree_progress'
).
removeClass
(
"loading"
)
# Maintain forward/back history while browsing the file tree
((
window
)
->
History
=
window
.
History
$
=
window
.
jQuery
document
=
window
.
document
# Check to see if History.js is enabled for our Browser
unless
History
.
enabled
return
false
$
->
$
(
'#tree-slider .tree-item-file-name a, .breadcrumb li > a'
).
live
'click'
,
(
e
)
->
History
.
pushState
(
null
,
null
,
$
(
@
).
attr
(
'href'
))
return
false
History
.
Adapter
.
bind
window
,
'statechange'
,
->
state
=
History
.
getState
()
window
.
ajaxGet
(
state
.
url
)
)(
window
)
app/controllers/refs_controller.rb
View file @
a100c578
...
@@ -54,10 +54,8 @@ class RefsController < ProjectResourceController
...
@@ -54,10 +54,8 @@ class RefsController < ProjectResourceController
@hex_path
=
Digest
::
SHA1
.
hexdigest
(
params
[
:path
]
||
""
)
@hex_path
=
Digest
::
SHA1
.
hexdigest
(
params
[
:path
]
||
""
)
if
params
[
:path
]
if
params
[
:path
]
@history_path
=
project_tree_path
(
@project
,
File
.
join
(
@ref
,
params
[
:path
]))
@logs_path
=
logs_file_project_ref_path
(
@project
,
@ref
,
params
[
:path
])
@logs_path
=
logs_file_project_ref_path
(
@project
,
@ref
,
params
[
:path
])
else
else
@history_path
=
project_tree_path
(
@project
,
@ref
)
@logs_path
=
logs_tree_project_ref_path
(
@project
,
@ref
)
@logs_path
=
logs_tree_project_ref_path
(
@project
,
@ref
)
end
end
rescue
rescue
...
...
app/controllers/tree_controller.rb
View file @
a100c578
...
@@ -10,10 +10,8 @@ class TreeController < ProjectResourceController
...
@@ -10,10 +10,8 @@ class TreeController < ProjectResourceController
before_filter
:assign_ref_vars
before_filter
:assign_ref_vars
def
show
def
show
@hex_path
=
Digest
::
SHA1
.
hexdigest
(
@path
)
@hex_path
=
Digest
::
SHA1
.
hexdigest
(
@path
)
@logs_path
=
logs_file_project_ref_path
(
@project
,
@ref
,
@path
)
@history_path
=
project_tree_path
(
@project
,
@id
)
@logs_path
=
logs_file_project_ref_path
(
@project
,
@ref
,
@path
)
respond_to
do
|
format
|
respond_to
do
|
format
|
format
.
html
format
.
html
...
...
app/views/tree/_tree.html.haml
View file @
a100c578
%ul
.breadcrumb
%ul
.breadcrumb
%li
%li
%span
.arrow
%span
.arrow
=
link_to
project_tree_path
(
@project
,
@ref
)
,
remote:
true
do
=
link_to
project_tree_path
(
@project
,
@ref
)
do
=
@project
.
name
=
@project
.
name
-
tree
.
breadcrumbs
(
6
)
do
|
link
|
-
tree
.
breadcrumbs
(
6
)
do
|
link
|
\/
\/
...
@@ -26,7 +26,7 @@
...
@@ -26,7 +26,7 @@
%tr
.tree-item
%tr
.tree-item
%td
.tree-item-file-name
%td
.tree-item-file-name
=
image_tag
"file_empty.png"
,
size:
'16x16'
=
image_tag
"file_empty.png"
,
size:
'16x16'
=
link_to
".."
,
tree
.
up_dir_path
,
remote:
true
=
link_to
".."
,
tree
.
up_dir_path
%td
%td
%td
%td
...
@@ -44,22 +44,9 @@
...
@@ -44,22 +44,9 @@
-
else
-
else
=
raw
GitHub
::
Markup
.
render
(
content
.
name
,
content
.
data
)
=
raw
GitHub
::
Markup
.
render
(
content
.
name
,
content
.
data
)
:javascript
$
(
function
(){
history
.
pushState
({
path
:
this
.
path
},
''
,
"
#{
@history_path
}
"
);
});
-
unless
tree
.
is_blob?
-
unless
tree
.
is_blob?
:javascript
:javascript
// Load last commit log for each file in tree
// Load last commit log for each file in tree
$
(
window
).
load
(
function
(){
$
(
window
).
load
(
function
(){
ajaxGet
(
'
#{
@logs_path
}
'
);
ajaxGet
(
'
#{
@logs_path
}
'
);
});
});
-
if
@path
.
present?
&&
request
.
xhr?
:javascript
$
(
window
).
unbind
(
'
popstate
'
);
$
(
window
).
bind
(
'
popstate
'
,
function
()
{
if
(
location
.
pathname
.
search
(
"
tree
"
)
!=
-
1
)
{
$
.
ajax
({
type
:
"
GET
"
,
url
:
location
.
pathname
,
dataType
:
"
script
"
})}
else
{
location
.
href
=
location
.
pathname
;}});
app/views/tree/_tree_item.html.haml
View file @
a100c578
%tr
{
class:
"tree-item #{tree_hex_class(tree_item)}"
}
%tr
{
class:
"tree-item #{tree_hex_class(tree_item)}"
}
%td
.tree-item-file-name
%td
.tree-item-file-name
=
tree_icon
(
type
)
=
tree_icon
(
type
)
%strong
=
link_to
truncate
(
tree_item
.
name
,
length:
40
),
project_tree_path
(
@project
,
tree_join
(
@id
||
@commit
.
id
,
tree_item
.
name
))
,
remote:
true
%strong
=
link_to
truncate
(
tree_item
.
name
,
length:
40
),
project_tree_path
(
@project
,
tree_join
(
@id
||
@commit
.
id
,
tree_item
.
name
))
%td
.tree_time_ago.cgray
%td
.tree_time_ago.cgray
%span
.log_loading.hide
%span
.log_loading.hide
Loading commit data...
Loading commit data...
...
...
vendor/assets/javascripts/jquery.history.js
0 → 100644
View file @
a100c578
This diff is collapsed.
Click to expand it.
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