Giter Club home page Giter Club logo

jquery-slugify-plugin's Introduction

jQuery Slugify

Update

Please have a look at Madflow's implementation of jQuery Slugify. It's a more mature and active project. In theory, you should be able to drop in and replace the code. Please let us know how it goes.

About this version

A jQuery plugin to create a URL slug as you type a page title (like Django slugify())

Say you have form that looks like this:

<label for="title">Title, e.g. "My Cool Blog Post"</label>
<input type="text" name="title" id="title">
...

<label for="slug">Slug, e.g. "my-cool-blog-post"</label>
<input type="text" name="slug" id="slug">

Use slugify() to automatically fill out the slug field as the user types a title.

$('#slug').slugify('#title');

More docs and live examples at http://patrickmcelhaney.com/jQuery-Slugify-Plugin

jquery-slugify-plugin's People

Contributors

davidduffett avatar hbasria avatar jastanton avatar joshhornby avatar kshlyk avatar pmcelhaney avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

jquery-slugify-plugin's Issues

Bower

Can we get this onto bower?

Would make it easer for using in projects.

Thanks

Residual "-" with this string

Hi,

It appears a residual "-" character at the end of the string when you type the following string:
Merci a vous tous !

This is converted to :
merci-a-vous-tous-

How can we fix this ?

Thanks

Merge with the other, more mature slugify project

I just discovered another jQuery plugin on Github that's very similar to this one. It's not as popular as this one (which has been around quite a while) but it's more mature from a software engineering perspective. Rather than continuing to contribute to this repo, I think we should all throw our support behind the newer one. I just posted a proposal on @madflow's repo

Huge thanks to everyone who has used and contributed to this project over the years and taken it much further than I imagined!

Dashes being added with lots of spacing

There is a bug where for every space you add in the title, an extra dash will be placed in the slug. I think that it should probably trim it down and only ever use one dash.

Unit Tests

This plugin should have unit tests to make sure it behaves as expected, the behavior is formally documented, and improvements to the code don't accidentally break anything.

Improvement - double dash, first n last dash

Thank you for this good plugin.

I have some improvement suggest:

  • double or more dash into single dash
  • remove first and last dash

Find

return str.toLowerCase()

Replace with

return str.toLowerCase().replace(/[-]+/g, '-').replace(/^-+|-+$/g, '');
// .replace(/[-]+/g, '-')   replace -- more to single -
// .replace(/^-+|-+$/g, '')   remove - at first and last string

Text to test

! lorëm Ipsum блог sit amet بلوق vivendum 博客  ãàáäâẽèéëêìíïîõòóöôùúüûñç·/_,:; !

Result

lorem-ipsum-6jior-sit-amet-vivendum-aaaaaeeeeiiiiooooouuuunc

Hope this help, thanks.

The Pig Latin function in the example doesn't work very well

It gets the point across but sometimes puts letters in the wrong place. Who wants to take a stab at improving this guy?

var pigLatin = function(str) {
    return str.replace(/(\w*)([aeiou]\w*)/g, "$2$1ay");
}

Hint: it would probably be easier to ditch the regular expression and just loop over the letters until you find a vowel.

Not Work with Utf-8 characters

I work in arabic project and need to slugify input url But your plugin not support Unicode Utf-8 characters Like This :

slug

how do fix this?

Call to val(slug).text(slug)

When updating the slug on the target you have the following line:

$target.filter(':not(.slugify-locked)').val(slug).text(slug);

The appended .text(slug) on the end is causing jQuery script errors in IE7 and IE8 (yes, I know, move forward Internet please!).

Was just wondering why you are doing both val(slug) and text(slug)? Is this so you can cater for other HTML elements apart from inputs?

Thanks

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.