Sha256: d1a4403be33525a9989daa5bff1bf8dbce094b2a608f929c5a02f1f0f1831ce6

Contents?: true

Size: 681 Bytes

Versions: 13

Compression:

Stored size: 681 Bytes

Contents

/**
 * Version 0.0.1
 * Fill in an input field from another one (source)
 * and apply a filter on the string (slugify)
 * Didier Lafforgue
 */
$.fn.slugify = function(settings) {

  settings = $.extend({
    sep: '-'
  }, settings);

  var target = $(settings.target);
  target.data('touched', (target.val() != ''));

  var makeSlug = function(event) {
    var source = $(this);
    var newVal = source.val().slugify(settings.sep);

    if (!target.data('touched')) {
      target.val(newVal);
      target.trigger('change');
    }
  }

  target.bind('keyup', function(event) {
    $(this).data('touched', ($(this).val() != ''));
  });

  return $(this).bind('keyup', makeSlug);
};

Version data entries

13 entries across 13 versions & 2 rubygems

Version Path
tribeca_cms-0.1.1 vendor/assets/javascripts/locomotive/slugify.js
tribeca_cms-2.0.0.rc12 vendor/assets/javascripts/locomotive/slugify.js
locomotive_cms-2.0.0.rc12 vendor/assets/javascripts/locomotive/slugify.js
locomotive_cms-2.0.0.rc11 vendor/assets/javascripts/locomotive/slugify.js
locomotive_cms-2.0.0.rc10 vendor/assets/javascripts/locomotive/slugify.js
locomotive_cms-2.0.0.rc9 vendor/assets/javascripts/locomotive/slugify.js
locomotive_cms-2.0.0.rc8 vendor/assets/javascripts/locomotive/slugify.js
locomotive_cms-2.0.0.rc7 vendor/assets/javascripts/locomotive/slugify.js
locomotive_cms-2.0.0.rc6 vendor/assets/javascripts/locomotive/slugify.js
locomotive_cms-2.0.0.rc5 vendor/assets/javascripts/locomotive/slugify.js
locomotive_cms-2.0.0.rc4 vendor/assets/javascripts/locomotive/slugify.js
locomotive_cms-2.0.0.rc2 vendor/assets/javascripts/locomotive/slugify.js
locomotive_cms-2.0.0.rc1 vendor/assets/javascripts/locomotive/slugify.js