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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
8455e8c4
Commit
8455e8c4
authored
Jun 24, 2017
by
Mike Greiling
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
move emoji category index to helper method
parent
73c5c001
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
27 deletions
+32
-27
app/assets/javascripts/awards_handler.js
app/assets/javascripts/awards_handler.js
+8
-27
app/assets/javascripts/emoji/index.js
app/assets/javascripts/emoji/index.js
+24
-0
No files found.
app/assets/javascripts/awards_handler.js
View file @
8455e8c4
...
...
@@ -3,15 +3,18 @@
import
Cookies
from
'
js-cookie
'
;
import
{
glEmojiTag
}
from
'
./behaviors/gl_emoji
'
;
import
{
emojiMap
,
filterEmojiNamesByAlias
,
isEmojiNameValid
,
normalizeEmojiName
}
from
'
./emoji
'
;
import
{
filterEmojiNamesByAlias
,
getEmojiByCategory
,
isEmojiNameValid
,
normalizeEmojiName
,
}
from
'
./emoji
'
;
const
animationEndEventString
=
'
animationend webkitAnimationEnd MSAnimationEnd oAnimationEnd
'
;
const
transitionEndEventString
=
'
transitionend webkitTransitionEnd oTransitionEnd MSTransitionEnd
'
;
const
FROM_SENTENCE_REGEX
=
/
(?:
, and | and |,
)
/
;
// For separating lists produced by ruby's Array#toSentence
let
categoryMap
=
null
;
const
categoryLabelMap
=
{
activity
:
'
Activity
'
,
people
:
'
People
'
,
...
...
@@ -23,26 +26,6 @@ const categoryLabelMap = {
flags
:
'
Flags
'
,
};
function
buildCategoryMap
()
{
return
Object
.
keys
(
emojiMap
).
reduce
((
currentCategoryMap
,
emojiNameKey
)
=>
{
const
emojiInfo
=
emojiMap
[
emojiNameKey
];
if
(
currentCategoryMap
[
emojiInfo
.
category
])
{
currentCategoryMap
[
emojiInfo
.
category
].
push
(
emojiNameKey
);
}
return
currentCategoryMap
;
},
{
activity
:
[],
people
:
[],
nature
:
[],
food
:
[],
travel
:
[],
objects
:
[],
symbols
:
[],
flags
:
[],
});
}
function
renderCategory
(
name
,
emojiList
,
opts
=
{})
{
return
`
<h5 class="emoji-menu-title">
...
...
@@ -71,8 +54,6 @@ export default class AwardsHandler {
if
(
$menu
.
length
===
0
)
{
setTimeout
(()
=>
this
.
createEmojiMenu
());
}
// Prebuild the categoryMap
categoryMap
=
categoryMap
||
buildCategoryMap
();
});
this
.
registerEventListener
(
'
on
'
,
$
(
document
),
'
click
'
,
'
.js-add-award
'
,
(
e
)
=>
{
e
.
stopPropagation
();
...
...
@@ -158,7 +139,7 @@ export default class AwardsHandler {
this
.
isCreatingEmojiMenu
=
true
;
// Render the first category
c
ategoryMap
=
categoryMap
||
buildCategoryMap
();
c
onst
categoryMap
=
getEmojiByCategory
();
const
categoryNameKey
=
Object
.
keys
(
categoryMap
)[
0
];
const
emojisInCategory
=
categoryMap
[
categoryNameKey
];
const
firstCategory
=
renderCategory
(
categoryLabelMap
[
categoryNameKey
],
emojisInCategory
);
...
...
@@ -198,7 +179,7 @@ export default class AwardsHandler {
}
this
.
isAddingRemainingEmojiMenuCategories
=
true
;
c
ategoryMap
=
categoryMap
||
buildCategoryMap
();
c
onst
categoryMap
=
getEmojiByCategory
();
// Avoid the jank and render the remaining categories separately
// This will take more time, but makes UI more responsive
...
...
app/assets/javascripts/emoji/index.js
View file @
8455e8c4
...
...
@@ -22,12 +22,36 @@ function filterEmojiNamesByAlias(filter) {
return
_
.
uniq
(
filterEmojiNames
(
filter
).
map
(
name
=>
normalizeEmojiName
(
name
)));
}
let
emojiByCategory
;
function
getEmojiByCategory
(
category
=
null
)
{
if
(
!
emojiByCategory
)
{
emojiByCategory
=
{
activity
:
[],
people
:
[],
nature
:
[],
food
:
[],
travel
:
[],
objects
:
[],
symbols
:
[],
flags
:
[],
};
Object
.
keys
(
emojiMap
).
forEach
((
name
)
=>
{
const
emoji
=
emojiMap
[
name
];
if
(
emojiByCategory
[
emoji
.
category
])
{
emojiByCategory
[
emoji
.
category
].
push
(
name
);
}
});
}
return
category
?
emojiByCategory
[
category
]
:
emojiByCategory
;
}
export
{
emojiMap
,
emojiAliases
,
normalizeEmojiName
,
filterEmojiNames
,
filterEmojiNamesByAlias
,
getEmojiByCategory
,
getUnicodeSupportMap
,
isEmojiNameValid
,
isEmojiUnicodeSupported
,
...
...
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