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
40c86c91
Commit
40c86c91
authored
May 28, 2016
by
Fatih Acet
Committed by
Z.J. van de Weg
Jun 06, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor awardsHandler methods to work with votesBlock.
parent
f261be09
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
36 additions
and
35 deletions
+36
-35
app/assets/javascripts/awards_handler.coffee
app/assets/javascripts/awards_handler.coffee
+34
-34
app/assets/javascripts/notes.js.coffee
app/assets/javascripts/notes.js.coffee
+2
-1
No files found.
app/assets/javascripts/awards_handler.coffee
View file @
40c86c91
...
...
@@ -32,7 +32,7 @@ class @AwardsHandler
emoji
=
$target
.
find
(
'.icon'
).
data
'emoji'
$target
.
closest
(
'.js-awards-block'
).
addClass
'current'
@
addAward
@
getAwardUrl
(),
emoji
@
addAward
@
get
VotesBlock
(),
@
get
AwardUrl
(),
emoji
showEmojiMenu
:
(
$addBtn
)
->
...
...
@@ -100,23 +100,23 @@ class @AwardsHandler
$menu
.
css
(
css
)
addAward
:
(
awardUrl
,
emoji
,
checkMutuality
=
yes
)
->
addAward
:
(
votesBlock
,
awardUrl
,
emoji
,
checkMutuality
=
yes
)
->
emoji
=
@
normilizeEmojiName
emoji
@
postEmoji
awardUrl
,
emoji
,
=>
@
addAwardToEmojiBar
emoji
,
checkMutuality
@
addAwardToEmojiBar
votesBlock
,
emoji
,
checkMutuality
$
(
'.emoji-menu'
).
removeClass
'is-visible'
addAwardToEmojiBar
:
(
emoji
,
checkForMutuality
=
yes
)
->
addAwardToEmojiBar
:
(
votesBlock
,
emoji
,
checkForMutuality
=
yes
)
->
@
checkMutuality
emoji
if
checkForMutuality
@
addEmojiToFrequentlyUsedList
(
emoji
)
@
checkMutuality
votesBlock
,
emoji
if
checkForMutuality
@
addEmojiToFrequentlyUsedList
emoji
emoji
=
@
normilizeEmojiName
(
emoji
)
$emojiBtn
=
@
findEmojiIcon
(
emoji
).
parent
()
emoji
=
@
normilizeEmojiName
emoji
$emojiBtn
=
@
findEmojiIcon
(
votesBlock
,
emoji
).
parent
()
if
$emojiBtn
.
length
>
0
if
@
isActive
$emojiBtn
...
...
@@ -125,10 +125,10 @@ class @AwardsHandler
counter
=
$emojiBtn
.
find
'.js-counter'
counter
.
text
parseInt
(
counter
.
text
())
+
1
$emojiBtn
.
addClass
'active'
@
addMeToUserList
emoji
@
addMeToUserList
votesBlock
,
emoji
else
@
getVotesBlock
()
.
removeClass
'hidden'
@
createEmoji
emoji
votesBlock
.
removeClass
'hidden'
@
createEmoji
votesBlock
,
emoji
getVotesBlock
:
->
return
$
'.js-awards-block.current'
...
...
@@ -137,7 +137,7 @@ class @AwardsHandler
getAwardUrl
:
->
return
@
getVotesBlock
().
data
'award-url'
checkMutuality
:
(
emoji
)
->
checkMutuality
:
(
votesBlock
,
emoji
)
->
awardUrl
=
@
getAwardUrl
()
...
...
@@ -145,8 +145,8 @@ class @AwardsHandler
mutualVote
=
if
emoji
is
'thumbsup'
then
'thumbsdown'
else
'thumbsup'
selector
=
"[data-emoji=
#{
mutualVote
}
]"
isAlreadyVoted
=
@
getVotesBlock
()
.
find
(
selector
).
parent
().
hasClass
'active'
@
addAward
awardUrl
,
mutualVote
,
no
if
isAlreadyVoted
isAlreadyVoted
=
votesBlock
.
find
(
selector
).
parent
().
hasClass
'active'
@
addAward
votesBlock
,
awardUrl
,
mutualVote
,
no
if
isAlreadyVoted
isActive
:
(
$emojiBtn
)
->
$emojiBtn
.
hasClass
'active'
...
...
@@ -155,20 +155,20 @@ class @AwardsHandler
decrementCounter
:
(
$emojiBtn
,
emoji
)
->
counter
=
$
(
'.js-counter'
,
$emojiBtn
)
counterNumber
=
parseInt
(
counter
.
text
())
counterNumber
=
parseInt
counter
.
text
(),
10
if
counterNumber
>
1
counter
.
text
(
counterNumber
-
1
)
@
removeMeFromUserList
(
$emojiBtn
,
emoji
)
counter
.
text
counterNumber
-
1
@
removeMeFromUserList
$emojiBtn
,
emoji
else
if
emoji
is
'thumbsup'
or
emoji
is
'thumbsdown'
$emojiBtn
.
tooltip
(
'destroy'
)
counter
.
text
(
'0'
)
@
removeMeFromUserList
(
$emojiBtn
,
emoji
)
$emojiBtn
.
tooltip
'destroy'
counter
.
text
'0'
@
removeMeFromUserList
$emojiBtn
,
emoji
@
removeEmoji
$emojiBtn
if
$emojiBtn
.
parents
(
'.note'
).
length
else
@
removeEmoji
$emojiBtn
$emojiBtn
.
removeClass
(
'active'
)
$emojiBtn
.
removeClass
'active'
removeEmoji
:
(
$emojiBtn
)
->
...
...
@@ -207,9 +207,9 @@ class @AwardsHandler
@
resetTooltip
(
awardBlock
)
addMeToUserList
:
(
emoji
)
->
addMeToUserList
:
(
votesBlock
,
emoji
)
->
awardBlock
=
@
findEmojiIcon
(
emoji
).
parent
()
awardBlock
=
@
findEmojiIcon
(
votesBlock
,
emoji
).
parent
()
origTitle
=
@
getAwardTooltip
awardBlock
users
=
[]
...
...
@@ -231,29 +231,29 @@ class @AwardsHandler
),
200
createEmoji_
:
(
emoji
)
->
createEmoji_
:
(
votesBlock
,
emoji
)
->
emojiCssClass
=
@
resolveNameToCssClass
emoji
buttonHtml
=
"<button class='btn award-control js-emoji-btn has-tooltip active' title='me' data-placement='bottom'>
buttonHtml
=
"<button class='btn award-control js-emoji-btn has-tooltip active' title='me' data-placement='bottom'>
<div class='icon emoji-icon
#{
emojiCssClass
}
' data-emoji='
#{
emoji
}
'></div>
<span class='award-control-text js-counter'>1</span>
</button>"
emoji_node
=
$
(
buttonHtml
)
.
insertBefore
'.js-awards-block.current
.js-award-holder:not(.js-award-action-btn)'
.
insertBefore
votesBlock
.
find
'
.js-award-holder:not(.js-award-action-btn)'
.
find
'.emoji-icon'
.
data
'emoji'
,
emoji
$
(
'.award-control'
).
tooltip
()
$
(
'.js-awards-block.current'
)
.
removeClass
'current'
votesBlock
.
removeClass
'current'
createEmoji
:
(
emoji
)
->
createEmoji
:
(
votesBlock
,
emoji
)
->
return
@
createEmoji_
emoji
if
$
(
'.emoji-menu'
).
length
if
$
(
'.emoji-menu'
).
length
return
@
createEmoji_
votesBlock
,
emoji
@
createEmojiMenu
@
getAwardMenuUrl
(),
=>
@
createEmoji
emoji
@
createEmojiMenu
@
getAwardMenuUrl
(),
=>
@
createEmoji
votesBlock
,
emoji
getAwardMenuUrl
:
->
return
gl
.
awardMenuUrl
or
'/emojis'
...
...
@@ -278,14 +278,14 @@ class @AwardsHandler
callback
.
call
()
if
data
.
ok
findEmojiIcon
:
(
emoji
)
->
findEmojiIcon
:
(
votesBlock
,
emoji
)
->
return
$
(
".js-awards-block.current > .js-emoji-btn [data-emoji='
#{
emoji
}
']"
)
return
votesBlock
.
find
".js-emoji-btn [data-emoji='
#{
emoji
}
']"
scrollToAwards
:
->
options
=
scrollTop
:
$
(
'.awards'
).
offset
().
top
-
8
0
options
=
scrollTop
:
$
(
'.awards'
).
offset
().
top
-
11
0
$
(
'body, html'
).
animate
options
,
200
...
...
app/assets/javascripts/notes.js.coffee
View file @
40c86c91
...
...
@@ -167,7 +167,8 @@ class @Notes
return
if
note
.
award
awardsHandler
.
addAwardToEmojiBar
(
note
.
name
)
votesBlock
=
$
(
'.js-awards-block'
).
eq
0
awardsHandler
.
addAwardToEmojiBar
votesBlock
,
note
.
name
awardsHandler
.
scrollToAwards
()
# render note if it not present in loaded list
...
...
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