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
b7a0044a
Commit
b7a0044a
authored
Jun 24, 2017
by
Mike Greiling
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
move normalizeEmojiName method to emoji helper module
parent
35ee21d9
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
14 additions
and
20 deletions
+14
-20
app/assets/javascripts/awards_handler.js
app/assets/javascripts/awards_handler.js
+3
-8
app/assets/javascripts/emoji/index.js
app/assets/javascripts/emoji/index.js
+11
-1
app/assets/javascripts/emoji/is_emoji_name_valid.js
app/assets/javascripts/emoji/is_emoji_name_valid.js
+0
-11
No files found.
app/assets/javascripts/awards_handler.js
View file @
b7a0044a
...
@@ -3,7 +3,7 @@
...
@@ -3,7 +3,7 @@
import
Cookies
from
'
js-cookie
'
;
import
Cookies
from
'
js-cookie
'
;
import
{
glEmojiTag
}
from
'
./behaviors/gl_emoji
'
;
import
{
glEmojiTag
}
from
'
./behaviors/gl_emoji
'
;
import
{
emojiMap
,
emojiAliases
,
isEmojiNameValid
}
from
'
./emoji
'
;
import
{
emojiMap
,
emojiAliases
,
isEmojiNameValid
,
normalizeEmojiName
}
from
'
./emoji
'
;
const
animationEndEventString
=
'
animationend webkitAnimationEnd MSAnimationEnd oAnimationEnd
'
;
const
animationEndEventString
=
'
animationend webkitAnimationEnd MSAnimationEnd oAnimationEnd
'
;
const
transitionEndEventString
=
'
transitionend webkitTransitionEnd oTransitionEnd MSTransitionEnd
'
;
const
transitionEndEventString
=
'
transitionend webkitTransitionEnd oTransitionEnd MSTransitionEnd
'
;
...
@@ -65,7 +65,6 @@ function renderCategory(name, emojiList, opts = {}) {
...
@@ -65,7 +65,6 @@ function renderCategory(name, emojiList, opts = {}) {
export
default
class
AwardsHandler
{
export
default
class
AwardsHandler
{
constructor
()
{
constructor
()
{
this
.
eventListeners
=
[];
this
.
eventListeners
=
[];
this
.
aliases
=
emojiAliases
;
// If the user shows intent let's pre-build the menu
// If the user shows intent let's pre-build the menu
this
.
registerEventListener
(
'
one
'
,
$
(
document
),
'
mouseenter focus
'
,
'
.js-add-award
'
,
'
mouseenter focus
'
,
()
=>
{
this
.
registerEventListener
(
'
one
'
,
$
(
document
),
'
mouseenter focus
'
,
'
.js-add-award
'
,
'
mouseenter focus
'
,
()
=>
{
const
$menu
=
$
(
'
.emoji-menu
'
);
const
$menu
=
$
(
'
.emoji-menu
'
);
...
@@ -260,7 +259,7 @@ export default class AwardsHandler {
...
@@ -260,7 +259,7 @@ export default class AwardsHandler {
checkMutuality
,
checkMutuality
,
callback
,
callback
,
)
{
)
{
const
normalizedEmoji
=
this
.
normalizeEmojiName
(
emoji
);
const
normalizedEmoji
=
normalizeEmojiName
(
emoji
);
const
$emojiButton
=
this
.
findEmojiIcon
(
votesBlock
,
normalizedEmoji
).
parent
();
const
$emojiButton
=
this
.
findEmojiIcon
(
votesBlock
,
normalizedEmoji
).
parent
();
this
.
postEmoji
(
$emojiButton
,
awardUrl
,
normalizedEmoji
,
()
=>
{
this
.
postEmoji
(
$emojiButton
,
awardUrl
,
normalizedEmoji
,
()
=>
{
this
.
addAwardToEmojiBar
(
votesBlock
,
normalizedEmoji
,
checkMutuality
);
this
.
addAwardToEmojiBar
(
votesBlock
,
normalizedEmoji
,
checkMutuality
);
...
@@ -279,7 +278,7 @@ export default class AwardsHandler {
...
@@ -279,7 +278,7 @@ export default class AwardsHandler {
this
.
checkMutuality
(
votesBlock
,
emoji
);
this
.
checkMutuality
(
votesBlock
,
emoji
);
}
}
this
.
addEmojiToFrequentlyUsedList
(
emoji
);
this
.
addEmojiToFrequentlyUsedList
(
emoji
);
const
normalizedEmoji
=
this
.
normalizeEmojiName
(
emoji
);
const
normalizedEmoji
=
normalizeEmojiName
(
emoji
);
const
$emojiButton
=
this
.
findEmojiIcon
(
votesBlock
,
normalizedEmoji
).
parent
();
const
$emojiButton
=
this
.
findEmojiIcon
(
votesBlock
,
normalizedEmoji
).
parent
();
if
(
$emojiButton
.
length
>
0
)
{
if
(
$emojiButton
.
length
>
0
)
{
if
(
this
.
isActive
(
$emojiButton
))
{
if
(
this
.
isActive
(
$emojiButton
))
{
...
@@ -469,10 +468,6 @@ export default class AwardsHandler {
...
@@ -469,10 +468,6 @@ export default class AwardsHandler {
return
$
(
'
body, html
'
).
animate
(
options
,
200
);
return
$
(
'
body, html
'
).
animate
(
options
,
200
);
}
}
normalizeEmojiName
(
emoji
)
{
return
Object
.
prototype
.
hasOwnProperty
.
call
(
this
.
aliases
,
emoji
)
?
this
.
aliases
[
emoji
]
:
emoji
;
}
addEmojiToFrequentlyUsedList
(
emoji
)
{
addEmojiToFrequentlyUsedList
(
emoji
)
{
if
(
isEmojiNameValid
(
emoji
))
{
if
(
isEmojiNameValid
(
emoji
))
{
this
.
frequentlyUsedEmojis
=
_
.
uniq
(
this
.
getFrequentlyUsedEmojis
().
concat
(
emoji
));
this
.
frequentlyUsedEmojis
=
_
.
uniq
(
this
.
getFrequentlyUsedEmojis
().
concat
(
emoji
));
...
...
app/assets/javascripts/emoji/index.js
View file @
b7a0044a
import
emojiMap
from
'
emojis/digests.json
'
;
import
emojiMap
from
'
emojis/digests.json
'
;
import
emojiAliases
from
'
emojis/aliases.json
'
;
import
emojiAliases
from
'
emojis/aliases.json
'
;
import
getUnicodeSupportMap
from
'
./unicode_support_map
'
;
import
getUnicodeSupportMap
from
'
./unicode_support_map
'
;
import
isEmojiNameValid
from
'
./is_emoji_name_valid
'
;
import
isEmojiUnicodeSupported
from
'
./is_emoji_unicode_supported
'
;
import
isEmojiUnicodeSupported
from
'
./is_emoji_unicode_supported
'
;
const
validEmojiNames
=
[...
Object
.
keys
(
emojiMap
),
...
Object
.
keys
(
emojiAliases
)];
function
normalizeEmojiName
(
name
)
{
return
Object
.
prototype
.
hasOwnProperty
.
call
(
emojiAliases
,
name
)
?
emojiAliases
[
name
]
:
name
;
}
function
isEmojiNameValid
(
name
)
{
return
validEmojiNames
.
indexOf
(
name
)
>=
0
;
}
export
{
export
{
emojiMap
,
emojiMap
,
emojiAliases
,
emojiAliases
,
normalizeEmojiName
,
getUnicodeSupportMap
,
getUnicodeSupportMap
,
isEmojiNameValid
,
isEmojiNameValid
,
isEmojiUnicodeSupported
,
isEmojiUnicodeSupported
,
...
...
app/assets/javascripts/emoji/is_emoji_name_valid.js
deleted
100644 → 0
View file @
35ee21d9
import
emojiMap
from
'
emojis/digests.json
'
;
import
emojiAliases
from
'
emojis/aliases.json
'
;
function
isEmojiNameValid
(
inputName
)
{
const
name
=
Object
.
prototype
.
hasOwnProperty
.
call
(
emojiAliases
,
inputName
)
?
emojiAliases
[
inputName
]
:
inputName
;
return
name
&&
emojiMap
[
name
];
}
export
default
isEmojiNameValid
;
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