Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
converse.js
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
nexedi
converse.js
Commits
f8c6467f
Commit
f8c6467f
authored
Jul 16, 2017
by
JC Brand
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
emoji: Show only one skin-tone at a time (including the "neutral" one)
parent
3ebe4138
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
44 additions
and
11 deletions
+44
-11
src/converse-chatview.js
src/converse-chatview.js
+26
-4
src/templates/emojis.html
src/templates/emojis.html
+1
-2
src/utils.js
src/utils.js
+17
-5
No files found.
src/converse-chatview.js
View file @
f8c6467f
...
...
@@ -134,14 +134,15 @@
this
.
setScrollPosition
=
_
.
debounce
(
this
.
setScrollPosition
,
50
);
},
render
:
function
()
{
var
emojis_by_category
=
utils
.
marshallEmojis
(
emojione
);
render
()
{
var
emojis_html
=
tpl_emojis
(
_
.
extend
(
this
.
model
.
toJSON
(),
{
'
transform
'
:
_converse
.
use_emojione
?
emojione
.
shortnameToImage
:
emojione
.
shortnameToUnicode
,
'
emojis_by_category
'
:
emojis_by_category
,
'
emojis_by_category
'
:
utils
.
getEmojisByCategory
(
_converse
,
emojione
),
'
toned_emojis
'
:
utils
.
getTonedEmojis
(
_converse
),
'
skintones
'
:
[
'
tone1
'
,
'
tone2
'
,
'
tone3
'
,
'
tone4
'
,
'
tone5
'
],
'
shouldBeHidden
'
:
this
.
shouldBeHidden
}
));
this
.
el
.
innerHTML
=
emojis_html
;
...
...
@@ -155,6 +156,23 @@
return
this
;
},
shouldBeHidden
(
shortname
,
current_skintone
,
toned_emojis
)
{
/* Helper method for the template which decides whether an
* emoji should be hidden, based on which skin tone is
* currently being applied.
*/
if
(
_
.
includes
(
shortname
,
'
_tone
'
))
{
if
(
!
current_skintone
||
!
_
.
includes
(
shortname
,
current_skintone
))
{
return
true
;
}
}
else
{
if
(
current_skintone
&&
_
.
includes
(
toned_emojis
,
shortname
))
{
return
true
;
}
}
return
false
;
},
restoreScrollPosition
()
{
const
current_picker
=
_
.
difference
(
this
.
el
.
querySelectorAll
(
'
.emoji-picker
'
),
...
...
@@ -173,7 +191,11 @@
ev
.
preventDefault
();
ev
.
stopPropagation
();
const
skintone
=
ev
.
target
.
parentElement
.
getAttribute
(
"
data-skintone
"
).
trim
();
if
(
this
.
model
.
get
(
'
current_skintone
'
)
===
skintone
)
{
this
.
model
.
set
({
'
current_skintone
'
:
''
});
}
else
{
this
.
model
.
set
({
'
current_skintone
'
:
skintone
});
}
},
chooseCategory
(
ev
)
{
...
...
src/templates/emojis.html
View file @
f8c6467f
{[ _.forEach(emojis_by_category, function (obj, category) { ]}
<ul
class=
"emoji-picker emoji-picker-{{{category}}} {[ if (current_category !== category) { ]} hidden {[ } ]}"
>
{[ _.forEach(emojis_by_category[category], function (emoji) { ]}
<li
class=
"emoji insert-emoji
{[ if (emoji._shortname.indexOf('_tone') !== -1 && (!current_skintone || emoji._shortname.indexOf(current_skintone) === -1)) { ]} hidden {[ }; ]}"
<li
class=
"emoji insert-emoji {[ if (shouldBeHidden(emoji._shortname, current_skintone, toned_emojis)) { ]} hidden {[ }; ]}"
data-emoji=
"{{{emoji._shortname}}}"
>
<a
href=
"#"
data-emoji=
"{{{emoji._shortname}}}"
>
{{ transform(emoji._shortname) }}
</a>
</li>
...
...
src/utils.js
View file @
f8c6467f
...
...
@@ -616,11 +616,11 @@
}
}
utils
.
marshallEmojis
=
function
(
emojione
)
{
utils
.
getEmojisByCategory
=
function
(
_converse
,
emojione
)
{
/* Return a dict of emojis with the categories as keys and
* lists of emojis in that category as values.
*/
if
(
_
.
isUndefined
(
this
.
emojis_by_category
))
{
if
(
_
.
isUndefined
(
_converse
.
emojis_by_category
))
{
const
emojis
=
_
.
values
(
_
.
mapValues
(
emojione
.
emojioneList
,
function
(
value
,
key
,
o
)
{
value
.
_shortname
=
key
;
return
value
...
...
@@ -657,10 +657,22 @@
}
emojis_by_category
[
cat
]
=
list
;
});
this
.
emojis_by_category
=
emojis_by_category
;
}
return
this
.
emojis_by_category
;
_converse
.
emojis_by_category
=
emojis_by_category
;
}
return
_converse
.
emojis_by_category
;
};
utils
.
getTonedEmojis
=
function
(
_converse
)
{
_converse
.
toned_emojis
=
_
.
uniq
(
_
.
map
(
_
.
filter
(
utils
.
getEmojisByCategory
(
_converse
).
people
,
(
person
)
=>
_
.
includes
(
person
.
_shortname
,
'
_tone
'
)
),
(
person
)
=>
person
.
_shortname
.
replace
(
/_tone
[
1-5
]
/
,
''
)
));
return
_converse
.
toned_emojis
;
};
utils
.
isPersistableModel
=
function
(
model
)
{
return
model
.
collection
&&
model
.
collection
.
browserStorage
;
...
...
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