Sha256: 4648e499655e920cf24a13c7b434fa29e052f8507838b594a9831ef5680fefe1

Contents?: true

Size: 1.57 KB

Versions: 3

Compression:

Stored size: 1.57 KB

Contents

//= require love_monster/emojis
// Place all the behaviors and hooks related to the matching controller here.
// All this logic will automatically be available in application.js.

(function() {
  $(function() {
    // Enable recipient auto complete
    $.getJSON('/api/v1/people', function(people_json) {
      var usernameSelector = $("#love_person_to");

      var people = people_json.data.forEach(function(person) {
        var display;

        if (person.name) {
          display = person.name + " <" + person.email + ">";
        } else {
          display = person.email;
        }

        usernameSelector.append('<option value="' + person.email + '">' + display + "</option>");
      });

      usernameSelector.chosen({
        width: "100%"
      });
    });

    // Enable emoji auto complete in messages
    $('#love_reason, #love_message').textcomplete([{
      match: /\B:([\-+\w]*)$/,
      search: function(term, callback) {
        var matchedEmojis = this.emojis.filter(function(emoji) {
          return emoji.indexOf(term) == 0;
        });

        callback(matchedEmojis);
      }.bind(this),
      template: function(value) {
        var swappedValue = value.replace(/\+/, '_');
        return "<img height='20px' src='/assets/love_monster/emoji/" + swappedValue + ".png'></img> " + value;
      },
      replace: function(value) {
        return ":" + value + ": "
      },
      index: 1,
      maxCount: 5
    }])

    // Convert emoji tags to images
    emojify.setConfig({
      img_dir: '/assets/love_monster/emoji'
    });

    emojify.run();
  })
}).call(this);

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
love_monster-0.0.3 app/assets/javascripts/love_monster/loves.js
love_monster-0.0.2 app/assets/javascripts/love_monster/loves.js
love_monster-0.0.1 app/assets/javascripts/love_monster/loves.js