npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

hypher-for-jquery

v1.0.3

Published

A fast and small JavaScript hyphenation engine for jQuery

Downloads

331

Readme

Hypher for jQuery

A small and fast JavaScript hyphenation engine for jQuery (and also Zepto.js). Hypher is the fastest javascipt based hypenation engine and is very lightweight. It's also very easy to use.

The core is based on the code of Bram Stein (@bramstein), which is build for jQuery and Node.js, but has some pitfalls in the jQuery version.

##Requirements

  • Apache/NGINX (the script needs to do some HTTP Requests)

##Setup Have a look inside the @example folder.

###1. Include jQuery or Zepto.js This hyphenation engine is mostly written in plain JavaScript, but also needs jQuery or Zepto.js.

jQuery 1.x, 2.x or 3.x Because it's just an wrapper for jQuery. The web-plugin works with every version of jQuery. The core is written in plain javascipt.

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>

Zepto.js

<script src="http://zeptojs.com/zepto.min.js"></script>

###2. Include language pattern Make sure to include the right pattern for your desired language. You can use Hypher with multiple languages. The patterns are inside the patterns folder (easiest way to do: copy the whole patterns-folder in your project). Be sure to set the language code either in the settings or embeed it into the "lang" attribute inside the HTML-tag. You can use the language code (ISO 639-1) or also the WordPress Locale, which mostly includes the country. All patterns are compatible with the following list, see Internationalization.

###3. Include Hypher Include the main file. (dist/jquery.hypher.js)

<script src="dist/jquery.hypher.js"></script>

###4. Init Select the text you'd like to hyphenate and then call the function.

<script>
    $('p').hyphenate();
</script>

… if you like to customize it a little, do it like this:

<script>
    $('h3, .lead').hyphenate({
        lang: 'de',
        hypenChar: true,
        exceptions: 'Flatla|nd, bec|ause'
    });
</script>

##Customization Your available settings in Hypher:

| Option | Default | Type | Description |--------|---------|------|------------ | lang | lang-attr in html | String | Set the correct language for your content. Make sure to set the name of your pattern file | leftMin | patterns | Int | The minimum amount of characters on the left of the word | rightMin | patterns | Int | The minimum amount of characters on the right of the word | minLength | 4 | Int | Minimumal word length to hyphenate | path | '../patterns' | String | Pattern-file path (viewed from included hypher.js file) | autoload | true | Bol | By default the lang-patterns will be loaded automaticly. You can turn this off here and insert patterns by yourself. | hypenChar | false | Bol/String | This shows, where the words would hypenate - for debugging. You can also add a string with your preferred character. (Default is |) | exceptions | patterns | String | Add exceptions as a comma-separated string - add your custom hypenation with | (vertical bar) | devMode | false | Bol | When set to true, options are shown as objects in console - for debugging.

###Include lang-patterns manually You're free to include language pattern by hand like below. Be sure to disable the autoload settings inside hyphers function call.

<script src="patterns/en-us.js"></script>
<script src="patterns/de.js"></script>

<script>
    $('h3').hyphenate({
        autoload: false,
    });
</script>

##Changelog 1.0.3 / 23.12.2016

  • Fix hyphenating all uppercase text
  • Fix inconsistent soft hyphen handling.

1.0.2 / 04.11.2016

  • Update to jQuery 3 and test it
  • Edit metadata

1.0.1 / 05.01.2016

  • Remove case sensitive validation for language (de-CH is now equal to de-ch)
  • Return options in console when option 'devMode' set to true - for debugging

1.0.0 / 27.08.2015

  • Autoload pattern files
  • Improve patterns locale
  • Register all pattern-files and add some logic to it
  • Minor tweaks inside settings

0.2.0 / 21.02.2015

  • Add Zepto.js support
  • Add different settings for customization
  • Easier init

0.1.0 / 21.02.2015

  • Bootstrap
  • Core engine written by Bram Stein (https://github.com/bramstein/hypher)

License

Hypher is licensed under the three clause BSD license (see BSD.txt.)

See also

Contributors

  • Bram Stein - core hypenation engine
  • Marc Wieland - improved jQuery support