Skip to content

qq99/emojify.js

 
 

Repository files navigation

emojify.js v0.9.0

A Javascript module to convert emoji keywords to images. Used by Gitter

The emoji keywords are as described by emoji-cheat-sheet.com.

Go to this project's GitHub pages to see the module in action.

Rationale

I wanted my blog to display smileys nicely, decided to use Emojis because they look nice. GitterHQ wanted to use it in Gitter, so they very kindly rewrote it and here we are.

Usage

Add the following line to your HTML:

<script src="emojify.js"></script>

Now type in an emoji keyword in your HTML, for example :smile: Now run emojify using emojify.run(). To exclude tags from being emojified, add no-emojify to their class attributes.

You can optionally pass an object to emojify.run() to restrict the emojification to that object only: emojify.run(document.getElementById('my-element'))

Configuration

To set configuration options, use emojify.setConfig() and a JSON object as a parameter with the following attributes:

  • emojify_tag_type: Set to <div> by default. Sets the element the emojify.js uses to replace emoji keywords
  • emoticons_enabled: Set to true by default. Enables detection of emoticon keywords.
  • people_enabled: Set to false by default. Enables detection of emoji people keywords.
  • nature_enabled: Set to false by default. Enables detection of emoji nature keywords.
  • objects_enabled: Set to false by default. Enables detection of emoji objects keywords.
  • places_enabled: Set to false by default. Enables detection of emoji places keywords.
  • symbols_enabled: Set to false by default. Enables detection of emoji symbols keywords.
  • only_crawl_id: Set to null by default. Restricts searching for emojis to a specified element & it's children. If null, and no object is passed to run(), document.body is used.

Code Example

emojify.setConfig({

    emojify_tag_type : 'div',           // Only run emojify.js on this element
    only_crawl_id    : null,            // Use to restrict where emojify.js applies
    img_dir          : 'images/emoji',  // Directory for emoji images
    ignored_tags     : {                // Ignore the following tags
        'SCRIPT'  : 1,
        'TEXTAREA': 1,
        'A'       : 1,
        'PRE'     : 1,
        'CODE'    : 1
    }
});
emojify.run();

Dependencies

This module depends on LESS, or at least requires you to compile the LESS source to CSS.

License

Copyright 2014 Hassan Khan

Licensed under the MIT License

About

A Javascript module to convert Emoji keywords to images

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 73.8%
  • CoffeeScript 26.2%