Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@rvagg
Created February 20, 2012 04:05
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rvagg/1867765 to your computer and use it in GitHub Desktop.
Save rvagg/1867765 to your computer and use it in GitHub Desktop.
DailyJS "Ender Roundup" #3, February 2011
layout title author categories
post
Ender Roundup: Radio.js, one.color, Hypher
Rod Vagg
ender
frameworks
modules
libraries
pubsub
events
color
hyphenation
You can send in your Ender-related projects for review through our contact form or @dailyjs. Be sure to also update the Ender package list page on the Ender wiki.

Radio.js

Radio.js (GitHub: uxder/Radio, Licence: MIT, npm / Ender: radio) by Scott Murphy is a simple publish / subscribe library with a well-designed chainable API. Radio.js operates through the $.radio() method from within Ender.

{% highlight javascript %} //create topic called changeTabEvent and subscribe myFunction $.radio('changeTabEvent').subscribe(myfunction); //publish to the topic changeTabEvent $.radio('changeTabEvent').broadcast(data); //unsubscribe myFunction from the topic changeTabEvent $.radio('changeTabEvent').unsubscribe(myFunction); //do all of the above in one line via chaining $.radio('changeTabEvent').subscribe(myFunction).broadcast(data).unsubscribe(myFunction); {% endhighlight %}

Event "channels" are created by the main radio() method. You can then use the three main API calls to interact with the channels: subscribe(), broadcast() and unsubscribe(), each able to take different types and numbers of arguments.

Radio.js will also work as a stand-alone browser library and in node.js.

one.color

one.color (GitHub: One-com/one-color, Licence: BSD, npm / Ender: onecolor) by Peter Müller and One.com is an amazingly comprehensive color toolkit. It implicitly converts between RGB, HSV, HSL and CMYK color spaces with or without alpha transparency. Its API is chainable for composing, adjusting, and serializing color values. A demo page gives you some idea of the potential of one.color.

one.color

{% highlight javascript %} $.color('rgb(102, 76, 230)'). // Can parse CSS color strings lightness(+.2, true). // Implicit conversion to HSL red(-.1). // Implicit conversion back to RGB hex(); // "#00a6f2" {% endhighlight %}

one.color will also work as a stand-alone browser library and in node.js.

Hypher

Hypher (GitHub: bramstein/hypher, Licence: BSD, npm / Ender: hypher) by Bram Stein is a small hyphenation engine compatible with Hyphenation.js language objects.

Hypher adds soft hyphens to text strings (Unicode: U+00AD, HTML: ­ or ­) according to language rules as defined in the patterns objects. Modern browsers then use these soft hyphens to break words where wrapping is required, otherwise they are invisible.

Hypher comes with a large number of language patterns which are also available in the NPM repository as hyphenation.lang (e.g. hyphenation.en-us or hyphenation.fr). Simply include hypher and at least one language pattern in your Ender build.

{% highlight javascript %} // generates 'Hy|phen|ation is use|ful when cen|ter jus|ti|fy|ing a text.' // where | is a soft hyphen $('

Hyphenation is useful when center justifying a text.

') .appendTo('body') .hyphenate('en-us'); {% endhighlight %}

Hypher is also available as a jQuery plugin and will work as a stand-alone browser library and in node.js.

Tidbits and updates

Some minor notable items since the last Roundup:

Bonzo goes 1.0.0

Bonzo, the DOM manipulation library included in The Jeesh, has received a lot of minor fixes this week and its test suite has been significantly expanded, so much so that a bump to 1.0.0 seemed appropriate.

Minor Qwery update

Qwery, the selector engine included in The Jeesh had some minor performance improvements, particularly for IE8, and can now be configured to turn off use of native querySelectorAll if required: $.configure({ useNativeQSA: false }).

Bean does better delegation

Bean, the event manager included in The Jeesh, has received some delegation-love, fixing bugs related to clone() and erroneous event.currentTarget values.

Bean is also likely to see a change in the implementation of on() that will make it (mostly) compatible with the implementations in Prototype, jQuery and Zepto. Further details are available on GitHub.

Ender via CDN

After the flurry of recent activity on core Ender modules, Dustin Diaz has updated the The Jeesh and a more bulky Ender build on S3 this week, so is these builds suit your needs then point your script tag to one of these CloudFront URLs:

The Jeesh (Qwery, Bonzo, Bean, domReady)

http://cdn.enderjs.com/jeesh.js
http://cdn.enderjs.com/jeesh.min.js

http://cdn.enderjs.com/ender.js
http://cdn.enderjs.com/ender.min.js

Twitter's Bootstrap for Ender

Along with the release of Bootstrap v2, an Ender compatible version is now available in NPM. Unlike the v1.x port, this new version makes each plugin available separately so you only need to include the ones you intend to use in your Ender build.

With all plugins installed, a minimal Ender build for full Bootstrap functionality comes in at a little under 1/2 the size of the equivilant jQuery Bootstrap.

Further details available on the new ender-bootstrap repository.

@rvagg
Copy link
Author

rvagg commented Feb 20, 2012

Forgot that I probably should have just posted this as raw because it doesn't render so well as plain MD. The heading is for Jekyll and the syntax highlighting is for Pygments so they won't show up properly here.

Comments & changes welcome before I pass it on to Alex.

@fat
Copy link

fat commented Feb 20, 2012

This is cool - way to be!

@rvagg
Copy link
Author

rvagg commented Feb 20, 2012

edited to expand on the soft hyphen explanation, I realised I only wrote ½ of what I meant to about it for people new to the concept.

@rvagg
Copy link
Author

rvagg commented Feb 22, 2012

edited to add note about Bonzo v1 and ender*js on S3

@ded
Copy link

ded commented Feb 22, 2012

this is super rad! what an update

@rvagg
Copy link
Author

rvagg commented Feb 22, 2012

AWS CDN URLs now CF not S3

@ded
Copy link

ded commented Feb 22, 2012

still working on getting the CNAMES setup

@ded
Copy link

ded commented Feb 22, 2012

@rvagg
Copy link
Author

rvagg commented Feb 22, 2012

modified gist

@ded
Copy link

ded commented Feb 22, 2012

Haha. I love that it's called Jeesh++ - awesome

@ded
Copy link

ded commented Feb 22, 2012

i think this is all ready to go.

@ded
Copy link

ded commented Feb 24, 2012

what's the happs on this?

@rvagg
Copy link
Author

rvagg commented Feb 24, 2012

Should be the next post on dailyjs.com I think, Alex publishes at around 6-7 GMT which is ~15h from now methinks, I've asked him to grab the latest from here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment