mumuki-emojis 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: c21a2c7b6a89e484b1801c5481a5a72d5a91ca3950fdef2bd52ef0625f2ac9dc
4
+ data.tar.gz: dea746935d7d2ea88563f984babaca356b93a75685f5883829ca849c97e457ed
5
+ SHA512:
6
+ metadata.gz: 153d54ff710652e872b42da4dc196569522c713452e4a5dbc172a79ff0fa57545d16db03e603d8b47ea254ea47061c024d67075e54d294eb1f6762ed40327bf3
7
+ data.tar.gz: f628a8fc43411e880df50ffca49caa18eb27eaf690d54185a559c9e050f25aa36218b5ad6690d6060d2f1262d54efd3001eee90f09e9055be2746fd81b85e674
data/README.md ADDED
@@ -0,0 +1,38 @@
1
+ # Mumuki Emojis
2
+
3
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/mumuki/emojis`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'mumuki-emojis'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install mumuki-emojis
20
+
21
+ ## Usage
22
+
23
+ TODO: Write usage instructions here
24
+
25
+ ## Development
26
+
27
+ After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
28
+
29
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
30
+
31
+ ## Contributing
32
+
33
+ Bug reports and pull requests are welcome on GitHub at https://github.com/mumuki/mumuki-emojis.
34
+
35
+
36
+ ## License
37
+
38
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,22 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
7
+
8
+ namespace :wrapper do
9
+ desc 'Wrap emojis assets into this gem'
10
+ task wrap: :clean do
11
+ cp_r '../assets', 'app'
12
+ cp '../mumuki-emojis-shortnames.json', 'app/assets/json'
13
+ end
14
+
15
+ task :clean do
16
+ rm_rf 'app'
17
+ mkdir_p 'app/assets/json'
18
+ mkdir_p 'app/assets/images'
19
+ mkdir_p 'app/assets/javascripts'
20
+ mkdir_p 'app/assets/stylesheets'
21
+ end
22
+ end
Binary file
@@ -0,0 +1,31 @@
1
+ (function (window) {
2
+
3
+ window.muEmojis = window.muEmojis || {};
4
+
5
+ window.muEmojis.object = {};
6
+
7
+ function compareEmojis(a, b) {
8
+ return a.order < b.order ? -1 : (a.order == b.order ? 0 : 1);
9
+ }
10
+
11
+ function fullEmoji(emoji) {
12
+ return {
13
+ name: emoji.n,
14
+ category: emoji.ca,
15
+ sprite_category: emoji.sc,
16
+ order: emoji.o,
17
+ shortname: emoji.s,
18
+ shortname_alternates: emoji.ss,
19
+ diversity: emoji.d,
20
+ diversities: emoji.ds,
21
+ keywords: emoji.k,
22
+ code_points: {
23
+ base: emoji.co
24
+ }
25
+ }
26
+ }
27
+
28
+ window.muEmojis.fullEmoji = fullEmoji;
29
+ window.muEmojis.list = Object.values(window.muEmojis.object).map(fullEmoji).sort(compareEmojis);
30
+
31
+ })(window);
@@ -0,0 +1,146 @@
1
+ (function (window) {
2
+
3
+ window.muEmojis = window.muEmojis || {};
4
+
5
+ var availableLanguages = ['en', 'es', 'pt'];
6
+
7
+ function currentLanguage() {
8
+ var _language = window.navigator.languages && window.navigator.languages[0] ||
9
+ window.navigator.language ||
10
+ window.navigator.browserLanguage ||
11
+ window.navigator.systemLanguage ||
12
+ window.navigator.userLanguage;
13
+
14
+ var language = _language.split("-")[0];
15
+
16
+ return availableLanguages.indexOf(language) >= 0 ? language : "en";
17
+ }
18
+
19
+ window.muEmojis._inputPlaceholder_ = {
20
+ en: "Search emojis",
21
+ es: "Buscar emoticón",
22
+ pt: "Emoticon de busca",
23
+ }
24
+
25
+ window.muEmojis._categories_ = [
26
+ {
27
+ name: "mumoji",
28
+ icon_class: "da da-mumuki-circle",
29
+ caption: {
30
+ en: "Mumoji",
31
+ es: "Mumoji",
32
+ pt: "Mumoji",
33
+ }
34
+ },
35
+ {
36
+ name: "people",
37
+ icon_class: "fa fa-fw fa-smile-o",
38
+ caption: {
39
+ en: "Smileys & People",
40
+ es: "Sonrisas y gente",
41
+ pt: "Sorrisos e pessoas",
42
+ }
43
+ },
44
+ {
45
+ name: "nature",
46
+ icon_class: "fa fa-fw fa-leaf",
47
+ caption: {
48
+ en: "Animals & Nature",
49
+ es: "Animales y naturaleza",
50
+ pt: "Animais e natureza",
51
+ }
52
+ },
53
+ {
54
+ name: "food",
55
+ icon_class: "fa fa-fw fa-cutlery",
56
+ caption: {
57
+ en: "Food & Drink",
58
+ es: "Comida y bebida",
59
+ pt: "Comida e bebida",
60
+ }
61
+ },
62
+ {
63
+ name: "activity",
64
+ icon_class: "fa fa-fw fa-futbol-o",
65
+ caption: {
66
+ en: "Activity",
67
+ es: "Actividad",
68
+ pt: "Atividade",
69
+ }
70
+ },
71
+ {
72
+ name: "travel",
73
+ icon_class: "fa fa-fw fa-plane",
74
+ caption: {
75
+ en: "Travel & Places",
76
+ es: "Viajes y lugares",
77
+ pt: "Viagens e lugares",
78
+ }
79
+ },
80
+ {
81
+ name: "objects",
82
+ icon_class: "fa fa-fw fa-wrench",
83
+ caption: {
84
+ en: "Objects",
85
+ es: "Objetos",
86
+ pt: "Objetos",
87
+ }
88
+ },
89
+ {
90
+ name: "symbols",
91
+ icon_class: "fa fa-fw fa-hashtag",
92
+ caption: {
93
+ en: "Symbols",
94
+ es: "Símbolos",
95
+ pt: "Símbolos",
96
+ }
97
+ },
98
+ {
99
+ name: "flags",
100
+ icon_class: "fa fa-fw fa-flag-o",
101
+ caption: {
102
+ en: "Flags",
103
+ es: "Banderas",
104
+ pt: "Bandeiras",
105
+ }
106
+ }
107
+ ]
108
+
109
+ window._searchEmojiPlaceholder = {
110
+ en: 'Search emoji',
111
+ es: 'Buscar emoticón',
112
+ pt: 'Pesquisar emoji',
113
+ }
114
+
115
+ function compareEmojis(a, b) {
116
+ return a.order < b.order ? -1 : (a.order == b.order ? 0 : 1);
117
+ }
118
+
119
+ function fromCategory(category, jsCriteria, emoji) {
120
+ return emoji.category === category.name && jsCriteria(emoji);
121
+ }
122
+
123
+ function filterEmojisBy(category, jsCriteria) {
124
+ return window.muEmojis.list.filter(fromCategory.bind(window.muEmojis, category, jsCriteria));
125
+ }
126
+
127
+ function alwaysTrue(_emoji) {
128
+ return true;
129
+ }
130
+
131
+ window.muEmojis.filterEmojisBy = filterEmojisBy;
132
+
133
+ window.muEmojis.categories = window.muEmojis._categories_.map(function (category, index) {
134
+ return {
135
+ name: category.name,
136
+ icon_class: category.icon_class,
137
+ order: index + 1,
138
+ caption: category.caption[currentLanguage()],
139
+ list: filterEmojisBy(category, alwaysTrue),
140
+ };
141
+ })
142
+
143
+ window.muEmojis.inputPlaceholder = window.muEmojis._inputPlaceholder_[currentLanguage()];
144
+ window.searchEmojiPlaceholder = window._searchEmojiPlaceholder[currentLanguage()];
145
+
146
+ })(window);
@@ -0,0 +1,509 @@
1
+ function renderMumukiEmojis() {
2
+
3
+ var ESCAPE_KEY = 27;
4
+
5
+ var OPEN_CLASS = 'open';
6
+ var ACTIVE_CLASS = 'active';
7
+ var DISABLED_CLASS = 'disabled';
8
+
9
+ function noop() {}
10
+ function id(x) { return x }
11
+ function $class(clazz) { return '.' + clazz }
12
+
13
+ function $$(array) {
14
+ return $(array.join('\n'));
15
+ }
16
+
17
+ MuEmoji.DROPDOWN = 'mu-emoji-dropdown';
18
+
19
+ MuEmoji.DROPDOWN_MENU = MuEmoji.DROPDOWN + '-menu';
20
+
21
+ MuEmoji.DROPDOWN_TOGGLE = MuEmoji.DROPDOWN + '-toggle';
22
+
23
+ MuEmoji.DROPDOWN_MENU_ALIGNMENT = MuEmoji.DROPDOWN_MENU + '-alignment';
24
+ MuEmoji.DROPDOWN_MENU_ALIGNMENT_LEFT = MuEmoji.DROPDOWN_MENU_ALIGNMENT + '-left';
25
+ MuEmoji.DROPDOWN_MENU_ALIGNMENT_RIGHT = MuEmoji.DROPDOWN_MENU_ALIGNMENT + '-right';
26
+ MuEmoji.DROPDOWN_MENU_ALIGNMENT_CENTER = MuEmoji.DROPDOWN_MENU_ALIGNMENT + '-center';
27
+
28
+ MuEmoji.DROPDOWN_MENU_TABS = MuEmoji.DROPDOWN_MENU + '-tabs';
29
+ MuEmoji.DROPDOWN_MENU_TAB = MuEmoji.DROPDOWN_MENU_TABS + '-item';
30
+
31
+ MuEmoji.DROPDOWN_MENU_SEARCH = MuEmoji.DROPDOWN_MENU + '-search';
32
+ MuEmoji.DROPDOWN_MENU_SEARCH_ICON = MuEmoji.DROPDOWN_MENU_SEARCH + '-icon';
33
+ MuEmoji.DROPDOWN_MENU_SEARCH_INPUT = MuEmoji.DROPDOWN_MENU_SEARCH + '-input';
34
+
35
+ MuEmoji.DROPDOWN_MENU_EMOJIS = MuEmoji.DROPDOWN_MENU + '-emojis';
36
+ MuEmoji.DROPDOWN_MENU_EMOJIS_CATEGORIES = MuEmoji.DROPDOWN_MENU_EMOJIS + '-categories';
37
+ MuEmoji.DROPDOWN_MENU_EMOJIS_CATEGORY = MuEmoji.DROPDOWN_MENU_EMOJIS_CATEGORIES + '-item';
38
+
39
+ MuEmoji.DROPDOWN_MENU_EMOJI = MuEmoji.DROPDOWN_MENU_EMOJIS + '-item';
40
+
41
+ MuEmoji.DROPDOWN_MENU_FOOTER = 'mu-emojis-footer';
42
+
43
+ function hideAllDropdownMenues() {
44
+ $($class(MuEmoji.DROPDOWN_MENU)).removeClass(OPEN_CLASS);
45
+ }
46
+
47
+ $(document).keydown(function (e) {
48
+ if (e.keyCode === ESCAPE_KEY) hideAllDropdownMenues();
49
+ });
50
+
51
+ $(document).click(function (e) {
52
+ var clazz = $class(MuEmoji.DROPDOWN_MENU);
53
+ if (!$(e.target).is(clazz + ', ' + clazz + ' *')) hideAllDropdownMenues();
54
+ });
55
+
56
+ function MuEmoji($element, index) {
57
+ this.$element = $element;
58
+ this.index = index;
59
+ }
60
+
61
+ MuEmoji.prototype = {
62
+
63
+ create: function () {
64
+ this.$element.empty();
65
+ this.createDropdownToggle();
66
+ this.createDropdownMenu();
67
+ },
68
+
69
+ createDropdownToggle: function () {
70
+ this.toggle = new MuEmojiDropdownToggle(this);
71
+ this.$element.append(this.toggle.create());
72
+ },
73
+
74
+ createDropdownMenu: function () {
75
+ this.menu = new MuEmojiDropdownMenu(this);
76
+ this.$element.append(this.menu.create());
77
+ },
78
+
79
+ dropdownToggleIconClass: function () {
80
+ return this.$element.data('icon-class') || 'fa fa-fw fa-smile-o';
81
+ },
82
+
83
+ dropdownMenuAlignmentClass: function () {
84
+ switch (this.$element.data('dropdown-alignment')) {
85
+ case 'right': return MuEmoji.DROPDOWN_MENU_ALIGNMENT_RIGHT;
86
+ case 'center': return MuEmoji.DROPDOWN_MENU_ALIGNMENT_CENTER;
87
+ default: return MuEmoji.DROPDOWN_MENU_ALIGNMENT_LEFT;
88
+ }
89
+ },
90
+
91
+ openDropdown: function () {
92
+ this.menu.open();
93
+ },
94
+
95
+ closeDropdown: function () {
96
+ this.menu.close();
97
+ },
98
+
99
+ toggleDropdown: function (event) {
100
+ this.menu.toggleDropdown(event);
101
+ },
102
+
103
+ clickedOnEmoji: function (emoji) {
104
+ eval(this.$element.data('on-emoji-click'))(emoji);
105
+ this.closeDropdown();
106
+ },
107
+
108
+ }
109
+
110
+
111
+
112
+ function MuEmojiDropdownToggle(parent) {
113
+ this.parent = parent;
114
+ }
115
+
116
+ MuEmojiDropdownToggle.prototype = {
117
+
118
+ create: function () {
119
+ return this.$element = $('<a>', {
120
+ class: MuEmoji.DROPDOWN_TOGGLE,
121
+ html: this.icon(),
122
+ click: this.parent.toggleDropdown.bind(this.parent)
123
+ });
124
+ },
125
+
126
+ icon: function () {
127
+ return $('<i>', {
128
+ class: this.parent.dropdownToggleIconClass()
129
+ });
130
+ }
131
+
132
+ }
133
+
134
+
135
+
136
+ function MuEmojiDropdownMenu(parent) {
137
+ this.parent = parent;
138
+ this.categories = JSON.parse(JSON.stringify(window.window.muEmojis.categories));
139
+ }
140
+
141
+ MuEmojiDropdownMenu.prototype = {
142
+
143
+ create: function () {
144
+ this.$element = $('<div>', {
145
+ class: [MuEmoji.DROPDOWN_MENU, this.alignmentClass()].join(' '),
146
+ });
147
+ this.createTabs();
148
+ this.createSearch();
149
+ this.createEmojis();
150
+ this.createFooter();
151
+ return this.$element;
152
+ },
153
+
154
+ alignmentClass: function () {
155
+ return this.parent.dropdownMenuAlignmentClass();
156
+ },
157
+
158
+ createTabs: function () {
159
+ this.tabs = new MuEmojiDropdownMenuTabs(this);
160
+ this.$element.append(this.tabs.create());
161
+ },
162
+
163
+ createSearch: function () {
164
+ this.search = new MuEmojiDropdownMenuSearch(this);
165
+ this.$element.append(this.search.create());
166
+ },
167
+
168
+ createEmojis: function () {
169
+ this.emojis = new MuEmojiDropdownMenuEmojis(this);
170
+ this.$element.append(this.emojis.create());
171
+ },
172
+
173
+ createFooter: function () {
174
+ this.footer = new MuEmojiDropdownMenuFooter(this);
175
+ this.$element.append(this.footer.create());
176
+ },
177
+
178
+ open: function () {
179
+ this.$element.addClass(OPEN_CLASS);
180
+ this.search.$input.focus();
181
+ },
182
+
183
+ isOpen: function () {
184
+ return this.$element.hasClass(OPEN_CLASS);
185
+ },
186
+
187
+ close: function () {
188
+ this.$element.removeClass(OPEN_CLASS);
189
+ },
190
+
191
+ isClosed: function () {
192
+ return !this.isOpen();
193
+ },
194
+
195
+ toggleDropdown: function (event) {
196
+ hideAllDropdownMenues();
197
+ if (this.isClosed()) {
198
+ this.open();
199
+ event.stopPropagation();
200
+ }
201
+ },
202
+
203
+ clickedOnEmoji: function (emoji) {
204
+ this.parent.clickedOnEmoji(emoji);
205
+ },
206
+
207
+ scrollToCategory(category) {
208
+ this.emojis.scrollToCategory(category);
209
+ },
210
+
211
+ updateEmojis: function () {
212
+ this.emojis.createEmojis();
213
+ },
214
+
215
+ updateActiveTabs: function () {
216
+ this.tabs.updateActiveTabs();
217
+ }
218
+ }
219
+
220
+
221
+ function MuEmojiDropdownMenuTabs(parent) {
222
+ this.parent = parent;
223
+ this.tabs = [];
224
+ }
225
+
226
+ MuEmojiDropdownMenuTabs.prototype = {
227
+
228
+ create: function () {
229
+ this.$element = $('<ul>', {
230
+ class: MuEmoji.DROPDOWN_MENU_TABS
231
+ });
232
+ this.createCategories();
233
+ return this.$element;
234
+ },
235
+
236
+ createCategories: function () {
237
+ var self = this;
238
+ this.parent.categories.forEach(function (category, index) {
239
+ var tab = new MuEmojiDropdownMenuTab(self, category, index);
240
+ self.tabs.push(tab);
241
+ self.$element.append(tab.create());
242
+ });
243
+ },
244
+
245
+ clickedOnTab: function (clickedTab) {
246
+ this.tabs.forEach(function (tab) {
247
+ tab.deactivate();
248
+ });
249
+ this.parent.scrollToCategory(clickedTab.category);
250
+ },
251
+
252
+ updateActiveTabs: function () {
253
+ var self = this;
254
+ self.tabs.forEach(function (tab, i) {
255
+ self.parent.categories[i].list.length === 0 ?
256
+ tab.disable() : tab.enable();
257
+ });
258
+ var tab = self.tabs.find(function (tab) { return tab.isEnable() });
259
+ self.tabs.forEach(function (tab) {
260
+ tab.deactivate();
261
+ });
262
+ tab && tab.activate();
263
+ },
264
+
265
+ }
266
+
267
+
268
+ function MuEmojiDropdownMenuTab(parent, category, index) {
269
+ this.parent = parent;
270
+ this.category = category;
271
+ this.index = index;
272
+ }
273
+
274
+ MuEmojiDropdownMenuTab.prototype = {
275
+
276
+ create: function () {
277
+ var self = this
278
+ return self.$element = $('<li>', {
279
+ class: [MuEmoji.DROPDOWN_MENU_TAB, self.index === 0 && 'active'].filter(id).join(' '),
280
+ title: self.category.description,
281
+ html: self.icon(),
282
+ click: function (event) {
283
+ self.parent.clickedOnTab(self);
284
+ self.activate();
285
+ event.stopPropagation();
286
+ }
287
+ });
288
+ },
289
+
290
+ icon: function () {
291
+ return $('<i>', {
292
+ class: this.category.icon_class
293
+ });
294
+ },
295
+
296
+ deactivate: function () {
297
+ this.$element.removeClass(ACTIVE_CLASS);
298
+ },
299
+
300
+ activate: function () {
301
+ this.$element.addClass(ACTIVE_CLASS);
302
+ },
303
+
304
+ enable: function () {
305
+ this.$element.removeClass(DISABLED_CLASS);
306
+ },
307
+
308
+ isEnable: function () {
309
+ return !this.$element.hasClass(DISABLED_CLASS);
310
+ },
311
+
312
+ disable: function () {
313
+ this.$element.addClass(DISABLED_CLASS);
314
+ }
315
+
316
+ }
317
+
318
+
319
+ function MuEmojiDropdownMenuSearch(parent) {
320
+ this.parent = parent;
321
+ this.searchTimeout = setTimeout(noop);
322
+ }
323
+
324
+ MuEmojiDropdownMenuSearch.prototype = {
325
+
326
+ create: function () {
327
+ this.$element = $('<div>', {
328
+ class: MuEmoji.DROPDOWN_MENU_SEARCH
329
+ });
330
+ this.createIcon();
331
+ this.createInput();
332
+ return this.$element;
333
+ },
334
+
335
+ createIcon: function () {
336
+ this.$icon = $('<i>', {
337
+ class: [MuEmoji.DROPDOWN_MENU_SEARCH_ICON, 'fa fa-fw fa-search'].join(' '),
338
+ });
339
+ this.$element.append(this.$icon);
340
+ },
341
+
342
+ createInput: function () {
343
+ var self = this;
344
+ this.$input = $('<input>', {
345
+ class: MuEmoji.DROPDOWN_MENU_SEARCH_INPUT,
346
+ placeholder: window.searchEmojiPlaceholder,
347
+ keyup: function (event) {
348
+ self.search();
349
+ }
350
+ });
351
+ this.$element.append(this.$input);
352
+ },
353
+
354
+ search: function () {
355
+ var self = this;
356
+ clearTimeout(this.searchTimeout);
357
+ this.searchTimeout = setTimeout(function () {
358
+ self._doSearch(self.$input.val().trim());
359
+ }, 500);
360
+ },
361
+
362
+ _doSearch: function (query) {
363
+ this.parent.categories.forEach(function (category) {
364
+ category.list = window.muEmojis.filterEmojisBy(category, function (emoji) {
365
+ return !query ? true :
366
+ [emoji.name, emoji.shortname].concat(emoji.shortname_alternates).concat(emoji.keywords).some(function (s) {
367
+ return s && s.toLowerCase().indexOf(query.toLowerCase()) >= 0;
368
+ });
369
+ });
370
+ });
371
+ this.parent.updateEmojis();
372
+ },
373
+
374
+ }
375
+
376
+
377
+ function MuEmojiDropdownMenuEmojis(parent) {
378
+ this.parent = parent;
379
+ this.categories = [];
380
+ }
381
+
382
+ MuEmojiDropdownMenuEmojis.prototype = {
383
+
384
+ create: function () {
385
+ this.$element = $('<ul>', {
386
+ class: MuEmoji.DROPDOWN_MENU_EMOJIS
387
+ });
388
+ this.createEmojis();
389
+ return this.$element;
390
+ },
391
+
392
+ createEmojis: function () {
393
+ var self = this
394
+ self.$element.empty();
395
+ self.categories = [];
396
+ self.parent.updateActiveTabs();
397
+ this.parent.categories.forEach(function (cat) {
398
+ if (cat.list.length === 0) return;
399
+ var category = new MuEmojiDropdownMenuEmojisCategory(self, cat);
400
+ self.categories.push(category);
401
+ self.$element.append(category.create());
402
+ });
403
+ },
404
+
405
+ scrollToCategory(category) {
406
+ var firstCategory = this.categories[0];
407
+ var categoryToScroll = this.categories.find(function (cat) {
408
+ return cat.category.name === category.name;
409
+ });
410
+ var scrollTop = categoryToScroll.$element.position().top - firstCategory.$element.position().top;
411
+ this.$element.scrollTop(scrollTop);
412
+ },
413
+
414
+ clickedOnEmoji: function (emoji) {
415
+ this.parent.clickedOnEmoji(emoji)
416
+ },
417
+
418
+ }
419
+
420
+
421
+ function MuEmojiDropdownMenuEmojisCategory(parent, category) {
422
+ this.parent = parent;
423
+ this.category = category;
424
+ }
425
+
426
+ MuEmojiDropdownMenuEmojisCategory.prototype = {
427
+
428
+ create: function () {
429
+ this.$element = $('<li>', {
430
+ class: MuEmoji.DROPDOWN_MENU_EMOJIS_CATEGORIES,
431
+ });
432
+ this.createTitle();
433
+ this.createEmojis();
434
+ return this.$element;
435
+ },
436
+
437
+ createTitle: function () {
438
+ this.$title = $('<h4>', {
439
+ text: this.category.caption
440
+ });
441
+ this.$element.append(this.$title);
442
+ },
443
+
444
+ createEmojis: function () {
445
+ this.$emojis = $('<ul>', {
446
+ class: MuEmoji.DROPDOWN_MENU_EMOJIS_CATEGORY
447
+ });
448
+ this.populate();
449
+ this.$element.append(this.$emojis);
450
+ },
451
+
452
+ populate: function () {
453
+ var self = this
454
+ self.category.list.forEach(function (emoji) {
455
+ if (emoji.diversity) return;
456
+ var $emoji = $('<li>', {
457
+ class: MuEmoji.DROPDOWN_MENU_EMOJI,
458
+ html: self.icon(emoji.category, emoji),
459
+ click: function () {
460
+ self.parent.clickedOnEmoji(emoji);
461
+ }
462
+ });
463
+ self.$emojis.append($emoji);
464
+ });
465
+ },
466
+
467
+ icon: function (categoryName, emoji) {
468
+ return $('<i>', {
469
+ class: ['mu-emoji', 'px24', categoryName, '_' + emoji.code_points.base].join(' '),
470
+ title: emoji.name,
471
+ data: {
472
+ code: emoji.shortname
473
+ }
474
+ });
475
+ },
476
+
477
+ }
478
+
479
+
480
+ function MuEmojiDropdownMenuFooter(parent) {
481
+ this.parent = parent;
482
+ }
483
+
484
+ MuEmojiDropdownMenuFooter.prototype = {
485
+
486
+ create: function () {
487
+ this.$element = $('<div>', {
488
+ class: MuEmoji.DROPDOWN_MENU_FOOTER,
489
+ });
490
+ return this.$element;
491
+ },
492
+
493
+ }
494
+
495
+
496
+
497
+ $.fn.renderEmojis = function () {
498
+ var self = this;
499
+ self.each(function (i) {
500
+ var $element = $(self[i]);
501
+ $element.empty();
502
+ new MuEmoji($element, i).create();
503
+ });
504
+ return self;
505
+ }
506
+
507
+ $($class(MuEmoji.DROPDOWN)).renderEmojis();
508
+
509
+ }