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
cd1d045f
Commit
cd1d045f
authored
Mar 09, 2016
by
Phil Hughes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed issue with timeago not firing
parent
12506abf
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
24 additions
and
7 deletions
+24
-7
app/helpers/application_helper.rb
app/helpers/application_helper.rb
+8
-2
app/views/projects/_last_commit.html.haml
app/views/projects/_last_commit.html.haml
+1
-1
app/views/projects/blame/show.html.haml
app/views/projects/blame/show.html.haml
+1
-1
app/views/projects/commits/_commit.html.haml
app/views/projects/commits/_commit.html.haml
+1
-1
spec/helpers/application_helper_spec.rb
spec/helpers/application_helper_spec.rb
+13
-2
No files found.
app/helpers/application_helper.rb
View file @
cd1d045f
...
@@ -179,13 +179,19 @@ module ApplicationHelper
...
@@ -179,13 +179,19 @@ module ApplicationHelper
# `html_class` argument is provided.
# `html_class` argument is provided.
#
#
# Returns an HTML-safe String
# Returns an HTML-safe String
def
time_ago_with_tooltip
(
time
,
placement:
'top'
,
html_class:
'time_ago'
)
def
time_ago_with_tooltip
(
time
,
placement:
'top'
,
html_class:
'time_ago'
,
skip_js:
false
)
element
=
content_tag
:time
,
time
.
to_s
,
element
=
content_tag
:time
,
time
.
to_s
,
class:
"
#{
html_class
}
js-timeago"
,
class:
"
#{
html_class
}
js-timeago
#{
"js-timeago-pending"
unless
skip_js
}
"
,
datetime:
time
.
to_time
.
getutc
.
iso8601
,
datetime:
time
.
to_time
.
getutc
.
iso8601
,
title:
time
.
in_time_zone
.
to_s
(
:medium
),
title:
time
.
in_time_zone
.
to_s
(
:medium
),
data:
{
toggle:
'tooltip'
,
placement:
placement
,
container:
'body'
}
data:
{
toggle:
'tooltip'
,
placement:
placement
,
container:
'body'
}
unless
skip_js
element
<<
javascript_tag
(
"$('.js-timeago-pending').removeClass('js-timeago-pending').timeago()"
)
end
element
element
end
end
...
...
app/views/projects/_last_commit.html.haml
View file @
cd1d045f
...
@@ -8,5 +8,5 @@
...
@@ -8,5 +8,5 @@
=
link_to
commit
.
short_id
,
namespace_project_commit_path
(
project
.
namespace
,
project
,
commit
),
class:
"commit_short_id"
=
link_to
commit
.
short_id
,
namespace_project_commit_path
(
project
.
namespace
,
project
,
commit
),
class:
"commit_short_id"
=
link_to_gfm
commit
.
title
,
namespace_project_commit_path
(
project
.
namespace
,
project
,
commit
),
class:
"commit-row-message"
=
link_to_gfm
commit
.
title
,
namespace_project_commit_path
(
project
.
namespace
,
project
,
commit
),
class:
"commit-row-message"
·
·
#{
time_ago_with_tooltip
(
commit
.
committed_date
)
}
by
#{
time_ago_with_tooltip
(
commit
.
committed_date
,
skip_js:
true
)
}
by
=
commit_author_link
(
commit
,
avatar:
true
,
size:
24
)
=
commit_author_link
(
commit
,
avatar:
true
,
size:
24
)
app/views/projects/blame/show.html.haml
View file @
cd1d045f
...
@@ -29,7 +29,7 @@
...
@@ -29,7 +29,7 @@
.light
.light
=
commit_author_link
(
commit
,
avatar:
false
)
=
commit_author_link
(
commit
,
avatar:
false
)
authored
authored
#{
time_ago_with_tooltip
(
commit
.
committed_date
)
}
#{
time_ago_with_tooltip
(
commit
.
committed_date
,
skip_js:
true
)
}
%td
.line-numbers
%td
.line-numbers
-
line_count
=
blame_group
[
:lines
].
count
-
line_count
=
blame_group
[
:lines
].
count
-
(
current_line
...
(
current_line
+
line_count
)).
each
do
|
i
|
-
(
current_line
...
(
current_line
+
line_count
)).
each
do
|
i
|
...
...
app/views/projects/commits/_commit.html.haml
View file @
cd1d045f
...
@@ -38,5 +38,5 @@
...
@@ -38,5 +38,5 @@
=
commit_author_link
(
commit
,
avatar:
true
,
size:
24
)
=
commit_author_link
(
commit
,
avatar:
true
,
size:
24
)
authored
authored
.committed_ago
.committed_ago
#{
time_ago_with_tooltip
(
commit
.
committed_date
)
}
#{
time_ago_with_tooltip
(
commit
.
committed_date
,
skip_js:
true
)
}
=
link_to_browse_code
(
project
,
commit
)
=
link_to_browse_code
(
project
,
commit
)
spec/helpers/application_helper_spec.rb
View file @
cd1d045f
...
@@ -263,18 +263,29 @@ describe ApplicationHelper do
...
@@ -263,18 +263,29 @@ describe ApplicationHelper do
end
end
it
'includes a default js-timeago class'
do
it
'includes a default js-timeago class'
do
expect
(
element
.
attr
(
'class'
)).
to
eq
'time_ago js-timeago'
expect
(
element
.
attr
(
'class'
)).
to
eq
'time_ago js-timeago
js-timeago-pending
'
end
end
it
'accepts a custom html_class'
do
it
'accepts a custom html_class'
do
expect
(
element
(
html_class:
'custom_class'
).
attr
(
'class'
)).
expect
(
element
(
html_class:
'custom_class'
).
attr
(
'class'
)).
to
eq
'custom_class js-timeago'
to
eq
'custom_class js-timeago
js-timeago-pending
'
end
end
it
'accepts a custom tooltip placement'
do
it
'accepts a custom tooltip placement'
do
expect
(
element
(
placement:
'bottom'
).
attr
(
'data-placement'
)).
to
eq
'bottom'
expect
(
element
(
placement:
'bottom'
).
attr
(
'data-placement'
)).
to
eq
'bottom'
end
end
it
're-initializes timeago Javascript'
do
el
=
element
.
next_element
expect
(
el
.
name
).
to
eq
'script'
expect
(
el
.
text
).
to
include
"$('.js-timeago-pending').removeClass('js-timeago-pending').timeago()"
end
it
'allows the script tag to be excluded'
do
expect
(
element
(
skip_js:
true
)).
not_to
include
'script'
end
it
'converts to Time'
do
it
'converts to Time'
do
expect
{
helper
.
time_ago_with_tooltip
(
Date
.
today
)
}.
not_to
raise_error
expect
{
helper
.
time_ago_with_tooltip
(
Date
.
today
)
}.
not_to
raise_error
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