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
36d0442e
Commit
36d0442e
authored
Nov 17, 2015
by
Valery Sizov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
replace emoji references from class name to data [ci skip]
parent
06a4fd10
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
26 additions
and
22 deletions
+26
-22
app/assets/javascripts/awards_handler.coffee
app/assets/javascripts/awards_handler.coffee
+20
-16
app/assets/javascripts/notes.js.coffee
app/assets/javascripts/notes.js.coffee
+1
-1
app/views/votes/_votes_block.html.haml
app/views/votes/_votes_block.html.haml
+5
-5
No files found.
app/assets/javascripts/awards_handler.coffee
View file @
36d0442e
...
@@ -3,25 +3,27 @@ class @AwardsHandler
...
@@ -3,25 +3,27 @@ class @AwardsHandler
addAward
:
(
emoji
)
->
addAward
:
(
emoji
)
->
@
postEmoji
emoji
,
=>
@
postEmoji
emoji
,
=>
if
@
exist
(
emoji
)
@
addAwardToEmojiBar
(
emoji
)
if
@
isActive
(
emoji
)
@
decrementCounter
(
emoji
)
else
counter
=
$
(
".icon."
+
emoji
).
siblings
(
".counter"
)
counter
.
text
(
parseInt
(
counter
.
text
())
+
1
)
counter
.
parent
().
addClass
(
"active"
)
else
@
createEmoji
(
emoji
)
addAwardToEmojiBar
:
(
emoji
)
->
if
@
exist
(
emoji
)
if
@
isActive
(
emoji
)
@
decrementCounter
(
emoji
)
else
counter
=
@
findEmojiIcon
(
emoji
).
siblings
(
".counter"
)
counter
.
text
(
parseInt
(
counter
.
text
())
+
1
)
counter
.
parent
().
addClass
(
"active"
)
else
@
createEmoji
(
emoji
)
exist
:
(
emoji
)
->
exist
:
(
emoji
)
->
$
(
".icon"
).
hasClass
(
emoji
)
@
findEmojiIcon
(
emoji
).
length
>
0
isActive
:
(
emoji
)
->
isActive
:
(
emoji
)
->
$
(
".icon."
+
emoji
).
parent
().
hasClass
(
"active"
)
@
findEmojiIcon
(
emoji
).
parent
().
hasClass
(
"active"
)
decrementCounter
:
(
emoji
)
->
decrementCounter
:
(
emoji
)
->
counter
=
$
(
".icon."
+
emoji
).
siblings
(
".counter"
)
counter
=
@
findEmojiIcon
(
emoji
).
siblings
(
".counter"
)
if
parseInt
(
counter
.
text
())
>
1
if
parseInt
(
counter
.
text
())
>
1
counter
.
text
(
parseInt
(
counter
.
text
())
-
1
)
counter
.
text
(
parseInt
(
counter
.
text
())
-
1
)
...
@@ -33,7 +35,7 @@ class @AwardsHandler
...
@@ -33,7 +35,7 @@ class @AwardsHandler
createEmoji
:
(
emoji
)
->
createEmoji
:
(
emoji
)
->
nodes
=
[]
nodes
=
[]
nodes
.
push
(
"<div class='award active'>"
)
nodes
.
push
(
"<div class='award active'>"
)
nodes
.
push
(
"<div class='icon
"
+
emoji
+
"'>"
)
nodes
.
push
(
"<div class='icon
' data-emoji='
"
+
emoji
+
"'>"
)
nodes
.
push
(
@
getImage
(
emoji
))
nodes
.
push
(
@
getImage
(
emoji
))
nodes
.
push
(
"</div>"
)
nodes
.
push
(
"</div>"
)
nodes
.
push
(
"<div class='counter'>1"
)
nodes
.
push
(
"<div class='counter'>1"
)
...
@@ -42,14 +44,16 @@ class @AwardsHandler
...
@@ -42,14 +44,16 @@ class @AwardsHandler
$
(
".awards-controls"
).
before
(
nodes
.
join
(
"
\n
"
))
$
(
".awards-controls"
).
before
(
nodes
.
join
(
"
\n
"
))
getImage
:
(
emoji
)
->
getImage
:
(
emoji
)
->
$
(
"li
."
+
emoji
).
html
()
$
(
"li
[data-emoji='"
+
emoji
+
"'"
).
html
()
postEmoji
:
(
emoji
,
callback
)
->
postEmoji
:
(
emoji
,
callback
)
->
emoji
=
emoji
.
replace
(
"emoji-"
,
""
)
$
.
post
@
post_emoji_url
,
{
$
.
post
@
post_emoji_url
,
{
emoji
:
emoji
emoji
:
emoji
noteable_type
:
@
noteable_type
noteable_type
:
@
noteable_type
noteable_id
:
@
noteable_id
noteable_id
:
@
noteable_id
},(
data
)
->
},(
data
)
->
if
data
.
ok
if
data
.
ok
callback
.
call
()
callback
.
call
()
\ No newline at end of file
findEmojiIcon
:
(
emoji
)
->
$
(
".icon[data-emoji='"
+
emoji
+
"'"
)
\ No newline at end of file
app/assets/javascripts/notes.js.coffee
View file @
36d0442e
...
@@ -121,7 +121,7 @@ class @Notes
...
@@ -121,7 +121,7 @@ class @Notes
@
initTaskList
()
@
initTaskList
()
if
note
.
award
if
note
.
award
awards_handler
.
addAward
(
"emoji-"
+
note
.
note
)
awards_handler
.
addAward
ToEmojiBar
(
note
.
note
)
###
###
Check if note does not exists on page
Check if note does not exists on page
...
...
app/views/votes/_votes_block.html.haml
View file @
36d0442e
.awards.votes-block
.awards.votes-block
-
votable
.
notes
.
awards
.
grouped_awards
.
each
do
|
vote
|
-
votable
.
notes
.
awards
.
grouped_awards
.
each
do
|
vote
|
.
award
{
class:
(
"active"
if
vote
.
last
.
pluck
(
:author_id
).
include?
(
current_user
.
id
))}
.
award
{
class:
(
"active"
if
vote
.
last
.
pluck
(
:author_id
).
include?
(
current_user
.
id
))}
.icon
{
class:
"emoji-
#{vote.first}"
}
.icon
{
"data-emoji"
=>
"
#{vote.first}"
}
=
image_tag
url_to_emoji
(
vote
.
first
),
height:
"20px"
,
width:
"20px"
=
image_tag
url_to_emoji
(
vote
.
first
),
height:
"20px"
,
width:
"20px"
.counter
.counter
=
vote
.
last
.
count
=
vote
.
last
.
count
...
@@ -10,22 +10,22 @@
...
@@ -10,22 +10,22 @@
%a
#add-award
{
"data-toggle"
=>
"dropdown"
,
"data-target"
=>
"#"
,
"href"
=>
"#"
}
+
%a
#add-award
{
"data-toggle"
=>
"dropdown"
,
"data-target"
=>
"#"
,
"href"
=>
"#"
}
+
%ul
.dropdown-menu.awards-menu
%ul
.dropdown-menu.awards-menu
-
[
"100"
,
"blush"
,
"heart"
,
"smile"
,
"rage"
,
"beers"
,
"thumbsup"
,
"disappointed"
,
"ok_hand"
,
"helicopter"
].
each
do
|
emoji
|
-
[
"100"
,
"blush"
,
"heart"
,
"smile"
,
"rage"
,
"beers"
,
"thumbsup"
,
"disappointed"
,
"ok_hand"
,
"helicopter"
].
each
do
|
emoji
|
%li
{
class:
"emoji-
#{emoji}"
}=
image_tag
url_to_emoji
(
emoji
),
height:
"20px"
,
width:
"20px"
%li
{
"data-emoji"
=>
"
#{emoji}"
}=
image_tag
url_to_emoji
(
emoji
),
height:
"20px"
,
width:
"20px"
:coffeescript
:coffeescript
post_emoji_url = "
#{
award_toggle_namespace_project_notes_path
(
@project
.
namespace
,
@project
)
}
"
post_emoji_url = "
#{
award_toggle_namespace_project_notes_path
(
@project
.
namespace
,
@project
)
}
"
noteable_type = "Issue"
noteable_type = "Issue"
noteable_id =
#{
@issue
.
id
}
noteable_id =
#{
@issue
.
id
}
awards_handler = new AwardsHandler(post_emoji_url, noteable_type, noteable_id)
window.
awards_handler = new AwardsHandler(post_emoji_url, noteable_type, noteable_id)
$ ->
$ ->
$(".awards-menu li").click (e)->
$(".awards-menu li").click (e)->
emoji = $(this).
attr("class
")
emoji = $(this).
data("emoji
")
awards_handler.addAward(emoji)
awards_handler.addAward(emoji)
$(".awards").on "click", ".award", (e)->
$(".awards").on "click", ".award", (e)->
emoji =
/(emoji-\S*)/.exec($(this).find(".icon").attr("class"))[0]
emoji =
$(this).find(".icon").data("emoji")
awards_handler.addAward(emoji)
awards_handler.addAward(emoji)
...
...
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