@@ -21,12 +21,21 @@ $(document).ready(function (e) {
2121
2222 Array . prototype . forEach . call ( subGroup . Emojis , function ( emoji ) {
2323 var emojiElement = document . createElement ( 'div' )
24-
24+
2525 emojiElement . className = 'emoji col l2 m2 s6'
26- emojiElement . innerHTML = "<span class='flow-text' title='" + emoji . Name . toLocaleUpperCase ( ) + "'>" + emoji . Name + "</span><div><img alt='" + emoji . Name + "' title='Click to copy to clipboard' src='" + emoji . Url + "' /><p>:" + emoji . Code + ':</p></div>'
27-
26+
27+ emojiElement . setAttribute ( 'data-search' ,
28+ ( emoji . Name + ' ' + group . Name + ' ' + subGroup . Name ) . toLowerCase ( )
29+ )
30+
31+ emojiElement . innerHTML =
32+ "<span class='flow-text' title='" + emoji . Name . toLocaleUpperCase ( ) + "'>" +
33+ emoji . Name +
34+ "</span><div><img alt='" + emoji . Name + "' title='Click to copy to clipboard' src='" + emoji . Url + "' />" +
35+ "<p>:" + emoji . Code + ":</p></div>"
36+
2837 availableTags . push ( emoji . Name )
29-
38+
3039 subGroupElement . append ( emojiElement )
3140 } )
3241
@@ -74,21 +83,22 @@ $(document).ready(function (e) {
7483 var idTimer
7584
7685 $ ( '#search-field' ) . on ( 'input' , function ( ) {
77- var search = $ ( this ) . val ( )
78-
86+ var search = $ ( this ) . val ( ) . trim ( ) . toLowerCase ( )
87+
7988 clearTimeout ( idTimer )
80-
8189 idTimer = setTimeout ( function ( ) {
8290 $ ( '.sub-group, .group' ) . removeClass ( 'hidden' )
8391 $ ( '#main' ) . find ( '.no-results' ) . remove ( )
84-
92+
8593 if ( search !== '' ) {
8694 search = search . normalize ( 'NFD' ) . replace ( / [ \u0300 - \u036f ] / g, '' )
87- search = search . toLocaleLowerCase ( )
88-
89- $ ( 'div.emoji span:not(' + search + ')' ) . closest ( 'div.emoji' ) . addClass ( 'hidden' )
90- $ ( 'div.emoji span:contains(' + search + ')' ) . closest ( 'div.emoji' ) . removeClass ( 'hidden' )
91-
95+
96+ $ ( '.emoji' ) . addClass ( 'hidden' )
97+
98+ $ ( '.emoji' ) . filter ( function ( ) {
99+ return $ ( this ) . attr ( 'data-search' ) . includes ( search )
100+ } ) . removeClass ( 'hidden' )
101+
92102 hideEmptySection ( '.sub-group' )
93103 hideEmptySection ( '.group' , function ( arraySections ) {
94104 if ( arraySections . toArray ( ) . every ( function ( e ) { return e } ) ) {
0 commit comments