Project Summary

  Analyzed 10 days ago based on code collected 10 days ago.

The focus is to extend the language, modifying the base classes to add several handy methods and shortcuts. It works on top of Prototype and extends the core classes somewhat to the same extent than ActiveSupport extends ruby's core to make a lot of stuff pretty.

For example, you can do things like:

(10).minutes().fromNow() //=> Date object ten minutes in the future
"person".pluralize() //=> "people"
["dog", "cat", "mouse"].toSentence() //=> "dog, cat and mouse"
Date.now().strftime("It's %H:%M") //=> "It's 16:23"Plus several other stuff, like string interpolation (a la Ruby), so you get:

var name = "johnny";
$Q("Hello, my name is #{name.capitalize()}"); //=> "Hello, my name is JohnnyAnd you can even interpolate inside objects! For example, let's suppose you have the following class:

var Dog = Class.create();
Dog.prototype = {
initialize: function(name) { this.name = name; },
woof: function() { return "woof!"; }
}

var bobby = new Dog("bobby");You can use interpolation inside the class passing the binding to $Q as a second parameter :

Dog.prototype.greet = function() {
$Q("I'm #{this.name} and I #{this.woof()}", this); //=> "I'm bobby and I woof!"
}Or you can do this even outside classes:

$Q("It's #{this.getMinutes()} after #{this.getHours()}", new Date());So whatever you pass to $Q on the second parameter becomes what "this" points to inside the strings.

And there's a whole other world of stuff for you to discover (and for me --and whoever wants to help-- to document), so check out the code and start marvelling at the flexibility of JavaScript, and the wonders of ActiveSupport ;)

Share

In a Nutshell, active-support-for-javascript...

Languages

JavaScript
98%
3 Other
2%
 
 

Lines of Code

 

Activity

30 Day Summary Apr 12 2013 — May 12 2013

12 Month Summary May 12 2012 — May 12 2013

Community

Ratings

Be the first to rate this project
 
Click to add your rating
 
Review this Project!
 
 
 

Creative Commons License Copyright © 2013 Black Duck Software, Inc. and its contributors, Some Rights Reserved. Unless otherwise marked, this work is licensed under a Creative Commons Attribution 3.0 Unported License . Ohloh ® and the Ohloh logo are trademarks of Black Duck Software, Inc. in the United States and/or other jurisdictions. All other trademarks are the property of their respective holders.